Create initial implementation of messaging

This commit is contained in:
Bálint Bokros 2018-02-01 16:08:51 +01:00
parent 6b9c2c19e3
commit 1c1bddd955
3 changed files with 39 additions and 1 deletions

View File

@ -1 +1,11 @@
<div>
<ul>
<li *ngFor="let message of messages">
<p>
<strong>{{message.originator}}</strong>
<span class="timestamp">{{message.timestamp | date:'yyyy-MM-dd HH:mm:ss'}}</span><br>
<span [innerHtml]="message.message"></span>
</p>
</li>
</ul>
</div>

View File

@ -0,0 +1,14 @@
div {
display: block;
overflow: auto;
max-height: 100%;
}
ul {
max-height: inherit;
list-style-type: none;
}
.timestamp {
opacity: 0.37;
}

View File

@ -1,5 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { MarkdownService } from '../markdown.service';
import { WebSocketService } from '../websocket.service';
class Message {
originator: string;
@ -13,10 +14,23 @@ class Message {
styleUrls: ['./logs.component.scss']
})
export class LogsComponent implements OnInit {
constructor(private markdownService: MarkdownService) {
messages: Message[] = [];
constructor(
private markdownService: MarkdownService,
private websocketService: WebSocketService
) {}
convert(text: string) {
return this.markdownService.convertToHtml(text);
}
ngOnInit() {
this.websocketService.observeAnchor<Message>('message').subscribe(
(event) => {
this.messages.push(event.data);
event.data.message = this.convert(event.data.message);
}
);
}
}