Isolate action added

This commit is contained in:
piotrpekala7 2021-12-28 00:18:28 +01:00
parent f721bd0d26
commit 6353207d40
5 changed files with 45 additions and 0 deletions

View File

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

View File

@ -0,0 +1,4 @@
<button mat-menu-item (click)="isolate()">
<mat-icon>link_off</mat-icon>
<span>Isolate</span>
</button>

View File

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

View File

@ -32,6 +32,9 @@
[server]="server"
[node]="nodes[0]"
></app-open-file-explorer-action>
<app-isolate-node-action *ngIf="nodes.length === 1" [server]="server" [node]="nodes[0]"></app-isolate-node-action>
<app-change-hostname-action
*ngIf="!projectService.isReadOnly(project) && nodes.length === 1"
[server]="server"

View File

@ -16,6 +16,14 @@ export class NodeService {
return this.httpServer.get(server, `/projects/${projectId}/nodes/${nodeId}`);
}
isolate(server: Server, node: Node) {
return this.httpServer.post<Node>(server, `/projects/${node.project_id}/nodes/${node.node_id}/isolate`, {});
}
unisolate(server: Server, node: Node) {
return this.httpServer.post<Node>(server, `/projects/${node.project_id}/nodes/${node.node_id}/unisolate`, {});
}
start(server: Server, node: Node) {
return this.httpServer.post<Node>(server, `/projects/${node.project_id}/nodes/${node.node_id}/start`, {});
}