mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2024-12-28 08:48:50 +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 { DrawingService } from '../../../../../services/drawing.service';
|
||||||
import { LinkService } from '../../../../../services/link.service';
|
import { LinkService } from '../../../../../services/link.service';
|
||||||
import { NodeService } from '../../../../../services/node.service';
|
import { NodeService } from '../../../../../services/node.service';
|
||||||
|
import { ToasterService } from '../../../../../services/toaster.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-delete-action',
|
selector: 'app-delete-action',
|
||||||
@ -23,6 +24,7 @@ export class DeleteActionComponent implements OnInit {
|
|||||||
@Input() links: Link[];
|
@Input() links: Link[];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
private toasterService: ToasterService,
|
||||||
private nodesDataSource: NodesDataSource,
|
private nodesDataSource: NodesDataSource,
|
||||||
private drawingsDataSource: DrawingsDataSource,
|
private drawingsDataSource: DrawingsDataSource,
|
||||||
private linksDataSource: LinksDataSource,
|
private linksDataSource: LinksDataSource,
|
||||||
@ -46,22 +48,34 @@ export class DeleteActionComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
delete() {
|
delete() {
|
||||||
this.nodes.forEach((node) => {
|
|
||||||
this.nodesDataSource.remove(node);
|
|
||||||
|
|
||||||
|
this.nodes.forEach((node) => {
|
||||||
|
if (!node.locked) {
|
||||||
|
this.nodesDataSource.remove(node);
|
||||||
this.nodeService.delete(this.controller, node).subscribe((node: 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.drawings.forEach((drawing) => {
|
||||||
|
if (!drawing.locked) {
|
||||||
this.drawingsDataSource.remove(drawing);
|
this.drawingsDataSource.remove(drawing);
|
||||||
|
|
||||||
this.drawingService.delete(this.controller, drawing).subscribe((drawing: Drawing) => {});
|
this.drawingService.delete(this.controller, drawing).subscribe((drawing: Drawing) => {});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.toasterService.error('Cannot delete locked drawing');
|
||||||
|
return;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (this.nodes.length == 0 && this.drawings.length == 0) {
|
||||||
this.links.forEach((link) => {
|
this.links.forEach((link) => {
|
||||||
this.linksDataSource.remove(link);
|
this.linksDataSource.remove(link);
|
||||||
|
|
||||||
this.linkService.deleteLink(this.controller, link).subscribe(() => {});
|
this.linkService.deleteLink(this.controller, link).subscribe(() => {});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user