Add support for sending arbitrary TFW message on bot message click

This commit is contained in:
Kristóf Tóth 2019-12-19 14:49:27 +01:00
parent f17fe18cef
commit f7a2182ba6
3 changed files with 9 additions and 1 deletions

View File

@ -4,6 +4,7 @@ export interface MessageData {
originator?: string; originator?: string;
timestamp?: Date; timestamp?: Date;
typing?: boolean; typing?: boolean;
command?: any;
message: string; message: string;
} }

View File

@ -1,7 +1,8 @@
<div class="tfw-messages-main"> <div class="tfw-messages-main">
<div class="tfw-grid-message" <div class="tfw-grid-message"
*ngFor="let message of messages.slice(); let last = last" *ngFor="let message of messages.slice(); let last = last"
[class.highlighted-message]="last"> [class.highlighted-message]="last"
(click)="sendMessageCommand(message)">
<div class="tfw-grid-message-header"> <div class="tfw-grid-message-header">
<img class="tao-grid-center-left" src="images/avataobot.svg"/> <img class="tao-grid-center-left" src="images/avataobot.svg"/>
<div class="tao-grid-center-left originator">{{message.originator}}</div> <div class="tao-grid-center-left originator">{{message.originator}}</div>

View File

@ -65,4 +65,10 @@ export class MessagesComponent implements OnInit {
'key': 'message.queue.drain' 'key': 'message.queue.drain'
}); });
} }
sendMessageCommand(message: MessageData) {
if ('command' in message) {
this.websocketService.send(message.command);
}
}
} }