mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2024-12-27 00:21:03 +00:00
Prevent to delete locked nodes and drawings
This commit is contained in:
parent
3c48ef67dc
commit
a27a7ff4ee
@ -11,6 +11,7 @@ import { Controller } from '../../../../../models/controller';
|
||||
import { DrawingService } from '../../../../../services/drawing.service';
|
||||
import { LinkService } from '../../../../../services/link.service';
|
||||
import { NodeService } from '../../../../../services/node.service';
|
||||
import { ToasterService } from '../../../../../services/toaster.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-delete-action',
|
||||
@ -23,6 +24,7 @@ export class DeleteActionComponent implements OnInit {
|
||||
@Input() links: Link[];
|
||||
|
||||
constructor(
|
||||
private toasterService: ToasterService,
|
||||
private nodesDataSource: NodesDataSource,
|
||||
private drawingsDataSource: DrawingsDataSource,
|
||||
private linksDataSource: LinksDataSource,
|
||||
@ -46,22 +48,34 @@ export class DeleteActionComponent implements OnInit {
|
||||
}
|
||||
|
||||
delete() {
|
||||
this.nodes.forEach((node) => {
|
||||
this.nodesDataSource.remove(node);
|
||||
|
||||
this.nodeService.delete(this.controller, node).subscribe((node: Node) => {});
|
||||
this.nodes.forEach((node) => {
|
||||
if (!node.locked) {
|
||||
this.nodesDataSource.remove(node);
|
||||
this.nodeService.delete(this.controller, node).subscribe((node: Node) => {});
|
||||
}
|
||||
else {
|
||||
this.toasterService.error('Cannot delete locked node: ' + node.name);
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
this.drawings.forEach((drawing) => {
|
||||
this.drawingsDataSource.remove(drawing);
|
||||
|
||||
this.drawingService.delete(this.controller, drawing).subscribe((drawing: Drawing) => {});
|
||||
if (!drawing.locked) {
|
||||
this.drawingsDataSource.remove(drawing);
|
||||
this.drawingService.delete(this.controller, drawing).subscribe((drawing: Drawing) => {});
|
||||
}
|
||||
else {
|
||||
this.toasterService.error('Cannot delete locked drawing');
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
this.links.forEach((link) => {
|
||||
this.linksDataSource.remove(link);
|
||||
|
||||
this.linkService.deleteLink(this.controller, link).subscribe(() => {});
|
||||
});
|
||||
if (this.nodes.length == 0 && this.drawings.length == 0) {
|
||||
this.links.forEach((link) => {
|
||||
this.linksDataSource.remove(link);
|
||||
this.linkService.deleteLink(this.controller, link).subscribe(() => {});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user