From cd5edebd98a229759b21867034d5519a3513cc8c Mon Sep 17 00:00:00 2001 From: Piotr Pekala Date: Fri, 6 Sep 2019 08:51:13 -0700 Subject: [PATCH] Reload action added --- src/app/app.module.ts | 4 ++- .../reload-node-action.component.html | 4 +++ .../reload-node-action.component.spec.ts | 0 .../reload-node-action.component.ts | 31 +++++++++++++++++++ .../context-menu/context-menu.component.html | 3 ++ 5 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 src/app/components/project-map/context-menu/actions/reload-node-action/reload-node-action.component.html create mode 100644 src/app/components/project-map/context-menu/actions/reload-node-action/reload-node-action.component.spec.ts create mode 100644 src/app/components/project-map/context-menu/actions/reload-node-action/reload-node-action.component.ts diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 3914b17b..d14e9e91 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -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, diff --git a/src/app/components/project-map/context-menu/actions/reload-node-action/reload-node-action.component.html b/src/app/components/project-map/context-menu/actions/reload-node-action/reload-node-action.component.html new file mode 100644 index 00000000..f8884c90 --- /dev/null +++ b/src/app/components/project-map/context-menu/actions/reload-node-action/reload-node-action.component.html @@ -0,0 +1,4 @@ + diff --git a/src/app/components/project-map/context-menu/actions/reload-node-action/reload-node-action.component.spec.ts b/src/app/components/project-map/context-menu/actions/reload-node-action/reload-node-action.component.spec.ts new file mode 100644 index 00000000..e69de29b diff --git a/src/app/components/project-map/context-menu/actions/reload-node-action/reload-node-action.component.ts b/src/app/components/project-map/context-menu/actions/reload-node-action/reload-node-action.component.ts new file mode 100644 index 00000000..7cee91cc --- /dev/null +++ b/src/app/components/project-map/context-menu/actions/reload-node-action/reload-node-action.component.ts @@ -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) => {}); + }); + } +} diff --git a/src/app/components/project-map/context-menu/context-menu.component.html b/src/app/components/project-map/context-menu/context-menu.component.html index 91962af5..ebfb04cf 100644 --- a/src/app/components/project-map/context-menu/context-menu.component.html +++ b/src/app/components/project-map/context-menu/context-menu.component.html @@ -7,6 +7,9 @@ > +