mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-06-18 14:58:15 +00:00
Resize evnt added
This commit is contained in:
@ -119,6 +119,8 @@ 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.resizeTerminal();
|
||||||
}
|
}
|
||||||
|
|
||||||
close() {
|
close() {
|
||||||
|
@ -9,7 +9,7 @@ import { NodeConsoleService } from '../../../services/nodeConsole.service';
|
|||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
encapsulation: ViewEncapsulation.None,
|
encapsulation: ViewEncapsulation.ShadowDom,
|
||||||
selector: 'app-web-console',
|
selector: 'app-web-console',
|
||||||
templateUrl: './web-console.component.html',
|
templateUrl: './web-console.component.html',
|
||||||
styleUrls: ['../../../../../node_modules/xterm/css/xterm.css']
|
styleUrls: ['../../../../../node_modules/xterm/css/xterm.css']
|
||||||
@ -18,17 +18,23 @@ export class WebConsoleComponent implements OnInit, AfterViewInit {
|
|||||||
@Input() server: Server;
|
@Input() server: Server;
|
||||||
@Input() project: Project;
|
@Input() project: Project;
|
||||||
@Input() node: Node;
|
@Input() node: Node;
|
||||||
public term: Terminal;
|
|
||||||
|
public term: Terminal = new Terminal();
|
||||||
|
public fitAddon: FitAddon = new FitAddon();
|
||||||
|
|
||||||
@ViewChild('terminal', {static: false}) terminal: ElementRef;
|
@ViewChild('terminal', {static: false}) terminal: ElementRef;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private consoleService: NodeConsoleService
|
private consoleService: NodeConsoleService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {}
|
ngOnInit() {
|
||||||
|
this.consoleService.consoleResized.subscribe(ev => {
|
||||||
|
this.fitAddon.fit();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
this.term = new Terminal();
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.term.open(this.terminal.nativeElement);
|
this.term.open(this.terminal.nativeElement);
|
||||||
const socket = new WebSocket(this.getUrl());
|
const socket = new WebSocket(this.getUrl());
|
||||||
@ -44,9 +50,10 @@ export class WebConsoleComponent implements OnInit, AfterViewInit {
|
|||||||
this.term.loadAddon(attachAddon);
|
this.term.loadAddon(attachAddon);
|
||||||
this.term.setOption('cursorBlink', true);
|
this.term.setOption('cursorBlink', true);
|
||||||
|
|
||||||
const fitAddon = new FitAddon();
|
this.term.loadAddon(this.fitAddon);
|
||||||
this.term.loadAddon(fitAddon);
|
this.fitAddon.activate(this.term);
|
||||||
fitAddon.activate(this.term);
|
|
||||||
|
this.term.focus();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import { Subject } from 'rxjs';
|
|||||||
export class NodeConsoleService {
|
export class NodeConsoleService {
|
||||||
public nodeConsoleTrigger = new EventEmitter<Node>();
|
public nodeConsoleTrigger = new EventEmitter<Node>();
|
||||||
public closeNodeConsoleTrigger = new Subject<Node>();
|
public closeNodeConsoleTrigger = new Subject<Node>();
|
||||||
|
public consoleResized = new Subject<boolean>();
|
||||||
|
|
||||||
constructor() {}
|
constructor() {}
|
||||||
|
|
||||||
@ -14,6 +15,10 @@ export class NodeConsoleService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
closeConsoleForNode(node: Node) {
|
closeConsoleForNode(node: Node) {
|
||||||
this.closeNodeConsoleTrigger.next(node)
|
this.closeNodeConsoleTrigger.next(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
resizeTerminal() {
|
||||||
|
this.consoleResized.next(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user