mirror of
https://github.com/avatao-content/frontend-tutorial-framework
synced 2025-01-16 02:51:57 +00:00
Merge pull request #2 from avatao-content/messaging
Initial messaging implementation
This commit is contained in:
commit
451ee47825
@ -3,7 +3,7 @@
|
|||||||
<div class="row tfw-first-row">
|
<div class="row tfw-first-row">
|
||||||
<div class="col-sm"><app-login></app-login></div>
|
<div class="col-sm"><app-login></app-login></div>
|
||||||
<div class="col-sm-6"><app-webide></app-webide></div>
|
<div class="col-sm-6"><app-webide></app-webide></div>
|
||||||
<div class="col-sm"><app-logs></app-logs></div>
|
<div class="col-sm"><app-messages></app-messages></div>
|
||||||
</div>
|
</div>
|
||||||
<!--div class="row">
|
<!--div class="row">
|
||||||
<div class="col-sm"><app-test-button [anchor_id]="'anchor_a'"></app-test-button></div>
|
<div class="col-sm"><app-test-button [anchor_id]="'anchor_a'"></app-test-button></div>
|
||||||
|
@ -12,7 +12,7 @@ import { LoginComponent } from './login/login.component';
|
|||||||
import { MarkdownService } from './markdown.service';
|
import { MarkdownService } from './markdown.service';
|
||||||
import { TerminadoService } from './terminado.service';
|
import { TerminadoService } from './terminado.service';
|
||||||
import { WebideComponent } from './webide/webide.component';
|
import { WebideComponent } from './webide/webide.component';
|
||||||
import { LogsComponent } from './logs/logs.component';
|
import { MessagesComponent } from './messages/messages.component';
|
||||||
import { TestButtonComponent } from './test-button/test-button.component';
|
import { TestButtonComponent } from './test-button/test-button.component';
|
||||||
import { WebSocketService } from './websocket.service';
|
import { WebSocketService } from './websocket.service';
|
||||||
import { TerminalComponent } from './terminal/terminal.component';
|
import { TerminalComponent } from './terminal/terminal.component';
|
||||||
@ -25,7 +25,7 @@ import { FSMUpdateService } from './fsmupdate.service';
|
|||||||
HeaderComponent,
|
HeaderComponent,
|
||||||
LoginComponent,
|
LoginComponent,
|
||||||
WebideComponent,
|
WebideComponent,
|
||||||
LogsComponent,
|
MessagesComponent,
|
||||||
TestButtonComponent,
|
TestButtonComponent,
|
||||||
TerminalComponent
|
TerminalComponent
|
||||||
],
|
],
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
<div [innerHtml]="this.markdown">
|
|
||||||
</div>
|
|
@ -1,28 +0,0 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
|
||||||
import { MarkdownService } from '../markdown.service';
|
|
||||||
|
|
||||||
const mdText =
|
|
||||||
`# Showdown test
|
|
||||||
|
|
||||||
**bold**
|
|
||||||
|
|
||||||
_italic_
|
|
||||||
|
|
||||||
[link](https://avatao.com)
|
|
||||||
`;
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-logs',
|
|
||||||
templateUrl: './logs.component.html',
|
|
||||||
styleUrls: ['./logs.component.scss']
|
|
||||||
})
|
|
||||||
export class LogsComponent implements OnInit {
|
|
||||||
markdown: string;
|
|
||||||
constructor(private markdownService: MarkdownService) {
|
|
||||||
this.markdown = markdownService.convertToHtml(mdText);
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit() {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
5
src/app/messages/message.ts
Normal file
5
src/app/messages/message.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
export class Message {
|
||||||
|
originator: string;
|
||||||
|
timestamp: Date;
|
||||||
|
message: string;
|
||||||
|
}
|
11
src/app/messages/messages.component.html
Normal file
11
src/app/messages/messages.component.html
Normal 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>
|
14
src/app/messages/messages.component.scss
Normal file
14
src/app/messages/messages.component.scss
Normal 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;
|
||||||
|
}
|
32
src/app/messages/messages.component.ts
Normal file
32
src/app/messages/messages.component.ts
Normal 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);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user