Implement testing component for sending messages to TFW backend

This commit is contained in:
Kristóf Tóth 2018-03-02 17:41:50 +01:00
parent 3cfcf8fddc
commit a0368cb3a5
4 changed files with 27 additions and 1 deletions

View File

@ -19,6 +19,7 @@ import { TerminalComponent } from './terminal/terminal.component';
import { FSMUpdateService } from './services/fsmupdate.service';
import { ProcessManagerService } from './services/processmanager.service';
import { AppRoutingModule } from './app-routing.module';
import { TestmessagerComponent } from './testmessager/testmessager.component';
@NgModule({
@ -29,7 +30,8 @@ import { AppRoutingModule } from './app-routing.module';
WebideComponent,
MessagesComponent,
TerminalComponent,
DashboardComponent
DashboardComponent,
TestmessagerComponent
],
imports: [
BrowserModule,

View File

@ -0,0 +1,2 @@
<textarea [(ngModel)]="messageStr" cols="33" rows="7"></textarea><br>
<button class="btn btn-primary" (click)="sendTestMessage()">Send</button>

View File

@ -0,0 +1,22 @@
import { Component, OnInit } from '@angular/core';
import { WebSocketService } from '../services/websocket.service';
@Component({
selector: 'app-testmessager',
templateUrl: './testmessager.component.html',
styleUrls: ['./testmessager.component.scss']
})
export class TestmessagerComponent implements OnInit {
messageStr = `{"key": "",\n"data": {}}`;
constructor(private webSocketService: WebSocketService) {}
ngOnInit() {
this.webSocketService.connect();
}
sendTestMessage() {
const jsonObject = JSON.parse(this.messageStr);
this.webSocketService.send(jsonObject['key'], jsonObject['data']);
}
}