/**
* @file NS Compose Component
*/
+import { isNullOrUndefined } from 'util';
import { HttpHeaders } from '@angular/common/http';
import { Component, ElementRef, Injector, ViewChild, ViewEncapsulation } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
} from 'NSDModel';
import { RestService } from 'RestService';
import { SharedService } from 'SharedService';
-import { isNullOrUndefined } from 'util';
import { VNFD, VNFData } from 'VNFDModel';
/**
};
/** Contains the information of the type of modification @public */
public putType: string;
+ /** Contains index of old VLD @public */
+ public getOldVLDIndex: string[];
/** Conatins mousedown action @public */
public mousedownNode: COMPOSERNODES = null;
/** Conatins mouseup action @public */
/** Contains sidebar open status @public */
public sideBarOpened: boolean = false;
/** Contains SVG attributes @private */
- // tslint:disable-next-line:no-any
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
private svg: any;
/** Contains the Drag line */
- // tslint:disable-next-line: no-any
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
private dragLine: any;
/** Contains VL node @private */
- // tslint:disable-next-line:no-any
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
private vlNode: any;
/** Contains VNFD node @private */
- // tslint:disable-next-line:no-any
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
private vnfdnode: any;
/** Contains CP node @private */
- // tslint:disable-next-line:no-any
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
private cpnode: any;
/** Rendered nodes represent VL @private */
- // tslint:disable-next-line:no-any
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
private gvlNode: any;
/** Rendered nodes represent VL @private */
- // tslint:disable-next-line:no-any
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
private gvnfdNode: any;
/** Rendered nodes represent VL @private */
- // tslint:disable-next-line:no-any
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
private gcpNode: any;
/** Contains forced node animations @private */
- // tslint:disable-next-line:no-any
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
private force: any;
/** Contains all the selected node @private */
private selectedNode: COMPOSERNODES[] = [];
/** Contains the VNFD copy @private */
private vnfdCopy: string;
/** Contains path information of the node */
- // tslint:disable-next-line:no-any
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
private path: any;
/** Contains the node information @private */
private nodes: COMPOSERNODES[] = [];
this.modalService = this.injector.get(NgbModal);
this.sharedService = this.injector.get(SharedService);
}
- /** Lifecyle Hooks the trigger before component is instantiate @public */
+ /** Lifecyle Hooks the trigger before component is instantiated @public */
public ngOnInit(): void {
- // tslint:disable-next-line:no-backbone-get-set-outside-model
this.identifier = this.activatedRoute.snapshot.paramMap.get('id');
this.generateData();
this.headers = new HttpHeaders({
- 'Content-Type': 'application/zip',
+ 'Content-Type': 'application/gzip',
Accept: 'application/json',
'Cache-Control': 'no-cache, no-store, must-revalidate, max-age=0'
});
}
/** Events handles at drag on D3 region @public */
- // tslint:disable-next-line:no-any
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
public drag(ev: any): void {
if (ev.target.id === 'vl') {
ev.dataTransfer.setData('text', ev.target.id);
}
/** Show Info @public */
public showInfo(): void {
+ // eslint-disable-next-line security/detect-non-literal-fs-filename
const modalRef: NgbModalRef = this.modalService.open(ConfirmationTopologyComponent, { backdrop: 'static' });
modalRef.componentInstance.topologyType = 'Info';
modalRef.componentInstance.topologytitle = this.translateService.instant('PAGE.TOPOLOGY.INFO');
if (result) {
// empty
}
- }).catch();
+ }).catch((): void => {
+ // Catch Navigation Error
+ });
}
/** Event to freeze the animation @public */
public onFreeze(): void {
this.separateAndCreatenode();
}, (error: ERRORDATA): void => {
if (error.error.status === HttpStatus.NOT_FOUND || error.error.status === HttpStatus.UNAUTHORIZED) {
- this.router.navigateByUrl('404', { skipLocationChange: true }).catch();
+ this.router.navigateByUrl('404', { skipLocationChange: true }).catch((): void => {
+ // Catch Navigation Error
+ });
} else {
this.restService.handleError(error, 'get');
}
resultVLC['constituent-cpd-id'].forEach((resultCCI: CCI): void => {
this.vnfdCopy = resultVLC['virtual-link-profile-id'];
this.connectionPoint = resVNF.id + ':' + resultCCI['constituent-base-element-id'] + index + ':' + resultCCI['constituent-cpd-id'];
- const connectionPointPos: number = this.nodes.map((e: COMPOSERNODES): string => { return e.id; }).indexOf(this.connectionPoint);
- const nsdPos: number = this.nodes.map((e: COMPOSERNODES): string => { return e.id; }).indexOf(this.nsdCopy);
- const vnfdPos: number = this.nodes.map((e: COMPOSERNODES): string => { return e.id; }).indexOf(this.vnfdCopy);
+ const connectionPointPos: number = this.nodes.map((e: COMPOSERNODES): string => e.id).indexOf(this.connectionPoint);
+ const nsdPos: number = this.nodes.map((e: COMPOSERNODES): string => e.id).indexOf(this.nsdCopy);
+ const vnfdPos: number = this.nodes.map((e: COMPOSERNODES): string => e.id).indexOf(this.vnfdCopy);
this.links.push(
{
+ // eslint-disable-next-line security/detect-object-injection
source: this.nodes[connectionPointPos],
+ // eslint-disable-next-line security/detect-object-injection
target: this.nodes[nsdPos]
},
{
+ // eslint-disable-next-line security/detect-object-injection
source: this.nodes[connectionPointPos],
+ // eslint-disable-next-line security/detect-object-injection
target: this.nodes[vnfdPos]
});
});
.attr('x', graphContainerAttr.imageX)
.attr('y', graphContainerAttr.imageY)
.call(this.onDragDrop())
- .attr('id', (d: COMPOSERNODES): string => { return d.selectorId; })
+ .attr('id', (d: COMPOSERNODES): string => d.selectorId)
.attr('class', 'node').attr('width', graphContainerAttr.nodeWidth).attr('height', graphContainerAttr.nodeHeight)
.attr('xlink:href', 'assets/images/VL.svg')
.on('mousedown', (d: COMPOSERNODES): void => { this.mouseDown(d); })
.attr('x', graphContainerAttr.imageX)
.attr('y', graphContainerAttr.imageY)
.call(this.onDragDrop())
- .attr('id', (d: COMPOSERNODES): string => { return d.selectorId; })
+ .attr('id', (d: COMPOSERNODES): string => d.selectorId)
.attr('class', 'node').attr('width', graphContainerAttr.nodeWidth).attr('height', graphContainerAttr.nodeHeight)
.attr('xlink:href', 'assets/images/VNFD.svg')
.on('mousedown', (d: COMPOSERNODES): void => { this.mouseDown(d); })
.attr('x', graphContainerAttr.imageX)
.attr('y', graphContainerAttr.imageY)
.call(this.onDragDrop())
- .attr('id', (d: COMPOSERNODES): string => { return d.selectorId; })
+ .attr('id', (d: COMPOSERNODES): string => d.selectorId)
.attr('class', 'node').attr('width', graphContainerAttr.nodeWidth).attr('height', graphContainerAttr.nodeHeight)
.attr('xlink:href', 'assets/images/CP.svg')
.on('mousedown', (d: COMPOSERNODES): void => { this.mouseDown(d); })
});
}
if (this.vlName !== undefined && this.setVnfdName !== undefined && this.setVnfdConnectionPointRef !== undefined) {
+ // eslint-disable-next-line security/detect-non-literal-fs-filename
const modalRef: NgbModalRef = this.modalService.open(ConfirmationTopologyComponent, { backdrop: 'static' });
modalRef.componentInstance.topologyType = 'Add';
modalRef.componentInstance.cpDetails = this.getVNFSelectedData['ext-cpd'];
} else {
this.deselectPath();
}
- }).catch();
+ }).catch((): void => {
+ // Catch Navigation Error
+ });
} else {
this.deselectPath();
this.notifierService.notify('error', this.translateService.instant('ERROR'));
}
/** Events handles when mousedown click it will capture the selected node data @private */
private mouseDown(d: COMPOSERNODES): void {
+ // eslint-disable-next-line deprecation/deprecation
event.preventDefault();
if (d3.event.ctrlKey) { return; }
if (d3.event.shiftKey) {
if (!this.mousedownNode) { return; }
this.dragLine.classed('hidden', true).style('marker-end', '');
this.mouseupNode = d;
- if (this.mousedownNode.type === 'vld' && this.mouseupNode.type === 'vnfd') {
- const getOldVLDIndex: string[] = this.mouseupNode.id.split(':');
- const setOldVLDindex: string = getOldVLDIndex[1];
- this.putType = 'cpAdded';
- this.getAddConfirmation(this.mousedownNode, this.nsData, this.putType, setOldVLDindex);
- } else if (this.mousedownNode.type === 'vnfd' && this.mouseupNode.type === 'vld') {
- const getOldVLDIndex: string[] = this.mousedownNode.id.split(':');
- const setOldVLDindex: string = getOldVLDIndex[1];
+ if ((this.mousedownNode.type === 'vld' && this.mouseupNode.type === 'vnfd') ||
+ (this.mousedownNode.type === 'vnfd' && this.mouseupNode.type === 'vld')) {
+ if (this.mouseupNode.type === 'vnfd') {
+ this.getOldVLDIndex = this.mouseupNode.id.split(':');
+ } else if (this.mousedownNode.type === 'vnfd') {
+ this.getOldVLDIndex = this.mousedownNode.id.split(':');
+ }
+ const setOldVLDindex: string = this.getOldVLDIndex[1];
this.putType = 'cpAdded';
this.getAddConfirmation(this.mousedownNode, this.nsData, this.putType, setOldVLDindex);
} else if (this.mousedownNode.type === 'vnfd' && this.mouseupNode.type === 'ns') {
this.isShowCPDetails = cpDetails;
}
/** Events handles when Shift Click to perform create cp @private */
- // tslint:disable-next-line: no-any
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
private singleClick(nodeSelected: any, d: COMPOSERNODES): void {
this.selectNodeExclusive(nodeSelected, d);
}
/** Selected nodes @private */
- // tslint:disable-next-line: no-any
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
private selectNodeExclusive(nodeSeleced: any, d: COMPOSERNODES): void {
const alreadyIsActive: boolean = nodeSeleced.select('#' + d.selectorId).classed(this.activeClass);
this.deselectAllNodes();
}
/** Get confirmation Before Deleting the Link in Topology @private */
private getDeleteLinkConfirmation(d: Tick): void {
+ // eslint-disable-next-line security/detect-non-literal-fs-filename
const modalRef: NgbModalRef = this.modalService.open(ConfirmationTopologyComponent, { backdrop: 'static' });
modalRef.componentInstance.topologyType = 'Delete';
modalRef.componentInstance.topologyname = this.translateService.instant('PAGE.TOPOLOGY.LINK') + ' - ' + d.source.id;
if (result) {
this.doubleClickLink(d);
}
- }).catch();
+ }).catch((): void => {
+ // Catch Navigation Error
+ });
}
/** Events handles when Double Click to Delete the link @private */
private doubleClickLink(d: Tick): void {
}
/** Get confirmation Before Deleting the Node in Topology @private */
private getDeleteConfirmation(d: COMPOSERNODES): void {
+ // eslint-disable-next-line security/detect-non-literal-fs-filename
const modalRef: NgbModalRef = this.modalService.open(ConfirmationTopologyComponent, { backdrop: 'static' });
modalRef.componentInstance.topologyType = 'Delete';
modalRef.componentInstance.topologyname = d.name;
if (result) {
this.doubleClick(d);
}
- }).catch();
+ }).catch((): void => {
+ // Catch Navigation Error
+ });
}
/** Events handles when Double Click to Delete @private */
private doubleClick(d: COMPOSERNODES): void {
if (res.id === d.id) {
if (deletedNode.type === 'vld') {
/** Remove the virtual-link-desc related to VL */
- const pos: number = this.nsData['virtual-link-desc'].map((e: VLD): string => { return e.id; }).indexOf(d.id);
+ const pos: number = this.nsData['virtual-link-desc'].map((e: VLD): string => e.id).indexOf(d.id);
this.nsData['virtual-link-desc'].splice(pos, 1);
/** Remove the virtual-link-connectivity between VL and VNFD */
this.nsData.df.forEach((resultDF: DF): void => {
if (getVLArray.length > 0) {
getVLArray.forEach((removeIndex: number): void => {
const index: string = removeIndex.toString();
+ // eslint-disable-next-line security/detect-object-injection
resVNF['virtual-link-connectivity'].splice(resVNF['virtual-link-connectivity'][index], 1);
});
}
this.nsData.df.forEach((resultDF: DF): void => {
if (resultDF['vnf-profile'] !== undefined) {
/** Remove the vnf-profile related to VNFD */
- const posVNF: number = resultDF['vnf-profile'].findIndex((e: VNFPROFILE): boolean => {
- return e['vnfd-id'] === d.name && e.id === d.nodeIndex;
- });
+ const posVNF: number = resultDF['vnf-profile'].findIndex((e: VNFPROFILE): boolean => e['vnfd-id'] === d.name && e.id === d.nodeIndex);
resultDF['vnf-profile'].splice(posVNF, 1);
/** Check the VNFD exists in any vnf-profile */
- const isVNFDExists: boolean = resultDF['vnf-profile'].some((e: VNFPROFILE): boolean => {
- return e['vnfd-id'] === d.name;
- });
+ const isVNFDExists: boolean = resultDF['vnf-profile'].some((e: VNFPROFILE): boolean => e['vnfd-id'] === d.name);
/** If VNFD not exists in the vnf-profile remove from vnfd-id */
if (!isVNFDExists) {
- const posVNFD: number = this.nsData['vnfd-id'].findIndex((e: string): boolean => {
- return e === d.name;
- });
+ const posVNFD: number = this.nsData['vnfd-id'].findIndex((e: string): boolean => e === d.name);
this.nsData['vnfd-id'].splice(posVNFD, 1);
}
}
});
}
/** drag event @private */
- // tslint:disable-next-line: no-any
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
private onDragDrop(): any {
return d3.drag().filter(this.dragFilter)
.on('start', this.dragstarted)