From a0368cb3a570b0d8a9259d19a1f02e8dff6b67e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Fri, 2 Mar 2018 17:41:50 +0100 Subject: [PATCH] Implement testing component for sending messages to TFW backend --- src/app/app.module.ts | 4 +++- .../testmessager/testmessager.component.html | 2 ++ .../testmessager/testmessager.component.scss | 0 .../testmessager/testmessager.component.ts | 22 +++++++++++++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 src/app/testmessager/testmessager.component.html create mode 100644 src/app/testmessager/testmessager.component.scss create mode 100644 src/app/testmessager/testmessager.component.ts diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 93fd321..adf6909 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -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, diff --git a/src/app/testmessager/testmessager.component.html b/src/app/testmessager/testmessager.component.html new file mode 100644 index 0000000..3b024d3 --- /dev/null +++ b/src/app/testmessager/testmessager.component.html @@ -0,0 +1,2 @@ +
+ diff --git a/src/app/testmessager/testmessager.component.scss b/src/app/testmessager/testmessager.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/testmessager/testmessager.component.ts b/src/app/testmessager/testmessager.component.ts new file mode 100644 index 0000000..1b212b5 --- /dev/null +++ b/src/app/testmessager/testmessager.component.ts @@ -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']); + } +}