From 6353207d4072767ad89a90edd2b90095496f37e0 Mon Sep 17 00:00:00 2001 From: piotrpekala7 <31202938+piotrpekala7@users.noreply.github.com> Date: Tue, 28 Dec 2021 00:18:28 +0100 Subject: [PATCH] Isolate action added --- src/app/app.module.ts | 2 ++ .../isolate-node-action.component.html | 4 +++ .../isolate-node-action.component.ts | 28 +++++++++++++++++++ .../context-menu/context-menu.component.html | 3 ++ src/app/services/node.service.ts | 8 ++++++ 5 files changed, 45 insertions(+) create mode 100644 src/app/components/project-map/context-menu/actions/isolate-node-action/isolate-node-action.component.html create mode 100644 src/app/components/project-map/context-menu/actions/isolate-node-action/isolate-node-action.component.ts diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 9d2d369b..414ff253 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -129,6 +129,7 @@ import { StartCaptureOnStartedLinkActionComponent } from './components/project-m import { StartCaptureActionComponent } from './components/project-map/context-menu/actions/start-capture/start-capture-action.component'; import { StartNodeActionComponent } from './components/project-map/context-menu/actions/start-node-action/start-node-action.component'; import { StopCaptureActionComponent } from './components/project-map/context-menu/actions/stop-capture/stop-capture-action.component'; +import { IsolateNodeActionComponent } from './components/project-map/context-menu/actions/isolate-node-action/isolate-node-action.component'; import { StopNodeActionComponent } from './components/project-map/context-menu/actions/stop-node-action/stop-node-action.component'; import { SuspendLinkActionComponent } from './components/project-map/context-menu/actions/suspend-link/suspend-link-action.component'; import { SuspendNodeActionComponent } from './components/project-map/context-menu/actions/suspend-node-action/suspend-node-action.component'; @@ -290,6 +291,7 @@ import { LoggedUserComponent } from './components/users/logged-user/logged-user. ContextMenuComponent, ContextConsoleMenuComponent, StartNodeActionComponent, + IsolateNodeActionComponent, StopNodeActionComponent, TemplateComponent, TemplateListDialogComponent, diff --git a/src/app/components/project-map/context-menu/actions/isolate-node-action/isolate-node-action.component.html b/src/app/components/project-map/context-menu/actions/isolate-node-action/isolate-node-action.component.html new file mode 100644 index 00000000..656bd1eb --- /dev/null +++ b/src/app/components/project-map/context-menu/actions/isolate-node-action/isolate-node-action.component.html @@ -0,0 +1,4 @@ + diff --git a/src/app/components/project-map/context-menu/actions/isolate-node-action/isolate-node-action.component.ts b/src/app/components/project-map/context-menu/actions/isolate-node-action/isolate-node-action.component.ts new file mode 100644 index 00000000..2bd1d117 --- /dev/null +++ b/src/app/components/project-map/context-menu/actions/isolate-node-action/isolate-node-action.component.ts @@ -0,0 +1,28 @@ +import { Component, Input, OnInit } from '@angular/core'; +import { Node } from '../../../../../cartography/models/node'; +import { Server } from '../../../../../models/server'; +import { NodeService } from '../../../../../services/node.service'; +import { ToasterService } from '../../../../../services/toaster.service'; + +@Component({ + selector: 'app-isolate-node-action', + templateUrl: './isolate-node-action.component.html', +}) +export class IsolateNodeActionComponent implements OnInit { + @Input() server: Server; + @Input() node: Node; + isNodeWithStoppedStatus: boolean; + + constructor(private nodeService: NodeService, private toasterService: ToasterService) {} + + ngOnInit() {} + + isolate() { + this.nodeService.isolate(this.server, this.node).subscribe( + (n: Node) => {}, + (error) => { + this.toasterService.error(error.error.message); + } + ); + } +} 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 38c810d0..6f0bf4b7 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 @@ -32,6 +32,9 @@ [server]="server" [node]="nodes[0]" > + + + (server, `/projects/${node.project_id}/nodes/${node.node_id}/isolate`, {}); + } + + unisolate(server: Server, node: Node) { + return this.httpServer.post(server, `/projects/${node.project_id}/nodes/${node.node_id}/unisolate`, {}); + } + start(server: Server, node: Node) { return this.httpServer.post(server, `/projects/${node.project_id}/nodes/${node.node_id}/start`, {}); }