From 8442a9055c87a185e806739683f40cba7c2e1ae9 Mon Sep 17 00:00:00 2001 From: ziajka Date: Tue, 12 Mar 2019 14:11:05 +0100 Subject: [PATCH] Fix starting and stopping nodes --- .../start-node-action.component.ts | 20 ++++++++++++------- .../stop-node-action.component.ts | 20 ++++++++++++------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/app/components/project-map/context-menu/actions/start-node-action/start-node-action.component.ts b/src/app/components/project-map/context-menu/actions/start-node-action/start-node-action.component.ts index 80247bae..991bd5b5 100644 --- a/src/app/components/project-map/context-menu/actions/start-node-action/start-node-action.component.ts +++ b/src/app/components/project-map/context-menu/actions/start-node-action/start-node-action.component.ts @@ -1,4 +1,4 @@ -import { Component, Input, OnInit } from '@angular/core'; +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'; @@ -7,7 +7,7 @@ import { Node } from '../../../../../cartography/models/node'; selector: 'app-start-node-action', templateUrl: './start-node-action.component.html' }) -export class StartNodeActionComponent implements OnInit { +export class StartNodeActionComponent implements OnInit, OnChanges { @Input() server: Server; @Input() nodes: Node[]; isNodeWithStoppedStatus: boolean; @@ -15,11 +15,17 @@ export class StartNodeActionComponent implements OnInit { constructor(private nodeService: NodeService) {} ngOnInit() { - this.nodes.forEach((node) => { - if (node.status === 'stopped') { - this.isNodeWithStoppedStatus = true; - } - }); + } + + ngOnChanges(changes) { + if(changes.nodes) { + this.isNodeWithStoppedStatus = false; + this.nodes.forEach((node) => { + if (node.status === 'stopped') { + this.isNodeWithStoppedStatus = true; + } + }); + } } startNodes() { diff --git a/src/app/components/project-map/context-menu/actions/stop-node-action/stop-node-action.component.ts b/src/app/components/project-map/context-menu/actions/stop-node-action/stop-node-action.component.ts index 36fd1a64..2d7fcc81 100644 --- a/src/app/components/project-map/context-menu/actions/stop-node-action/stop-node-action.component.ts +++ b/src/app/components/project-map/context-menu/actions/stop-node-action/stop-node-action.component.ts @@ -1,4 +1,4 @@ -import { Component, Input, OnInit } from '@angular/core'; +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'; @@ -7,7 +7,7 @@ import { Node } from '../../../../../cartography/models/node'; selector: 'app-stop-node-action', templateUrl: './stop-node-action.component.html' }) -export class StopNodeActionComponent implements OnInit { +export class StopNodeActionComponent implements OnInit, OnChanges { @Input() server: Server; @Input() nodes: Node[]; isNodeWithStartedStatus: boolean; @@ -15,11 +15,17 @@ export class StopNodeActionComponent implements OnInit { constructor(private nodeService: NodeService) {} ngOnInit() { - this.nodes.forEach((node) => { - if (node.status === 'started') { - this.isNodeWithStartedStatus = true; - } - }); + } + + ngOnChanges(changes) { + if(changes.nodes) { + this.isNodeWithStartedStatus = false; + this.nodes.forEach((node) => { + if (node.status === 'started') { + this.isNodeWithStartedStatus = true; + } + }); + } } stopNodes() {