diff options
author | 2019-12-10 16:47:11 +0200 | |
---|---|---|
committer | 2019-12-16 15:08:01 +0200 | |
commit | 8d17bc384337849ffdf4a8369834c4480c9c5d93 (patch) | |
tree | 5c3c10bb49d2ae687a64aaf89f8b4e3da77a644e /vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popuop.service.ts | |
parent | 4a42937926e558e61364998c626b86e1e56708e6 (diff) |
Do not show retain VGs checkbox in VFM Upgrade modal + tests modifications
Business&test(cypress&UT), refactor of some files, fix of typos,
upgrade jest version etc.
Issue-ID: VID-603
Change-Id: I2153c8a7f300bfa34f6817704b08f0c2a046a4e7
Signed-off-by: Amir Skalka <amir.skalka@intl.att.com>
Diffstat (limited to 'vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popuop.service.ts')
-rw-r--r-- | vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popuop.service.ts | 211 |
1 files changed, 0 insertions, 211 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 deleted file mode 100644 index 3119cc8f8..000000000 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popuop.service.ts +++ /dev/null @@ -1,211 +0,0 @@ -import {Injectable} from "@angular/core"; -import {FormPopupDetails, PopupType} from "../../../../models/formControlModels/formPopupDetails.model"; -import {BasicControlGenerator} from "../../../genericForm/formControlsServices/basic.control.generator"; -import {AppState} from "../../../../store/reducers"; -import {NgRedux} from "@angular-redux/store"; -import {ITreeNode} from "angular-tree-component/dist/defs/api"; -import {ModelInformationItem} from "../../../model-information/model-information.component"; -import {Constants} from "../../../../utils/constants"; -import {AaiService} from "../../../../services/aaiService/aai.service"; -import {ServiceModel} from "../../../../models/serviceModel"; -import {FormGroup} from "@angular/forms"; -import {ModelInfo} from "../../../../models/modelInfo"; -import {IframeService} from "../../../../utils/iframe.service"; -import {GenericPopupInterface} from "../generic-popup.interface"; -import {Subject} from "rxjs/Subject"; -import {DefaultDataGeneratorService} from "../../../../services/defaultDataServiceGenerator/default.data.generator.service"; -import {BasicPopupService} from "../basic.popup.service"; -import {VfModuleInstance} from "../../../../models/vfModuleInstance"; -import {VfModuleControlGenerator} from "../../../genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator"; -import {FormControlModel} from "../../../../models/formControlModels/formControl.model"; -import * as _ from 'lodash'; -import {createVFModuleInstance, updateVFModuleInstance} from "../../../../storeUtil/utils/vfModule/vfModule.actions"; - -export abstract class VfModulePopupServiceBase { - dynamicInputs: any; - instance: any; - model: any; - serviceModel: ServiceModel; - modelInformations: ModelInformationItem[] = []; - 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)); - } - }; - - 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 { - if (_.isNil(vnfStoreKey) || _.isNil(vfModuleStoreKey)) { - return new VfModuleInstance(); - } - const vfModules = this._store.getState().service.serviceInstance[serviceId].vnfs[vnfStoreKey].vfModules; - return vfModules[this.uuidData['modelName']][vfModuleStoreKey]; - } - - 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), - this._basicPopupService.createMaximumToInstantiateModelInformationItem(this.model), - new ModelInformationItem("Recommended to instantiate", "initial", [this.model.initial]) - ]; - }); - } - - 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); - } - - 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 { - - this.uuidData = uuidData; - this.instance = this.getInstance(serviceId, vnfStoreKey, vfModuleStoreKey); - this.getModelInformation(serviceId, uuidData['modelName']); - - return new FormPopupDetails(this, - PopupType.VFMODULE, - uuidData, - this.getTitle(isUpdateMode), - this.getSubLeftTitle(), - this.getSubRightTitle(), - 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); - } - ); - } - - updateFormValueWithSupplementaryFile(form: FormGroup, that) { - if (!_.isNil(form.controls['supplementaryFile_hidden_content']) && form.controls['supplementaryFile_hidden_content'].value) { - form.value['supplementaryFileContent'] = JSON.parse(form.controls['supplementaryFile_hidden_content'].value); - if (!_.isNil(form.controls['supplementaryFile_hidden'].value)) { - form.value['supplementaryFileName'] = form.controls['supplementaryFile_hidden'].value.name; - } else { - form.value['supplementaryFileName'] = that.instance.supplementaryFileName; - } - } else { - delete form.value['supplementaryFileContent']; - delete form.value['supplementaryFileName']; - } - } -} - -@Injectable() -export class VfModulePopuopService extends VfModulePopupServiceBase implements GenericPopupInterface { - - - 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); - } else { - return this._vfModuleControlGenerator.getAlaCarteFormControls(serviceId, vnfStoreKey, vfModuleStoreKey, this.uuidData, isUpdateMode); - } - } - - - onSubmit(that, form: FormGroup) { - form.value['instanceParams'] = form.value['instanceParams'] && [form.value['instanceParams']]; - this.updateFormValueWithSupplementaryFile(form, that); - that.storeVFModule(that, form.value); - this.postSubmitIframeMessage(that); - this.onCancel(that, form); - } - - getTitle(isUpdateMode : boolean) : string { - return isUpdateMode ? 'Edit Module (Heat stack)' : 'Set new Module (Heat stack)'; - } - -} |