Refactor command handling initialization in DashboardComponent

This commit is contained in:
Kristóf Tóth 2018-05-17 16:03:35 +02:00
parent 5d0fb1ab19
commit 3980051823

View File

@ -29,10 +29,7 @@ export class DashboardComponent implements OnInit, OnDestroy {
ngOnInit() {
this.webSocketService.connect();
this.webSocketService.observeKey<LayoutCommand>('dashboard').subscribe((event) => {
this.command_handlers[event.data.command](event.data);
this.changeDetectorRef.detectChanges();
});
this.initCommandHandling();
this.deploymentNotificationSubscription = this.deploymentNotificationService.deploying.subscribe(
(deploying) => {
this.deploying = deploying;
@ -42,6 +39,13 @@ export class DashboardComponent implements OnInit, OnDestroy {
});
}
initCommandHandling() {
this.webSocketService.observeKey<LayoutCommand>('dashboard').subscribe((event) => {
this.command_handlers[event.data.command](event.data);
this.changeDetectorRef.detectChanges();
});
}
layoutHandler(data: LayoutCommand) {
if (config.dashboard.enabledLayouts.includes(data.layout)) {
this.setLayout(data.layout);