diff options
Diffstat (limited to 'vid-webpack-master/src')
38 files changed, 500 insertions, 320 deletions
diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/basic.model.info.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/basic.model.info.ts index 5ae64376a..9c102069b 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/basic.model.info.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/basic.model.info.ts @@ -63,8 +63,9 @@ export interface ILevelNodeInfo { * @param model - The model of current object * @param parentModel * @param storeKey - instance storeKey if exist (for duplicate) + * @param serviceModelId ************************************************************/ - createInstanceTreeNode(instance: any, model: any, parentModel: any, storeKey: string): any + createInstanceTreeNode(instance: any, model: any, parentModel: any, storeKey: string, serviceModelId: string): any /*********************************************************** * return if instance has some missing data diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/collectionResource/collectionResource.model.info.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/collectionResource/collectionResource.model.info.ts index 339951de5..c9c718f44 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/collectionResource/collectionResource.model.info.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/collectionResource/collectionResource.model.info.ts @@ -29,16 +29,16 @@ export class CollectionResourceModelInfo implements ILevelNodeInfo{ updateDynamicInputsDataFromModel = (currentModel): any => []; getModel = (collectionResourceModelId: string, instance: CollectionResourceInstance, serviceHierarchy): CollectionResourceModel => { - const originalModelName = instance.originalName ? instance.originalName : collectionResourceModelId; - return new CollectionResourceModel(this._sharedTreeService.modelByIdentifier(serviceHierarchy, this.name, originalModelName)); + const uniqueIdOrName = this._sharedTreeService.modelUniqueNameOrId(instance); + return new CollectionResourceModel(this._sharedTreeService.modelByIdentifiers(serviceHierarchy, this.name, uniqueIdOrName, collectionResourceModelId)); }; - createInstanceTreeNode = (instance: CollectionResourceInstance, model: CollectionResourceModel, parentModel, storeKey: string): CollectionResourceTreeNode => { + createInstanceTreeNode = (instance: any, model: any, parentModel: any, storeKey: string, serviceModelId: string): any => { let node = new CollectionResourceTreeNode(instance, model, storeKey); node.missingData = this.hasMissingData(instance, node, model.isEcompGeneratedNaming); node.typeName = this.typeName; - node.menuActions = this.getMenuAction(<any>node, model.uuid); + node.menuActions = this.getMenuAction(<any>node, serviceModelId); node.isFailed = _.isNil(instance.isFailed) ? false : instance.isFailed; node.statusMessage = !_.isNil(instance.statusMessage) ? instance.statusMessage : ""; return node; diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/configuration/configuration.model.info.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/configuration/configuration.model.info.ts index d9702b4c4..31c44390d 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/configuration/configuration.model.info.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/configuration/configuration.model.info.ts @@ -31,14 +31,14 @@ export class ConfigurationModelInfo implements ILevelNodeInfo{ * @param serviceHierarchy - serviceHierarchy ************************************************************/ getModel = (configurationModelId : string, serviceHierarchy) : any =>{ - const model = this._sharedTreeService.modelByIdentifier(serviceHierarchy, this.name, configurationModelId); + const model = this._sharedTreeService.modelByIdentifiers(serviceHierarchy, this.name, configurationModelId); if (!_.isNil(model)) { return model; } return {}; }; - createInstanceTreeNode(instance: any, model: any, storeKey: string): any {return null;} + createInstanceTreeNode(instance: any, model: any, storeKey: string, serviceModelId: string): any {return null;} childNames: string[]; diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/ncf/ncf.model.info.spec.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/ncf/ncf.model.info.spec.ts index 6c8382808..951145870 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/ncf/ncf.model.info.spec.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/ncf/ncf.model.info.spec.ts @@ -69,7 +69,7 @@ describe('NCF Model Info', () => { typeName: "NCF" }; - const ncfTreeNode: NcfTreeNode = ncfModel.createInstanceTreeNode(instance, {}, parentModel, "6b3536cf-3a12-457f-abb5-fa2203e0d923"); + const ncfTreeNode: NcfTreeNode = ncfModel.createInstanceTreeNode(instance, {}, parentModel, "6b3536cf-3a12-457f-abb5-fa2203e0d923", "dd182d7d-6949-4b90-b3cc-5befe400742e"); expect(ncfTreeNode).toMatchObject(expected); }); diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/ncf/ncf.model.info.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/ncf/ncf.model.info.ts index 4db41c0d1..5c03b379b 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/ncf/ncf.model.info.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/ncf/ncf.model.info.ts @@ -37,7 +37,7 @@ export class NcfModelInfo implements ILevelNodeInfo { }; - createInstanceTreeNode = (instance: Level1Instance, model: Level1Model, parentModel, storeKey: string): NcfTreeNode => { + createInstanceTreeNode = (instance: any, model: any, parentModel: any, storeKey: string, serviceModelId: string): any => { let modelVersion: string = null; if (parentModel.networksCollection && instance.originalName) { const ncfRealModel: NcfModelInterface = parentModel.networksCollection[instance.originalName]; @@ -47,7 +47,7 @@ export class NcfModelInfo implements ILevelNodeInfo { } let node = new NcfTreeNode(instance, model, storeKey, modelVersion); - node.menuActions = this.getMenuAction(<any>node, model.uuid); + node.menuActions = this.getMenuAction(<any>node, serviceModelId); node.typeName = this.typeName; return node; }; diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/network/network.model.info.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/network/network.model.info.ts index 7c240a9b9..ae28fc2d9 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/network/network.model.info.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/network/network.model.info.ts @@ -71,9 +71,9 @@ export class NetworkModelInfo implements ILevelNodeInfo { * @param serviceHierarchy - serviceHierarchy ************************************************************/ getModel = (networkModelId: string, instance: NetworkInstance, serviceHierarchy): NetworkModel => { - const originalModelName = instance.originalName ? instance.originalName : networkModelId; + const uniqueIdOrName = this._sharedTreeService.modelUniqueNameOrId(instance); return new NetworkModel( - this._sharedTreeService.modelByIdentifier(serviceHierarchy, this.name, originalModelName), + this._sharedTreeService.modelByIdentifiers(serviceHierarchy, this.name, uniqueIdOrName, networkModelId), this._featureFlagsService.getAllFlags()); }; @@ -85,11 +85,11 @@ export class NetworkModelInfo implements ILevelNodeInfo { * @param parentModel * @param storeKey - store key if exist ************************************************************/ - createInstanceTreeNode = (instance: NetworkInstance, model: NetworkModel, parentModel, storeKey: string): NetworkTreeNode => { + createInstanceTreeNode = (instance: any, model: any, parentModel: any, storeKey: string, serviceModelId: string): any => { let node = new NetworkTreeNode(instance, model, storeKey); node.missingData = this.hasMissingData(instance, node, model.isEcompGeneratedNaming); node.typeName = this.typeName; - node.menuActions = this.getMenuAction(<any>node, model.uuid); + node.menuActions = this.getMenuAction(<any>node, serviceModelId); node.isFailed = _.isNil(instance.isFailed) ? false : instance.isFailed; node.statusMessage = !_.isNil(instance.statusMessage) ? instance.statusMessage : ""; node = this._sharedTreeService.addingStatusProperty(node); @@ -234,8 +234,8 @@ export class NetworkModelInfo implements ILevelNodeInfo { }); } }, - visible: (node) => node.data.parentType !== 'VRF' && this._sharedTreeService.shouldShowDelete(node), - enable: (node) => node.data.parentType !== 'VRF' && this._sharedTreeService.shouldShowDelete(node) + visible: (node) => node.data.parentType !== 'VRF' && this._sharedTreeService.shouldShowDelete(node, serviceModelId), + enable: (node) => node.data.parentType !== 'VRF' && this._sharedTreeService.shouldShowDelete(node, serviceModelId) }, undoDelete: { method: (node, serviceModelId) => { diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/pnf/pnf.model.info.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/pnf/pnf.model.info.ts index 05e05a744..b87551547 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/pnf/pnf.model.info.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/pnf/pnf.model.info.ts @@ -21,7 +21,7 @@ export class PnfModelInfo implements ILevelNodeInfo{ childNames: string[]; componentInfoType = ComponentInfoType.PNF; - createInstanceTreeNode = (instance: PnfInstance, model: PNFModel, parentModel: any, storeKey: string): PnfTreeNode => null; + createInstanceTreeNode = (instance: any, model: any, parentModel: any, storeKey: string, serviceModelId: string): any => null; getInfo(model, instance): ModelInformationItem[] { return []; @@ -32,8 +32,8 @@ export class PnfModelInfo implements ILevelNodeInfo{ } getModel = (pnfModelId: string, instance: PnfInstance, serviceHierarchy): PNFModel => { - const originalModelName = instance.originalName ? instance.originalName : pnfModelId; - return new PNFModel(this._sharedTreeService.modelByIdentifier(serviceHierarchy, this.name, originalModelName)); + const uniqueIdOrName = this._sharedTreeService.modelUniqueNameOrId(instance); + return new PNFModel(this._sharedTreeService.modelByIdentifiers(serviceHierarchy, this.name, uniqueIdOrName, pnfModelId)); }; getNextLevelObject(): any { return null; } diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/relatedVnfMember/relatedVnfMember.info.model.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/relatedVnfMember/relatedVnfMember.info.model.ts index 86455ce60..f31a3b2e8 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/relatedVnfMember/relatedVnfMember.info.model.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/relatedVnfMember/relatedVnfMember.info.model.ts @@ -54,8 +54,8 @@ export class RelatedVnfMemberInfoModel implements ILevelNodeInfo { * @param serviceHierarchy - serviceHierarchy ************************************************************/ getModel = (vnfModelId: string, instance: VnfInstance, serviceHierarchy): VNFModel => { - const originalModelName = instance.originalName ? instance.originalName : vnfModelId; - return new VNFModel(this._sharedTreeService.modelByIdentifier(serviceHierarchy, this.name, originalModelName)); + const uniqueIdOrName = this._sharedTreeService.modelUniqueNameOrId(instance); + return new VNFModel(this._sharedTreeService.modelByIdentifiers(serviceHierarchy, this.name, uniqueIdOrName, vnfModelId)); }; @@ -65,12 +65,13 @@ export class RelatedVnfMemberInfoModel implements ILevelNodeInfo { * @param model - vnf model * @param parentModel * @param storeKey - store key if exist + * @param serviceModelId ************************************************************/ - createInstanceTreeNode = (instance: VnfInstance, model: VNFModel, parentModel, storeKey: string): VnfTreeNode => { + createInstanceTreeNode = (instance: any, model: any, parentModel: any, storeKey: string, serviceModelId: string): any => { let node = new VnfTreeNode(instance, model, storeKey); node.missingData = this.hasMissingData(instance, node, model.isEcompGeneratedNaming); node.typeName = this.typeName; - node.menuActions = this.getMenuAction(<any>node, model.uuid); + node.menuActions = this.getMenuAction(<any>node, serviceModelId); node.isFailed = _.isNil(instance.isFailed) ? false : instance.isFailed; node.statusMessage = !_.isNil(instance.statusMessage) ? instance.statusMessage: ""; node = this._sharedTreeService.addingStatusProperty(node); @@ -128,8 +129,8 @@ export class RelatedVnfMemberInfoModel implements ILevelNodeInfo { method : (node, serviceModelId) => { this._store.dispatch(deleteActionRelatedVnfMemberInstance(node.parent.data.vnfGroupStoreKey, node.data.vnfStoreKey, serviceModelId)); }, - visible: (node) => this._sharedTreeService.shouldShowDelete(node), - enable: (node) => this._sharedTreeService.shouldShowDelete(node) + visible: (node) => this._sharedTreeService.shouldShowDelete(node, serviceModelId), + enable: (node) => this._sharedTreeService.shouldShowDelete(node, serviceModelId) }, undoDelete : { method : (node, serviceModelId) => { @@ -137,7 +138,7 @@ export class RelatedVnfMemberInfoModel implements ILevelNodeInfo { }, visible: (node) => this._sharedTreeService.shouldShowUndoDelete(node), - enable: (node, serviceModelId) => this._sharedTreeService.shouldShowUndoDelete(node) && this._sharedTreeService.shouldShowDelete(node.parent) && !this._sharedTreeService.isServiceOnDeleteMode(serviceModelId) + enable: (node, serviceModelId) => this._sharedTreeService.shouldShowUndoDelete(node) && this._sharedTreeService.shouldShowDelete(node.parent, serviceModelId) && !this._sharedTreeService.isServiceOnDeleteMode(serviceModelId) } } } diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.ts index 1b92eb81b..dcc6a29f8 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.ts @@ -79,14 +79,14 @@ export class VFModuleModelInfo implements ILevelNodeInfo { * @param serviceHierarchy - serviceHierarchy ************************************************************/ getModel = (vfModuleModelId: string, instance, serviceHierarchy): Partial<VfModule> => { - const model = this._sharedTreeService.modelByIdentifier(serviceHierarchy, this.name, vfModuleModelId); + const model = this._sharedTreeService.modelByIdentifiers(serviceHierarchy, this.name, vfModuleModelId); if (!_.isNil(model)) { return new VfModule(model, this._featureFlagsService.getAllFlags()); } return {}; }; - createNode(instance: VfModuleInstance, currentModel: VfModule, parentModel: VNFModel, modelName: string, index: number): VfModuleTreeNode { + createNode(instance: VfModuleInstance, currentModel: VfModule, parentModel: VNFModel, modelName: string, index: number, serviceModelId: string): VfModuleTreeNode { let dynamicModelName = Object.keys(instance)[index]; instance = instance[Object.keys(instance)[index]]; const isEcompGeneratedNaming: boolean = this.isEcompGeneratedNaming(currentModel, parentModel); @@ -96,7 +96,7 @@ export class VFModuleModelInfo implements ILevelNodeInfo { newVfModule.missingData = this._sharedTreeService.hasMissingData(instance, newVfModule.dynamicInputs, isEcompGeneratedNaming, []); newVfModule.typeName = this.typeName; - newVfModule.menuActions = this.getMenuAction(<any>newVfModule, currentModel.uuid); + newVfModule.menuActions = this.getMenuAction(<any>newVfModule, serviceModelId); newVfModule.isFailed = _.isNil(instance.isFailed) ? false : instance.isFailed; newVfModule.statusMessage = !_.isNil(instance.statusMessage) ? instance.statusMessage : ""; @@ -104,16 +104,16 @@ export class VFModuleModelInfo implements ILevelNodeInfo { return newVfModule; } - createInstanceTreeNode(instance: VfModuleInstance, currentModel: VfModule, parentModel: VNFModel, modelName: string): VfModuleTreeNode | VfModuleTreeNode[] { + createInstanceTreeNode(instance: any, model: any, parentModel: any, storeKey: string, serviceModelId: string): any { let numberOfChilds = Object.keys(instance).length; if (numberOfChilds > 1) { let result: VfModuleTreeNode[] = []; for (let i = 0; i < numberOfChilds; i++) { - result.push(this.createNode(instance, currentModel, parentModel, modelName, i)); + result.push(this.createNode(instance, model, parentModel, storeKey, i, serviceModelId)); } return result; } else { - return this.createNode(instance, currentModel, parentModel, modelName, 0); + return this.createNode(instance, model, parentModel, storeKey, 0, serviceModelId); } } @@ -355,8 +355,8 @@ export class VFModuleModelInfo implements ILevelNodeInfo { method: (node, serviceModelId) => { this._store.dispatch(deleteActionVfModuleInstance(node.data.dynamicModelName, node.parent.data.vnfStoreKey, serviceModelId)) }, - visible: (node) => this._sharedTreeService.shouldShowDelete(node), - enable: (node) => this._sharedTreeService.shouldShowDelete(node) + visible: (node) => this._sharedTreeService.shouldShowDelete(node, serviceModelId), + enable: (node) => this._sharedTreeService.shouldShowDelete(node, serviceModelId) }, undoDelete: { method: (node, serviceModelId) => { @@ -364,7 +364,7 @@ export class VFModuleModelInfo implements ILevelNodeInfo { this._store.dispatch(deleteVFModuleField(node.data.modelName, node.parent.data.vnfStoreKey, node.data.servicedId ,node.data.dynamicModelName, 'retainAssignments')); }, visible: (node) => this._sharedTreeService.shouldShowUndoDelete(node), - enable: (node, serviceModelId) => this._sharedTreeService.shouldShowUndoDelete(node) && this._sharedTreeService.shouldShowDelete(node.parent) && !this._sharedTreeService.isServiceOnDeleteMode(serviceModelId) + enable: (node, serviceModelId) => this._sharedTreeService.shouldShowUndoDelete(node) && this._sharedTreeService.shouldShowDelete(node.parent, serviceModelId) && !this._sharedTreeService.isServiceOnDeleteMode(serviceModelId) }, upgrade: { method: (node, serviceModelId) => { diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vnf/vnf.model.info.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vnf/vnf.model.info.ts index 1215bb80e..b2b7b43e2 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vnf/vnf.model.info.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vnf/vnf.model.info.ts @@ -88,25 +88,25 @@ export class VnfModelInfo implements ILevelNodeInfo { * @param serviceHierarchy - serviceHierarchy ************************************************************/ getModel = (vnfModelId: string, instance: VnfInstance, serviceHierarchy): VNFModel => { - const originalModelName = instance.originalName ? instance.originalName : vnfModelId; + const uniqueIdOrName = this._sharedTreeService.modelUniqueNameOrId(instance); return new VNFModel( - this._sharedTreeService.modelByIdentifier(serviceHierarchy, this.name, originalModelName), + this._sharedTreeService.modelByIdentifiers(serviceHierarchy, this.name, uniqueIdOrName, vnfModelId), this._featureFlagsService.getAllFlags()); }; - /*********************************************************** * return vnf instance tree node * @param instance - vnf instance * @param model - vnf model * @param parentModel * @param storeKey - store key if exist + * @param serviceModelId ************************************************************/ - createInstanceTreeNode = (instance: VnfInstance, model: VNFModel, parentModel, storeKey: string): VnfTreeNode => { + createInstanceTreeNode = (instance: any, model: any, parentModel: any, storeKey: string, serviceModelId: string): any => { let node = new VnfTreeNode(instance, model, storeKey); node.missingData = this.hasMissingData(instance, node, model.isEcompGeneratedNaming); node.typeName = this.typeName; - node.menuActions = this.getMenuAction(<any>node, model.uuid); + node.menuActions = this.getMenuAction(<any>node, serviceModelId); node.isFailed = _.isNil(instance.isFailed) ? false : instance.isFailed; node.statusMessage = !_.isNil(instance.statusMessage) ? instance.statusMessage : ""; node = this._sharedTreeService.addingStatusProperty(node); @@ -271,8 +271,8 @@ export class VnfModelInfo implements ILevelNodeInfo { }); } }, - visible: (node) => this._sharedTreeService.shouldShowDelete(node), - enable: (node) => this._sharedTreeService.shouldShowDelete(node) + visible: (node) => this._sharedTreeService.shouldShowDelete(node, serviceModelId), + enable: (node) => this._sharedTreeService.shouldShowDelete(node, serviceModelId) }, undoDelete: { method: (node, serviceModelId) => { diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vnfGrouping/vnfGrouping.model.info.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vnfGrouping/vnfGrouping.model.info.ts index fa785bc73..d89f307d9 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vnfGrouping/vnfGrouping.model.info.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vnfGrouping/vnfGrouping.model.info.ts @@ -83,12 +83,12 @@ export class VnfGroupingModelInfo implements ILevelNodeInfo { getType = (): string => 'VnfGroup'; - createInstanceTreeNode(instance: any, model: any, parentModel: any, storeKey: string): any { + createInstanceTreeNode(instance: any, model: any, parentModel: any, storeKey: string, serviceModelId: string): any { let node = new VnfGroupTreeNode(instance, model, storeKey); node.missingData = this.hasMissingData(instance, node, model.isEcompGeneratedNaming); node = this._sharedTreeService.addingStatusProperty(node); node.typeName = this.typeName; - node.menuActions = this.getMenuAction(<any>node, model.uuid); + node.menuActions = this.getMenuAction(<any>node, serviceModelId); node.isFailed = _.isNil(instance.isFailed) ? false : instance.isFailed; node.statusMessage = !_.isNil(instance.statusMessage) ? instance.statusMessage : ""; node.limitMembers = (!_.isNil(model.properties.quantity)) ? model.properties.quantity : null; @@ -96,8 +96,8 @@ export class VnfGroupingModelInfo implements ILevelNodeInfo { } getModel(modelId: string, instance: any, serviceHierarchy): any { - const originalModelName = instance.originalName ? instance.originalName : modelId; - return new VnfGroupModel(this._sharedTreeService.modelByIdentifier(serviceHierarchy, this.name, originalModelName)); + const uniqueIdOrName = this._sharedTreeService.modelUniqueNameOrId(instance); + return new VnfGroupModel(this._sharedTreeService.modelByIdentifiers(serviceHierarchy, this.name, uniqueIdOrName, modelId)); } hasMissingData(instance, dynamicInputs: any, isEcompGeneratedNaming: boolean): boolean { @@ -275,8 +275,8 @@ export class VnfGroupingModelInfo implements ILevelNodeInfo { }); } }, - visible: (node) => this._sharedTreeService.shouldShowDelete(node), - enable: (node) => this._sharedTreeService.shouldShowDelete(node) + visible: (node) => this._sharedTreeService.shouldShowDelete(node, serviceModelId), + enable: (node) => this._sharedTreeService.shouldShowDelete(node, serviceModelId) }, undoDelete: { method: (node, serviceModelId) => { diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vpn/vpn.model.info.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vpn/vpn.model.info.ts index b951162f8..0fbbc4a2d 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vpn/vpn.model.info.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vpn/vpn.model.info.ts @@ -34,12 +34,12 @@ export class VpnModelInfo implements ILevelNodeInfo { }; - createInstanceTreeNode = (instance: NetworkInstance, model: any, parentModel, storeKey: string): VpnTreeNode => { + createInstanceTreeNode = (instance: any, model: any, parentModel: any, storeKey: string, serviceModelId: string): any => { let node = new VpnTreeNode(instance, model, storeKey); node.missingData = this.hasMissingData(instance, node, model.isEcompGeneratedNaming); node = this._sharedTreeService.addingStatusProperty(node); node.typeName = this.typeName; - node.menuActions = this.getMenuAction(<any>node, model.uuid); + node.menuActions = this.getMenuAction(<any>node, serviceModelId); node.isFailed = _.isNil(instance.isFailed) ? false : instance.isFailed; node.statusMessage = !_.isNil(instance.statusMessage) ? instance.statusMessage : ""; node = this._sharedTreeService.addingStatusProperty(node); diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vrf/vrf.model.info.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vrf/vrf.model.info.ts index 03f60211c..7b7437c5e 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vrf/vrf.model.info.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vrf/vrf.model.info.ts @@ -51,16 +51,16 @@ export class VrfModelInfo implements ILevelNodeInfo { updateDynamicInputsDataFromModel = (currentModel): any => []; getModel = (vrfModelId: string, instance: VrfInstance, serviceHierarchy): VrfModel => { - const originalModelName = instance.originalName ? instance.originalName : vrfModelId; - return new VrfModel(this._sharedTreeService.modelByIdentifier(serviceHierarchy, this.name, originalModelName)); + const uniqueIdOrName = this._sharedTreeService.modelUniqueNameOrId(instance); + return new VrfModel(this._sharedTreeService.modelByIdentifiers(serviceHierarchy, this.name, uniqueIdOrName, vrfModelId)); }; - createInstanceTreeNode = (instance: VrfInstance, model: VrfModel, parentModel, storeKey: string): VrfTreeNode => { + createInstanceTreeNode = (instance: any, model: any, parentModel: any, storeKey: string, serviceModelId: string): any => { let node = new VrfTreeNode(instance, model, storeKey); node.missingData = this.hasMissingData(instance, node, model.isEcompGeneratedNaming); node.typeName = this.typeName; - node.menuActions = this.getMenuAction(<any>node, model.uuid); + node.menuActions = this.getMenuAction(<any>node, serviceModelId); node.isFailed = _.isNil(instance.isFailed) ? false : instance.isFailed; node.statusMessage = !_.isNil(instance.statusMessage) ? instance.statusMessage : ""; return node; @@ -157,8 +157,8 @@ export class VrfModelInfo implements ILevelNodeInfo { method: (node, serviceModelId) => { this._store.dispatch(deleteActionVrfInstance(node.data.vrfStoreKey, serviceModelId)); }, - visible: (node) => this._sharedTreeService.shouldShowDelete(node), - enable: (node) => this._sharedTreeService.shouldShowDelete(node) + visible: (node) => this._sharedTreeService.shouldShowDelete(node, serviceModelId), + enable: (node) => this._sharedTreeService.shouldShowDelete(node, serviceModelId) }, undoDelete: { method: (node, serviceModelId) => { diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToInstanceTree/objectToInstanceTree.service.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToInstanceTree/objectToInstanceTree.service.ts index 8ddb4ba2d..89d901f55 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToInstanceTree/objectToInstanceTree.service.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToInstanceTree/objectToInstanceTree.service.ts @@ -34,10 +34,11 @@ export class ObjectToInstanceTreeService { this.numberOfFailed = 0; this.numberOfElements = 0; let _this = this; + const serviceModelId:string = serviceInstance.modelInfo.modelVersionId; const firstLevelOptions: ILevelNodeInfo[] = _this._objectToTreeService.getFirstLevelOptions(); for (let option of firstLevelOptions) { _.forOwn(serviceInstance[option.name], function (instance, modelName) { - nodes.push(_this.getNodeInstance(modelName, null, instance, serviceHierarchy, option)); + nodes.push(_this.getNodeInstance(modelName, null, instance, serviceHierarchy, option, serviceModelId)); }); } return this.sortElementsByPosition(nodes); @@ -71,18 +72,19 @@ export class ObjectToInstanceTreeService { * @param instance * @param serviceHierarchy - The service Hierarchy store * @param option + * @param serviceModelId * @param parentType ****************************************************************/ - getNodeInstance(modelName: string, parentModel: any, instance: any, serviceHierarchy, option: ILevelNodeInfo, parentType ?: string) { + getNodeInstance(modelName: string, parentModel: any, instance: any, serviceHierarchy, option: ILevelNodeInfo, serviceModelId: string, parentType ?: string) { const model = option.getModel(modelName, instance, serviceHierarchy); - let optionalNodes = option.createInstanceTreeNode(instance, model, parentModel, modelName); + let optionalNodes = option.createInstanceTreeNode(instance, model, parentModel, modelName, serviceModelId); this.increaseNumberOfFailed(optionalNodes); this.increaseNumberOfExcitingElements(); let nodes: any[] = _.isArray(optionalNodes) ? optionalNodes : [optionalNodes]; for (let node of nodes) { node = this.addingExtraDataToNode(node, modelName, parentModel, instance, serviceHierarchy, option, parentType); - let children = this.addNextInstanceTreeNode(instance, model, option, node, serviceHierarchy); + let children = this.addNextInstanceTreeNode(instance, model, option, node, serviceHierarchy, serviceModelId); if (!_.isNil(children) && children.length > 0) { node.children = this.sortElementsByPosition(children); } @@ -119,8 +121,9 @@ export class ObjectToInstanceTreeService { * @param levelNodeInfo * @param parentNode * @param serviceHierarchy - The service Hierarchy store + * @param serviceModelId ****************************************************************/ - addNextInstanceTreeNode(parentInstance, parentModel, levelNodeInfo: ILevelNodeInfo, parentNode, serviceHierarchy): any[] { + addNextInstanceTreeNode(parentInstance, parentModel, levelNodeInfo: ILevelNodeInfo, parentNode, serviceHierarchy, serviceModelId: string): any[] { if (!_.isNil(levelNodeInfo.childNames)&& levelNodeInfo.childNames.length > 0) { const that = this; parentNode.children = []; @@ -130,7 +133,7 @@ export class ObjectToInstanceTreeService { let nextLevelNodeInfo = levelNodeInfo.getNextLevelObject.apply(that, [childName]); Object.keys(parentInstance[childName]).map((modelName) => { let nextLevelInstance = parentInstance[childName][modelName]; - let nodes: any[] | any = that.getNodeInstance(modelName, parentModel, nextLevelInstance, serviceHierarchy, nextLevelNodeInfo, parentType); + let nodes: any[] | any = that.getNodeInstance(modelName, parentModel, nextLevelInstance, serviceHierarchy, nextLevelNodeInfo, serviceModelId, parentType); if (_.isArray(nodes)) { parentNode.children = parentNode.children.concat(nodes); } else { diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.spec.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.spec.ts index 87094e3bb..b4c58364b 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.spec.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.spec.ts @@ -63,7 +63,7 @@ function getNodeWithData(menuAction:string){ }; nodeData['menuActions'][menuAction] = { method: (node, serviceModelId) => {} - } + }; const node = { parent: { data: nodeData, @@ -134,7 +134,7 @@ describe('Shared Tree Service', () => { test('SharedTreeService upgradeBottomUp should call redux actions', () => { const serviceModelId = "1a80c596-27e5-4ca9-b5bb-e03a7fd4c0fd"; - const node = getNodeWithData("upgrade") + const node = getNodeWithData("upgrade"); spyOn(node.parent.data.menuActions['upgrade'], 'method'); service.upgradeBottomUp(node, serviceModelId); expect(node.parent.data.menuActions['upgrade'].method).toBeCalledWith(node.parent, serviceModelId); @@ -144,7 +144,7 @@ describe('Shared Tree Service', () => { test('SharedTreeService undoUpgradeBottomUp should call redux actions', () => { const serviceModelId = "1a80c596-27e5-4ca9-b5bb-e03a7fd4c0fd"; - const node = getNodeWithData("undoUpgrade") + const node = getNodeWithData("undoUpgrade"); spyOn(node.parent.data.menuActions['undoUpgrade'], 'method'); service.undoUpgradeBottomUp(node, serviceModelId); expect(node.parent.data.menuActions['undoUpgrade'].method).toBeCalledWith(node.parent, serviceModelId); @@ -179,7 +179,7 @@ describe('Shared Tree Service', () => { let serviceModelFromHierarchy = getStore().service.serviceHierarchy["1a80c596-27e5-4ca9-b5bb-e03a7fd4c0fd"]; - expect(service.modelByIdentifier(serviceModelFromHierarchy, modelTypeName, modelUniqueIdOrName)) + expect(service.modelByIdentifiers(serviceModelFromHierarchy, modelTypeName, modelUniqueIdOrName)) .toHaveProperty("modelCustomizationName", expectedModelCustomizationName); }); @@ -192,7 +192,7 @@ describe('Shared Tree Service', () => { let serviceModelFromHierarchy = getStore().service.serviceHierarchy["1a80c596-27e5-4ca9-b5bb-e03a7fd4c0fd"]; - expect(service.modelByIdentifier(serviceModelFromHierarchy, modelTypeName, modelUniqueIdOrName)) + expect(service.modelByIdentifiers(serviceModelFromHierarchy, modelTypeName, modelUniqueIdOrName)) .toBeUndefined(); }); @@ -264,7 +264,6 @@ describe('Shared Tree Service', () => { }); - test('statusProperties should be prop on node according to node properties', () => { let node = service.addingStatusProperty({orchStatus: 'completed', provStatus: 'inProgress', inMaint: false}); expect(node.statusProperties).toBeDefined(); @@ -284,6 +283,39 @@ describe('Shared Tree Service', () => { testId: 'inMaint' })]); }); + + each([ + [false, 'method is not in menu actions', ServiceInstanceActions.None, DrawingBoardModes.EDIT, {}, true], + [false, 'there is no action in node', null, DrawingBoardModes.EDIT, {someMethod: "someValue"}, true], + [true, 'edit mode, action is none, method in menu action', ServiceInstanceActions.None, DrawingBoardModes.EDIT, {someMethod: "someValue"}, true], + [false, 'edit mode, action is none, method in menu action, macro service', ServiceInstanceActions.None, DrawingBoardModes.EDIT, {someMethod: "someValue"}, false], + [false, 'edit mode, action is not none, method in menu action', ServiceInstanceActions.Resume, DrawingBoardModes.EDIT, {someMethod: "someValue"}, true], + [false, 'edit mode, action is CREATE, method in menu action', ServiceInstanceActions.Resume, DrawingBoardModes.EDIT, {someMethod: "someValue"}, true] + ]).test('shouldShowButtonGeneric return %s if %s ', (expected, description, action, mode, menuActions, isALaCarte) => { + jest.spyOn(store, 'getState').mockReturnValue(<any>{ + global: { + drawingBoardStatus: mode + }, + service : { + serviceInstance: { + someModelId : { + isALaCarte + } + } + + } + }); + let node = <any>{ + data:{ + action: action, + menuActions: menuActions + }, + }; + + let res = service.shouldShowButtonGeneric(node, "someMethod", "someModelId"); + expect(res).toBe(expected); + }); + const enableRemoveAndEditItemsDataProvider = [ ['Create action CREATE mode', DrawingBoardModes.CREATE ,ServiceInstanceActions.Create, true], ['Create action VIEW mode',DrawingBoardModes.VIEW , ServiceInstanceActions.Create,false], @@ -306,205 +338,8 @@ describe('Shared Tree Service', () => { let res = service.shouldShowRemoveAndEdit(node); expect(res).toBe(enabled); }); + }); -function generateService() { - return { - "vnfs": { - "2017-488_PASQUALE-vPE 0": { - "inMaint": false, - "rollbackOnFailure": "true", - "originalName": "2017-488_PASQUALE-vPE 0", - "isMissingData": false, - "trackById": "stigekyxrqi", - "vfModules": { - "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0": { - "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0gytfi": { - "isMissingData": false, - "sdncPreReload": null, - "modelInfo": { - "modelType": "VFmodule", - "modelInvariantId": "b34833bb-6aa9-4ad6-a831-70b06367a091", - "modelVersionId": "f8360508-3f17-4414-a2ed-6bc71161e8db", - "modelName": "2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0", - "modelVersion": "5", - "modelCustomizationId": "a55961b2-2065-4ab0-a5b7-2fcee1c227e3", - "modelCustomizationName": "2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0" - }, - "instanceParams": [{}], - "trackById": "3oj23o7nupo" - } - } - }, - "vnfStoreKey": "2017-488_PASQUALE-vPE 0", - "uuid": "69e09f68-8b63-4cc9-b9ff-860960b5db09", - "productFamilyId": "d8a6ed93-251c-47ca-adc9-86671fd19f4c", - "lcpCloudRegionId": "AAIAIC25", - "tenantId": "092eb9e8e4b7412e8787dd091bc58e86", - "lineOfBusiness": "ONAP", - "platformName": "xxx1", - "modelInfo": { - "modelInvariantId": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8", - "modelVersionId": "69e09f68-8b63-4cc9-b9ff-860960b5db09", - "modelName": "2017-488_PASQUALE-vPE", - "modelVersion": "5.0", - "modelCustomizationName": "2017-488_PASQUALE-vPE 0", - "modelCustomizationId": "1da7b585-5e61-4993-b95e-8e6606c81e45", - "uuid": "69e09f68-8b63-4cc9-b9ff-860960b5db09" - }, - "legacyRegion": "11111111", - "instanceParams": [{}] - }, - "2017-388_PASQUALE-vPE 0": { - "inMaint": false, - "rollbackOnFailure": "true", - "originalName": "2017-388_PASQUALE-vPE 0", - "isMissingData": false, - "trackById": "nib719t5vca", - "vfModules": {}, - "vnfStoreKey": "2017-388_PASQUALE-vPE 0", - "productFamilyId": "d8a6ed93-251c-47ca-adc9-86671fd19f4c", - "lcpCloudRegionId": "AAIAIC25", - "legacyRegion": "11111", - "tenantId": "092eb9e8e4b7412e8787dd091bc58e86", - "platformName": "platform", - "lineOfBusiness": "zzz1", - "instanceParams": [{}], - "modelInfo": { - "modelInvariantId": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8", - "modelVersionId": "afacccf6-397d-45d6-b5ae-94c39734b168", - "modelName": "2017-388_PASQUALE-vPE", - "modelVersion": "4.0", - "modelCustomizationId": "b3c76f73-eeb5-4fb6-9d31-72a889f1811c", - "modelCustomizationName": "2017-388_PASQUALE-vPE 0", - "uuid": "afacccf6-397d-45d6-b5ae-94c39734b168" - }, - "uuid": "afacccf6-397d-45d6-b5ae-94c39734b168" - }, - "2017-388_PASQUALE-vPE 1": { - "inMaint": false, - "rollbackOnFailure": "true", - "originalName": "2017-388_PASQUALE-vPE 1", - "isMissingData": false, - "trackById": "cv7l1ak8vpe", - "vfModules": {}, - "vnfStoreKey": "2017-388_PASQUALE-vPE 1", - "productFamilyId": "d8a6ed93-251c-47ca-adc9-86671fd19f4c", - "lcpCloudRegionId": "AAIAIC25", - "legacyRegion": "123", - "tenantId": "092eb9e8e4b7412e8787dd091bc58e86", - "platformName": "platform", - "lineOfBusiness": "ONAP", - "instanceParams": [{}], - "modelInfo": { - "modelInvariantId": "00beb8f9-6d39-452f-816d-c709b9cbb87d", - "modelVersionId": "0903e1c0-8e03-4936-b5c2-260653b96413", - "modelName": "2017-388_PASQUALE-vPE", - "modelVersion": "1.0", - "modelCustomizationId": "280dec31-f16d-488b-9668-4aae55d6648a", - "modelCustomizationName": "2017-388_PASQUALE-vPE 1", - "uuid": "0903e1c0-8e03-4936-b5c2-260653b96413" - }, - "uuid": "0903e1c0-8e03-4936-b5c2-260653b96413" - } - }, - "instanceParams": [{}], - "validationCounter": 0, - "existingNames": {"yoav": ""}, - "existingVNFCounterMap": { - "69e09f68-8b63-4cc9-b9ff-860960b5db09": 1, - "afacccf6-397d-45d6-b5ae-94c39734b168": 1, - "0903e1c0-8e03-4936-b5c2-260653b96413": 1 - }, - "existingVnfGroupCounterMap": { - "daeb6568-cef8-417f-9075-ed259ce59f48": 0, - "c2b300e6-45de-4e5e-abda-3032bee2de56": -1 - }, - "existingNetworksCounterMap": {"ddc3f20c-08b5-40fd-af72-c6d14636b986": 1}, - "networks": { - "ExtVL 0": { - "inMaint": false, - "rollbackOnFailure": "true", - "originalName": "ExtVL 0", - "isMissingData": false, - "trackById": "s6okajvv2n8", - "networkStoreKey": "ExtVL 0", - "productFamilyId": "d8a6ed93-251c-47ca-adc9-86671fd19f4c", - "lcpCloudRegionId": "AAIAIC25", - "legacyRegion": "12355555", - "tenantId": "092eb9e8e4b7412e8787dd091bc58e86", - "platformName": "platform", - "lineOfBusiness": null, - "instanceParams": [{}], - "modelInfo": { - "modelInvariantId": "379f816b-a7aa-422f-be30-17114ff50b7c", - "modelVersionId": "ddc3f20c-08b5-40fd-af72-c6d14636b986", - "modelName": "ExtVL", - "modelVersion": "37.0", - "modelCustomizationId": "94fdd893-4a36-4d70-b16a-ec29c54c184f", - "modelCustomizationName": "ExtVL 0", - "uuid": "ddc3f20c-08b5-40fd-af72-c6d14636b986" - }, - "uuid": "ddc3f20c-08b5-40fd-af72-c6d14636b986" - } - }, - "vnfGroups": { - "groupingservicefortest..ResourceInstanceGroup..0": { - "inMaint": false, - "rollbackOnFailure": "true", - "originalName": "groupingservicefortest..ResourceInstanceGroup..0", - "isMissingData": false, - "trackById": "se0obn93qq", - "vnfGroupStoreKey": "groupingservicefortest..ResourceInstanceGroup..0", - "instanceName": "groupingservicefortestResourceInstanceGroup0", - "instanceParams": [{}], - "modelInfo": { - "modelInvariantId": "4bb2e27e-ddab-4790-9c6d-1f731bc14a45", - "modelVersionId": "daeb6568-cef8-417f-9075-ed259ce59f48", - "modelName": "groupingservicefortest..ResourceInstanceGroup..0", - "modelVersion": "1", - "modelCustomizationName": "groupingservicefortest..ResourceInstanceGroup..0", - "uuid": "daeb6568-cef8-417f-9075-ed259ce59f48" - }, - "uuid": "daeb6568-cef8-417f-9075-ed259ce59f48" - } - }, - "instanceName": "yoav", - "globalSubscriberId": "e433710f-9217-458d-a79d-1c7aff376d89", - "subscriptionServiceType": "TYLER SILVIA", - "owningEntityId": "d61e6f2d-12fa-4cc2-91df-7c244011d6fc", - "productFamilyId": "d8a6ed93-251c-47ca-adc9-86671fd19f4c", - "lcpCloudRegionId": "AAIAIC25", - "tenantId": "092eb9e8e4b7412e8787dd091bc58e86", - "aicZoneId": "ATL53", - "pause": null, - "projectName": "WATKINS", - "rollbackOnFailure": "true", - "bulkSize": 1, - "aicZoneName": "AAIATLTE-ATL53", - "owningEntityName": "WayneHolland", - "testApi": "VNF_API", - "isEcompGeneratedNaming": false, - "tenantName": "USP-SIP-IC-24335-T-01", - "modelInfo": { - "modelInvariantId": "cdb90b57-ed78-4d44-a5b4-7f43a02ec632", - "modelVersionId": "1a80c596-27e5-4ca9-b5bb-e03a7fd4c0fd", - "modelName": "action-data", - "modelVersion": "1.0", - "uuid": "1a80c596-27e5-4ca9-b5bb-e03a7fd4c0fd" - }, - "isALaCarte": false, - "name": "action-data", - "version": "1.0", - "description": "PASQUALE vMX vPE based on Juniper 17.2 release. Updated with updated VF for v8.0 of VLM", - "category": "Network L1-3", - "uuid": "1a80c596-27e5-4ca9-b5bb-e03a7fd4c0fd", - "invariantUuid": "cdb90b57-ed78-4d44-a5b4-7f43a02ec632", - "serviceType": "pnf", - "serviceRole": "Testing", - "vidNotions": {"instantiationUI": "legacy", "modelCategory": "other", "viewEditUI": "legacy"}, - "isMultiStepDesign": true - }; -} function getStore() { return { diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.ts index 6c985ec6a..d60bbd3c9 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.ts @@ -54,23 +54,39 @@ export class SharedTreeService { : (nodeInstance.modelInfo.modelCustomizationId || nodeInstance.modelInfo.modelInvariantId); }; + modelUniqueNameOrId = (instance): string => + instance.originalName ? instance.originalName : this.modelUniqueId(instance); + /** * Finds a model inside a full service model * @param serviceModelFromHierarchy * @param modelTypeName "vnfs" | "networks" | "vfModules" | "collectionResources" | ... - * @param modelUniqueIdOrName Either an entry name (i.e. "originalName"), modelCustomizationId or modelInvariantId. + * @param modelUniqueNameOrId Either an entry name (i.e. "originalName"), modelCustomizationId or modelInvariantId. * Note that modelInvariantId will work only where model lacks a modelCustomizationId. + * @param modeName An optional entry name (i.e. "originalName"); will not try to use as id */ - modelByIdentifier = (serviceModelFromHierarchy, modelTypeName: string, modelUniqueIdOrName: string): any => { - if (_.isNil(serviceModelFromHierarchy)) return undefined; + modelByIdentifiers = (serviceModelFromHierarchy, modelTypeName: string, modelUniqueNameOrId: string, modeName?: string): any => { + const logErrorAndReturnUndefined = () => + console.info(`modelByIdentifiers: could not find a model matching query`, { + modelTypeName, modelUniqueNameOrId, modeName, serviceModelFromHierarchy + }); + + if (_.isNil(serviceModelFromHierarchy)) return logErrorAndReturnUndefined(); const modelsOfType = serviceModelFromHierarchy[modelTypeName]; - if (_.isNil(modelsOfType)) return undefined; + if (_.isNil(modelsOfType)) return logErrorAndReturnUndefined(); + + const modelIfModelIdentifierIsEntryName = modelsOfType[modelUniqueNameOrId]; + const modelIfModeNameExists = _.isNil(modeName) ? null : modelsOfType[modeName]; - const modelIfModelIdentifierIsEntryName = modelsOfType[modelUniqueIdOrName]; - return _.isNil(modelIfModelIdentifierIsEntryName) - ? _.find(modelsOfType, o => (o.customizationUuid || o.invariantUuid) === modelUniqueIdOrName) - : modelIfModelIdentifierIsEntryName; + if (!_.isNil(modelIfModelIdentifierIsEntryName)) { + return modelIfModelIdentifierIsEntryName; + } else if (!_.isNil(modelIfModeNameExists)) { + return modelIfModeNameExists; + } else { + // try modelUniqueNameOrId as an id + return _.find(modelsOfType, o => (o.customizationUuid || o.invariantUuid) === modelUniqueNameOrId) || logErrorAndReturnUndefined() + } }; hasMissingData(instance, dynamicInputs: any, isEcompGeneratedNaming: boolean, requiredFields: string[]): boolean { @@ -139,8 +155,8 @@ export class SharedTreeService { /********************************************** * should return true if can delete **********************************************/ - shouldShowDelete(node): boolean { - return this.shouldShowButtonGeneric(node, "delete") + shouldShowDelete(node, serviceModelId): boolean { + return this.shouldShowButtonGeneric(node, "delete", serviceModelId) } /********************************************** @@ -193,7 +209,7 @@ export class SharedTreeService { shouldShowUpgrade(node, serviceModelId): boolean { if (FeatureFlagsService.getFlagState(Features.FLAG_FLASH_REPLACE_VF_MODULE, this._store) && this.isThereAnUpdatedLatestVersion(serviceModelId)) { - return this.shouldShowButtonGeneric(node, VNFMethods.UPGRADE); + return this.shouldShowButtonGeneric(node, VNFMethods.UPGRADE, serviceModelId); } else { return false @@ -201,12 +217,22 @@ export class SharedTreeService { } private isThereAnUpdatedLatestVersion(serviceModelId) : boolean{ - let serviceInstance = this._store.getState().service.serviceInstance[serviceModelId]; + let serviceInstance = this.getServiceInstance(serviceModelId); return !_.isNil(serviceInstance.latestAvailableVersion) && (Number(serviceInstance.modelInfo.modelVersion) < serviceInstance.latestAvailableVersion); } - private shouldShowButtonGeneric(node, method) { + private getServiceInstance(serviceModelId): any { + return this._store.getState().service.serviceInstance[serviceModelId]; + } + + shouldShowButtonGeneric(node, method, serviceModelId) { const mode = this._store.getState().global.drawingBoardStatus; + const isMacro = !(this.getServiceInstance(serviceModelId).isALaCarte); + + if (isMacro) { //if macro action allowed only for service level + return false; + } + if (!_.isNil(node) && !_.isNil(node.data) && !_.isNil(node.data.action) && !_.isNil(node.data.menuActions[method])) { if (mode !== DrawingBoardModes.EDIT || node.data.action === ServiceInstanceActions.Create) { return false; @@ -288,7 +314,7 @@ export class SharedTreeService { ************************************************/ getExistingInstancesWithDeleteMode(node, serviceModelId: string, type: string): number { let counter = 0; - const existingInstances = this._store.getState().service.serviceInstance[serviceModelId][type]; + const existingInstances = this.getServiceInstance(serviceModelId)[type]; const modelUniqueId = node.data.modelUniqueId; if (!_.isNil(existingInstances)) { for (let instanceKey in existingInstances) { diff --git a/vid-webpack-master/src/app/shared/components/formControls/component/checkbox/checkbox.formControl.component.html b/vid-webpack-master/src/app/shared/components/formControls/component/checkbox/checkbox.formControl.component.html index 26362ebed..fe7744e43 100644 --- a/vid-webpack-master/src/app/shared/components/formControls/component/checkbox/checkbox.formControl.component.html +++ b/vid-webpack-master/src/app/shared/components/formControls/component/checkbox/checkbox.formControl.component.html @@ -8,4 +8,9 @@ data-toggle="toggle"> <label class="checkbox-label" for="{{data?.dataTestId}}">{{data?.displayName}}</label> + <div *ngFor="let extraContent of data?.extraContents" class="form-conrtols"> + <div [ngSwitch]="extraContent.type"> + <upload-files *ngSwitchCase="'UPLOAD_FILE'" [uploadFilesModel]="extraContent" [form]="form"></upload-files> + </div> + </div> </div> diff --git a/vid-webpack-master/src/app/shared/components/formControls/component/checkbox/checkbox.formControl.component.scss b/vid-webpack-master/src/app/shared/components/formControls/component/checkbox/checkbox.formControl.component.scss index 005e28cc6..81180e06f 100644 --- a/vid-webpack-master/src/app/shared/components/formControls/component/checkbox/checkbox.formControl.component.scss +++ b/vid-webpack-master/src/app/shared/components/formControls/component/checkbox/checkbox.formControl.component.scss @@ -11,6 +11,7 @@ .details-item label { position: relative; cursor: pointer; + float: left; } .details-item label:before { diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service.ts index acfaf78ab..83f722704 100644 --- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service.ts +++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service.ts @@ -133,13 +133,14 @@ export class SharedControllersService { }) }; - getSDNCControl = (instance: any): FormControlModel => { + getSDNCControl = (instance: any, extraContents? : object[]): FormControlModel => { return new CheckboxFormControl({ controlName: SDN_C_PRE_LOAD, displayName: 'SDN-C pre-load', dataTestId: 'sdncPreLoad', value: instance ? instance.sdncPreLoad : false, - validations: [new ValidatorModel(ValidatorOptions.required, 'is required')] + validations: [new ValidatorModel(ValidatorOptions.required, 'is required')], + extraContents }) }; diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.spec.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.spec.ts index b3bb1fe54..49deb3a50 100644 --- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.spec.ts +++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.spec.ts @@ -4,7 +4,7 @@ import {NgRedux} from '@angular-redux/store'; import {ControlGeneratorUtil, SDN_C_PRE_LOAD} from "../control.generator.util.service"; import {AaiService} from "../../../../services/aaiService/aai.service"; import {GenericFormService} from "../../generic-form.service"; -import {FormBuilder} from "@angular/forms"; +import {FormBuilder, FormControl, FormGroup} from "@angular/forms"; import {LogService} from "../../../../utils/log/log.service"; import { FormControlModel, @@ -16,6 +16,7 @@ import {FeatureFlagsService} from "../../../../services/featureFlag/feature-flag import {VfModuleInstance} from "../../../../models/vfModuleInstance"; import {VfModule} from "../../../../models/vfModule"; import {SharedControllersService} from "../sharedControlles/shared.controllers.service"; +import {AppState} from "../../../../store/reducers"; import {SharedTreeService} from "../../../../../drawingBoard/service-planning/objectsToTree/shared.tree.service"; class MockAppStore<T> { @@ -919,6 +920,7 @@ describe('VFModule Control Generator', () => { let injector; let service: VfModuleControlGenerator; let httpMock: HttpTestingController; + let store : NgRedux<AppState>; beforeAll(done => (async () => { TestBed.configureTestingModule({ @@ -939,6 +941,7 @@ describe('VFModule Control Generator', () => { injector = getTestBed(); service = injector.get(VfModuleControlGenerator); httpMock = injector.get(HttpTestingController); + store = injector.get(NgRedux); jest.spyOn(console, 'error'); })().then(done).catch(done.fail)); @@ -1164,5 +1167,29 @@ describe('VFModule Control Generator', () => { expect(controls[i].controlName).toEqual(orderedControls[i]); } }); + + + test('when flag is active - response should contains upload file', ()=>{ + spyOn(store, 'getState').and.returnValue( { + "global": { + "flags": { + "FLAG_2006_VFM_SDNC_PRELOAD_FILES" : true + } + } + }); + + const extraContent = service.getSdncExtraContents(); + console.log("extraContent", extraContent); + const uploadFileData = <any>extraContent[0]; + + expect(uploadFileData.type).toEqual('UPLOAD_FILE'); + expect(uploadFileData.dataTestId).toEqual('sdnc_pereload_upload_link'); + expect(uploadFileData.uploadMethod).toBeDefined(); + expect(uploadFileData.isDisabled).toBeDefined(); + expect(uploadFileData.onSuccess).toBeDefined(); + expect(uploadFileData.onFailed).toBeDefined(); + + }) + }); diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.ts index b00312d5f..702181581 100644 --- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.ts +++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.ts @@ -3,7 +3,7 @@ import {GenericFormService} from "../../generic-form.service"; import {AaiService} from "../../../../services/aaiService/aai.service"; import {NgRedux} from "@angular-redux/store"; import {HttpClient} from "@angular/common/http"; -import {ControlGeneratorUtil} from "../control.generator.util.service"; +import {ControlGeneratorUtil, SDN_C_PRE_LOAD} from "../control.generator.util.service"; import { CustomValidatorOptions, FormControlModel, @@ -20,6 +20,8 @@ import {VNFModel} from "../../../../models/vnfModel"; import {VnfInstance} from "../../../../models/vnfInstance"; import * as _ from 'lodash'; import {SharedControllersService} from "../sharedControlles/shared.controllers.service"; +import {MessageModal} from "../../../messageModal/message-modal.service"; +import {ButtonType} from "../../../customModal/models/button.type"; import {SharedTreeService} from "../../../../../drawingBoard/service-planning/objectsToTree/shared.tree.service"; export enum FormControlNames { @@ -36,7 +38,7 @@ export enum FormControlNames { export class VfModuleControlGenerator { aaiService: AaiService; vfModuleModel: VfModule; - isUpdateMode : boolean; + isUpdateMode: boolean; constructor(private genericFormService: GenericFormService, private _basicControlGenerator: ControlGeneratorUtil, @@ -54,7 +56,7 @@ export class VfModuleControlGenerator { if (isUpdateMode && this.store.getState().service.serviceInstance[serviceId] && _.has(this.store.getState().service.serviceInstance[serviceId].vnfs, vnfStoreKey) && _.has(this.store.getState().service.serviceInstance[serviceId].vnfs[vnfStoreKey].vfModules, UUIDData['modelName'])) { - vfModuleInstance = Object.assign({},this.store.getState().service.serviceInstance[serviceId].vnfs[vnfStoreKey].vfModules[UUIDData['modelName']][UUIDData['vFModuleStoreKey']]); + vfModuleInstance = Object.assign({}, this.store.getState().service.serviceInstance[serviceId].vnfs[vnfStoreKey].vfModules[UUIDData['modelName']][UUIDData['vFModuleStoreKey']]); } return vfModuleInstance; }; @@ -65,11 +67,11 @@ export class VfModuleControlGenerator { return vfModule; } - getMacroFormControls(serviceId: string, vnfStoreKey: string, vfModuleStoreKey: string, uuidData : Object, isUpdateMode: boolean): FormControlModel[] { + getMacroFormControls(serviceId: string, vnfStoreKey: string, vfModuleStoreKey: string, uuidData: Object, isUpdateMode: boolean): FormControlModel[] { this.isUpdateMode = isUpdateMode; this.extractVfAccordingToVfModuleUuid(serviceId, uuidData); if (_.isNil(serviceId) || _.isNil(vnfStoreKey) || _.isNil(vfModuleStoreKey)) { - if(isUpdateMode){ + if (isUpdateMode) { this._logService.error('should provide serviceId, vfModuleStoreKey, vnfStoreKey', serviceId); return []; } @@ -85,21 +87,21 @@ export class VfModuleControlGenerator { if (!_.isNil(vfModuleModel)) { result = this.pushInstanceAndVGToForm(result, vfModuleInstance, serviceId, vnfModel, false); } - if(this.store.getState().global.flags['FLAG_SUPPLEMENTARY_FILE']) { + if (this.store.getState().global.flags['FLAG_SUPPLEMENTARY_FILE']) { result = this._basicControlGenerator.concatSupplementaryFile(result, vfModuleInstance); } return result; } private newVNFModel(serviceId: string, vnf: VnfInstance) { - const vnfModelName: string = vnf.originalName; + const vnfModelName: string = this._sharedTreeService.modelUniqueNameOrId(vnf); const serviceModelFromHierarchy = this.store.getState().service.serviceHierarchy[serviceId]; - const model = this._sharedTreeService.modelByIdentifier(serviceModelFromHierarchy, "vnfs", vnfModelName); + const model = this._sharedTreeService.modelByIdentifiers(serviceModelFromHierarchy, "vnfs", vnfModelName); return new VNFModel(model); } - pushInstanceAndVGToForm(result: FormControlModel[], vfModuleElement: any, serviceId: string, vnfModel: any, isALaCarte: boolean) :FormControlModel[]{ + pushInstanceAndVGToForm(result: FormControlModel[], vfModuleElement: any, serviceId: string, vnfModel: any, isALaCarte: boolean): FormControlModel[] { result.push(this.getInstanceName(vfModuleElement, serviceId, vnfModel.isEcompGeneratedNaming)); if (this.vfModuleModel.volumeGroupAllowed) { result.push(this.getVolumeGroupData(vfModuleElement, serviceId, vnfModel.isEcompGeneratedNaming, isALaCarte)); @@ -107,16 +109,16 @@ export class VfModuleControlGenerator { return result; } - getAlaCarteFormControls(serviceId: string, vnfStoreKey: string, vfModuleStoreKey: string, uuidData : Object, isUpdateMode: boolean): FormControlModel[] { + getAlaCarteFormControls(serviceId: string, vnfStoreKey: string, vfModuleStoreKey: string, uuidData: Object, isUpdateMode: boolean): FormControlModel[] { this.isUpdateMode = isUpdateMode; this.extractVfAccordingToVfModuleUuid(serviceId, uuidData); if (_.isNil(serviceId) || _.isNil(vnfStoreKey) || _.isNil(vfModuleStoreKey)) { - if(isUpdateMode){ + if (isUpdateMode) { this._logService.error('should provide serviceId, vfModuleStoreKey, vnfStoreKey', serviceId); return []; } } - const vnf: VnfInstance = this.store.getState().service.serviceInstance[serviceId].vnfs[vnfStoreKey] ; + const vnf: VnfInstance = this.store.getState().service.serviceInstance[serviceId].vnfs[vnfStoreKey]; const vnfModel = this.newVNFModel(serviceId, vnf); const vfModuleInstance = this._basicControlGenerator.retrieveInstanceIfUpdateMode(this.store, this.getVfModuleInstance(serviceId, vnfStoreKey, uuidData, isUpdateMode)); @@ -126,26 +128,64 @@ export class VfModuleControlGenerator { result.push(this._sharedControllersService.getLegacyRegion(vfModuleInstance)); result.push(this._sharedControllersService.getTenantControl(serviceId, vfModuleInstance)); result.push(this._sharedControllersService.getRollbackOnFailureControl(vfModuleInstance)); - result.push(this._sharedControllersService.getSDNCControl(vfModuleInstance)); - if(this.store.getState().global.flags['FLAG_SUPPLEMENTARY_FILE']) { + result.push(this._sharedControllersService.getSDNCControl(vfModuleInstance, this.getSdncExtraContents())); + if (this.store.getState().global.flags['FLAG_SUPPLEMENTARY_FILE']) { result = this._basicControlGenerator.concatSupplementaryFile(result, vfModuleInstance); } return result; } - getInstanceName(instance: any, serviceId: string, isEcompGeneratedNaming: boolean): FormControlModel { - let formControlModel:FormControlModel = this._sharedControllersService.getInstanceNameController(instance, serviceId, isEcompGeneratedNaming, this.vfModuleModel); - formControlModel.onBlur = (event, form : FormGroup) => { - if(!_.isNil(form.controls['volumeGroupName'])&& event.target.value.length > 0){ - form.controls['volumeGroupName'].setValue(event.target.value + "_vol"); + getSdncExtraContents() : object[] { + return _.compact([ + !!this.store.getState().global.flags['FLAG_2006_VFM_SDNC_PRELOAD_FILES'] ? { + type: 'UPLOAD_FILE', + dataTestId: 'sdnc_pereload_upload_link', + uploadMethod: (form: FormGroup) : Promise<boolean> => { + // this -> files item + return this._aaiService.sdncPreload().toPromise() + .then((response : boolean)=>{ + return response; + }).catch(err => { + return false; + }); + }, + isDisabled: (form: FormGroup): boolean => { + return !form.controls[SDN_C_PRE_LOAD].value; + }, + onSuccess: (form: FormGroup): void => { + MessageModal.showMessageModal({ + text: 'The pre-load file(s) have been uploaded successfully.', + type: "success", + title: 'Success', + buttons: [{type: ButtonType.success, size: 'large', text: 'OK', closeModal: true}] + }) + }, + onFailed: (form: FormGroup) : void=> { + MessageModal.showMessageModal({ + text: 'Failed to upload one or more of the files, please retry.', + type: "error", + title: 'Failure', + buttons: [{type: ButtonType.error, size: 'large', text: 'OK', closeModal: true}] + }) } - }; + } : null + ]); + } + + + getInstanceName(instance: any, serviceId: string, isEcompGeneratedNaming: boolean): FormControlModel { + let formControlModel: FormControlModel = this._sharedControllersService.getInstanceNameController(instance, serviceId, isEcompGeneratedNaming, this.vfModuleModel); + formControlModel.onBlur = (event, form: FormGroup) => { + if (!_.isNil(form.controls['volumeGroupName']) && event.target.value.length > 0) { + form.controls['volumeGroupName'].setValue(event.target.value + "_vol"); + } + }; return formControlModel; } getDefaultVolumeGroupName(instance: any, isEcompGeneratedNaming: boolean): string { - if ((!_.isNil(instance) && instance.volumeGroupName)) { + if ((!_.isNil(instance) && instance.volumeGroupName)) { return instance.volumeGroupName; } if (isEcompGeneratedNaming) { @@ -165,12 +205,12 @@ export class VfModuleControlGenerator { displayName: 'Volume Group Name', dataTestId: 'volumeGroupName', validations: validations, - tooltip : 'When filled, VID will create a Volume Group by this name and associate with this module.\n' + - 'When empty, the module is created without a Volume Group.', - isVisible: this.shouldVGNameBeVisible(isEcompGeneratedNaming,isALaCarte), + tooltip: 'When filled, VID will create a Volume Group by this name and associate with this module.\n' + + 'When empty, the module is created without a Volume Group.', + isVisible: this.shouldVGNameBeVisible(isEcompGeneratedNaming, isALaCarte), value: this.getDefaultVolumeGroupName(instance, isEcompGeneratedNaming), onKeypress: (event) => { - const pattern:RegExp = ControlGeneratorUtil.INSTANCE_NAME_REG_EX; + const pattern: RegExp = ControlGeneratorUtil.INSTANCE_NAME_REG_EX; if (pattern) { if (!pattern.test(event['key'])) { event.preventDefault(); @@ -182,7 +222,7 @@ export class VfModuleControlGenerator { } private shouldVGNameBeVisible(isEcompGeneratedNaming: boolean, isALaCarte: boolean) { - if((!isALaCarte && !isEcompGeneratedNaming) || isALaCarte){ + if ((!isALaCarte && !isEcompGeneratedNaming) || isALaCarte) { return true; } return false; diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator.spec.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator.spec.ts index 018130eec..4572fa443 100644 --- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator.spec.ts +++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator.spec.ts @@ -957,7 +957,8 @@ describe('VNF Control Generator', () => { FormControlNames.INSTANCE_NAME, FormControlNames.LCPCLOUD_REGION_ID, FormControlNames.TENANT_ID, - 'platformName' + 'platformName', + FormControlNames.PRODUCT_FAMILY_ID ]; for(let i = 0 ; i < mandatoryControls.length ; i++){ diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator.ts index 14b31b4b7..169780b29 100644 --- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator.ts +++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator.ts @@ -50,7 +50,7 @@ export class VnfControlGenerator { if (!_.isNil(vnfModel)) { result.push(this.getInstanceName(vnfInstance, serviceId, vnfName, vnfModel.isEcompGeneratedNaming)); - result.push(this._sharedControllersService.getProductFamilyControl(vnfInstance, result, false)); + result.push(this._sharedControllersService.getProductFamilyControl(vnfInstance, result, true)); result.push(this._sharedControllersService.getLcpRegionControl(serviceId, vnfInstance, result)); result.push(this._sharedControllersService.getLegacyRegion(vnfInstance)); result.push(this._sharedControllersService.getTenantControl(serviceId, vnfInstance)); @@ -74,7 +74,7 @@ export class VnfControlGenerator { if (!_.isNil(vnfModel)) { const flags = this.store.getState().global.flags; result.push(this.getInstanceName(vnfInstance, serviceId, vnfName, vnfModel.isEcompGeneratedNaming)); - result.push(this._sharedControllersService.getProductFamilyControl(vnfInstance, result, false)); + result.push(this._sharedControllersService.getProductFamilyControl(vnfInstance, result, true)); result.push(this._sharedControllersService.getLcpRegionControl(serviceId, vnfInstance, result)); result.push(this._sharedControllersService.getLegacyRegion(vnfInstance)); result.push(this._sharedControllersService.getTenantControl(serviceId, vnfInstance)); diff --git a/vid-webpack-master/src/app/shared/components/genericForm/generic-form.component.html b/vid-webpack-master/src/app/shared/components/genericForm/generic-form.component.html index edf86823c..627f6426a 100644 --- a/vid-webpack-master/src/app/shared/components/genericForm/generic-form.component.html +++ b/vid-webpack-master/src/app/shared/components/genericForm/generic-form.component.html @@ -3,7 +3,7 @@ <div *ngFor="let formControl of formControls" class="form-conrtols"> <div [ngSwitch]="formControl.type"> <form-control-input *ngSwitchCase="'INPUT'" [data]="formControl" [form]="dynamicFormGroup"></form-control-input> - <checkbox-form-control *ngSwitchCase="'CHECKBOX'" [data]="formControl" [form]="dynamicFormGroup" ></checkbox-form-control> + <checkbox-form-control *ngSwitchCase="'CHECKBOX'" [data]="formControl" [form]="dynamicFormGroup"></checkbox-form-control> <dropdown-form-control *ngSwitchCase="'DROPDOWN'" [data]="formControl" [form]="dynamicFormGroup" ></dropdown-form-control> <file-form-control *ngSwitchCase="'FILE'" [data]="formControl" [form]="dynamicFormGroup"></file-form-control> <multiselect-form-control *ngSwitchCase="'MULTI_SELECT'" diff --git a/vid-webpack-master/src/app/shared/components/genericForm/genericFormSharedComponent/uploadFiles/upload-files-link.component.html b/vid-webpack-master/src/app/shared/components/genericForm/genericFormSharedComponent/uploadFiles/upload-files-link.component.html new file mode 100644 index 000000000..6f59c0ce2 --- /dev/null +++ b/vid-webpack-master/src/app/shared/components/genericForm/genericFormSharedComponent/uploadFiles/upload-files-link.component.html @@ -0,0 +1,15 @@ +<div> + <a [attr.data-tests-id]="uploadFilesModel.dataTestId" + (click)="uploadFilesTrigger()" + href="javascript:void(0)" + class="upload-text" + [class.disabled]="uploadFilesModel.isDisabled && uploadFilesModel.isDisabled(form)">{{uploadFilesModel.uploadText || 'Upload'}}</a> + <span class="hide-span"> + <input + type="file" + #fileInput + ng2FileSelect + [uploader]="uploader" + [attr.data-tests-id]="uploadFilesModel.dataTestId + '-input'"/> + </span> +</div> diff --git a/vid-webpack-master/src/app/shared/components/genericForm/genericFormSharedComponent/uploadFiles/upload-files-link.component.scss b/vid-webpack-master/src/app/shared/components/genericForm/genericFormSharedComponent/uploadFiles/upload-files-link.component.scss new file mode 100644 index 000000000..ce9e14fbe --- /dev/null +++ b/vid-webpack-master/src/app/shared/components/genericForm/genericFormSharedComponent/uploadFiles/upload-files-link.component.scss @@ -0,0 +1,23 @@ +.upload-text { + margin-left: 30px; + font-family: OpenSans-Semibold; + font-size: 14px; + line-height: 23px; +} + +a.disabled { + color: gray; + cursor: not-allowed; + text-decoration: underline; +} + +.hide-span { + visibility: hidden; + position: absolute; + overflow: hidden; + width: 0px; + height: 0px; + border: none; + margin: 0; + padding: 0 +} diff --git a/vid-webpack-master/src/app/shared/components/genericForm/genericFormSharedComponent/uploadFiles/upload-files-link.component.ts b/vid-webpack-master/src/app/shared/components/genericForm/genericFormSharedComponent/uploadFiles/upload-files-link.component.ts new file mode 100644 index 000000000..803d5d053 --- /dev/null +++ b/vid-webpack-master/src/app/shared/components/genericForm/genericFormSharedComponent/uploadFiles/upload-files-link.component.ts @@ -0,0 +1,41 @@ +import {Component, ElementRef, Input, OnInit, ViewChild} from "@angular/core"; +import {FileItem, FileUploader} from "ng2-file-upload"; +import {UploadFilesLinkModel} from "./upload-files-link.model"; +import {FormGroup} from "@angular/forms"; + +@Component({ + selector: 'upload-files', + templateUrl: './upload-files-link.component.html', + styleUrls: ['./upload-files-link.component.scss'] +}) +export class UploadFilesLinkComponent implements OnInit { + uploader: FileUploader; + @Input() uploadFilesModel: UploadFilesLinkModel; + @Input() form: FormGroup; + @ViewChild('fileInput', {static: false}) fileInput: ElementRef; + + ngOnInit(): void { + this.uploader = new FileUploader({}); + + this.uploader.onAfterAddingAll = async (files: FileItem[]) => { + const result = await this.uploadFilesModel.uploadMethod.call(files, this.form); + if (result && this.uploadFilesModel.onSuccess) { + this.uploadFilesModel.onSuccess.call(this.form); + } else if (!result && this.uploadFilesModel.onFailed) { + this.uploadFilesModel.onFailed.call(this.form); + } + this.uploadFilesModel.uploadText = result ? 'Upload another' : 'Upload' + }; + this.resetUpload(); + } + + resetUpload(): void { + this.fileInput.nativeElement.value = ''; + } + + uploadFilesTrigger() { + if (this.uploadFilesModel.isDisabled && !this.uploadFilesModel.isDisabled(this.form)) { + this.fileInput.nativeElement.click(); + } + } +} diff --git a/vid-webpack-master/src/app/shared/components/genericForm/genericFormSharedComponent/uploadFiles/upload-files-link.model.ts b/vid-webpack-master/src/app/shared/components/genericForm/genericFormSharedComponent/uploadFiles/upload-files-link.model.ts new file mode 100644 index 000000000..beb54f43a --- /dev/null +++ b/vid-webpack-master/src/app/shared/components/genericForm/genericFormSharedComponent/uploadFiles/upload-files-link.model.ts @@ -0,0 +1,30 @@ +import {FileItem} from "ng2-file-upload"; + +export class UploadFilesLinkModel { + uploadText?: string; + + /********************************************************************* + Implement success method - run after uploadMethod return true result + **********************************************************************/ + onSuccess?: (...args) => void; + + /********************************************************************* + Implement failed method - run after uploadMethod return false result + **********************************************************************/ + onFailed?: (...args) => void; + + /********************************************************************************* + Implement upload method and return the upload result status (false/true) + *********************************************************************************/ + uploadMethod: (file: FileItem[], ...args) => Promise<boolean>; + + /******************************** + Should upload file be disabled + ********************************/ + isDisabled?: (...args) => boolean; + + /******************************** + a tag data test id + ********************************/ + dataTestId : string; +} diff --git a/vid-webpack-master/src/app/shared/components/messageModal/message-modal.model.ts b/vid-webpack-master/src/app/shared/components/messageModal/message-modal.model.ts new file mode 100644 index 000000000..d29144095 --- /dev/null +++ b/vid-webpack-master/src/app/shared/components/messageModal/message-modal.model.ts @@ -0,0 +1,15 @@ +import {ButtonType} from "../customModal/models/button.type"; + +export class MessageModalModel { + title : string; + text : string; + type : 'error' | 'info' | 'success'; + buttons : {text: string, size: string, type : ButtonType, closeModal: boolean}[]; + + constructor( title : string, text : string, type , buttons : {text: string, size: string, type : ButtonType, closeModal: boolean}[]){ + this.title = title; + this.text = text; + this.type = type; + this.buttons = buttons; + } +} diff --git a/vid-webpack-master/src/app/shared/components/messageModal/message-modal.service.spec.ts b/vid-webpack-master/src/app/shared/components/messageModal/message-modal.service.spec.ts new file mode 100644 index 000000000..ffaccb198 --- /dev/null +++ b/vid-webpack-master/src/app/shared/components/messageModal/message-modal.service.spec.ts @@ -0,0 +1,56 @@ +import {MessageModal} from "./message-modal.service"; +import {getTestBed, TestBed} from "@angular/core/testing"; +import {SdcUiCommon} from "onap-ui-angular"; +import each from "jest-each"; +import {MessageBoxService} from "../messageBox/messageBox.service"; +import {MessageModalModel} from "./message-modal.model"; +import {MessageBoxData} from "../messageBox/messageBox.data"; + + +describe('Message Modal Service', () => { + let injector; + let service: MessageModal; + + beforeAll(done => (async () => { + TestBed.configureTestingModule({ + imports: [], + providers: [MessageModal] + }); + await TestBed.compileComponents(); + + injector = getTestBed(); + service = injector.get(MessageModal); + })().then(done).catch(done.fail)); + + + each([ + ["error", SdcUiCommon.ModalType.error], + ["info", SdcUiCommon.ModalType.info], + ["success", SdcUiCommon.ModalType.success] + ]).test('getModalType with type %s should return %s', (inputMessageType, expectedResult) => { + + let message = { + type: inputMessageType + }; + + const type = MessageModal.getModalType(<any>message) + expect(type).toEqual(expectedResult); + }); + + test('showMessageModal should call open modal with all data' , async (done)=>{ + spyOn(MessageBoxService.openModal, 'next'); + let message : MessageModalModel = new MessageModalModel('title', 'text', "success", []); + + MessageModal.showMessageModal(message); + setTimeout(()=>{ + const messageBoxData = new MessageBoxData( message.title, + message.text, + SdcUiCommon.ModalType.success, + SdcUiCommon.ModalSize.medium, + message.buttons) + expect(MessageBoxService.openModal.next).toHaveBeenCalledWith(messageBoxData); + done(); + }, 500) + }); + +}); diff --git a/vid-webpack-master/src/app/shared/components/messageModal/message-modal.service.ts b/vid-webpack-master/src/app/shared/components/messageModal/message-modal.service.ts new file mode 100644 index 000000000..e1f85bdb0 --- /dev/null +++ b/vid-webpack-master/src/app/shared/components/messageModal/message-modal.service.ts @@ -0,0 +1,39 @@ +import {Injectable} from "@angular/core"; +import {MessageBoxService} from '../messageBox/messageBox.service'; +import {MessageBoxData} from '../messageBox/messageBox.data'; +import {SdcUiCommon} from "onap-ui-angular"; +import {MessageModalModel} from "./message-modal.model"; + +@Injectable() +export class MessageModal { + static showMessageModal(message: MessageModalModel): void { + setTimeout(() => { + let messageBoxData: MessageBoxData = new MessageBoxData( + message.title, + message.text, + this.getModalType(message), + SdcUiCommon.ModalSize.medium, + message.buttons); + MessageBoxService.openModal.next(messageBoxData); + } + , 500); + }; + + + static getModalType = (message: MessageModalModel): string => { + switch (message.type) { + case "error": { + return SdcUiCommon.ModalType.error + } + case "info": { + return SdcUiCommon.ModalType.info; + } + case "success": { + return SdcUiCommon.ModalType.success; + } + } + }; +} + + + diff --git a/vid-webpack-master/src/app/shared/models/formControlModels/checkboxFormControl.model.ts b/vid-webpack-master/src/app/shared/models/formControlModels/checkboxFormControl.model.ts index f505b5667..1675917d2 100644 --- a/vid-webpack-master/src/app/shared/models/formControlModels/checkboxFormControl.model.ts +++ b/vid-webpack-master/src/app/shared/models/formControlModels/checkboxFormControl.model.ts @@ -1,11 +1,13 @@ import {FormControlModel} from "./formControl.model"; import {FormControlType} from "./formControlTypes.enum"; +import * as _ from "lodash"; export class CheckboxFormControl extends FormControlModel{ - + extraContents : object[]; constructor(data) { super(data); this.type = FormControlType.CHECKBOX; this.validations = []; + this.extraContents = !_.isNil(data.extraContents) ? data.extraContents : null; } } diff --git a/vid-webpack-master/src/app/shared/models/formControlModels/formControl.model.ts b/vid-webpack-master/src/app/shared/models/formControlModels/formControl.model.ts index 24116549e..b3a53d9f2 100644 --- a/vid-webpack-master/src/app/shared/models/formControlModels/formControl.model.ts +++ b/vid-webpack-master/src/app/shared/models/formControlModels/formControl.model.ts @@ -43,6 +43,7 @@ export class FormControlModel { this.preventionsAttribute = data.preventionsAttribute || []; this.onBlur = function(){}; this.onChange = data.onChange ? data.onChange: function () {} + } isRequired() : boolean { diff --git a/vid-webpack-master/src/app/shared/services/aaiService/aai.service.ts b/vid-webpack-master/src/app/shared/services/aaiService/aai.service.ts index 1cc5593f7..9026a5648 100644 --- a/vid-webpack-master/src/app/shared/services/aaiService/aai.service.ts +++ b/vid-webpack-master/src/app/shared/services/aaiService/aai.service.ts @@ -44,6 +44,11 @@ export class AaiService { } + sdncPreload(): Observable<boolean> { + let pathQuery: string = Constants.Path.PRE_LOAD; + return this.http.post<boolean>(pathQuery, {}) + } + getServiceModelById = (serviceModelId: string): Observable<any> => { if (_.has(this.store.getState().service.serviceHierarchy, serviceModelId)) { return of(<any> JSON.parse(JSON.stringify(this.store.getState().service.serviceHierarchy[serviceModelId]))); diff --git a/vid-webpack-master/src/app/shared/services/featureFlag/feature-flags.service.ts b/vid-webpack-master/src/app/shared/services/featureFlag/feature-flags.service.ts index 19a3fc73c..722deca99 100644 --- a/vid-webpack-master/src/app/shared/services/featureFlag/feature-flags.service.ts +++ b/vid-webpack-master/src/app/shared/services/featureFlag/feature-flags.service.ts @@ -15,8 +15,10 @@ export enum Features { FLAG_2002_VFM_UPGRADE_ADDITIONAL_OPTIONS ='FLAG_2002_VFM_UPGRADE_ADDITIONAL_OPTIONS', FLAG_2004_INSTANTIATION_STATUS_FILTER ='FLAG_2004_INSTANTIATION_STATUS_FILTER', FLAG_2004_CREATE_ANOTHER_INSTANCE_FROM_TEMPLATE = 'FLAG_2004_CREATE_ANOTHER_INSTANCE_FROM_TEMPLATE', + FLAG_2006_VFM_SDNC_PRELOAD_FILES = 'FLAG_2006_VFM_SDNC_PRELOAD_FILES', FLAG_MORE_AUDIT_INFO_LINK_ON_AUDIT_INFO = 'FLAG_MORE_AUDIT_INFO_LINK_ON_AUDIT_INFO', - FLAG_2004_INSTANTIATION_TEMPLATES_POPUP = 'FLAG_2004_INSTANTIATION_TEMPLATES_POPUP' + FLAG_2004_INSTANTIATION_TEMPLATES_POPUP = 'FLAG_2004_INSTANTIATION_TEMPLATES_POPUP', + FLAG_2006_USER_PERMISSIONS_BY_OWNING_ENTITY= 'FLAG_2006_USER_PERMISSIONS_BY_OWNING_ENTITY' } @Injectable() diff --git a/vid-webpack-master/src/app/shared/shared.module.ts b/vid-webpack-master/src/app/shared/shared.module.ts index 08b7fe520..bae7c11f9 100644 --- a/vid-webpack-master/src/app/shared/shared.module.ts +++ b/vid-webpack-master/src/app/shared/shared.module.ts @@ -93,6 +93,9 @@ import {SvgIconComponent} from "./components/customIcon/custom-icon.component"; import {TooltipTemplateComponent} from "./components/customTooltip/custom-tooltip.component"; import {TooltipDirective} from "./components/customTooltip/tooltip.directive"; import {SdcUiComponentsModule} from "onap-ui-angular"; +import {UploadFilesLinkComponent} from "./components/genericForm/genericFormSharedComponent/uploadFiles/upload-files-link.component"; +import { FileUploadModule } from 'ng2-file-upload'; +import {MessageModal} from "./components/messageModal/message-modal.service"; @@ -111,7 +114,8 @@ import {SdcUiComponentsModule} from "onap-ui-angular"; AngularMultiSelectModule, BootstrapModalModule, DataTableModule, - ModalModule.forRoot() + ModalModule.forRoot(), + FileUploadModule ], declarations: [ PopoverComponent, @@ -156,7 +160,8 @@ import {SdcUiComponentsModule} from "onap-ui-angular"; CustomModalButtonComponent, LoaderComponent, SvgIconComponent, - TooltipTemplateComponent + TooltipTemplateComponent, + UploadFilesLinkComponent ], exports: [ PopoverComponent, @@ -197,7 +202,8 @@ import {SdcUiComponentsModule} from "onap-ui-angular"; CustomModalButtonComponent, LoaderComponent, SvgIconComponent, - TooltipTemplateComponent + TooltipTemplateComponent, + UploadFilesLinkComponent ], entryComponents : [ GenericFormPopupComponent, @@ -248,7 +254,8 @@ import {SdcUiComponentsModule} from "onap-ui-angular"; ModelInformationService, MultiselectFormControlService, InstantiationTemplatesModalService, - LoaderService + LoaderService, + MessageModal ] }) export class SharedModule { diff --git a/vid-webpack-master/src/app/shared/utils/constants.ts b/vid-webpack-master/src/app/shared/utils/constants.ts index da717c8f4..01466f113 100644 --- a/vid-webpack-master/src/app/shared/utils/constants.ts +++ b/vid-webpack-master/src/app/shared/utils/constants.ts @@ -97,6 +97,7 @@ export module Constants { public static SERVICE_MODEL_ID = 'serviceModelId'; public static SERVICES_RETRY_TOPOLOGY = '../../asyncInstantiation/bulkForRetry'; public static INSTANTIATION_TEMPLATE_TOPOLOGY = '../../instantiationTemplates/templateTopology'; + public static PRE_LOAD = '../../preload'; public static CONFIGURATION_PATH = '../../get_property/{name}/defaultvalue'; public static SERVICES_JOB_AUDIT_PATH = '/auditStatus'; public static SERVICES_PROBE_PATH = "../../probe"; diff --git a/vid-webpack-master/src/styles.scss b/vid-webpack-master/src/styles.scss index f170f35f5..1d332ed63 100644 --- a/vid-webpack-master/src/styles.scss +++ b/vid-webpack-master/src/styles.scss @@ -239,4 +239,6 @@ sdc-checkbox { display: none !important; } - +sdc-modal { + z-index: 10000 !important; +} |