import { Component , ChangeDetectorRef , ViewChildren , ElementRef , QueryList , Input } from '@angular/core' ; import { NavController , ModalController } from '@ionic/angular' ; import { DeviceService } from 'src/app/core/services/device.service' ; import { NativeService } from 'src/app/core/services/native.service' ; @ Component ( { selector : 'own-sensor-dashboard' , templateUrl : 'own-sensor-dashboard.html' , styleUrls : [ 'own-sensor-dashboard.scss' ] } ) export class OwnSensorDashboard { @ Input ( ) device ; tab = 0 ; get switch ( ) { if ( this . device . data . switch == 'on' ) return true ; return false ; } get state ( ) { if ( this . device . data . state == 'online' ) return true ; return false ; } get power ( ) { return this . device . data . power ; } slidesOpts = { direction : 'vertical' } ; constructor ( private navCtrl , private changeDetectorRef , private modalCtrl , private deviceService , private nativeService ) { } ngAfterViewInit ( ) { } turnSwitch ( ) { let message ; if ( this . switch ) { message = `{"switch":"off"}` ; } else { message = `{"switch":"on"}` ; } this . deviceService . sendData ( this . device , message ) ; } changeTab ( tab ) { this . tab = tab ; if ( tab == 1 ) { } else if ( tab == 2 ) { } else if ( tab == 3 ) { } else if ( tab == 4 ) { window . setTimeout ( ( ) => { } , 100 ) ; } } }