Reverse order of messaging messages

This commit is contained in:
Kristóf Tóth 2018-06-26 14:13:29 +02:00
parent c6f9edc9f7
commit 8a2518fbd0
5 changed files with 31 additions and 12 deletions

View File

@ -4,8 +4,10 @@
<div [attr.class]="layout"> <div [attr.class]="layout">
<div class="tfw-grid-main-components"> <div class="tfw-grid-main-components">
<div class="tfw-header"><app-header></app-header></div> <div class="tfw-header"><app-header></app-header></div>
<div [ngClass]="{'hide-attribute': hideMessages}" class="tfw-messages"> <div [ngClass]="{'hide-attribute': hideMessages}"
<app-messages></app-messages> class="tfw-messages"
#tfwmessages>
<app-messages (newMessageEvent)="scrollMessagesToBottom()"></app-messages>
</div> </div>
<div class="tfw-web tao-grid-top-left" <div class="tfw-web tao-grid-top-left"
[ngClass]="{'deploy-blur': deploying}"> [ngClass]="{'deploy-blur': deploying}">

View File

@ -58,6 +58,11 @@
} }
} }
.tfw-messages::-webkit-scrollbar {
width: 0px;
background: transparent;
}
.tfw-ide { .tfw-ide {
background-color: #1e1e1e; // vscode dark theme background-color: #1e1e1e; // vscode dark theme
} }

View File

@ -20,6 +20,7 @@ export class DashboardComponent implements OnInit, OnDestroy {
deploying = false; deploying = false;
deploymentNotificationSubscription: Subscription; deploymentNotificationSubscription: Subscription;
@ViewChild('webiframe') webiframe: ElementRef; @ViewChild('webiframe') webiframe: ElementRef;
@ViewChild('tfwmessages') messages: ElementRef;
layout: string = config.dashboard.currentLayout; layout: string = config.dashboard.currentLayout;
hideMessages: boolean = config.dashboard.hideMessages; hideMessages: boolean = config.dashboard.hideMessages;
@ -125,4 +126,11 @@ export class DashboardComponent implements OnInit, OnDestroy {
this.selectTerminalMenuItem('console'); this.selectTerminalMenuItem('console');
} }
} }
scrollMessagesToBottom(): void {
const element = this.messages.nativeElement;
// This must be done in the Angular event loop to avoid messing up
// change detection (not in the template like ConsoleComponent does)
element.scrollTop = element.scrollHeight;
}
} }

View File

@ -3,17 +3,11 @@
<div class="tfw-messages-main"> <div class="tfw-messages-main">
<div class="tfw-grid-messages-header"> <div class="tfw-grid-messages-header">
<div class="tao-grid-top-left"><span>Instructions</span></div>
<div class="tao-grid-center-right"><button *ngIf="showNextButton" (click)="stepFSM()" class="tao-btn-rainbow">Next</button></div> <div class="tao-grid-center-right"><button *ngIf="showNextButton" (click)="stepFSM()" class="tao-btn-rainbow">Next</button></div>
</div> </div>
<div *ngIf="messageInQueue" class="tfw-grid-message jumping-circle-container">
<div class="jumping-circle" id="jc1"></div>
<div class="jumping-circle" id="jc2"></div>
<div class="jumping-circle" id="jc3"></div>
</div>
<div class="tfw-grid-message" <div class="tfw-grid-message"
*ngFor="let message of messages.slice().reverse(); let first = first" *ngFor="let message of messages.slice(); let last = last"
[class.highlighted-message]="first"> [class.highlighted-message]="last">
<div class="tfw-grid-message-header"> <div class="tfw-grid-message-header">
<img class="tao-grid-center-left" src="images/avataobot.svg"/> <img class="tao-grid-center-left" src="images/avataobot.svg"/>
<div class="tao-grid-center-left originator">{{message.originator}}</div> <div class="tao-grid-center-left originator">{{message.originator}}</div>
@ -21,4 +15,9 @@
</div> </div>
<div [innerHtml]="message.message"></div> <div [innerHtml]="message.message"></div>
</div> </div>
<div *ngIf="messageInQueue" class="tfw-grid-message jumping-circle-container">
<div class="jumping-circle" id="jc1"></div>
<div class="jumping-circle" id="jc2"></div>
<div class="jumping-circle" id="jc3"></div>
</div>
</div> </div>

View File

@ -1,7 +1,7 @@
// Copyright (C) 2018 Avatao.com Innovative Learning Kft. // Copyright (C) 2018 Avatao.com Innovative Learning Kft.
// All Rights Reserved. See LICENSE file for details. // All Rights Reserved. See LICENSE file for details.
import { ChangeDetectorRef, Component, OnInit } from '@angular/core'; import { ChangeDetectorRef, Component, OnInit, EventEmitter, Output } from '@angular/core';
import { MarkdownService } from '../services/markdown.service'; import { MarkdownService } from '../services/markdown.service';
import { WebSocketService } from '../services/websocket.service'; import { WebSocketService } from '../services/websocket.service';
@ -18,6 +18,7 @@ import { Subject, Observer, BehaviorSubject } from 'rxjs';
styleUrls: ['./messages.component.scss'] styleUrls: ['./messages.component.scss']
}) })
export class MessagesComponent implements OnInit { export class MessagesComponent implements OnInit {
@Output() newMessageEvent: EventEmitter<any> = new EventEmitter();
newMessage: Subject<MessagesMessage> = new Subject<MessagesMessage>(); newMessage: Subject<MessagesMessage> = new Subject<MessagesMessage>();
messageInQueue = true; messageInQueue = true;
@ -38,7 +39,11 @@ export class MessagesComponent implements OnInit {
} }
ngOnInit() { ngOnInit() {
this.newMessage.subscribe(this.writeMessage.bind(this)); this.newMessage.subscribe(
(message) => {
this.writeMessage(message);
this.newMessageEvent.emit();
});
this.messageQueueAttender.messageInQueue.subscribe( this.messageQueueAttender.messageInQueue.subscribe(
(value) => this.messageInQueue = value (value) => this.messageInQueue = value
); );