diff options
2 files changed, 113 insertions, 103 deletions
diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popuop.service.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popuop.service.ts index d0a68675c..9c900b77b 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popuop.service.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popuop.service.ts @@ -21,8 +21,7 @@ import {FormControlModel} from "../../../../models/formControlModels/formControl import * as _ from 'lodash'; import {createVFModuleInstance, updateVFModuleInstance} from "../../../../storeUtil/utils/vfModule/vfModule.actions"; -@Injectable() -export class VfModulePopuopService implements GenericPopupInterface { +export abstract class VfModulePopupServiceBase { dynamicInputs: any; instance: any; model: any; @@ -31,16 +30,27 @@ export class VfModulePopuopService implements GenericPopupInterface { uuidData: Object; closeDialogEvent: Subject<any> = new Subject<any>(); isUpdateMode: boolean; + storeVFModule = (that, formValues: any): void => { + formValues.modelInfo = new ModelInfo(that.model); + formValues.uuid = formValues.modelInfo.uuid; + formValues.isMissingData = false; + const vnf = that._store.getState().service.serviceInstance[that.uuidData.serviceId].vnfs[that.uuidData.vnfStoreKey]; + if (!that.uuidData.vFModuleStoreKey) { + this._store.dispatch(createVFModuleInstance(formValues, that.uuidData.modelName, that.uuidData.serviceId, 0, that.uuidData.vnfStoreKey)); + } else { + this._store.dispatch(updateVFModuleInstance(formValues, that.uuidData.modelName, that.uuidData.serviceId, that.uuidData.vFModuleStoreKey, that.uuidData.vnfStoreKey)); + } + }; - constructor(protected _basicControlGenerator: BasicControlGenerator, - protected _vfModuleControlGenerator: VfModuleControlGenerator, - protected _iframeService: IframeService, - protected _defaultDataGeneratorService: DefaultDataGeneratorService, - protected _aaiService: AaiService, - protected _basicPopupService : BasicPopupService, - protected _store: NgRedux<AppState>) { - + protected constructor( + protected _basicControlGenerator: BasicControlGenerator, + protected _vfModuleControlGenerator: VfModuleControlGenerator, + protected _iframeService: IframeService, + protected _defaultDataGeneratorService: DefaultDataGeneratorService, + protected _aaiService: AaiService, + protected _basicPopupService: BasicPopupService, + protected _store: NgRedux<AppState>) { } getInstance(serviceId: string, vnfStoreKey: string, vfModuleStoreKey: string): any { @@ -51,24 +61,58 @@ export class VfModulePopuopService implements GenericPopupInterface { return vfModules[this.uuidData['modelName']][vfModuleStoreKey]; } - getDynamicInputs(UUIDData : Object) : FormControlModel[]{ - let dynamic = this._defaultDataGeneratorService.getArbitraryInputs(this._store.getState().service.serviceHierarchy[UUIDData['serviceId']].vfModules[UUIDData['modelName']].inputs); - return this.getVFModuleDynamicInputs(dynamic, UUIDData); + getModelInformation(serviceId: string, modelName: string) { + this._aaiService.getServiceModelById(serviceId).subscribe((result: any) => { + this.serviceModel = new ServiceModel(result); + + this.model = this._basicPopupService.getModelFromResponse(result, 'vfModules', modelName); + const serviceInstance = this._store.getState().service.serviceInstance[serviceId]; + this.modelInformations = [ + new ModelInformationItem("Subscriber Name", "subscriberName", [this._basicPopupService.extractSubscriberNameBySubscriberId(serviceInstance.globalSubscriberId)], "", true), + new ModelInformationItem("Service Name", "serviceModelName", [this.serviceModel.name], "", true), + new ModelInformationItem("Service Instance Name", "serviceName", [serviceInstance.instanceName], "", false), + new ModelInformationItem("Model Name", "modelName", [this.model.name], "", true), + new ModelInformationItem("Model version", "modelVersion", [this.model.version], "", true), + new ModelInformationItem("Description", "description", [this.model.description]), + new ModelInformationItem("Category", "category", [this.model.category]), + new ModelInformationItem("Sub Category", "subCategory", [this.model.subCategory]), + new ModelInformationItem("UUID", "uuid", [this.model.uuid], Constants.ServicePopup.TOOLTIP_UUID, true), + new ModelInformationItem("Invariant UUID", "invariantUuid", [this.model.invariantUuid], Constants.ServicePopup.TOOLTIP_INVARIANT_UUID, true), + new ModelInformationItem("Service type", "serviceType", [this.serviceModel.serviceType]), + new ModelInformationItem("Service role", "serviceRole", [this.serviceModel.serviceRole]), + new ModelInformationItem("Minimum to instantiate", "min", this.model.min == undefined ? ['0'] : [this.model.min.toString()], "", true), + new ModelInformationItem("Maximum to instantiate", "max", this.model.max == undefined ? ['1'] : [this.model.max.toString()], "", true), + new ModelInformationItem("Recommended to instantiate", "initial", [this.model.initial]) + ]; + }); } - getVFModuleDynamicInputs(dynamicInputs : any, UUIDData : Object) : FormControlModel[] { - let result : FormControlModel[] = []; - if(dynamicInputs) { - let vfModuleInstance = null; - if (_.has(this._store.getState().service.serviceInstance[UUIDData['serviceId']].vnfs, UUIDData['vnfStoreKey']) && - _.has(this._store.getState().service.serviceInstance[UUIDData['serviceId']].vnfs[UUIDData['vnfStoreKey']].vfModules, UUIDData['modelName'])) { - vfModuleInstance = Object.assign({},this._store.getState().service.serviceInstance[UUIDData['serviceId']].vnfs[UUIDData['vnfStoreKey']].vfModules[UUIDData['modelName']][UUIDData['vfModuleStoreKey']]); + protected postSubmitIframeMessage(that) { + window.parent.postMessage({ + eventId: 'submitIframe', + data: { + serviceModelId: that.serviceModel.uuid } - result = this._basicControlGenerator.getDynamicInputs(dynamicInputs, vfModuleInstance); - } - return result; + }, "*"); + } + + onCancel(that, form) { + form.reset(); + that._iframeService.removeClassCloseModal('content'); + this.closeDialogEvent.next(that); } + getSubLeftTitle(): string { + return this.model.name; + } + + getSubRightTitle(): string { + return "Module (Heat stack) Instance Details"; + } + + abstract getTitle(isUpdateMode : boolean) : string; + abstract getControls(serviceId: string, vnfStoreKey: string, vfModuleStoreKey: string, isUpdateMode: boolean); + abstract getDynamicInputs(UUIDData : Object) : FormControlModel[]; getGenericFormPopupDetails(serviceId: string, vnfStoreKey: string, vfModuleStoreKey: string, node: ITreeNode, uuidData: Object, isUpdateMode: boolean): FormPopupDetails { @@ -85,37 +129,50 @@ export class VfModulePopuopService implements GenericPopupInterface { this.getControls(serviceId, vnfStoreKey, vfModuleStoreKey, isUpdateMode), this.getDynamicInputs(uuidData), this.modelInformations, - (that, form: FormGroup) => {that.onSubmit(that, form);}, - (that: any, form: FormGroup) => {that.onCancel(that, form); } + (that, form: FormGroup) => { + that.onSubmit(that, form); + }, + (that: any, form: FormGroup) => { + that.onCancel(that, form); + } ); } +} - getModelInformation(serviceId: string, modelName: string) { - this._aaiService.getServiceModelById(serviceId).subscribe((result: any) => { - this.serviceModel = new ServiceModel(result); +@Injectable() +export class VfModulePopuopService extends VfModulePopupServiceBase implements GenericPopupInterface { - this.model = this._basicPopupService.getModelFromResponse(result, 'vfModules', modelName); - const serviceInstance = this._store.getState().service.serviceInstance[serviceId]; - this.modelInformations = [ - new ModelInformationItem("Subscriber Name", "subscriberName", [this._basicPopupService.extractSubscriberNameBySubscriberId(serviceInstance.globalSubscriberId)], "", true), - new ModelInformationItem("Service Name", "serviceModelName", [this.serviceModel.name], "", true), - new ModelInformationItem("Service Instance Name", "serviceName", [serviceInstance.instanceName], "", false), - new ModelInformationItem("Model Name", "modelName", [this.model.name], "", true), - new ModelInformationItem("Model version", "modelVersion", [this.model.version], "", true), - new ModelInformationItem("Description", "description", [this.model.description]), - new ModelInformationItem("Category", "category", [this.model.category]), - new ModelInformationItem("Sub Category", "subCategory", [this.model.subCategory]), - new ModelInformationItem("UUID", "uuid", [this.model.uuid], Constants.ServicePopup.TOOLTIP_UUID, true), - new ModelInformationItem("Invariant UUID", "invariantUuid", [this.model.invariantUuid], Constants.ServicePopup.TOOLTIP_INVARIANT_UUID, true), - new ModelInformationItem("Service type", "serviceType", [this.serviceModel.serviceType]), - new ModelInformationItem("Service role", "serviceRole", [this.serviceModel.serviceRole]), - new ModelInformationItem("Minimum to instantiate", "min", this.model.min == undefined ? ['0'] : [this.model.min.toString()], "", true), - new ModelInformationItem("Maximum to instantiate", "max", this.model.max == undefined ? ['1'] : [this.model.max.toString()], "", true), - new ModelInformationItem("Recommended to instantiate", "initial", [this.model.initial]) - ]; - }); + + constructor(_basicControlGenerator: BasicControlGenerator, + _vfModuleControlGenerator: VfModuleControlGenerator, + _iframeService: IframeService, + _defaultDataGeneratorService: DefaultDataGeneratorService, + _aaiService: AaiService, + _basicPopupService : BasicPopupService, + _store: NgRedux<AppState>) { + super(_basicControlGenerator, _vfModuleControlGenerator, _iframeService, _defaultDataGeneratorService, _aaiService, _basicPopupService, _store); + + } + + getDynamicInputs(UUIDData : Object) : FormControlModel[]{ + let dynamic = this._defaultDataGeneratorService.getArbitraryInputs(this._store.getState().service.serviceHierarchy[UUIDData['serviceId']].vfModules[UUIDData['modelName']].inputs); + return this.getVFModuleDynamicInputs(dynamic, UUIDData); } + getVFModuleDynamicInputs(dynamicInputs : any, UUIDData : Object) : FormControlModel[] { + let result : FormControlModel[] = []; + if(dynamicInputs) { + let vfModuleInstance = null; + if (_.has(this._store.getState().service.serviceInstance[UUIDData['serviceId']].vnfs, UUIDData['vnfStoreKey']) && + _.has(this._store.getState().service.serviceInstance[UUIDData['serviceId']].vnfs[UUIDData['vnfStoreKey']].vfModules, UUIDData['modelName'])) { + vfModuleInstance = Object.assign({},this._store.getState().service.serviceInstance[UUIDData['serviceId']].vnfs[UUIDData['vnfStoreKey']].vfModules[UUIDData['modelName']][UUIDData['vfModuleStoreKey']]); + } + result = this._basicControlGenerator.getDynamicInputs(dynamicInputs, vfModuleInstance); + } + return result; + } + + getControls(serviceId: string, vnfStoreKey: string, vfModuleStoreKey: string, isUpdateMode: boolean) { if (this._store.getState().service.serviceHierarchy[serviceId].service.vidNotions.instantiationType === 'Macro') { return this._vfModuleControlGenerator.getMacroFormControls(serviceId, vnfStoreKey, vfModuleStoreKey, this.uuidData, isUpdateMode); @@ -145,44 +202,8 @@ export class VfModulePopuopService implements GenericPopupInterface { this.onCancel(that, form); } - - protected postSubmitIframeMessage(that) { - window.parent.postMessage({ - eventId: 'submitIframe', - data: { - serviceModelId: that.serviceModel.uuid - } - }, "*"); - } - - onCancel(that, form) { - form.reset(); - that._iframeService.removeClassCloseModal('content'); - this.closeDialogEvent.next(that); - } - - storeVFModule = (that, formValues: any): void => { - formValues.modelInfo = new ModelInfo(that.model); - formValues.uuid = formValues.modelInfo.uuid; - formValues.isMissingData = false; - const vnf = that._store.getState().service.serviceInstance[that.uuidData.serviceId].vnfs[that.uuidData.vnfStoreKey]; - - if (!that.uuidData.vFModuleStoreKey) { - this._store.dispatch(createVFModuleInstance(formValues, that.uuidData.modelName, that.uuidData.serviceId, 0, that.uuidData.vnfStoreKey)); - } else { - this._store.dispatch(updateVFModuleInstance(formValues, that.uuidData.modelName, that.uuidData.serviceId, that.uuidData.vFModuleStoreKey, that.uuidData.vnfStoreKey)); - } - }; - getTitle(isUpdateMode : boolean) : string { return isUpdateMode ? 'Edit Module (Heat stack)' : 'Set new Module (Heat stack)'; } - getSubLeftTitle(): string { - return this.model.name; - } - - getSubRightTitle(): string { - return "Module (Heat stack) Instance Details"; - } } diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popuop.service.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popuop.service.ts index c49081608..b82074d9c 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popuop.service.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popuop.service.ts @@ -1,8 +1,7 @@ import {Injectable} from "@angular/core"; import {ITreeNode} from "angular-tree-component/dist/defs/api"; import {FormGroup} from "@angular/forms"; -import {VfModulePopuopService} from "../vfModule/vfModule.popuop.service"; -import {FormPopupDetails} from "../../../../models/formControlModels/formPopupDetails.model"; +import {VfModulePopupServiceBase} from "../vfModule/vfModule.popuop.service"; import {updateVFModuleField, upgradeVFModule} from "../../../../storeUtil/utils/vfModule/vfModule.actions"; import {SharedTreeService} from "../../../../../drawingBoard/service-planning/objectsToTree/shared.tree.service"; import {NgRedux} from "@angular-redux/store"; @@ -13,9 +12,7 @@ import {IframeService} from "../../../../utils/iframe.service"; import {DefaultDataGeneratorService} from "../../../../services/defaultDataServiceGenerator/default.data.generator.service"; import {AaiService} from "../../../../services/aaiService/aai.service"; import {BasicPopupService} from "../basic.popup.service"; -import { - FormControlModel -} from "../../../../models/formControlModels/formControl.model"; +import {FormControlModel} from "../../../../models/formControlModels/formControl.model"; import {CheckboxFormControl} from "../../../../models/formControlModels/checkboxFormControl.model"; import {FormControlType} from "../../../../models/formControlModels/formControlTypes.enum"; @@ -25,8 +22,7 @@ export enum UpgradeFormControlNames { } @Injectable() -export class VfModuleUpgradePopupService extends VfModulePopuopService { - +export class VfModuleUpgradePopupService extends VfModulePopupServiceBase { constructor(protected _basicControlGenerator: BasicControlGenerator, protected _vfModuleControlGenerator: VfModuleControlGenerator, protected _iframeService: IframeService, @@ -39,14 +35,13 @@ export class VfModuleUpgradePopupService extends VfModulePopuopService { } node: ITreeNode; - getGenericFormPopupDetails(serviceId: string, vnfStoreKey: string, vfModuleStoreKey: string, node: ITreeNode, uuidData: Object, isUpdateMode: boolean): FormPopupDetails { - return super.getGenericFormPopupDetails(serviceId, vnfStoreKey, vfModuleStoreKey, node, uuidData, isUpdateMode); - } - getDynamicInputs = () => []; - getControls = () : FormControlModel[] => { - return this.getUpgradeFormControls() + getControls(serviceId: string, vnfStoreKey: string, vfModuleStoreKey: string, isUpdateMode: boolean) { + let result: FormControlModel[] = []; + result.push(this.getRetainVolumeGroupsControl()); + result.push(this.getRetainAssignmentsControl()); + return result; }; getTitle = (): string => 'Upgrade Module'; @@ -92,10 +87,4 @@ export class VfModuleUpgradePopupService extends VfModulePopuopService { }) }; - getUpgradeFormControls = (): FormControlModel[] => { - let result: FormControlModel[] = []; - result.push(this.getRetainVolumeGroupsControl()); - result.push(this.getRetainAssignmentsControl()); - return result; - } } |