Reload action added

This commit is contained in:
Piotr Pekala 2019-09-06 08:51:13 -07:00
parent 00597accac
commit cd5edebd98
5 changed files with 41 additions and 1 deletions

View File

@ -209,6 +209,7 @@ import { ChangeSymbolActionComponent } from './components/project-map/context-me
import { EditProjectDialogComponent } from './components/projects/edit-project-dialog/edit-project-dialog.component';
import { ProjectsFilter } from './filters/projectsFilter.pipe';
import { ComputeService } from './services/compute.service';
import { ReloadNodeActionComponent } from './components/project-map/context-menu/actions/reload-node-action/reload-node-action.component';
if (environment.production) {
Raven.config('https://b2b1cfd9b043491eb6b566fd8acee358@sentry.io/842726', {
@ -345,7 +346,8 @@ if (environment.production) {
ConsoleDeviceActionBrowserComponent,
ChangeSymbolDialogComponent,
ChangeSymbolActionComponent,
EditProjectDialogComponent
EditProjectDialogComponent,
ReloadNodeActionComponent
],
imports: [
BrowserModule,

View File

@ -0,0 +1,4 @@
<button mat-menu-item *ngIf="filteredNodes.length > 0" (click)="reloadNodes()">
<mat-icon>refresh</mat-icon>
<span>Reload</span>
</button>

View File

@ -0,0 +1,31 @@
import { Component, Input, OnInit, OnChanges } from '@angular/core';
import { Server } from '../../../../../models/server';
import { NodeService } from '../../../../../services/node.service';
import { Node } from '../../../../../cartography/models/node';
@Component({
selector: 'app-reload-node-action',
templateUrl: './reload-node-action.component.html'
})
export class ReloadNodeActionComponent implements OnInit {
@Input() server: Server;
@Input() nodes: Node[];
filteredNodes: Node[] = [];
constructor(private nodeService: NodeService) {}
ngOnInit() {
this.nodes.forEach((node) => {
if (node.node_type === 'vpcs' || node.node_type === 'qemu' || node.node_type === 'virtualbox' || node.node_type === 'vmware') {
this.filteredNodes.push(node);
}
});
}
reloadNodes() {
this.filteredNodes.forEach((node) => {
this.nodeService.reload(this.server, node).subscribe((n: Node) => {});
});
}
}

View File

@ -7,6 +7,9 @@
></app-show-node-action>
<app-start-node-action *ngIf="nodes.length && labels.length===0" [server]="server" [nodes]="nodes"></app-start-node-action>
<app-stop-node-action *ngIf="nodes.length && labels.length===0" [server]="server" [nodes]="nodes"></app-stop-node-action>
<app-reload-node-action
*ngIf="nodes.length" [server]="server" [nodes]="nodes"
></app-reload-node-action>
<app-console-device-action
*ngIf="!projectService.isReadOnly(project) && nodes.length && isElectronApp"
[server]="server"