mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-06-16 13:58:13 +00:00
Code optimization
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import { Component, Input, ChangeDetectionStrategy } from "@angular/core";
|
||||
import { Component, Input, ChangeDetectionStrategy } from '@angular/core';
|
||||
import { Project } from '../../../models/project';
|
||||
import { Server } from '../../../models/server';
|
||||
import { NodeService } from '../../../services/node.service';
|
||||
@ -9,68 +9,70 @@ import { SettingsService } from '../../../services/settings.service';
|
||||
import { ServerService } from '../../../services/server.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-nodes-menu',
|
||||
templateUrl: './nodes-menu.component.html',
|
||||
styleUrls: ['./nodes-menu.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
selector: 'app-nodes-menu',
|
||||
templateUrl: './nodes-menu.component.html',
|
||||
styleUrls: ['./nodes-menu.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class NodesMenuComponent {
|
||||
@Input('project') project: Project;
|
||||
@Input('server') server: Server;
|
||||
@Input('project') project: Project;
|
||||
@Input('server') server: Server;
|
||||
|
||||
constructor(
|
||||
private nodeService: NodeService,
|
||||
private nodesDataSource: NodesDataSource,
|
||||
private toasterService: ToasterService,
|
||||
private serverService: ServerService,
|
||||
private settingsService: SettingsService,
|
||||
private electronService: ElectronService
|
||||
) {}
|
||||
constructor(
|
||||
private nodeService: NodeService,
|
||||
private nodesDataSource: NodesDataSource,
|
||||
private toasterService: ToasterService,
|
||||
private serverService: ServerService,
|
||||
private settingsService: SettingsService,
|
||||
private electronService: ElectronService
|
||||
) {}
|
||||
|
||||
async startConsoleForAllNodes() {
|
||||
if (this.electronService.isElectronApp) {
|
||||
let consoleCommand = this.settingsService.get<string>('console_command') ? this.settingsService.get<string>('console_command') : this.nodeService.getDefaultCommand();
|
||||
async startConsoleForAllNodes() {
|
||||
if (this.electronService.isElectronApp) {
|
||||
let consoleCommand = this.settingsService.get<string>('console_command')
|
||||
? this.settingsService.get<string>('console_command')
|
||||
: this.nodeService.getDefaultCommand();
|
||||
|
||||
let nodes = this.nodesDataSource.getItems();
|
||||
for(var node of nodes) {
|
||||
const request = {
|
||||
command: consoleCommand,
|
||||
type: node.console_type,
|
||||
host: node.console_host,
|
||||
port: node.console,
|
||||
name: node.name,
|
||||
project_id: node.project_id,
|
||||
node_id: node.node_id,
|
||||
server_url: this.serverService.getServerUrl(this.server)
|
||||
};
|
||||
await this.electronService.remote.require('./console-executor.js').openConsole(request);
|
||||
}
|
||||
} else {
|
||||
this.toasterService.error("Option to start all nodes not available in web browser.");
|
||||
}
|
||||
let nodes = this.nodesDataSource.getItems();
|
||||
for (var node of nodes) {
|
||||
const request = {
|
||||
command: consoleCommand,
|
||||
type: node.console_type,
|
||||
host: node.console_host,
|
||||
port: node.console,
|
||||
name: node.name,
|
||||
project_id: node.project_id,
|
||||
node_id: node.node_id,
|
||||
server_url: this.serverService.getServerUrl(this.server),
|
||||
};
|
||||
await this.electronService.remote.require('./console-executor.js').openConsole(request);
|
||||
}
|
||||
} else {
|
||||
this.toasterService.error('Option to start all nodes not available in web browser.');
|
||||
}
|
||||
}
|
||||
|
||||
startNodes() {
|
||||
this.nodeService.startAll(this.server, this.project).subscribe(() => {
|
||||
this.toasterService.success('All nodes successfully started');
|
||||
});
|
||||
}
|
||||
startNodes() {
|
||||
this.nodeService.startAll(this.server, this.project).subscribe(() => {
|
||||
this.toasterService.success('All nodes successfully started');
|
||||
});
|
||||
}
|
||||
|
||||
stopNodes() {
|
||||
this.nodeService.stopAll(this.server, this.project).subscribe(() => {
|
||||
this.toasterService.success('All nodes successfully stopped');
|
||||
});
|
||||
}
|
||||
stopNodes() {
|
||||
this.nodeService.stopAll(this.server, this.project).subscribe(() => {
|
||||
this.toasterService.success('All nodes successfully stopped');
|
||||
});
|
||||
}
|
||||
|
||||
suspendNodes() {
|
||||
this.nodeService.suspendAll(this.server, this.project).subscribe(() => {
|
||||
this.toasterService.success('All nodes successfully suspended');
|
||||
});
|
||||
}
|
||||
suspendNodes() {
|
||||
this.nodeService.suspendAll(this.server, this.project).subscribe(() => {
|
||||
this.toasterService.success('All nodes successfully suspended');
|
||||
});
|
||||
}
|
||||
|
||||
reloadNodes() {
|
||||
this.nodeService.reloadAll(this.server, this.project).subscribe(() => {
|
||||
this.toasterService.success('All nodes successfully reloaded');
|
||||
});
|
||||
}
|
||||
reloadNodes() {
|
||||
this.nodeService.reloadAll(this.server, this.project).subscribe(() => {
|
||||
this.toasterService.success('All nodes successfully reloaded');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user