Option to resize console

This commit is contained in:
piotrpekala7
2020-08-28 14:14:40 +02:00
parent d266d5ece2
commit ad783722d0
5 changed files with 27 additions and 11 deletions

View File

@ -3,7 +3,7 @@
(document:mousemove)="dragWidget($event)" (document:mousemove)="dragWidget($event)"
(document:mouseup)="toggleDragging(false)"> (document:mouseup)="toggleDragging(false)">
</div> </div>
<!-- Option with resizing <!-- Option with resizing -->
<div <div
class="consoleWrapper" class="consoleWrapper"
[ngClass]="{lightTheme: isLightThemeEnabled}" [ngClass]="{lightTheme: isLightThemeEnabled}"
@ -14,12 +14,12 @@
[resizeEdges]="{ right: true, left: true, bottom: true, top: true }" [resizeEdges]="{ right: true, left: true, bottom: true, top: true }"
[enableGhostResize]="true" [enableGhostResize]="true"
(resizeStart)="toggleDragging(false)" (resizeStart)="toggleDragging(false)"
(resizeEnd)="onResizeEnd($event)"> --> (resizeEnd)="onResizeEnd($event)">
<div <!-- <div
class="consoleWrapper" class="consoleWrapper"
[ngClass]="{lightTheme: isLightThemeEnabled}" [ngClass]="{lightTheme: isLightThemeEnabled}"
(mousedown)="toggleDragging(true)" (mousedown)="toggleDragging(true)"
[ngStyle]="style"> [ngStyle]="style"> -->
<div class="consoleHeader"> <div class="consoleHeader">
<mat-tab-group class="tabs" [selectedIndex]="selected.value" (selectedIndexChange)="selected.setValue($event)"> <mat-tab-group class="tabs" [selectedIndex]="selected.value" (selectedIndexChange)="selected.setValue($event)">
@ -53,7 +53,7 @@
<app-log-console [hidden]="!(selected.value===0) || isMinimized" [server]="server" [project]="project"></app-log-console> <app-log-console [hidden]="!(selected.value===0) || isMinimized" [server]="server" [project]="project"></app-log-console>
<div [hidden]="isMinimized" *ngFor="let node of nodes; let index = index"> <div class="xterm-console" [hidden]="isMinimized" *ngFor="let node of nodes; let index = index">
<app-web-console [hidden]="!(selected.value===(index+1))" [server]="server" [node]="nodes[index]"></app-web-console> <app-web-console [hidden]="!(selected.value===(index+1))" [server]="server" [node]="nodes[index]"></app-web-console>
</div> </div>
</div> </div>

View File

@ -5,7 +5,7 @@
left: 20px; left: 20px;
height: 180px; height: 180px;
width: 600px; width: 600px;
background: #263238; background: #000000!important;
color: white; color: white;
overflow: hidden; overflow: hidden;
font-size: 12px; font-size: 12px;
@ -38,6 +38,7 @@
display: flex; display: flex;
padding: 2px; padding: 2px;
justify-content: space-between; justify-content: space-between;
background: #263238!important;
} }
.tabs { .tabs {
@ -54,6 +55,10 @@
scrollbar-width: thin; scrollbar-width: thin;
} }
.xterm-console {
background: black;
}
.consoleInput { .consoleInput {
width: 100%; width: 100%;
height: 30px; height: 30px;

View File

@ -113,8 +113,8 @@ export class ConsoleWrapperComponent implements OnInit {
if ( if (
event.rectangle.width && event.rectangle.width &&
event.rectangle.height && event.rectangle.height &&
(event.rectangle.width < 720 || (event.rectangle.width < 500 ||
event.rectangle.height < 460) event.rectangle.height < 100)
) { ) {
return false; return false;
} }
@ -134,6 +134,11 @@ export class ConsoleWrapperComponent implements OnInit {
height: `${event.rectangle.height - 60}px`, height: `${event.rectangle.height - 60}px`,
width: `${event.rectangle.width}px` width: `${event.rectangle.width}px`
}; };
this.consoleService.consoleResized.next({
width: event.rectangle.width,
height: event.rectangle.height - 53
})
} }
close() { close() {

View File

@ -31,7 +31,10 @@ export class WebConsoleComponent implements OnInit, AfterViewInit {
ngOnInit() { ngOnInit() {
this.consoleService.consoleResized.subscribe(ev => { this.consoleService.consoleResized.subscribe(ev => {
this.fitAddon.fit(); let numberOfColumns = Math.floor(ev.width / 9);
let numberOfRows = Math.floor(ev.height / 17);
this.term.resize(numberOfColumns, numberOfRows);
}); });
} }
@ -61,6 +64,9 @@ export class WebConsoleComponent implements OnInit, AfterViewInit {
} }
return true; return true;
}); });
// probably we need to take initial values of console wrapper and
// this.term.resize(80, 1);
} }
getUrl() { getUrl() {

View File

@ -39,6 +39,6 @@ export class NodeConsoleService {
} }
export interface ConsoleResizedEvent { export interface ConsoleResizedEvent {
numberOfColumns: number, width: number,
numberOfRows: number height: number
} }