Implement changing between terminal menu items

This commit is contained in:
Kristóf Tóth 2018-05-25 15:45:56 +02:00
parent 32dab3b967
commit 469c5ced7b
2 changed files with 14 additions and 5 deletions

View File

@ -23,13 +23,15 @@
<div class="tfw-terminal">
<div class="btn-group btn-group-sm flex-wrap tao-grid-center-left tfw-console-terminal-menu">
<button class="tfw-console-terminal-menu-button"
[class.selected]="terminalOrConsole === 'terminal'">TERMINAL</button>
(click)="selectTerminalMenuItem('terminal')"
[class.selected]="selectedTerminalMenuItem === 'terminal'">TERMINAL</button>
<button class="tfw-console-terminal-menu-button"
[class.selected]="terminalOrConsole === 'console'">CONSOLE</button>
(click)="selectTerminalMenuItem('console')"
[class.selected]="selectedTerminalMenuItem === 'console'">CONSOLE</button>
</div>
<hr>
<app-terminal *ngIf="terminalOrConsole === 'terminal'"></app-terminal>
<app-console *ngIf="terminalOrConsole === 'console'"></app-console>
<app-terminal [hidden]="selectedTerminalMenuItem !== 'terminal'"></app-terminal>
<app-console [hidden]="selectedTerminalMenuItem !== 'console'"></app-console>
</div>
<div class="tfw-sidebar">
<app-sidebar (layoutChanged)="setLayout($event)" [layout]="layout"></app-sidebar>

View File

@ -20,7 +20,7 @@ export class DashboardComponent implements OnInit, OnDestroy {
hide_messages: boolean = config.dashboard.hide_messages;
iframeUrl: string = config.dashboard.iframeUrl;
@ViewChild('webiframe') webiframe: ElementRef;
terminalOrConsole = config.dashboard.terminalOrConsole;
selectedTerminalMenuItem = config.dashboard.terminalOrConsole;
command_handlers = {'layout': this.layoutHandler.bind(this),
'reload_frontend': this.reloadFrontendHandlder.bind(this)};
@ -85,4 +85,11 @@ export class DashboardComponent implements OnInit, OnDestroy {
this.webiframe.nativeElement.contentWindow.location.reload(true);
});
}
selectTerminalMenuItem(item: string) {
if (!item.match('(terminal|console)')) {
return;
}
this.selectedTerminalMenuItem = item;
}
}