diff --git a/src/app/app.module.ts b/src/app/app.module.ts index d14e9e91..3edba25a 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -210,6 +210,7 @@ import { EditProjectDialogComponent } from './components/projects/edit-project-d 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'; +import { SuspendNodeActionComponent } from './components/project-map/context-menu/actions/suspend-node-action/suspend-node-action.component'; if (environment.production) { Raven.config('https://b2b1cfd9b043491eb6b566fd8acee358@sentry.io/842726', { @@ -347,7 +348,8 @@ if (environment.production) { ChangeSymbolDialogComponent, ChangeSymbolActionComponent, EditProjectDialogComponent, - ReloadNodeActionComponent + ReloadNodeActionComponent, + SuspendNodeActionComponent ], imports: [ BrowserModule, diff --git a/src/app/components/project-map/context-menu/actions/suspend-node-action/suspend-node-action.component.html b/src/app/components/project-map/context-menu/actions/suspend-node-action/suspend-node-action.component.html new file mode 100644 index 00000000..de0b01c3 --- /dev/null +++ b/src/app/components/project-map/context-menu/actions/suspend-node-action/suspend-node-action.component.html @@ -0,0 +1,4 @@ + diff --git a/src/app/components/project-map/context-menu/actions/suspend-node-action/suspend-node-action.component.spec.ts b/src/app/components/project-map/context-menu/actions/suspend-node-action/suspend-node-action.component.spec.ts new file mode 100644 index 00000000..e69de29b diff --git a/src/app/components/project-map/context-menu/actions/suspend-node-action/suspend-node-action.component.ts b/src/app/components/project-map/context-menu/actions/suspend-node-action/suspend-node-action.component.ts new file mode 100644 index 00000000..17688b62 --- /dev/null +++ b/src/app/components/project-map/context-menu/actions/suspend-node-action/suspend-node-action.component.ts @@ -0,0 +1,36 @@ +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-suspend-node-action', + templateUrl: './suspend-node-action.component.html' +}) +export class SuspendNodeActionComponent implements OnInit, OnChanges { + @Input() server: Server; + @Input() nodes: Node[]; + isNodeWithStartedStatus: boolean; + + constructor(private nodeService: NodeService) {} + + ngOnInit() { + } + + ngOnChanges(changes) { + if(changes.nodes) { + this.isNodeWithStartedStatus = false; + this.nodes.forEach((node) => { + if (node.status === 'started') { + this.isNodeWithStartedStatus = true; + } + }); + } + } + + suspendNodes() { + this.nodes.forEach((node) => { + this.nodeService.suspend(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 ebfb04cf..091a6fcf 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 @@ -6,6 +6,7 @@ [node]="nodes[0]" > +