Resize evnt added

This commit is contained in:
piotrpekala7 2020-03-26 22:53:29 +01:00
parent 4402a53ae0
commit 43787e94e8
3 changed files with 22 additions and 8 deletions

View File

@ -119,6 +119,8 @@ export class ConsoleWrapperComponent implements OnInit {
height: `${event.rectangle.height - 60}px`,
width: `${event.rectangle.width}px`
};
this.consoleService.resizeTerminal();
}
close() {

View File

@ -9,7 +9,7 @@ import { NodeConsoleService } from '../../../services/nodeConsole.service';
@Component({
encapsulation: ViewEncapsulation.None,
encapsulation: ViewEncapsulation.ShadowDom,
selector: 'app-web-console',
templateUrl: './web-console.component.html',
styleUrls: ['../../../../../node_modules/xterm/css/xterm.css']
@ -18,17 +18,23 @@ export class WebConsoleComponent implements OnInit, AfterViewInit {
@Input() server: Server;
@Input() project: Project;
@Input() node: Node;
public term: Terminal;
public term: Terminal = new Terminal();
public fitAddon: FitAddon = new FitAddon();
@ViewChild('terminal', {static: false}) terminal: ElementRef;
constructor(
private consoleService: NodeConsoleService
) {}
ngOnInit() {}
ngOnInit() {
this.consoleService.consoleResized.subscribe(ev => {
this.fitAddon.fit();
});
}
ngAfterViewInit() {
this.term = new Terminal();
setTimeout(() => {
this.term.open(this.terminal.nativeElement);
const socket = new WebSocket(this.getUrl());
@ -44,9 +50,10 @@ export class WebConsoleComponent implements OnInit, AfterViewInit {
this.term.loadAddon(attachAddon);
this.term.setOption('cursorBlink', true);
const fitAddon = new FitAddon();
this.term.loadAddon(fitAddon);
fitAddon.activate(this.term);
this.term.loadAddon(this.fitAddon);
this.fitAddon.activate(this.term);
this.term.focus();
}, 1000);
}

View File

@ -6,6 +6,7 @@ import { Subject } from 'rxjs';
export class NodeConsoleService {
public nodeConsoleTrigger = new EventEmitter<Node>();
public closeNodeConsoleTrigger = new Subject<Node>();
public consoleResized = new Subject<boolean>();
constructor() {}
@ -14,6 +15,10 @@ export class NodeConsoleService {
}
closeConsoleForNode(node: Node) {
this.closeNodeConsoleTrigger.next(node)
this.closeNodeConsoleTrigger.next(node);
}
resizeTerminal() {
this.consoleResized.next(true);
}
}