From 82f1ed17e9f7e23e5b722359d3cfa223bd62985a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Wed, 14 Mar 2018 18:06:37 +0100 Subject: [PATCH] Implement frontend API to manipulate next button visibility --- src/app/messages/messages.component.html | 2 +- src/app/messages/messages.component.ts | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/app/messages/messages.component.html b/src/app/messages/messages.component.html index 893907b..ba57822 100755 --- a/src/app/messages/messages.component.html +++ b/src/app/messages/messages.component.html @@ -1,7 +1,7 @@
Instructions
-
+
diff --git a/src/app/messages/messages.component.ts b/src/app/messages/messages.component.ts index acadec0..bf812e6 100644 --- a/src/app/messages/messages.component.ts +++ b/src/app/messages/messages.component.ts @@ -3,6 +3,7 @@ import { MarkdownService } from '../services/markdown.service'; import { WebSocketService } from '../services/websocket.service'; import { Message } from './message'; +import { MessageControl } from './messagecontrol'; @Component({ selector: 'app-messages', @@ -11,6 +12,9 @@ import { Message } from './message'; }) export class MessagesComponent implements OnInit { messages: Message[] = []; + showNextButton = false; + command_handlers = {'showbutton': this.showButton.bind(this)}; + constructor( private markdownService: MarkdownService, private websocketService: WebSocketService, @@ -21,6 +25,10 @@ export class MessagesComponent implements OnInit { return this.markdownService.convertToHtml(text); } + showButton(data: MessageControl) { + this.showNextButton = data.next_visibility; + } + ngOnInit() { this.websocketService.connect(); this.websocketService.observeKey('message').subscribe( @@ -28,7 +36,10 @@ export class MessagesComponent implements OnInit { this.messages.push(event.data); event.data.message = this.convert(event.data.message); this.changeDetectorRef.detectChanges(); - } - ); + }); + this.websocketService.observeKey('messagecontrol').subscribe( + (event) => { + this.command_handlers[event.data.command](event.data); + }); } }