Action to suspend added

This commit is contained in:
Piotr Pekala 2019-09-09 02:27:48 -07:00
parent cd5edebd98
commit 5e76feca5c
5 changed files with 44 additions and 1 deletions

View File

@ -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,

View File

@ -0,0 +1,4 @@
<button mat-menu-item *ngIf="isNodeWithStartedStatus" (click)="suspendNodes()">
<mat-icon>pause</mat-icon>
<span>Suspend</span>
</button>

View File

@ -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) => {});
});
}
}

View File

@ -6,6 +6,7 @@
[node]="nodes[0]"
></app-show-node-action>
<app-start-node-action *ngIf="nodes.length && labels.length===0" [server]="server" [nodes]="nodes"></app-start-node-action>
<app-suspend-node-action *ngIf="nodes.length && labels.length===0" [server]="server" [nodes]="nodes"></app-suspend-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"