aboutsummaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.ts
diff options
context:
space:
mode:
Diffstat (limited to 'vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.ts')
-rw-r--r--vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.ts123
1 files changed, 113 insertions, 10 deletions
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 1115d1bc6..9e7a0211e 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
@@ -19,7 +19,6 @@ import {NodeInstance} from "../../../shared/models/nodeInstance";
@Injectable()
export class SharedTreeService {
- private _sharedTreeService: SharedTreeService;
constructor(private _store: NgRedux<AppState>) {
}
@@ -54,6 +53,51 @@ export class SharedTreeService {
: (nodeInstance.modelInfo.modelCustomizationId || nodeInstance.modelInfo.modelInvariantId);
};
+ modelUniqueNameOrId = (instance): string => {
+ if (_.isNil(instance)) {
+ return null;
+ }
+
+ const innerInstance = _.find(instance) || {};
+
+ return instance.originalName
+ || this.modelUniqueId(instance)
+ || innerInstance.originalName
+ || this.modelUniqueId(innerInstance);
+ };
+
+ /**
+ * Finds a model inside a full service model
+ * @param serviceModelFromHierarchy
+ * @param modelTypeName "vnfs" | "networks" | "vfModules" | "collectionResources" | ...
+ * @param modelUniqueNameOrId Either an entry name (i.e. "originalName"), modelCustomizationId or modelInvariantId.
+ * Note that modelInvariantId will work only where model lacks a modelCustomizationId.
+ * @param modelName An optional entry name (i.e. "originalName"); will not try to use as id
+ */
+ modelByIdentifiers = (serviceModelFromHierarchy, modelTypeName: string, modelUniqueNameOrId: string, modelName?: string): any => {
+ const logErrorAndReturnUndefined = () =>
+ console.info(`modelByIdentifiers: could not find a model matching query`, {
+ modelTypeName, modelUniqueNameOrId, modelName, serviceModelFromHierarchy
+ });
+
+ if (_.isNil(serviceModelFromHierarchy)) return logErrorAndReturnUndefined();
+
+ const modelsOfType = serviceModelFromHierarchy[modelTypeName];
+ if (_.isNil(modelsOfType)) return logErrorAndReturnUndefined();
+
+ const modelIfModelIdentifierIsEntryName = modelsOfType[modelUniqueNameOrId];
+ const modelIfModeNameExists = _.isNil(modelName) ? null : modelsOfType[modelName];
+
+ 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 {
if (!isEcompGeneratedNaming && _.isEmpty(instance.instanceName)) {
return true;
@@ -120,8 +164,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)
}
/**********************************************
@@ -173,21 +217,74 @@ 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);
+ (this.isThereAnUpdatedLatestVersion(serviceModelId)) || this.isVfmoduleAlmostPartOfModelOnlyCustomizationUuidDiffer(node, serviceModelId)) {
+ return this.shouldShowButtonGeneric(node, VNFMethods.UPGRADE, serviceModelId);
}
else {
return false
}
}
- private isThereAnUpdatedLatestVersion(serviceModelId) : boolean{
- let serviceInstance = this._store.getState().service.serviceInstance[serviceModelId];
+
+ isVfmoduleAlmostPartOfModelOnlyCustomizationUuidDiffer(vfModuleNode, serviceModelId) : boolean {
+ /*
+ for `true`, should all:
+ 1. parent vnf found by model-mane
+ 2. vfmodule found by invariant
+ 3. vfmodule diff by customization
+ */
+
+ if (_.isNil(vfModuleNode.data)) {
+ return false;
+ }
+
+ const vnfHierarchy = this.getParentVnfHierarchy(vfModuleNode, serviceModelId);
+ if (_.isNil(vnfHierarchy)) {
+ return false;
+ }
+
+ const vfModuleHierarchyByInvariantId = this.getVfModuleHFromVnfHierarchyByInvariantId(vfModuleNode, vnfHierarchy);
+ if(_.isNil(vfModuleHierarchyByInvariantId)){
+ return false;
+ }
+
+ return vfModuleHierarchyByInvariantId.customizationUuid
+ && (vfModuleHierarchyByInvariantId.customizationUuid !== vfModuleNode.data.modelCustomizationId);
+ }
+
+ getParentVnfHierarchy(vfModuleNode, serviceModelId) {
+ if (vfModuleNode.parent && vfModuleNode.parent.data) {
+ return this._store.getState().service.serviceHierarchy[serviceModelId].vnfs[vfModuleNode.parent.data.modelName];
+ } else {
+ return null;
+ }
+ }
+
+ getVfModuleHFromVnfHierarchyByInvariantId(vfModuleNode, parentVnfHierarchy) {
+ if(vfModuleNode.data.modelInvariantId && parentVnfHierarchy && parentVnfHierarchy.vfModules){
+ return _.find(parentVnfHierarchy.vfModules, o => o.invariantUuid === vfModuleNode.data.modelInvariantId);
+ }
+ return null;
+ }
+
+
+ isThereAnUpdatedLatestVersion(serviceModelId) : boolean{
+ 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;
@@ -269,7 +366,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) {
@@ -358,7 +455,13 @@ export class SharedTreeService {
AuditInfoModalComponent.openInstanceAuditInfoModal.next({
instanceId: serviceModelId,
type: instanceType,
- model: modelInfoService.getModel(node.data.modelName, instance, this._store.getState().service.serviceHierarchy[serviceModelId]),
+ model: modelInfoService.getModel(
+ this.modelByIdentifiers(
+ this._store.getState().service.serviceHierarchy[serviceModelId],
+ modelInfoService.name,
+ this.modelUniqueNameOrId(instance), node.data.modelName
+ )
+ ),
instance
});
}