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

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