Rename LogsComponent to MessagesComponent

This commit is contained in:
Bálint Bokros
2018-02-01 16:33:25 +01:00
parent d5e14d0d8a
commit eb90c66c84
6 changed files with 7 additions and 7 deletions

View File

@ -0,0 +1,5 @@
export class Message {
originator: string;
timestamp: Date;
message: string;
}

View File

@ -0,0 +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

@ -0,0 +1,32 @@
import { Component, OnInit } from '@angular/core';
import { MarkdownService } from '../markdown.service';
import { WebSocketService } from '../websocket.service';
import { Message } from './message';
@Component({
selector: 'app-messages',
templateUrl: './messages.component.html',
styleUrls: ['./messages.component.scss']
})
export class MessagesComponent implements OnInit {
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);
}
);
}
}