mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-01-23 21:08:04 +00:00
64 lines
1.4 KiB
TypeScript
64 lines
1.4 KiB
TypeScript
import { Injectable, EventEmitter } from '@angular/core';
|
|
import { Node } from '../cartography/models/node';
|
|
import { Subject } from 'rxjs';
|
|
|
|
@Injectable()
|
|
export class NodeConsoleService {
|
|
public nodeConsoleTrigger = new EventEmitter<Node>();
|
|
public closeNodeConsoleTrigger = new Subject<Node>();
|
|
public consoleResized = new Subject<ConsoleResizedEvent>();
|
|
public openConsoles: number = 0;
|
|
|
|
public readonly defaultConsoleWidth = 720;
|
|
public readonly defaultConsoleHeight = 408;
|
|
|
|
public readonly defaultNumberOfColumns = 80;
|
|
public readonly defaultNumberOfRows = 24;
|
|
|
|
private lastNumberOfColumns: number;
|
|
private lastNumberOfRows: number;
|
|
|
|
constructor() {}
|
|
|
|
getNumberOfColumns() {
|
|
return this.lastNumberOfColumns;
|
|
}
|
|
|
|
getNumberOfRows() {
|
|
return this.lastNumberOfRows;
|
|
}
|
|
|
|
setNumberOfColumns(value: number) {
|
|
this.lastNumberOfColumns = value;
|
|
}
|
|
|
|
setNumberOfRows(value: number) {
|
|
this.lastNumberOfRows = value;
|
|
}
|
|
|
|
openConsoleForNode(node: Node) {
|
|
this.nodeConsoleTrigger.emit(node);
|
|
}
|
|
|
|
closeConsoleForNode(node: Node) {
|
|
this.closeNodeConsoleTrigger.next(node);
|
|
}
|
|
|
|
resizeTerminal(event: ConsoleResizedEvent) {
|
|
this.consoleResized.next(event);
|
|
}
|
|
|
|
getLineWidth() {
|
|
return this.defaultConsoleWidth / this.defaultNumberOfColumns;
|
|
}
|
|
|
|
getLineHeight() {
|
|
return this.defaultConsoleHeight / this.defaultNumberOfRows;
|
|
}
|
|
}
|
|
|
|
export interface ConsoleResizedEvent {
|
|
width: number,
|
|
height: number
|
|
}
|