mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-06-15 13:28:10 +00:00
Basic OS Console executor
This commit is contained in:
@ -0,0 +1,4 @@
|
||||
<button mat-menu-item (click)="console()">
|
||||
<mat-icon>web_asset</mat-icon>
|
||||
<span>Console</span>
|
||||
</button>
|
@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ConsoleDeviceActionComponent } from './console-device-action.component';
|
||||
|
||||
describe('ConsoleDeviceActionComponent', () => {
|
||||
let component: ConsoleDeviceActionComponent;
|
||||
let fixture: ComponentFixture<ConsoleDeviceActionComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ ConsoleDeviceActionComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ConsoleDeviceActionComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
@ -0,0 +1,43 @@
|
||||
import { Component, OnInit, Input } from '@angular/core';
|
||||
import { Node } from '../../../../../cartography/models/node';
|
||||
import { Server } from '../../../../../models/server';
|
||||
import { ElectronService } from 'ngx-electron';
|
||||
import { Project } from '../../../../../models/project';
|
||||
import { ServerService } from '../../../../../services/server.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-console-device-action',
|
||||
templateUrl: './console-device-action.component.html'
|
||||
})
|
||||
export class ConsoleDeviceActionComponent implements OnInit {
|
||||
@Input() server: Server;
|
||||
@Input() project: Project;
|
||||
@Input() nodes: Node[];
|
||||
|
||||
constructor(
|
||||
private electronService: ElectronService,
|
||||
private serverService: ServerService
|
||||
) { }
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
|
||||
async console() {
|
||||
for(var node of this.nodes) {
|
||||
const consoleRequest = {
|
||||
type: node.console_type,
|
||||
host: node.console_host,
|
||||
port: node.console,
|
||||
name: node.name,
|
||||
project_id: this.project.project_id,
|
||||
node_id: node.node_id,
|
||||
server_url: this.serverService.getServerUrl(this.server)
|
||||
};
|
||||
await this.openConsole(consoleRequest);
|
||||
}
|
||||
}
|
||||
|
||||
async openConsole(request) {
|
||||
return await this.electronService.remote.require('./console-executor.js').openConsole(request);
|
||||
}
|
||||
}
|
@ -3,6 +3,12 @@
|
||||
<mat-menu #contextMenu="matMenu" class="context-menu-items">
|
||||
<app-start-node-action *ngIf="nodes.length" [server]="server" [nodes]="nodes"></app-start-node-action>
|
||||
<app-stop-node-action *ngIf="nodes.length" [server]="server" [nodes]="nodes"></app-stop-node-action>
|
||||
<app-console-device-action
|
||||
*ngIf="!projectService.isReadOnly(project) && nodes.length && isElectronApp"
|
||||
[project]="project"
|
||||
[server]="server"
|
||||
[nodes]="nodes"
|
||||
></app-console-device-action>
|
||||
<app-edit-style-action *ngIf="drawings.length===1 && !hasTextCapabilities"
|
||||
[server]="server"
|
||||
[project]="project"
|
||||
|
@ -9,6 +9,7 @@ import { Drawing } from '../../../cartography/models/drawing';
|
||||
import { TextElement } from '../../../cartography/models/drawings/text-element';
|
||||
import { Label } from '../../../cartography/models/label';
|
||||
import { Link } from '../../../models/link';
|
||||
import { ElectronService } from 'ngx-electron';
|
||||
|
||||
|
||||
@Component({
|
||||
@ -30,16 +31,19 @@ export class ContextMenuComponent implements OnInit {
|
||||
labels: Label[] = [];
|
||||
links: Link[] = [];
|
||||
|
||||
hasTextCapabilities: boolean = false;
|
||||
hasTextCapabilities = false;
|
||||
isElectronApp = false;
|
||||
|
||||
constructor(
|
||||
private sanitizer: DomSanitizer,
|
||||
private changeDetector: ChangeDetectorRef,
|
||||
private electronService: ElectronService,
|
||||
public projectService: ProjectService
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.setPosition(0, 0);
|
||||
this.isElectronApp = this.electronService.isElectronApp;
|
||||
}
|
||||
|
||||
public setPosition(top: number, left: number) {
|
||||
|
Reference in New Issue
Block a user