#11 display warning

Open
trungnd wants to merge 1 commits from features/handle-toastr-message into master
  1. +15
    -4
      src/app/modules/overview/overall-ground/overall-ground.component.ts

+ 15
- 4
src/app/modules/overview/overall-ground/overall-ground.component.ts View File

private statusSubscription?: Subscription; private statusSubscription?: Subscription;
private messageSubscription?: Subscription; private messageSubscription?: Subscription;
private intervalId: any; private intervalId: any;
isShowingToastr: boolean = false;


constructor( constructor(
private socketService$: SocketService, private socketService$: SocketService,


this.Sstate1 = this.state1 === 'ON';// alarm 12h this.Sstate1 = this.state1 === 'ON';// alarm 12h
this.Sstate2 = this.state2 === 'ON';// alarm 1h this.Sstate2 = this.state2 === 'ON';// alarm 1h
if (message.ready === '0'){
this.toastr.warning('System not ready', 'Warning', {timeOut: 5000});
}
this.handleMessage(message);
}
}

handleMessage(message: any) {
if (message.ready === '0' && !this.isShowingToastr) {
this.showToastr();
} }
} }


showToastr() {
this.toastr.warning('System not ready', 'Warning', { timeOut: 5000 });
this.isShowingToastr = true;
setTimeout(() => {
this.isShowingToastr = false;
}, 5000);
}
} }

Loading…
Cancel
Save