mirror of
https://github.com/avatao-content/frontend-tutorial-framework
synced 2025-01-16 05:51:55 +00:00
Implement testing component for sending messages to TFW backend
This commit is contained in:
parent
3cfcf8fddc
commit
a0368cb3a5
@ -19,6 +19,7 @@ import { TerminalComponent } from './terminal/terminal.component';
|
|||||||
import { FSMUpdateService } from './services/fsmupdate.service';
|
import { FSMUpdateService } from './services/fsmupdate.service';
|
||||||
import { ProcessManagerService } from './services/processmanager.service';
|
import { ProcessManagerService } from './services/processmanager.service';
|
||||||
import { AppRoutingModule } from './app-routing.module';
|
import { AppRoutingModule } from './app-routing.module';
|
||||||
|
import { TestmessagerComponent } from './testmessager/testmessager.component';
|
||||||
|
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
@ -29,7 +30,8 @@ import { AppRoutingModule } from './app-routing.module';
|
|||||||
WebideComponent,
|
WebideComponent,
|
||||||
MessagesComponent,
|
MessagesComponent,
|
||||||
TerminalComponent,
|
TerminalComponent,
|
||||||
DashboardComponent
|
DashboardComponent,
|
||||||
|
TestmessagerComponent
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
|
2
src/app/testmessager/testmessager.component.html
Normal file
2
src/app/testmessager/testmessager.component.html
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<textarea [(ngModel)]="messageStr" cols="33" rows="7"></textarea><br>
|
||||||
|
<button class="btn btn-primary" (click)="sendTestMessage()">Send</button>
|
0
src/app/testmessager/testmessager.component.scss
Normal file
0
src/app/testmessager/testmessager.component.scss
Normal file
22
src/app/testmessager/testmessager.component.ts
Normal file
22
src/app/testmessager/testmessager.component.ts
Normal 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']);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user