aboutsummaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src
diff options
context:
space:
mode:
authorYoav Schneiderman <yoav.schneiderman@intl.att.com>2019-12-18 21:04:38 +0200
committerYoav Schneiderman <yoav.schneiderman@intl.att.com>2019-12-22 14:01:45 +0200
commit4c87ecaa8cce40f078f8540a15928e7e805e4ef7 (patch)
treef31c55200451d13f108c8583b8d275ae7a7c8bab /vid-webpack-master/src
parent54af5cdca044c7b486f02f4163d16c39e990f701 (diff)
Refactor Generic Generators
Issue-ID: VID-731 Signed-off-by: Yoav Schneiderman <yoav.schneiderman@intl.att.com> Change-Id: Ib851ff4056d64e12eaf415c5d689c832196ec8b0 Signed-off-by: Yoav Schneiderman <yoav.schneiderman@intl.att.com>
Diffstat (limited to 'vid-webpack-master/src')
-rw-r--r--vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToInstanceTree/objectToInstanceTree.service.spec.ts6
-rw-r--r--vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToModelTree/objectToModelTree.service.spec.ts6
-rw-r--r--vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.spec.ts8
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/control.generator.util.service.spec.ts (renamed from vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/basic.control.generator.spec.ts)64
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/control.generator.util.service.ts (renamed from vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/basic.control.generator.ts)170
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/networkGenerator/network.control.generator.spec.ts6
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/networkGenerator/network.control.generator.ts181
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/service.control.generator.spec.ts6
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/service.control.generator.ts10
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service.spec.ts263
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service.ts189
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.spec.ts6
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.ts137
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator.spec.ts18
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator.ts173
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGroupGenerator/vnfGroup.control.generator.spec.ts6
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGroupGenerator/vnfGroup.control.generator.ts24
-rw-r--r--vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.service.spec.ts6
-rw-r--r--vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/basic.popup.service.spec.ts4
-rw-r--r--vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/basic.popup.service.ts4
-rw-r--r--vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/network/network.popup.service.spec.ts6
-rw-r--r--vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/network/network.popup.service.ts4
-rw-r--r--vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/service/service.popup.service.spec.ts6
-rw-r--r--vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/service/service.popup.service.ts4
-rw-r--r--vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service.spec.ts6
-rw-r--r--vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service.ts11
-rw-r--r--vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popuop.service.ts10
-rw-r--r--vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popup.service.spec.ts8
-rw-r--r--vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service.spec.ts6
-rw-r--r--vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service.ts4
-rw-r--r--vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnfGroup/vnfGroup.popup.service.spec.ts6
-rw-r--r--vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnfGroup/vnfGroup.popup.service.ts4
-rw-r--r--vid-webpack-master/src/app/shared/shared.module.ts6
33 files changed, 706 insertions, 662 deletions
diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToInstanceTree/objectToInstanceTree.service.spec.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToInstanceTree/objectToInstanceTree.service.spec.ts
index c17d9c74c..1cec62b2c 100644
--- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToInstanceTree/objectToInstanceTree.service.spec.ts
+++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToInstanceTree/objectToInstanceTree.service.spec.ts
@@ -11,7 +11,7 @@ import {ObjectToTreeService} from "../objectToTree.service";
import {DrawingBoardModes} from "../../drawing-board.modes";
import {DialogService} from "ng2-bootstrap-modal";
import {VnfPopupService} from "../../../../shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service";
-import {BasicControlGenerator} from "../../../../shared/components/genericForm/formControlsServices/basic.control.generator";
+import {ControlGeneratorUtil} from "../../../../shared/components/genericForm/formControlsServices/control.generator.util.service";
import {AaiService} from "../../../../shared/services/aaiService/aai.service";
import {FeatureFlagsService} from "../../../../shared/services/featureFlag/feature-flags.service";
import {VnfControlGenerator} from "../../../../shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator";
@@ -33,6 +33,7 @@ import {ComponentInfoService} from "../../component-info/component-info.service"
import {NetworkStepService} from "../models/vrf/vrfModal/networkStep/network.step.service";
import {VpnStepService} from "../models/vrf/vrfModal/vpnStep/vpn.step.service";
import {VfModuleUpgradePopupService} from "../../../../shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popuop.service";
+import {SharedControllersService} from "../../../../shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service";
class MockAppStore<T> {
getState() {
@@ -65,7 +66,8 @@ describe('Model Tree Generator service', () => {
SharedTreeService,
VnfPopupService,
VnfGroupPopupService,
- BasicControlGenerator,
+ ControlGeneratorUtil,
+ SharedControllersService,
GenericFormService,
FormBuilder,
LogService,
diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToModelTree/objectToModelTree.service.spec.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToModelTree/objectToModelTree.service.spec.ts
index 8674a619e..0f7bf9a61 100644
--- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToModelTree/objectToModelTree.service.spec.ts
+++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToModelTree/objectToModelTree.service.spec.ts
@@ -14,7 +14,7 @@ import {
} from "../../available-models-tree/available-models-tree.service";
import {DialogService} from "ng2-bootstrap-modal";
import {VnfPopupService} from "../../../../shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service";
-import {BasicControlGenerator} from "../../../../shared/components/genericForm/formControlsServices/basic.control.generator";
+import {ControlGeneratorUtil} from "../../../../shared/components/genericForm/formControlsServices/control.generator.util.service";
import {GenericFormService} from "../../../../shared/components/genericForm/generic-form.service";
import {FormBuilder} from "@angular/forms";
import {LogService} from "../../../../shared/utils/log/log.service";
@@ -36,6 +36,7 @@ import {IModelTreeNodeModel} from "../../../objectsToTree/objectToModelTree/mode
import {VpnStepService} from "../models/vrf/vrfModal/vpnStep/vpn.step.service";
import {NetworkStepService} from "../models/vrf/vrfModal/networkStep/network.step.service";
import {VfModuleUpgradePopupService} from "../../../../shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popuop.service";
+import {SharedControllersService} from "../../../../shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service";
class MockAppStore<T> {
getState() {
@@ -90,7 +91,7 @@ describe('Model Tree Generator service', () => {
DialogService,
VnfPopupService,
VnfGroupPopupService,
- BasicControlGenerator,
+ ControlGeneratorUtil,
GenericFormService,
FormBuilder,
LogService,
@@ -111,6 +112,7 @@ describe('Model Tree Generator service', () => {
ComponentInfoService,
NetworkStepService,
VpnStepService,
+ SharedControllersService,
{provide: NgRedux, useClass: MockAppStore},
MockNgRedux ]
}).compileComponents();
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 277ea941e..3a65b93ef 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
@@ -8,7 +8,7 @@ import {DefaultDataGeneratorService} from "../../../shared/services/defaultDataS
import {DynamicInputsService} from "./dynamicInputs.service";
import {DialogService} from "ng2-bootstrap-modal";
import {VnfPopupService} from "../../../shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service";
-import {BasicControlGenerator} from "../../../shared/components/genericForm/formControlsServices/basic.control.generator";
+import {ControlGeneratorUtil} from "../../../shared/components/genericForm/formControlsServices/control.generator.util.service";
import {AaiService} from "../../../shared/services/aaiService/aai.service";
import {NetworkPopupService} from "../../../shared/components/genericFormPopup/genericFormServices/network/network.popup.service";
import {NetworkControlGenerator} from "../../../shared/components/genericForm/formControlsServices/networkGenerator/network.control.generator";
@@ -41,6 +41,7 @@ import {ModelInformationItem} from "../../../shared/components/model-information
import {VpnStepService} from "./models/vrf/vrfModal/vpnStep/vpn.step.service";
import {NetworkStepService} from "./models/vrf/vrfModal/networkStep/network.step.service";
import {VfModuleUpgradePopupService} from "../../../shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popuop.service";
+import {SharedControllersService} from "../../../shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service";
class MockAppStore<T> {
getState() {
@@ -82,11 +83,12 @@ describe('Shared Tree Service', () => {
imports: [HttpClientTestingModule, NgReduxTestingModule, SdcUiComponentsModule],
providers: [
SharedTreeService,
+ SharedControllersService,
ObjectToTreeService,
DefaultDataGeneratorService,
DialogService,
VnfPopupService,
- BasicControlGenerator,
+ ControlGeneratorUtil,
AaiService,
LogService,
BasicPopupService,
@@ -165,7 +167,7 @@ describe('Shared Tree Service', () => {
let modelInfoServiceMock: ILevelNodeInfo = new VnfModelInfo(null, null,
null, null, null, null, null,
- null, null, null, null,null);
+ null, null, null, null,null, null);
const modelMock = {"a": "a"};
const instanceMock = {"instance": "instance", "trackById": "123456789"};
const instanceTypeMock = "instanceTypeMock";
diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/basic.control.generator.spec.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/control.generator.util.service.spec.ts
index 7e2d3f942..9aefa98b8 100644
--- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/basic.control.generator.spec.ts
+++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/control.generator.util.service.spec.ts
@@ -1,27 +1,28 @@
import {getTestBed, TestBed} from '@angular/core/testing';
import {AaiService} from "../../../services/aaiService/aai.service";
-import {FormControlModel} from "../../../models/formControlModels/formControl.model";
import {FeatureFlagsService} from "../../../services/featureFlag/feature-flags.service";
-import {BasicControlGenerator} from "./basic.control.generator";
+import {ControlGeneratorUtil} from "./control.generator.util.service";
import {NgRedux} from '@angular-redux/store';
import each from "jest-each";
import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing';
import {FileFormControl} from "../../../models/formControlModels/fileFormControl.model";
+import {AppState} from "../../../store/reducers";
+import {SelectOption} from "../../../models/selectOption";
+import {SharedControllersService} from "./sharedControlles/shared.controllers.service";
-class MockAppStore<T> {}
-
-class MockFeatureFlagsService {}
-
-describe('Basic Control Generator', () => {
+describe('Control Generator Util', () => {
let injector;
- let service: BasicControlGenerator;
+ let service: ControlGeneratorUtil;
+ let sharedControllersService : SharedControllersService;
let httpMock: HttpTestingController;
+ let store: NgRedux<AppState>;
beforeAll(done => (async () => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
- providers: [BasicControlGenerator,
+ providers: [ControlGeneratorUtil,
+ SharedControllersService,
AaiService,
{provide:FeatureFlagsService, useClass: MockFeatureFlagsService},
{provide: NgRedux, useClass: MockAppStore}]
@@ -29,31 +30,14 @@ describe('Basic Control Generator', () => {
await TestBed.compileComponents();
injector = getTestBed();
- service = injector.get(BasicControlGenerator);
+ service = injector.get(ControlGeneratorUtil);
httpMock = injector.get(HttpTestingController);
+ sharedControllersService = injector.get(SharedControllersService);
+ store = injector.get(NgRedux);
})().then(done).catch(done.fail));
- test('getlegacyRegion with AAIAIC25 - isVisible true', () => {
- const instance = {lcpCloudRegionId : 'AAIAIC25'};
- const legacyRegionControl: FormControlModel = service.getLegacyRegion(instance);
- expect(legacyRegionControl.isVisible).toBeTruthy();
- });
-
- test('getlegacyRegion without AAIAIC25 - isVisible false', () => {
- const instance = {lcpCloudRegionId : 'olson3'};
- const legacyRegionControl: FormControlModel = service.getLegacyRegion(instance);
- expect(legacyRegionControl.isVisible).toBeFalsy();
- });
-
- test('sdn-preload checkbox is visible', () => {
- const instance = {};
- const sdncPreload: FormControlModel = service.getSDNCControl(instance);
- expect (sdncPreload.displayName).toEqual('SDN-C pre-load');
- expect (sdncPreload.value).toBeFalsy();
- });
-
test('given instance, get supp file from getSupplementaryFile ', () => {
const instance = {};
const suppFileForInstance: FileFormControl = service.getSupplementaryFile(instance);
@@ -66,7 +50,7 @@ describe('Basic Control Generator', () => {
//given
const instance = {};
- const controls = [service.getLegacyRegion(instance)];
+ const controls = [sharedControllersService.getLegacyRegion(instance)];
expect(controls).toHaveLength(1);
//when
@@ -105,4 +89,24 @@ describe('Basic Control Generator', () => {
});
+ test('getRollBackOnFailureOptions', async (done)=> {
+ service.getRollBackOnFailureOptions().subscribe((rollBackOnFailureOptions : SelectOption[])=>{
+ expect(rollBackOnFailureOptions[0].id).toEqual('true');
+ expect(rollBackOnFailureOptions[0].name).toEqual('Rollback');
+ expect(rollBackOnFailureOptions[1].id).toEqual('false');
+ expect(rollBackOnFailureOptions[1].name).toEqual('Don\'t Rollback');
+ done();
+ });
+ });
+
+
});
+
+
+class MockAppStore<T> {
+ getState() {
+ return {}
+ }
+}
+
+class MockFeatureFlagsService {}
diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/basic.control.generator.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/control.generator.util.service.ts
index aff33982f..08575bcad 100644
--- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/basic.control.generator.ts
+++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/control.generator.util.service.ts
@@ -1,7 +1,12 @@
import {Injectable} from "@angular/core";
import {DropdownFormControl} from "../../../models/formControlModels/dropdownFormControl.model";
import {FormGroup} from "@angular/forms";
-import {CustomValidatorOptions, FormControlModel, ValidatorModel, ValidatorOptions} from "../../../models/formControlModels/formControl.model";
+import {
+ CustomValidatorOptions,
+ FormControlModel,
+ ValidatorModel,
+ ValidatorOptions
+} from "../../../models/formControlModels/formControl.model";
import {InputFormControl} from "../../../models/formControlModels/inputFormControl.model";
import {AppState} from "../../../store/reducers";
import {NgRedux} from "@angular-redux/store";
@@ -9,28 +14,27 @@ import {NumberFormControl} from "../../../models/formControlModels/numberFormCon
import {FormControlType} from "../../../models/formControlModels/formControlTypes.enum";
import {FileFormControl} from "../../../models/formControlModels/fileFormControl.model";
import {SelectOption} from "../../../models/selectOption";
-import * as _ from 'lodash';
import {DynamicInputLabelPipe} from "../../../pipes/dynamicInputLabel/dynamic-input-label.pipe";
-import {AaiService} from "../../../services/aaiService/aai.service";
import {FormGeneralErrorsService} from "../../formGeneralErrors/formGeneralErrors.service";
import {Observable, of} from "rxjs";
import {NodeModel} from "../../../models/nodeModel";
import {Constants} from "../../../utils/constants";
import {FileUnit} from "../../formControls/component/file/fileUnit.enum";
-import {CheckboxFormControl} from "../../../models/formControlModels/checkboxFormControl.model";
+import * as _ from 'lodash';
export const SUPPLEMENTARY_FILE = 'supplementaryFile';
export const SDN_C_PRE_LOAD = 'sdncPreLoad';
@Injectable()
-export class BasicControlGenerator {
+export class ControlGeneratorUtil {
- public static readonly INSTANCE_NAME_REG_EX:RegExp = /^[a-zA-Z0-9._-]*$/;
- public static readonly GENERATED_NAME_REG_EX:RegExp = /[^a-zA-Z0-9._-]/g;
+ public static readonly INSTANCE_NAME_REG_EX: RegExp = /^[a-zA-Z0-9._-]*$/;
+ public static readonly GENERATED_NAME_REG_EX: RegExp = /[^a-zA-Z0-9._-]/g;
+
+ constructor(private _store: NgRedux<AppState>) {
+ }
- constructor(private _store : NgRedux<AppState>,
- private _aaiService : AaiService){}
- getSubscribeResult(subscribeFunction : Function, control : DropdownFormControl) : Observable<any>{
+ getSubscribeResult(subscribeFunction: Function, control: DropdownFormControl): Observable<any> {
return subscribeFunction(this).subscribe((res) => {
control.options$ = res;
control.hasEmptyOptions = res.length === 0;
@@ -39,16 +43,16 @@ export class BasicControlGenerator {
});
}
- getSubscribeInitResult(subscribeFunction : Function, control : DropdownFormControl, form : FormGroup) : Observable<any>{
+ getSubscribeInitResult(subscribeFunction: Function, control: DropdownFormControl, form: FormGroup): Observable<any> {
return subscribeFunction(this).subscribe((res) => {
- if(!_.isNil(control['onInitSelectedField'])){
+ if (!_.isNil(control['onInitSelectedField'])) {
let result = res;
- for(let key of control['onInitSelectedField']){
+ for (let key of control['onInitSelectedField']) {
result = !_.isNil(result[key]) ? result[key] : [];
}
control.options$ = result;
control.hasEmptyOptions = _.isNil(result) || result.length === 0;
- } else{
+ } else {
control.options$ = !_.isNil(res) ? res : [];
control.hasEmptyOptions = _.isNil(res) || res.length === 0;
}
@@ -58,58 +62,16 @@ export class BasicControlGenerator {
});
}
- getInstanceNameController(instance: any, serviceId: string, isEcompGeneratedNaming: boolean, model: NodeModel): FormControlModel {
- let validations: ValidatorModel[] = this.createValidationsForInstanceName(instance, serviceId, isEcompGeneratedNaming);
- return new InputFormControl({
- controlName: 'instanceName',
- displayName: 'Instance name',
- dataTestId: 'instanceName',
- placeHolder: (!isEcompGeneratedNaming) ? 'Instance name' : 'Automatically generated when not provided',
- validations: validations,
- isVisible : true,
- value : (!isEcompGeneratedNaming || (!_.isNil(instance) && !_.isNil(instance.instanceName)))
- ? this.getDefaultInstanceName(instance, model) : null,
- onKeypress : (event) => {
- const pattern:RegExp = BasicControlGenerator.INSTANCE_NAME_REG_EX;
- if(pattern){
- if(!pattern.test(event['key'])){
- event.preventDefault();
- }
- }
- return event;
- }
- });
- }
-
- getInstanceName(instance : any, serviceId : string, isEcompGeneratedNaming: boolean): FormControlModel {
- let formControlModel:FormControlModel = this.getInstanceNameController(instance, serviceId, isEcompGeneratedNaming, new NodeModel());
- formControlModel.value = instance ? instance.instanceName : null;
- return formControlModel;
- }
-
- isLegacyRegionShouldBeVisible(instance : any) : boolean {
- if(!_.isNil(instance) && !_.isNil(instance.lcpCloudRegionId)) {
+ isLegacyRegionShouldBeVisible(instance: any): boolean {
+ if (!_.isNil(instance) && !_.isNil(instance.lcpCloudRegionId)) {
return Constants.LegacyRegion.MEGA_REGION.indexOf(instance.lcpCloudRegionId) !== -1;
}
return false;
}
- getLegacyRegion(instance: any): FormControlModel {
- return new InputFormControl({
- controlName: 'legacyRegion',
- displayName: 'Legacy Region',
- dataTestId: 'lcpRegionText',
- placeHolder: 'Type Legacy Region',
- validations: [],
- isVisible: this.isLegacyRegionShouldBeVisible(instance),
- isDisabled : _.isNil(instance) ? true : Constants.LegacyRegion.MEGA_REGION.indexOf(instance.lcpCloudRegionId),
- value: instance ? instance.legacyRegion : null
- });
- }
-
- private createValidationsForInstanceName(instance: any, serviceId: string, isEcompGeneratedNaming: boolean): ValidatorModel[] {
+ createValidationsForInstanceName(instance: any, serviceId: string, isEcompGeneratedNaming: boolean): ValidatorModel[] {
let validations: ValidatorModel[] = [
- new ValidatorModel(ValidatorOptions.pattern, 'Instance name may include only alphanumeric characters and underscore.', BasicControlGenerator.INSTANCE_NAME_REG_EX),
+ new ValidatorModel(ValidatorOptions.pattern, 'Instance name may include only alphanumeric characters and underscore.', ControlGeneratorUtil.INSTANCE_NAME_REG_EX),
new ValidatorModel(CustomValidatorOptions.uniqueInstanceNameValidator, 'some error', [this._store, serviceId, instance && instance.instanceName])
];
if (!isEcompGeneratedNaming) {
@@ -118,7 +80,7 @@ export class BasicControlGenerator {
return validations;
}
- getInputsOptions = (options: any[]) : Observable<SelectOption[]> =>{
+ getInputsOptions = (options: any[]): Observable<SelectOption[]> => {
let optionList: SelectOption[] = [];
options.forEach((option) => {
optionList.push(new SelectOption({
@@ -129,26 +91,9 @@ export class BasicControlGenerator {
return of(optionList);
};
- getProductFamilyControl = (instance : any, controls : FormControlModel[], isMandatory?: boolean) : DropdownFormControl => {
- return new DropdownFormControl({
- type : FormControlType.DROPDOWN,
- controlName : 'productFamilyId',
- displayName : 'Product family',
- dataTestId : 'productFamily',
- placeHolder : 'Select Product Family',
- isDisabled : false,
- name : "product-family-select",
- value : instance ? instance.productFamilyId : null,
- validations : _.isNil(isMandatory) || isMandatory === true ? [new ValidatorModel(ValidatorOptions.required, 'is required')]: [],
- onInit : this.getSubscribeResult.bind(this, this._aaiService.getProductFamilies),
- })
- };
-
-
-
- getDynamicInputsByType(dynamicInputs : any, serviceModelId : string, storeKey : string, type: string ) : FormControlModel[] {
- let result : FormControlModel[] = [];
- if(dynamicInputs) {
+ getDynamicInputsByType(dynamicInputs: any, serviceModelId: string, storeKey: string, type: string): FormControlModel[] {
+ let result: FormControlModel[] = [];
+ if (dynamicInputs) {
let nodeInstance = null;
if (_.has(this._store.getState().service.serviceInstance[serviceModelId][type], storeKey)) {
nodeInstance = Object.assign({}, this._store.getState().service.serviceInstance[serviceModelId][type][storeKey]);
@@ -158,8 +103,7 @@ export class BasicControlGenerator {
return result;
}
-
- getServiceDynamicInputs(dynamicInputs : any, serviceModelId : string) : FormControlModel[] {
+ getServiceDynamicInputs(dynamicInputs: any, serviceModelId: string): FormControlModel[] {
let result: FormControlModel[] = [];
if (dynamicInputs) {
let serviceInstance = null;
@@ -171,23 +115,23 @@ export class BasicControlGenerator {
return result;
}
- getDynamicInputs(dynamicInputs : any, instance :any) : FormControlModel[]{
- let result : FormControlModel[] = [];
- if(dynamicInputs) {
- dynamicInputs.forEach((input)=> {
+ getDynamicInputs(dynamicInputs: any, instance: any): FormControlModel[] {
+ let result: FormControlModel[] = [];
+ if (dynamicInputs) {
+ dynamicInputs.forEach((input) => {
let validations: ValidatorModel[] = [];
- if(input.isRequired) {
+ if (input.isRequired) {
validations.push(new ValidatorModel(ValidatorOptions.required, 'is required'))
}
- if(input.minLength) {
+ if (input.minLength) {
validations.push(new ValidatorModel(ValidatorOptions.minLength, '', input.minLength))
}
- if(input.maxLength) {
+ if (input.maxLength) {
validations.push(new ValidatorModel(ValidatorOptions.maxLength, '', input.maxLength))
}
let dynamicInputLabelPipe: DynamicInputLabelPipe = new DynamicInputLabelPipe();
- let data:any = {
+ let data: any = {
controlName: input.name,
displayName: dynamicInputLabelPipe.transform(input.name).slice(0, -1),
dataTestId: input.id,
@@ -200,9 +144,9 @@ export class BasicControlGenerator {
switch (input.type) {
case 'select' :
- case 'boolean' :{
- data.value = data.value || input.optionList.filter((option) => option.isDefault ? option.id || option.name: null);
- data.onInit = this.getSubscribeInitResult.bind(null, this.getInputsOptions.bind(this, input.optionList));
+ case 'boolean' : {
+ data.value = data.value || input.optionList.filter((option) => option.isDefault ? option.id || option.name : null);
+ data.onInit = this.getSubscribeInitResult.bind(null, this.getInputsOptions.bind(this, input.optionList));
result.push(new DropdownFormControl(data));
break;
}
@@ -231,8 +175,8 @@ export class BasicControlGenerator {
return result;
}
- getDefaultInstanceName(instance: any, model: NodeModel) : string {
- const initialInstanceName = (!_.isNil(instance) && instance.instanceName) || (!_.isNil(model.name) ? model.name.replace(BasicControlGenerator.GENERATED_NAME_REG_EX, "") : model.name);
+ getDefaultInstanceName(instance: any, model: NodeModel): string {
+ const initialInstanceName = (!_.isNil(instance) && instance.instanceName) || (!_.isNil(model.name) ? model.name.replace(ControlGeneratorUtil.GENERATED_NAME_REG_EX, "") : model.name);
return initialInstanceName;
}
@@ -241,26 +185,16 @@ export class BasicControlGenerator {
return originalArray.concat([suppFileInput], suppFileInput.hiddenFile);
}
- getSDNCControl = (instance: any): 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')]
- })
- };
-
getSupplementaryFile(instance: any): FileFormControl {
return new FileFormControl({
controlName: SUPPLEMENTARY_FILE,
displayName: 'Supplementary Data File (JSON format)',
dataTestId: 'SupplementaryFile',
placeHolder: 'Choose file',
- selectedFile: !_.isNil(instance) ? instance.supplementaryFileName: null,
+ selectedFile: !_.isNil(instance) ? instance.supplementaryFileName : null,
isVisible: true,
acceptedExtentions: "application/json",
- hiddenFile : [new InputFormControl({
+ hiddenFile: [new InputFormControl({
controlName: SUPPLEMENTARY_FILE + "_hidden",
isVisible: false,
validations: [new ValidatorModel(CustomValidatorOptions.isFileTooBig, "File size exceeds 5MB.", [FileUnit.MB, 5])]
@@ -269,18 +203,18 @@ export class BasicControlGenerator {
controlName: SUPPLEMENTARY_FILE + "_hidden_content",
isVisible: false,
validations: [new ValidatorModel(CustomValidatorOptions.isValidJson,
- "File is invalid, please make sure a legal JSON file is uploaded using name:value pairs.",[]),
+ "File is invalid, please make sure a legal JSON file is uploaded using name:value pairs.", []),
new ValidatorModel(CustomValidatorOptions.isStringContainTags,
- "File is invalid, please remove tags <>.",[])],
- value: !_.isNil(instance) ? (instance.supplementaryFile_hidden_content): null,
+ "File is invalid, please remove tags <>.", [])],
+ value: !_.isNil(instance) ? (instance.supplementaryFile_hidden_content) : null,
})
],
- onDelete : this.getOnDeleteForSupplementaryFile(),
- onChange : this.getOnChangeForSupplementaryFile()
+ onDelete: this.getOnDeleteForSupplementaryFile(),
+ onChange: this.getOnChangeForSupplementaryFile()
})
};
- retrieveInstanceIfUpdateMode(store: NgRedux<AppState>, instance: any): any{
+ retrieveInstanceIfUpdateMode(store: NgRedux<AppState>, instance: any): any {
return store.getState().global.isUpdateModalMode ? instance : null;
}
@@ -307,4 +241,12 @@ export class BasicControlGenerator {
}
};
}
+
+ getRollBackOnFailureOptions = (): Observable<SelectOption[]> => {
+ return of([
+ new SelectOption({id: 'true', name: 'Rollback'}),
+ new SelectOption({id: 'false', name: 'Don\'t Rollback'})
+ ]);
+ };
+
}
diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/networkGenerator/network.control.generator.spec.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/networkGenerator/network.control.generator.spec.ts
index 0bb278a8e..b5277b48d 100644
--- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/networkGenerator/network.control.generator.spec.ts
+++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/networkGenerator/network.control.generator.spec.ts
@@ -1,7 +1,7 @@
import {getTestBed, TestBed} from '@angular/core/testing';
import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing';
import {NgRedux} from '@angular-redux/store';
-import {BasicControlGenerator} from "../basic.control.generator";
+import {ControlGeneratorUtil} from "../control.generator.util.service";
import {AaiService} from "../../../../services/aaiService/aai.service";
import {GenericFormService} from "../../generic-form.service";
import {FormBuilder} from "@angular/forms";
@@ -9,6 +9,7 @@ import {LogService} from "../../../../utils/log/log.service";
import {FormControlNames, NetworkControlGenerator} from "./network.control.generator";
import {FormControlModel, ValidatorModel, ValidatorOptions} from "../../../../models/formControlModels/formControl.model";
import {FeatureFlagsService} from "../../../../services/featureFlag/feature-flags.service";
+import {SharedControllersService} from "../sharedControlles/shared.controllers.service";
class MockAppStore<T> {
getState(){
@@ -1812,7 +1813,8 @@ describe('Network Control Generator', () => {
imports: [HttpClientTestingModule],
providers: [NetworkControlGenerator,
GenericFormService,
- BasicControlGenerator,
+ ControlGeneratorUtil,
+ SharedControllersService,
AaiService,
FormBuilder,
LogService,
diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/networkGenerator/network.control.generator.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/networkGenerator/network.control.generator.ts
index 19c85a1ff..a7f16db4b 100644
--- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/networkGenerator/network.control.generator.ts
+++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/networkGenerator/network.control.generator.ts
@@ -3,53 +3,33 @@ 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 {BasicControlGenerator} from "../basic.control.generator";
+import {ControlGeneratorUtil} from "../control.generator.util.service";
import * as _ from 'lodash';
-import {Observable, of} from "rxjs";
-import {
- FormControlModel,
- ValidatorModel,
- ValidatorOptions
-} from "../../../../models/formControlModels/formControl.model";
+import {FormControlModel,} from "../../../../models/formControlModels/formControl.model";
import {LogService} from "../../../../utils/log/log.service";
import {AppState} from "../../../../store/reducers";
-import {FormGroup} from "@angular/forms";
import {DropdownFormControl} from "../../../../models/formControlModels/dropdownFormControl.model";
import {FormControlType} from "../../../../models/formControlModels/formControlTypes.enum";
-import {SelectOption} from "../../../../models/selectOption";
import {NetworkInstance} from "../../../../models/networkInstance";
import {NetworkModel} from "../../../../models/networkModel";
-import {Constants} from "../../../../utils/constants";
+import {SharedControllersService} from "../sharedControlles/shared.controllers.service";
export enum FormControlNames {
INSTANCE_NAME = 'instanceName',
- GLOBAL_SUBSCRIBER_ID = 'globalSubscriberId',
PRODUCT_FAMILY_ID = 'productFamilyId',
LCPCLOUD_REGION_ID = 'lcpCloudRegionId',
- TENANT_ID = 'tenantId',
- AICZONE_ID = 'aicZoneId',
- ROLLBACK_ON_FAILURE = 'rollbackOnFailure',
- LEGACY_REGION = 'legacyRegion'
+ ROLLBACK_ON_FAILURE = 'rollbackOnFailure'
}
-enum InputType {
- LCP_REGION = "lcpCloudRegionId",
- TENANT = "tenantId",
- LOB = "lineOfBusiness",
- PLATFORM = "platformName",
- ROLLBACK = "rollbackOnFailure",
- PRODUCT_FAMILY = "productFamilyId",
- VG = "volumeGroupName"
-}
-
@Injectable()
export class NetworkControlGenerator {
aaiService: AaiService;
constructor(private genericFormService: GenericFormService,
- private _basicControlGenerator: BasicControlGenerator,
+ private _basicControlGenerator: ControlGeneratorUtil,
+ private _sharedControllersService: SharedControllersService,
private store: NgRedux<AppState>,
private http: HttpClient,
private _aaiService: AaiService,
@@ -57,8 +37,8 @@ export class NetworkControlGenerator {
this.aaiService = _aaiService;
}
- getNetworkInstance = (serviceId: string, networkName: string, isUpdateMode : boolean): NetworkInstance => {
- let networkInstance : NetworkInstance = null;
+ getNetworkInstance = (serviceId: string, networkName: string, isUpdateMode: boolean): NetworkInstance => {
+ let networkInstance: NetworkInstance = null;
if (isUpdateMode && this.store.getState().service.serviceInstance[serviceId] && _.has(this.store.getState().service.serviceInstance[serviceId].networks, networkName)) {
networkInstance = Object.assign({}, this.store.getState().service.serviceInstance[serviceId].networks[networkName]);
}
@@ -66,7 +46,7 @@ export class NetworkControlGenerator {
};
- getMacroFormControls(serviceId: string, networkStoreKey: string, networkName: string, isUpdateMode : boolean): FormControlModel[] {
+ getMacroFormControls(serviceId: string, networkStoreKey: string, networkName: string, isUpdateMode: boolean): FormControlModel[] {
networkStoreKey = _.isNil(networkStoreKey) ? networkName : networkStoreKey;
if (_.isNil(serviceId) || _.isNil(networkStoreKey) || _.isNil(networkName)) {
@@ -79,18 +59,18 @@ export class NetworkControlGenerator {
if (!_.isNil(networkModel)) {
result.push(this.getInstanceName(networkInstance, serviceId, networkName, networkModel.isEcompGeneratedNaming));
- result.push(this._basicControlGenerator.getProductFamilyControl(networkInstance, result, false));
- result.push(this.getLcpRegionControl(serviceId, networkInstance, result));
- result.push(this._basicControlGenerator.getLegacyRegion(networkInstance));
- result.push(this.getTenantControl(serviceId, networkInstance, result));
- result.push(this.getPlatformControl(networkInstance, result));
- result.push(this.getLineOfBusinessControl(networkInstance, result));
+ result.push(this._sharedControllersService.getProductFamilyControl(networkInstance, result, false));
+ result.push(this._sharedControllersService.getLcpRegionControl(serviceId, networkInstance, result));
+ result.push(this._sharedControllersService.getLegacyRegion(networkInstance));
+ result.push(this._sharedControllersService.getTenantControl(serviceId, networkInstance));
+ result.push(this.getPlatformControl(networkInstance));
+ result.push(this._sharedControllersService.getLineOfBusinessControl(networkInstance));
}
return result;
}
- getAlaCarteFormControls(serviceId: string, networkStoreKey: string, networkName: string, isUpdateMode : boolean): FormControlModel[] {
+ getAlaCarteFormControls(serviceId: string, networkStoreKey: string, networkName: string, isUpdateMode: boolean): FormControlModel[] {
networkStoreKey = _.isNil(networkStoreKey) ? networkName : networkStoreKey;
if (_.isNil(serviceId) || _.isNil(networkStoreKey) || _.isNil(networkName)) {
this._logService.error('should provide serviceId, networkName, networkStoreKey', serviceId);
@@ -103,45 +83,24 @@ export class NetworkControlGenerator {
if (!_.isNil(networkModel)) {
result.push(this.getInstanceName(networkInstance, serviceId, networkName, networkModel.isEcompGeneratedNaming));
- result.push(this._basicControlGenerator.getProductFamilyControl(networkInstance, result, false));
- result.push(this.getLcpRegionControl(serviceId, networkInstance, result));
- result.push(this._basicControlGenerator.getLegacyRegion(networkInstance));
- result.push(this.getTenantControl(serviceId, networkInstance, result));
- result.push(this.getPlatformControl(networkInstance, result));
- result.push(this.getLineOfBusinessControl(networkInstance, result));
- result.push(this.getRollbackOnFailureControl(networkInstance, result));
+ result.push(this._sharedControllersService.getProductFamilyControl(networkInstance, result, false));
+ result.push(this._sharedControllersService.getLcpRegionControl(serviceId, networkInstance, result));
+ result.push(this._sharedControllersService.getLegacyRegion(networkInstance));
+ result.push(this._sharedControllersService.getTenantControl(serviceId, networkInstance));
+ result.push(this.getPlatformControl(networkInstance));
+ result.push(this._sharedControllersService.getLineOfBusinessControl(networkInstance));
+ result.push(this._sharedControllersService.getRollbackOnFailureControl(networkInstance));
}
return result;
-
}
- isInputShouldBeShown = (inputType: any): boolean => {
- let networkInputs = [InputType.LCP_REGION, InputType.LOB, InputType.TENANT, InputType.PRODUCT_FAMILY, InputType.PLATFORM, InputType.ROLLBACK];
- return networkInputs.indexOf(inputType) > -1;
- };
- getInstanceName(instance : any, serviceId : string, networkName : string, isEcompGeneratedNaming: boolean): FormControlModel {
- const networkModel : NetworkModel = this.store.getState().service.serviceHierarchy[serviceId].networks[networkName];
- return this._basicControlGenerator.getInstanceNameController(instance, serviceId, isEcompGeneratedNaming, networkModel);
+ getInstanceName(instance: any, serviceId: string, networkName: string, isEcompGeneratedNaming: boolean): FormControlModel {
+ const networkModel: NetworkModel = this.store.getState().service.serviceHierarchy[serviceId].networks[networkName];
+ return this._sharedControllersService.getInstanceNameController(instance, serviceId, isEcompGeneratedNaming, networkModel);
}
- getLineOfBusinessControl = (instance: any, controls: FormControlModel[]): DropdownFormControl => {
- return new DropdownFormControl({
- type: FormControlType.DROPDOWN,
- controlName: 'lineOfBusiness',
- displayName: 'Line of business',
- dataTestId: 'lineOfBusiness',
- placeHolder: 'Select Line Of Business',
- isDisabled: false,
- name: "lineOfBusiness",
- value: instance ? instance.lineOfBusiness : null,
- validations: [new ValidatorModel(ValidatorOptions.required, 'is required')],
- onInitSelectedField: ['lineOfBusinessList'],
- onInit: this._basicControlGenerator.getSubscribeInitResult.bind(null, this._aaiService.getCategoryParameters)
- })
- };
-
- getPlatformControl = (instance: any, controls: FormControlModel[]): DropdownFormControl => {
+ getPlatformControl = (instance: any): DropdownFormControl => {
return new DropdownFormControl({
type: FormControlType.DROPDOWN,
controlName: 'platformName',
@@ -156,90 +115,4 @@ export class NetworkControlGenerator {
onInit: this._basicControlGenerator.getSubscribeInitResult.bind(null, this._aaiService.getCategoryParameters)
})
};
-
- getTenantControl = (serviceId: string, instance: any, controls: FormControlModel[]): DropdownFormControl => {
- const service = this.store.getState().service.serviceInstance[serviceId];
- const globalCustomerId: string = service.globalSubscriberId;
- const serviceType: string = service.subscriptionServiceType;
- return new DropdownFormControl({
- type: FormControlType.DROPDOWN,
- controlName: FormControlNames.TENANT_ID,
- displayName: 'Tenant',
- dataTestId: 'tenant',
- placeHolder: 'Select Tenant',
- name: "tenant",
- isDisabled: _.isNil(instance) || _.isNil(instance.lcpCloudRegionId),
- onInitSelectedField: instance ? ['lcpRegionsTenantsMap', instance.lcpCloudRegionId] : null,
- value: instance ? instance.tenantId : null,
- validations: [new ValidatorModel(ValidatorOptions.required, 'is required')],
- onInit : instance ? this._basicControlGenerator.getSubscribeInitResult.bind(
- this._aaiService,
- this.aaiService.getLcpRegionsAndTenants.bind(this, globalCustomerId, serviceType)) : ()=>{},
- })
- };
-
- getLcpRegionControl = (serviceId: string, instance: any, controls: FormControlModel[]): DropdownFormControl => {
- const service = this.store.getState().service.serviceInstance[serviceId];
- const globalCustomerId: string = service.globalSubscriberId;
- const serviceType: string = service.subscriptionServiceType;
- return new DropdownFormControl({
- type: FormControlType.DROPDOWN,
- controlName: 'lcpCloudRegionId',
- displayName: 'LCP region',
- dataTestId: 'lcpRegion',
- placeHolder: 'Select LCP Region',
- name: "lcpRegion",
- isDisabled: false,
- value: instance ? instance.lcpCloudRegionId : null,
- validations: [new ValidatorModel(ValidatorOptions.required, 'is required')],
- onInitSelectedField: ['lcpRegionList'],
- onInit: this._basicControlGenerator.getSubscribeInitResult.bind(
- this._aaiService,
- this._aaiService.getLcpRegionsAndTenants.bind(this, globalCustomerId, serviceType)),
- onChange: (param: string, form: FormGroup) => {
- form.controls[FormControlNames.TENANT_ID].enable();
- form.controls[FormControlNames.TENANT_ID].reset();
- if (!_.isNil(globalCustomerId) && !_.isNil(serviceType)) {
- this._basicControlGenerator.getSubscribeResult.bind(this, this._aaiService.getLcpRegionsAndTenants(globalCustomerId, serviceType).subscribe(res => {
- controls.find(item => item.controlName === FormControlNames.TENANT_ID)['options$'] = res.lcpRegionsTenantsMap[param];
- if(res.lcpRegionsTenantsMap[param]){
- controls.find(item => item.controlName === FormControlNames.TENANT_ID)['hasEmptyOptions'] = res.lcpRegionsTenantsMap[param].length === 0;
- }
- }));
- }
-
- if (Constants.LegacyRegion.MEGA_REGION.indexOf(param) !== -1) {
- form.controls['legacyRegion'].enable();
- controls.find(item => item.controlName === 'legacyRegion').isVisible = true;
-
- } else {
- controls.find(item => item.controlName === 'legacyRegion').isVisible = false;
- form.controls['legacyRegion'].setValue(null);
- form.controls['legacyRegion'].reset();
- form.controls['legacyRegion'].disable();
- }
- }
- })
- };
-
- getRollbackOnFailureControl = (instance: any, controls: FormControlModel[]): DropdownFormControl => {
- return new DropdownFormControl({
- type: FormControlType.DROPDOWN,
- controlName: FormControlNames.ROLLBACK_ON_FAILURE,
- displayName: 'Rollback on failure',
- dataTestId: 'rollback',
- placeHolder: 'Rollback on failure',
- isDisabled: false,
- validations: [new ValidatorModel(ValidatorOptions.required, 'is required')],
- value: instance ? instance.rollbackOnFailure : 'true',
- onInit: this._basicControlGenerator.getSubscribeInitResult.bind(null, this.getRollBackOnFailureOptions)
- })
- };
-
- getRollBackOnFailureOptions = (): Observable<SelectOption[]> => {
- return of([
- new SelectOption({id: 'true', name: 'Rollback'}),
- new SelectOption({id: 'false', name: 'Don\'t Rollback'})
- ]);
- };
}
diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/service.control.generator.spec.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/service.control.generator.spec.ts
index 6bcec09c4..88a8a53d6 100644
--- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/service.control.generator.spec.ts
+++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/service.control.generator.spec.ts
@@ -2,7 +2,7 @@ import {getTestBed, TestBed} from '@angular/core/testing';
import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing';
import {NgRedux} from '@angular-redux/store';
import {FormControlNames, ServiceControlGenerator} from "./service.control.generator";
-import {BasicControlGenerator} from "./basic.control.generator";
+import {ControlGeneratorUtil} from "./control.generator.util.service";
import {AaiService} from "../../../services/aaiService/aai.service";
import {GenericFormService} from "../generic-form.service";
import {FormBuilder} from "@angular/forms";
@@ -13,6 +13,7 @@ import {DropdownFormControl} from "../../../models/formControlModels/dropdownFor
import {FeatureFlagsService} from "../../../services/featureFlag/feature-flags.service";
import each from 'jest-each';
import {VidNotions} from "../../../models/vidNotions";
+import {SharedControllersService} from "./sharedControlles/shared.controllers.service";
class MockAppStore<T> {
getState() {
@@ -912,7 +913,8 @@ describe('Service Control Generator', () => {
imports: [HttpClientTestingModule],
providers: [ServiceControlGenerator,
GenericFormService,
- BasicControlGenerator,
+ ControlGeneratorUtil,
+ SharedControllersService,
AaiService,
FormBuilder,
LogService,
diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/service.control.generator.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/service.control.generator.ts
index 12054a8a7..da13b0be4 100644
--- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/service.control.generator.ts
+++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/service.control.generator.ts
@@ -5,7 +5,7 @@ import {AppState} from "../../../store/reducers";
import {FormControlModel, ValidatorModel, ValidatorOptions} from "../../../models/formControlModels/formControl.model";
import {DropdownFormControl} from "../../../models/formControlModels/dropdownFormControl.model";
import * as _ from 'lodash';
-import {BasicControlGenerator} from "./basic.control.generator";
+import {ControlGeneratorUtil} from "./control.generator.util.service";
import {AaiService} from "../../../services/aaiService/aai.service";
import {FormGroup} from "@angular/forms";
import {FormControlType} from "../../../models/formControlModels/formControlTypes.enum";
@@ -17,6 +17,7 @@ import {ServiceModel} from "../../../models/serviceModel";
import {CheckboxFormControl} from "../../../models/formControlModels/checkboxFormControl.model";
import {VidNotions} from "../../../models/vidNotions";
+import {SharedControllersService} from "./sharedControlles/shared.controllers.service";
export enum FormControlNames {
INSTANCE_NAME = 'instanceName',
@@ -36,7 +37,8 @@ export enum FormControlNames {
export class ServiceControlGenerator {
aaiService : AaiService;
constructor(private genericFormService : GenericFormService,
- private _basicControlGenerator : BasicControlGenerator,
+ private _basicControlGenerator : ControlGeneratorUtil,
+ private _sharedControllersService : SharedControllersService,
private store: NgRedux<AppState>,
private http: HttpClient,
private _aaiService : AaiService,
@@ -64,7 +66,7 @@ export class ServiceControlGenerator {
const serviceModel = new ServiceModel(this.store.getState().service.serviceHierarchy[serviceId]);
if(!_.isNil(serviceModel)){
- result.push(this._basicControlGenerator.getInstanceName(serviceInstance, serviceId, serviceModel.isEcompGeneratedNaming));
+ result.push(this._sharedControllersService.getInstanceName(serviceInstance, serviceId, serviceModel.isEcompGeneratedNaming));
result.push(this.getGlobalSubscriberControl(serviceInstance, result));
result.push(this.getServiceTypeControl(serviceInstance, result, false));
result.push(this.getOwningEntityControl(serviceInstance, result));
@@ -87,7 +89,7 @@ export class ServiceControlGenerator {
let result : FormControlModel[] = [];
const serviceModel = new ServiceModel(this.store.getState().service.serviceHierarchy[serviceId]);
if(!_.isNil(serviceModel)){
- result.push(this._basicControlGenerator.getInstanceName(serviceInstance, serviceId, serviceModel.isEcompGeneratedNaming));
+ result.push(this._sharedControllersService.getInstanceName(serviceInstance, serviceId, serviceModel.isEcompGeneratedNaming));
result.push(this.getGlobalSubscriberControl(serviceInstance, result));
result.push(this.getServiceTypeControl(serviceInstance, result, true));
result.push(this.getOwningEntityControl(serviceInstance, result));
diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service.spec.ts
new file mode 100644
index 000000000..58ee33b53
--- /dev/null
+++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service.spec.ts
@@ -0,0 +1,263 @@
+import * as _ from "lodash";
+import {getTestBed, TestBed} from '@angular/core/testing';
+import {SharedControllersService} from "./shared.controllers.service";
+import {HttpClientTestingModule, HttpTestingController} from "@angular/common/http/testing";
+import {AppState} from "../../../../store/reducers";
+import {NgRedux} from "@angular-redux/store";
+import {AaiService} from "../../../../services/aaiService/aai.service";
+import {FeatureFlagsService} from "../../../../services/featureFlag/feature-flags.service";
+import {DropdownFormControl} from "../../../../models/formControlModels/dropdownFormControl.model";
+import {FormControlModel, ValidatorOptions} from "../../../../models/formControlModels/formControl.model";
+import {ControlGeneratorUtil} from "../control.generator.util.service";
+
+
+
+describe('Shared Controllers Service', () => {
+ let injector;
+ let service: SharedControllersService;
+ let httpMock: HttpTestingController;
+ let store: NgRedux<AppState>;
+ let basicControlGenerator : ControlGeneratorUtil;
+
+ beforeAll(done => (async () => {
+ TestBed.configureTestingModule({
+ imports: [HttpClientTestingModule],
+ providers: [SharedControllersService,
+ AaiService,
+ ControlGeneratorUtil,
+ {provide:FeatureFlagsService, useClass: MockFeatureFlagsService},
+ {provide: NgRedux, useClass: MockAppStore}]
+ });
+ await TestBed.compileComponents();
+
+ injector = getTestBed();
+ service = injector.get(SharedControllersService);
+ basicControlGenerator = injector.get(ControlGeneratorUtil);
+ httpMock = injector.get(HttpTestingController);
+ store = injector.get(NgRedux);
+
+ })().then(done).catch(done.fail));
+
+
+
+
+
+ test('getLineOfBusinessControl', ()=> {
+ const lineOfBusinessControl :DropdownFormControl = service.getLineOfBusinessControl();
+ expect(lineOfBusinessControl.name).toEqual('lineOfBusiness');
+ expect(lineOfBusinessControl.controlName).toEqual('lineOfBusiness');
+ expect(lineOfBusinessControl.displayName).toEqual('Line of business');
+ expect(lineOfBusinessControl.dataTestId).toEqual('lineOfBusiness');
+ expect(lineOfBusinessControl.placeHolder).toEqual('Select Line Of Business');
+ expect(lineOfBusinessControl.onInitSelectedField).toEqual(['lineOfBusinessList']);
+ expect(lineOfBusinessControl.onInit).toBeDefined();
+ expect(lineOfBusinessControl.value).toBeNull();
+ expect(lineOfBusinessControl.validations.find((validation)=> validation.validatorName === ValidatorOptions.required)).toBeDefined();
+ expect(lineOfBusinessControl.isDisabled).toBeFalsy();
+ });
+
+ test('getTenantControl', ()=> {
+ const serviceId : string = Object.keys(store.getState().service.serviceInstance)[0];
+ const vnfs = store.getState().service.serviceInstance[serviceId].vnfs;
+ const currentVnf = vnfs[Object.keys(vnfs)[0]];
+
+ const tanantControl :DropdownFormControl = service.getTenantControl(serviceId, currentVnf);
+ expect(tanantControl.name).toEqual('tenant');
+ expect(tanantControl.controlName).toEqual('tenantId');
+ expect(tanantControl.displayName).toEqual('Tenant');
+ expect(tanantControl.dataTestId).toEqual('tenant');
+ expect(tanantControl.placeHolder).toEqual('Select Tenant');
+ expect(tanantControl.onInitSelectedField).toEqual(['lcpRegionsTenantsMap', currentVnf.lcpCloudRegionId]);
+ expect(tanantControl.onInit).toBeDefined();
+ expect(tanantControl.validations.find((validation)=> validation.validatorName === ValidatorOptions.required)).toBeDefined();
+ expect(tanantControl.isDisabled).toEqual(_.isNil(currentVnf.lcpCloudRegionId));
+ });
+
+
+ test('getRollbackOnFailureControl', ()=> {
+ const rollbackOnFailureControl :DropdownFormControl = service.getRollbackOnFailureControl();
+ expect(rollbackOnFailureControl.controlName).toEqual('rollbackOnFailure');
+ expect(rollbackOnFailureControl.displayName).toEqual('Rollback on failure');
+ expect(rollbackOnFailureControl.dataTestId).toEqual('rollback');
+ expect(rollbackOnFailureControl.placeHolder).toEqual('Rollback on failure');
+ expect(rollbackOnFailureControl.onInit).toBeDefined();
+ expect(rollbackOnFailureControl.validations.find((validation)=> validation.validatorName === ValidatorOptions.required)).toBeDefined();
+ expect(rollbackOnFailureControl.isDisabled).toBeFalsy();
+ });
+
+ test('getLcpRegionControl', ()=> {
+ const serviceId : string = Object.keys(store.getState().service.serviceInstance)[0];
+ const vnfs = store.getState().service.serviceInstance[serviceId].vnfs;
+ const currentVnf = vnfs[Object.keys(vnfs)[0]];
+ const lcpRegionControl :DropdownFormControl = service.getLcpRegionControl(serviceId, currentVnf, []);
+ expect(lcpRegionControl.controlName).toEqual('lcpCloudRegionId');
+ expect(lcpRegionControl.displayName).toEqual('LCP region');
+ expect(lcpRegionControl.dataTestId).toEqual('lcpRegion');
+ expect(lcpRegionControl.placeHolder).toEqual('Select LCP Region');
+ expect(lcpRegionControl.onInit).toBeDefined();
+ expect(lcpRegionControl.onChange).toBeDefined();
+ expect(lcpRegionControl.validations.find((validation)=> validation.validatorName === ValidatorOptions.required)).toBeDefined();
+ expect(lcpRegionControl.isDisabled).toBeFalsy();
+ });
+
+ test('sdn-preload checkbox is visible', () => {
+ const instance = {};
+ const sdncPreload: FormControlModel = service.getSDNCControl(instance);
+ expect (sdncPreload.displayName).toEqual('SDN-C pre-load');
+ expect (sdncPreload.value).toBeFalsy();
+ });
+
+ test('getlegacyRegion with AAIAIC25 - isVisible true', () => {
+ const instance = {lcpCloudRegionId : 'AAIAIC25'};
+ const legacyRegionControl: FormControlModel = service.getLegacyRegion(instance);
+ expect(legacyRegionControl.isVisible).toBeTruthy();
+ });
+
+ test('getlegacyRegion without AAIAIC25 - isVisible false', () => {
+ const instance = {lcpCloudRegionId : 'olson3'};
+ const legacyRegionControl: FormControlModel = service.getLegacyRegion(instance);
+ expect(legacyRegionControl.isVisible).toBeFalsy();
+ });
+});
+
+class MockAppStore<T> {
+ getState() {
+ return {
+ "global": {
+ "flags": {
+ "FLAG_NETWORK_TO_ASYNC_INSTANTIATION": false,
+ "FLAG_SHOW_ASSIGNMENTS": true,
+ "FLAG_FABRIC_CONFIGURATION_ASSIGNMENTS": true,
+ "FLAG_SHOW_VERIFY_SERVICE": false,
+ "FLAG_SERVICE_MODEL_CACHE": true,
+ "FLAG_ADD_MSO_TESTAPI_FIELD": true
+ }
+ },
+ "service": {
+ "serviceHierarchy": {
+ "4117a0b6-e234-467d-b5b9-fe2f68c8b0fc": {
+ "service": {
+ "uuid": "4117a0b6-e234-467d-b5b9-fe2f68c8b0fc",
+ "invariantUuid": "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0",
+ "name": "ComplexService",
+ "version": "1.0",
+ "toscaModelURL": null,
+ "category": "Emanuel",
+ "serviceType": "",
+ "serviceRole": "",
+ "description": "ComplexService",
+ "serviceEcompNaming": "false",
+ "instantiationType": "Macro",
+ "inputs": {}
+ },
+ "vnfs": {
+ "VF_vGeraldine 0": {
+ "uuid": "d6557200-ecf2-4641-8094-5393ae3aae60",
+ "invariantUuid": "4160458e-f648-4b30-a176-43881ffffe9e",
+ "description": "VSP_vGeraldine",
+ "name": "VF_vGeraldine",
+ "version": "2.0",
+ "customizationUuid": "91415b44-753d-494c-926a-456a9172bbb9",
+ "inputs": {},
+ "commands": {},
+ "properties": {
+ "max_instances": 10,
+ "min_instances": 1,
+
+ },
+ "type": "VF",
+ "modelCustomizationName": "VF_vGeraldine 0",
+ "vfModules": {
+ "vf_vgeraldine0..VfVgeraldine..vflorence_vlc..module-1": {
+ "uuid": "522159d5-d6e0-4c2a-aa44-5a542a12a830",
+ "invariantUuid": "98a7c88b-b577-476a-90e4-e25a5871e02b",
+ "customizationUuid": "55b1be94-671a-403e-a26c-667e9c47d091",
+ "description": null,
+ "name": "VfVgeraldine..vflorence_vlc..module-1",
+ "version": "2",
+ "modelCustomizationName": "VfVgeraldine..vflorence_vlc..module-1",
+ "properties": {
+ "minCountInstances": 0,
+ "maxCountInstances": null,
+ "initialCount": 0,
+ "vfModuleLabel": "vflorence_vlc"
+ },
+ "inputs": {},
+ "volumeGroupAllowed": true
+ }
+ }
+ }
+ }
+ }
+ },
+ "serviceInstance": {
+ "4117a0b6-e234-467d-b5b9-fe2f68c8b0fc": {
+ "vnfs": {
+ "2017-388_PASQUALE-vPE 0": {
+ "action": "Create",
+ "inMaint": false,
+ "rollbackOnFailure": "true",
+ "originalName": "2017-388_PASQUALE-vPE 0",
+ "isMissingData": false,
+ "trackById": "eymgwlevh54",
+ "vfModules": {},
+ "vnfStoreKey": "2017-388_PASQUALE-vPE 0",
+ "uuid": "afacccf6-397d-45d6-b5ae-94c39734b168",
+ "productFamilyId": "e433710f-9217-458d-a79d-1c7aff376d89",
+ "lcpCloudRegionId": "AAIAIC25",
+ "tenantId": "092eb9e8e4b7412e8787dd091bc58e86",
+ "lineOfBusiness": "ONAP",
+ "platformName": "platform",
+ "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",
+ "modelUniqueId": "b3c76f73-eeb5-4fb6-9d31-72a889f1811c"
+ },
+ "instanceName": "2017-388_PASQUALE-vPEAjXzainstanceName",
+ "legacyRegion": "some legacy region",
+ "instanceParams": [
+ {
+ "vnf_config_template_version": "17.2",
+ "bandwidth_units": "Gbps",
+ "bandwidth": "10",
+ "AIC_CLLI": "ATLMY8GA",
+ "ASN": "AV_vPE",
+ "vnf_instance_name": "mtnj309me6"
+ }
+ ]
+ }
+ },
+ "service": {
+ "vidNotions": {
+ "instantiationUI": "serviceWithVRF",
+ "modelCategory": "other",
+ "viewEditUI": "serviceWithVRF",
+ "instantiationType": "ALaCarte"
+ },
+ "uuid": "4117a0b6-e234-467d-b5b9-fe2f68c8b0fc",
+ "invariantUuid": "7ee41ce4-4827-44b0-a48e-2707a59905d2",
+ "name": "VRF Service for Test",
+ "version": "1.0",
+ "toscaModelURL": null,
+ "category": "Network L4+",
+ "serviceType": "INFRASTRUCTURE",
+ "serviceRole": "Configuration",
+ "description": "xxx",
+ "serviceEcompNaming": "true",
+ "instantiationType": "A-La-Carte",
+ "inputs": {}
+ },
+ "isALaCarte": true
+ }
+ }
+ }
+ }
+ }
+}
+
+class MockFeatureFlagsService {}
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
new file mode 100644
index 000000000..e82ea5d85
--- /dev/null
+++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service.ts
@@ -0,0 +1,189 @@
+import {Injectable} from "@angular/core";
+import {DropdownFormControl} from "../../../../models/formControlModels/dropdownFormControl.model";
+import {FormControlType} from "../../../../models/formControlModels/formControlTypes.enum";
+import {
+ FormControlModel,
+ ValidatorModel,
+ ValidatorOptions
+} from "../../../../models/formControlModels/formControl.model";
+import {NgRedux} from "@angular-redux/store";
+import {AppState} from "../../../../store/reducers";
+import {AaiService} from "../../../../services/aaiService/aai.service";
+import {ControlGeneratorUtil, SDN_C_PRE_LOAD} from "../control.generator.util.service";
+import * as _ from "lodash";
+import {FormGroup} from "@angular/forms";
+import {Constants} from "../../../../utils/constants";
+import {CheckboxFormControl} from "../../../../models/formControlModels/checkboxFormControl.model";
+import {InputFormControl} from "../../../../models/formControlModels/inputFormControl.model";
+import {NodeModel} from "../../../../models/nodeModel";
+
+@Injectable()
+export class SharedControllersService {
+ constructor(private _store : NgRedux<AppState>,
+ private _aaiService : AaiService,
+ private _basicControlGenerator : ControlGeneratorUtil){}
+
+
+ getLineOfBusinessControl = (instance?: any): DropdownFormControl => {
+ return new DropdownFormControl({
+ type: FormControlType.DROPDOWN,
+ controlName: 'lineOfBusiness',
+ displayName: 'Line of business',
+ dataTestId: 'lineOfBusiness',
+ placeHolder: 'Select Line Of Business',
+ isDisabled: false,
+ name: "lineOfBusiness",
+ value: instance ? instance.lineOfBusiness : null,
+ validations: [new ValidatorModel(ValidatorOptions.required, 'is required')],
+ onInitSelectedField: ['lineOfBusinessList'],
+ onInit: this._basicControlGenerator.getSubscribeInitResult.bind(null, this._aaiService.getCategoryParameters)
+ })
+ };
+
+ getTenantControl = (serviceId: string, instance?: any): DropdownFormControl => {
+ const service = this._store.getState().service.serviceInstance[serviceId];
+ const globalCustomerId: string = service.globalSubscriberId;
+ const serviceType: string = service.subscriptionServiceType;
+ return new DropdownFormControl({
+ type: FormControlType.DROPDOWN,
+ controlName: 'tenantId',
+ displayName: 'Tenant',
+ dataTestId: 'tenant',
+ placeHolder: 'Select Tenant',
+ name: 'tenant',
+ isDisabled: _.isNil(instance) || _.isNil(instance.lcpCloudRegionId),
+ onInitSelectedField: instance ? ['lcpRegionsTenantsMap', instance.lcpCloudRegionId] : null,
+ value: instance ? instance.tenantId : null,
+ validations: [new ValidatorModel(ValidatorOptions.required, 'is required')],
+ onInit: instance ? this._basicControlGenerator.getSubscribeInitResult.bind(
+ this._aaiService,
+ this._aaiService.getLcpRegionsAndTenants.bind(this, globalCustomerId, serviceType)) : () => {
+ }
+ })
+ };
+
+ getRollbackOnFailureControl = (instance?: any): DropdownFormControl => {
+ return new DropdownFormControl({
+ type: FormControlType.DROPDOWN,
+ controlName: 'rollbackOnFailure',
+ displayName: 'Rollback on failure',
+ dataTestId: 'rollback',
+ placeHolder: 'Rollback on failure',
+ isDisabled: false,
+ validations: [new ValidatorModel(ValidatorOptions.required, 'is required')],
+ value: instance ? instance.rollbackOnFailure : 'true',
+ onInit: this._basicControlGenerator.getSubscribeInitResult.bind(null, this._basicControlGenerator.getRollBackOnFailureOptions)
+ })
+ };
+
+ getLegacyRegion(instance: any): FormControlModel {
+ return new InputFormControl({
+ controlName: 'legacyRegion',
+ displayName: 'Legacy Region',
+ dataTestId: 'lcpRegionText',
+ placeHolder: 'Type Legacy Region',
+ validations: [],
+ isVisible: this._basicControlGenerator.isLegacyRegionShouldBeVisible(instance),
+ isDisabled : _.isNil(instance) ? true : Constants.LegacyRegion.MEGA_REGION.indexOf(instance.lcpCloudRegionId),
+ value: instance ? instance.legacyRegion : null
+ });
+ }
+
+ getLcpRegionControl = (serviceId: string, instance: any, controls: FormControlModel[]): DropdownFormControl => {
+ const service = this._store.getState().service.serviceInstance[serviceId];
+ const globalCustomerId: string = service.globalSubscriberId;
+ const serviceType: string = service.subscriptionServiceType;
+ return new DropdownFormControl({
+ type: FormControlType.DROPDOWN,
+ controlName: 'lcpCloudRegionId',
+ displayName: 'LCP region',
+ dataTestId: 'lcpRegion',
+ placeHolder: 'Select LCP Region',
+ name: "lcpRegion",
+ isDisabled: false,
+ value: instance ? instance.lcpCloudRegionId : null,
+ validations: [new ValidatorModel(ValidatorOptions.required, 'is required')],
+ onInitSelectedField: ['lcpRegionList'],
+ onInit: this._basicControlGenerator.getSubscribeInitResult.bind(
+ this._aaiService,
+ this._aaiService.getLcpRegionsAndTenants.bind(this, globalCustomerId, serviceType)),
+ onChange: (param: string, form: FormGroup) => {
+ form.controls['tenantId'].enable();
+ form.controls['tenantId'].reset();
+ if (!_.isNil(globalCustomerId) && !_.isNil(serviceType)) {
+ this._basicControlGenerator.getSubscribeResult.bind(this, this._aaiService.getLcpRegionsAndTenants(globalCustomerId, serviceType).subscribe(res => {
+ controls.find(item => item.controlName === 'tenantId')['options$'] = res.lcpRegionsTenantsMap[param];
+ if (res.lcpRegionsTenantsMap[param]) {
+ controls.find(item => item.controlName === 'tenantId')['hasEmptyOptions'] = res.lcpRegionsTenantsMap[param].length === 0;
+ }
+ }));
+ }
+
+ if (Constants.LegacyRegion.MEGA_REGION.indexOf(param) !== -1) {
+ form.controls['legacyRegion'].enable();
+ controls.find(item => item.controlName === 'legacyRegion').isVisible = true;
+
+ } else {
+ controls.find(item => item.controlName === 'legacyRegion').isVisible = false;
+ form.controls['legacyRegion'].setValue(null);
+ form.controls['legacyRegion'].reset();
+ form.controls['legacyRegion'].disable();
+ }
+ }
+ })
+ };
+
+ getSDNCControl = (instance: any): 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')]
+ })
+ };
+
+ getProductFamilyControl = (instance : any, controls : FormControlModel[], isMandatory?: boolean) : DropdownFormControl => {
+ return new DropdownFormControl({
+ type : FormControlType.DROPDOWN,
+ controlName : 'productFamilyId',
+ displayName : 'Product family',
+ dataTestId : 'productFamily',
+ placeHolder : 'Select Product Family',
+ isDisabled : false,
+ name : "product-family-select",
+ value : instance ? instance.productFamilyId : null,
+ validations : _.isNil(isMandatory) || isMandatory === true ? [new ValidatorModel(ValidatorOptions.required, 'is required')]: [],
+ onInit : this._basicControlGenerator.getSubscribeResult.bind(this, this._aaiService.getProductFamilies),
+ })
+ };
+
+ getInstanceNameController(instance: any, serviceId: string, isEcompGeneratedNaming: boolean, model: NodeModel): FormControlModel {
+ let validations: ValidatorModel[] = this._basicControlGenerator.createValidationsForInstanceName(instance, serviceId, isEcompGeneratedNaming);
+ return new InputFormControl({
+ controlName: 'instanceName',
+ displayName: 'Instance name',
+ dataTestId: 'instanceName',
+ placeHolder: (!isEcompGeneratedNaming) ? 'Instance name' : 'Automatically generated when not provided',
+ validations: validations,
+ isVisible : true,
+ value : (!isEcompGeneratedNaming || (!_.isNil(instance) && !_.isNil(instance.instanceName)))
+ ? this._basicControlGenerator.getDefaultInstanceName(instance, model) : null,
+ onKeypress : (event) => {
+ const pattern:RegExp = ControlGeneratorUtil.INSTANCE_NAME_REG_EX;
+ if(pattern){
+ if(!pattern.test(event['key'])){
+ event.preventDefault();
+ }
+ }
+ return event;
+ }
+ });
+ }
+
+ getInstanceName(instance : any, serviceId : string, isEcompGeneratedNaming: boolean): FormControlModel {
+ let formControlModel:FormControlModel = this.getInstanceNameController(instance, serviceId, isEcompGeneratedNaming, new NodeModel());
+ formControlModel.value = instance ? instance.instanceName : null;
+ return formControlModel;
+ }
+}
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 deb1a784a..f3d32b9bb 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
@@ -1,7 +1,7 @@
import {getTestBed, TestBed} from '@angular/core/testing';
import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing';
import {NgRedux} from '@angular-redux/store';
-import {BasicControlGenerator, SDN_C_PRE_LOAD} from "../basic.control.generator";
+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";
@@ -11,6 +11,7 @@ import {FormControlNames, VfModuleControlGenerator} from "./vfModule.control.gen
import {FeatureFlagsService} from "../../../../services/featureFlag/feature-flags.service";
import {VfModuleInstance} from "../../../../models/vfModuleInstance";
import {VfModule} from "../../../../models/vfModule";
+import {SharedControllersService} from "../sharedControlles/shared.controllers.service";
class MockAppStore<T> {
getState() {
@@ -919,7 +920,8 @@ describe('VFModule Control Generator', () => {
imports: [HttpClientTestingModule],
providers: [VfModuleControlGenerator,
GenericFormService,
- BasicControlGenerator,
+ SharedControllersService,
+ ControlGeneratorUtil,
AaiService,
FormBuilder,
LogService,
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 011f43447..60ffc3e96 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,10 +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 {BasicControlGenerator} from "../basic.control.generator";
-import * as _ from 'lodash';
-import {Observable, of} from "rxjs";
-
+import {ControlGeneratorUtil} from "../control.generator.util.service";
import {
CustomValidatorOptions,
FormControlModel,
@@ -16,19 +13,13 @@ import {
import {LogService} from "../../../../utils/log/log.service";
import {AppState} from "../../../../store/reducers";
import {FormGroup} from "@angular/forms";
-import {DropdownFormControl} from "../../../../models/formControlModels/dropdownFormControl.model";
-import {FormControlType} from "../../../../models/formControlModels/formControlTypes.enum";
import {InputFormControl} from "../../../../models/formControlModels/inputFormControl.model";
-import {SelectOption} from "../../../../models/selectOption";
import {VfModuleInstance} from "../../../../models/vfModuleInstance";
import {VfModule} from "../../../../models/vfModule";
import {VNFModel} from "../../../../models/vnfModel";
import {VnfInstance} from "../../../../models/vnfInstance";
-import {FileFormControl} from "../../../../models/formControlModels/fileFormControl.model";
-import {CheckboxFormControl} from "../../../../models/formControlModels/checkboxFormControl.model";
-import {FileUnit} from "../../../formControls/component/file/fileUnit.enum";
-import {Constants} from "../../../../utils/constants";
-
+import * as _ from 'lodash';
+import {SharedControllersService} from "../sharedControlles/shared.controllers.service";
export enum FormControlNames {
INSTANCE_NAME = 'instanceName',
@@ -47,7 +38,8 @@ export class VfModuleControlGenerator {
isUpdateMode : boolean;
constructor(private genericFormService: GenericFormService,
- private _basicControlGenerator: BasicControlGenerator,
+ private _basicControlGenerator: ControlGeneratorUtil,
+ private _sharedControllersService: SharedControllersService,
private store: NgRedux<AppState>,
private http: HttpClient,
private _aaiService: AaiService,
@@ -55,17 +47,6 @@ export class VfModuleControlGenerator {
this.aaiService = _aaiService;
}
- setVFModuleStoreKey = (serviceId: string, vfModuleUuid: string) => {
- const vfModules = this.store.getState().service.serviceHierarchy[serviceId].vfModules;
- const vfModulesKeys = Object.keys(vfModules);
- for(let key of vfModulesKeys){
- if(vfModules[key].uuid === vfModuleUuid){
- return;
- }
- }
- };
-
-
getVfModuleInstance = (serviceId: string, vnfStoreKey: string, UUIDData: Object, isUpdateMode: boolean): VfModuleInstance => {
let vfModuleInstance: VfModuleInstance = null;
if (isUpdateMode && this.store.getState().service.serviceInstance[serviceId] &&
@@ -133,11 +114,11 @@ export class VfModuleControlGenerator {
const vfModuleInstance = this._basicControlGenerator.retrieveInstanceIfUpdateMode(this.store, this.getVfModuleInstance(serviceId, vnfStoreKey, uuidData, isUpdateMode));
let result: FormControlModel[] = [];
this.pushInstanceAndVGToForm(result, vfModuleInstance, serviceId, vnfModel, true);
- result.push(this.getLcpRegionControl(serviceId, vfModuleInstance, result));
- result.push(this._basicControlGenerator.getLegacyRegion(vfModuleInstance));
- result.push(this.getTenantControl(serviceId, vfModuleInstance, result));
- result.push(this.getRollbackOnFailureControl(vfModuleInstance, result));
- result.push(this._basicControlGenerator.getSDNCControl(vfModuleInstance));
+ result.push(this._sharedControllersService.getLcpRegionControl(serviceId, vfModuleInstance, result));
+ 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 = this._basicControlGenerator.concatSupplementaryFile(result, vfModuleInstance);
}
@@ -145,7 +126,7 @@ export class VfModuleControlGenerator {
}
getInstanceName(instance: any, serviceId: string, isEcompGeneratedNaming: boolean): FormControlModel {
- let formControlModel:FormControlModel = this._basicControlGenerator.getInstanceNameController(instance, serviceId, isEcompGeneratedNaming, this.vfModuleModel);
+ 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");
@@ -167,25 +148,21 @@ export class VfModuleControlGenerator {
getVolumeGroupData(instance: any, serviceId: string, isEcompGeneratedNaming: boolean, isALaCarte: boolean): FormControlModel {
let validations: ValidatorModel[] = [
- new ValidatorModel(ValidatorOptions.pattern, 'Instance name may include only alphanumeric characters and underscore.', BasicControlGenerator.INSTANCE_NAME_REG_EX),
+ new ValidatorModel(ValidatorOptions.pattern, 'Instance name may include only alphanumeric characters and underscore.', ControlGeneratorUtil.INSTANCE_NAME_REG_EX),
new ValidatorModel(CustomValidatorOptions.uniqueInstanceNameValidator, 'Volume Group instance name is already in use, please pick another name', [this.store, serviceId, instance && instance.volumeGroupName])
];
- // comment out because if not provided vid won't create VG
- // if (!isEcompGeneratedNaming) {
- // validations.push(new ValidatorModel(ValidatorOptions.required, 'is required'));
- // }
+
return new InputFormControl({
controlName: 'volumeGroupName',
displayName: 'Volume Group Name',
dataTestId: 'volumeGroupName',
- // placeHolder: (!isEcompGeneratedNaming) ? 'Volume Group Name' : 'Automatically generated when not provided',
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),
value: this.getDefaultVolumeGroupName(instance, isEcompGeneratedNaming),
onKeypress: (event) => {
- const pattern:RegExp = BasicControlGenerator.INSTANCE_NAME_REG_EX;
+ const pattern:RegExp = ControlGeneratorUtil.INSTANCE_NAME_REG_EX;
if (pattern) {
if (!pattern.test(event['key'])) {
event.preventDefault();
@@ -203,90 +180,4 @@ export class VfModuleControlGenerator {
return false;
}
-
- getTenantControl = (serviceId: string, instance: any, controls: FormControlModel[]): DropdownFormControl => {
- const service = this.store.getState().service.serviceInstance[serviceId];
- const globalCustomerId: string = service.globalSubscriberId;
- const serviceType: string = service.subscriptionServiceType;
- return new DropdownFormControl({
- type: FormControlType.DROPDOWN,
- controlName: FormControlNames.TENANT_ID,
- displayName: 'Tenant',
- dataTestId: 'tenant',
- placeHolder: 'Select Tenant',
- name: "tenant",
- isDisabled: _.isNil(instance) || _.isNil(instance.lcpCloudRegionId),
- onInitSelectedField: instance ? ['lcpRegionsTenantsMap', instance.lcpCloudRegionId] : null,
- value: instance ? instance.tenantId : null,
- validations: [new ValidatorModel(ValidatorOptions.required, 'is required')],
- onInit: instance ? this._basicControlGenerator.getSubscribeInitResult.bind(
- this._aaiService,
- this.aaiService.getLcpRegionsAndTenants.bind(this, globalCustomerId, serviceType)) : () => {
- },
- })
- };
-
- getLcpRegionControl = (serviceId: string, instance: any, controls: FormControlModel[]): DropdownFormControl => {
- const service = this.store.getState().service.serviceInstance[serviceId];
- const globalCustomerId: string = service.globalSubscriberId;
- const serviceType: string = service.subscriptionServiceType;
- return new DropdownFormControl({
- type: FormControlType.DROPDOWN,
- controlName: 'lcpCloudRegionId',
- displayName: 'LCP region',
- dataTestId: 'lcpRegion',
- placeHolder: 'Select LCP Region',
- name: "lcpRegion",
- isDisabled: false,
- value: instance ? instance.lcpCloudRegionId : null,
- validations: [new ValidatorModel(ValidatorOptions.required, 'is required')],
- onInitSelectedField: ['lcpRegionList'],
- onInit: this._basicControlGenerator.getSubscribeInitResult.bind(
- this._aaiService,
- this._aaiService.getLcpRegionsAndTenants.bind(this, globalCustomerId, serviceType)),
- onChange: (param: string, form: FormGroup) => {
- form.controls[FormControlNames.TENANT_ID].enable();
- form.controls[FormControlNames.TENANT_ID].reset();
- if (!_.isNil(globalCustomerId) && !_.isNil(serviceType)) {
- this._basicControlGenerator.getSubscribeResult.bind(this, this._aaiService.getLcpRegionsAndTenants(globalCustomerId, serviceType).subscribe(res => {
- controls.find(item => item.controlName === FormControlNames.TENANT_ID)['options$'] = res.lcpRegionsTenantsMap[param];
- if (res.lcpRegionsTenantsMap[param]) {
- controls.find(item => item.controlName === FormControlNames.TENANT_ID)['hasEmptyOptions'] = res.lcpRegionsTenantsMap[param].length === 0;
- }
- }));
- }
-
- if (Constants.LegacyRegion.MEGA_REGION.indexOf(param) !== -1) {
- form.controls['legacyRegion'].enable();
- controls.find(item => item.controlName === 'legacyRegion').isVisible = true;
-
- } else {
- controls.find(item => item.controlName === 'legacyRegion').isVisible = false;
- form.controls['legacyRegion'].setValue(null);
- form.controls['legacyRegion'].reset();
- form.controls['legacyRegion'].disable();
- }
- }
- })
- };
-
- getRollbackOnFailureControl = (instance: any, controls: FormControlModel[]): DropdownFormControl => {
- return new DropdownFormControl({
- type: FormControlType.DROPDOWN,
- controlName: FormControlNames.ROLLBACK_ON_FAILURE,
- displayName: 'Rollback on failure',
- dataTestId: 'rollback',
- isDisabled: false,
- validations: [new ValidatorModel(ValidatorOptions.required, 'is required')],
- value: instance ? instance.rollbackOnFailure : 'true',
- onInit: this._basicControlGenerator.getSubscribeInitResult.bind(null, this.getRollBackOnFailureOptions)
- })
- };
-
- getRollBackOnFailureOptions = (): Observable<SelectOption[]> => {
- return of([
- new SelectOption({id: 'true', name: 'Rollback'}),
- new SelectOption({id: 'false', name: 'Don\'t Rollback'})
- ]);
- };
}
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 28d49d51b..018130eec 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
@@ -2,17 +2,16 @@ import {getTestBed, TestBed} from '@angular/core/testing';
import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing';
import {NgRedux} from '@angular-redux/store';
import {FormControlNames} from "../service.control.generator";
-import {BasicControlGenerator} from "../basic.control.generator";
+import {ControlGeneratorUtil} from "../control.generator.util.service";
import {AaiService} from "../../../../services/aaiService/aai.service";
import {GenericFormService} from "../../generic-form.service";
import {FormBuilder} from "@angular/forms";
import {FormControlModel, ValidatorModel, ValidatorOptions} from "../../../../models/formControlModels/formControl.model";
import {LogService} from "../../../../utils/log/log.service";
import {VnfControlGenerator} from "./vnf.control.generator";
-import {Observable} from "rxjs";
-import {SelectOption} from "../../../../models/selectOption";
import {FeatureFlagsService} from "../../../../services/featureFlag/feature-flags.service";
import {FormControlType} from "../../../../models/formControlModels/formControlTypes.enum";
+import {SharedControllersService} from "../sharedControlles/shared.controllers.service";
class MockAppStore<T> {
getState(){
@@ -918,7 +917,8 @@ describe('VNF Control Generator', () => {
imports: [HttpClientTestingModule],
providers: [VnfControlGenerator,
GenericFormService,
- BasicControlGenerator,
+ ControlGeneratorUtil,
+ SharedControllersService,
AaiService,
FormBuilder,
LogService,
@@ -1053,15 +1053,5 @@ describe('VNF Control Generator', () => {
const instanceNameValidator: ValidatorModel = instanceNameControl.validations.find(val => val.validatorName === ValidatorOptions.pattern);
expect(instanceNameValidator.validatorArg).toEqual(/^[a-zA-Z0-9._-]*$/);
});
-
- test('rollback should return observable of true, false', () => {
- let result : Observable<SelectOption[]> = service.getRollBackOnFailureOptions();
- result.subscribe((val)=>{
- expect(val).toEqual([
- new SelectOption({id: 'true', name: 'Rollback'}),
- new SelectOption({id: 'false', name: 'Don\'t Rollback'})
- ]);
- });
- });
});
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 c45fa968f..14b31b4b7 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
@@ -3,54 +3,24 @@ 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 {BasicControlGenerator} from "../basic.control.generator";
-import {
- FormControlModel,
- ValidatorModel,
- ValidatorOptions
-} from "../../../../models/formControlModels/formControl.model";
+import {ControlGeneratorUtil} from "../control.generator.util.service";
+import {FormControlModel, ValidatorModel, ValidatorOptions} from "../../../../models/formControlModels/formControl.model";
import {LogService} from "../../../../utils/log/log.service";
import {VNFModel} from "../../../../models/vnfModel";
import {AppState} from "../../../../store/reducers";
import {FormGroup} from "@angular/forms";
-import {DropdownFormControl} from "../../../../models/formControlModels/dropdownFormControl.model";
import {FormControlType} from "../../../../models/formControlModels/formControlTypes.enum";
-import {Observable, of} from "rxjs";
-import {SelectOption} from "../../../../models/selectOption";
import * as _ from 'lodash';
-import {Constants} from "../../../../utils/constants";
import {MultiselectFormControl} from "../../../../models/formControlModels/multiselectFormControl.model";
import {MultiSelectItem} from "../../../formControls/component/multiselect/multiselect.model";
-
-export enum FormControlNames {
- INSTANCE_NAME = 'instanceName',
- GLOBAL_SUBSCRIBER_ID = 'globalSubscriberId',
- SUBSCRIPTION_SERVICE_TYPE = 'subscriptionServiceType',
- PRODUCT_FAMILY_ID = 'productFamilyId',
- LCPCLOUD_REGION_ID = 'lcpCloudRegionId',
- TENANT_ID = 'tenantId',
- AICZONE_ID = 'aicZoneId',
- PROJECT_NAME = 'projectName',
- OWNING_ENTITY_ID = 'owningEntityId',
- ROLLBACK_ON_FAILURE = 'rollbackOnFailure',
- PAUSE = 'pause'
-}
-
-enum InputType {
- LCP_REGION = "lcpCloudRegionId",
- TENANT = "tenantId",
- LOB = "lineOfBusiness",
- PLATFORM = "platformName",
- ROLLBACK = "rollbackOnFailure",
- PRODUCT_FAMILY = "productFamilyId",
- VG = "volumeGroupName"
-}
+import {SharedControllersService} from "../sharedControlles/shared.controllers.service";
@Injectable()
export class VnfControlGenerator {
aaiService: AaiService;
constructor(private genericFormService: GenericFormService,
- private _basicControlGenerator: BasicControlGenerator,
+ private _basicControlGenerator: ControlGeneratorUtil,
+ private _sharedControllersService : SharedControllersService,
private store: NgRedux<AppState>,
private http: HttpClient,
private _aaiService: AaiService,
@@ -80,12 +50,12 @@ export class VnfControlGenerator {
if (!_.isNil(vnfModel)) {
result.push(this.getInstanceName(vnfInstance, serviceId, vnfName, vnfModel.isEcompGeneratedNaming));
- result.push(this._basicControlGenerator.getProductFamilyControl(vnfInstance, result, false));
- result.push(this.getLcpRegionControl(serviceId, vnfInstance, result));
- result.push(this._basicControlGenerator.getLegacyRegion(vnfInstance));
- result.push(this.getTenantControl(serviceId, vnfInstance, result));
+ result.push(this._sharedControllersService.getProductFamilyControl(vnfInstance, result, false));
+ result.push(this._sharedControllersService.getLcpRegionControl(serviceId, vnfInstance, result));
+ result.push(this._sharedControllersService.getLegacyRegion(vnfInstance));
+ result.push(this._sharedControllersService.getTenantControl(serviceId, vnfInstance));
result.push(this.getPlatformMultiselectControl(vnfInstance, result, flags['FLAG_2002_VNF_PLATFORM_MULTI_SELECT']));
- result.push(this.getLineOfBusinessControl(vnfInstance, result));
+ result.push(this._sharedControllersService.getLineOfBusinessControl(vnfInstance));
}
return result;
}
@@ -104,45 +74,22 @@ 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._basicControlGenerator.getProductFamilyControl(vnfInstance, result, false));
- result.push(this.getLcpRegionControl(serviceId, vnfInstance, result));
- result.push(this._basicControlGenerator.getLegacyRegion(vnfInstance));
- result.push(this.getTenantControl(serviceId, vnfInstance, result));
+ result.push(this._sharedControllersService.getProductFamilyControl(vnfInstance, result, false));
+ result.push(this._sharedControllersService.getLcpRegionControl(serviceId, vnfInstance, result));
+ result.push(this._sharedControllersService.getLegacyRegion(vnfInstance));
+ result.push(this._sharedControllersService.getTenantControl(serviceId, vnfInstance));
result.push(this.getPlatformMultiselectControl(vnfInstance, result, flags['FLAG_2002_VNF_PLATFORM_MULTI_SELECT']));
- result.push(this.getLineOfBusinessControl(vnfInstance, result));
- result.push(this.getRollbackOnFailureControl(vnfInstance, result));
+ result.push(this._sharedControllersService.getLineOfBusinessControl(vnfInstance));
+ result.push(this._sharedControllersService.getRollbackOnFailureControl(vnfInstance));
}
return result;
}
- isInputShouldBeShown = (inputType: any): boolean => {
- let vnfInputs = [InputType.LCP_REGION, InputType.LOB, InputType.TENANT, InputType.PRODUCT_FAMILY, InputType.PLATFORM, InputType.ROLLBACK];
- return vnfInputs.indexOf(inputType) > -1;
- };
-
getInstanceName(instance : any, serviceId : string, vnfName : string, isEcompGeneratedNaming: boolean): FormControlModel {
const vnfModel : VNFModel = this.store.getState().service.serviceHierarchy[serviceId].vnfs[vnfName];
- return this._basicControlGenerator.getInstanceNameController(instance, serviceId, isEcompGeneratedNaming, vnfModel);
+ return this._sharedControllersService.getInstanceNameController(instance, serviceId, isEcompGeneratedNaming, vnfModel);
}
- getLineOfBusinessControl = (instance: any, controls: FormControlModel[]): DropdownFormControl => {
- return new DropdownFormControl({
- type: FormControlType.DROPDOWN,
- controlName: 'lineOfBusiness',
- displayName: 'Line of business',
- dataTestId: 'lineOfBusiness',
- placeHolder: 'Select Line Of Business',
- isDisabled: false,
- name: "lineOfBusiness",
- value: instance ? instance.lineOfBusiness : null,
- validations: [new ValidatorModel(ValidatorOptions.required, 'is required')],
- onInitSelectedField: ['lineOfBusinessList'],
- onInit: this._basicControlGenerator.getSubscribeInitResult.bind(null, this._aaiService.getCategoryParameters)
- })
- };
-
-
-
getPlatformMultiselectControl = (instance: any, controls: FormControlModel[], isMultiSelected: boolean) : MultiselectFormControl => {
return new MultiselectFormControl({
type: FormControlType.MULTI_SELECT ,
@@ -170,90 +117,4 @@ export class VnfControlGenerator {
}
});
};
-
- getTenantControl = (serviceId: string, instance: any, controls: FormControlModel[]): DropdownFormControl => {
- const service = this.store.getState().service.serviceInstance[serviceId];
- const globalCustomerId: string = service.globalSubscriberId;
- const serviceType: string = service.subscriptionServiceType;
- return new DropdownFormControl({
- type: FormControlType.DROPDOWN,
- controlName: FormControlNames.TENANT_ID,
- displayName: 'Tenant',
- dataTestId: 'tenant',
- placeHolder: 'Select Tenant',
- name: "tenant",
- isDisabled: _.isNil(instance) || _.isNil(instance.lcpCloudRegionId),
- onInitSelectedField: instance ? ['lcpRegionsTenantsMap', instance.lcpCloudRegionId] : null,
- value: instance ? instance.tenantId : null,
- validations: [new ValidatorModel(ValidatorOptions.required, 'is required')],
- onInit : instance ? this._basicControlGenerator.getSubscribeInitResult.bind(
- this._aaiService,
- this.aaiService.getLcpRegionsAndTenants.bind(this, globalCustomerId, serviceType)) : ()=>{},
- })
- };
-
- getLcpRegionControl = (serviceId: string, instance: any, controls: FormControlModel[]): DropdownFormControl => {
- const service = this.store.getState().service.serviceInstance[serviceId];
- const globalCustomerId: string = service.globalSubscriberId;
- const serviceType: string = service.subscriptionServiceType;
- return new DropdownFormControl({
- type: FormControlType.DROPDOWN,
- controlName: 'lcpCloudRegionId',
- displayName: 'LCP region',
- dataTestId: 'lcpRegion',
- placeHolder: 'Select LCP Region',
- name: "lcpRegion",
- isDisabled: false,
- value: instance ? instance.lcpCloudRegionId : null,
- validations: [new ValidatorModel(ValidatorOptions.required, 'is required')],
- onInitSelectedField: ['lcpRegionList'],
- onInit: this._basicControlGenerator.getSubscribeInitResult.bind(
- this._aaiService,
- this._aaiService.getLcpRegionsAndTenants.bind(this, globalCustomerId, serviceType)),
- onChange: (param: string, form: FormGroup) => {
- form.controls[FormControlNames.TENANT_ID].enable();
- form.controls[FormControlNames.TENANT_ID].reset();
- if (!_.isNil(globalCustomerId) && !_.isNil(serviceType)) {
- this._basicControlGenerator.getSubscribeResult.bind(this, this._aaiService.getLcpRegionsAndTenants(globalCustomerId, serviceType).subscribe(res => {
- controls.find(item => item.controlName === FormControlNames.TENANT_ID)['options$'] = res.lcpRegionsTenantsMap[param];
- if(res.lcpRegionsTenantsMap[param]){
- controls.find(item => item.controlName === FormControlNames.TENANT_ID)['hasEmptyOptions'] = res.lcpRegionsTenantsMap[param].length === 0;
- }
- }));
- }
-
- if (Constants.LegacyRegion.MEGA_REGION.indexOf(param) !== -1) {
- form.controls['legacyRegion'].enable();
- controls.find(item => item.controlName === 'legacyRegion').isVisible = true;
-
- } else {
- controls.find(item => item.controlName === 'legacyRegion').isVisible = false;
- form.controls['legacyRegion'].setValue(null);
- form.controls['legacyRegion'].reset();
- form.controls['legacyRegion'].disable();
- }
- }
- })
- };
-
- getRollbackOnFailureControl = (instance: any, controls: FormControlModel[]): DropdownFormControl => {
- return new DropdownFormControl({
- type: FormControlType.DROPDOWN,
- controlName: FormControlNames.ROLLBACK_ON_FAILURE,
- displayName: 'Rollback on failure',
- dataTestId: 'rollback',
- placeHolder: 'Rollback on failure',
- isDisabled: false,
- validations: [new ValidatorModel(ValidatorOptions.required, 'is required')],
- value: instance ? instance.rollbackOnFailure : 'true',
- onInit: this._basicControlGenerator.getSubscribeInitResult.bind(null, this.getRollBackOnFailureOptions)
- })
- };
-
- getRollBackOnFailureOptions = (): Observable<SelectOption[]> => {
- return of([
- new SelectOption({id: 'true', name: 'Rollback'}),
- new SelectOption({id: 'false', name: 'Don\'t Rollback'})
- ]);
- };
}
diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGroupGenerator/vnfGroup.control.generator.spec.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGroupGenerator/vnfGroup.control.generator.spec.ts
index 81cfd9614..c485dc04e 100644
--- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGroupGenerator/vnfGroup.control.generator.spec.ts
+++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGroupGenerator/vnfGroup.control.generator.spec.ts
@@ -2,7 +2,7 @@ import {getTestBed, TestBed} from '@angular/core/testing';
import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing';
import {NgRedux} from '@angular-redux/store';
import {FormControlNames} from "../service.control.generator";
-import {BasicControlGenerator} from "../basic.control.generator";
+import {ControlGeneratorUtil} from "../control.generator.util.service";
import {AaiService} from "../../../../services/aaiService/aai.service";
import {GenericFormService} from "../../generic-form.service";
import {FormBuilder} from "@angular/forms";
@@ -12,6 +12,7 @@ import {VnfGroupControlGenerator} from "./vnfGroup.control.generator";
import {Observable} from "rxjs";
import {SelectOption} from "../../../../models/selectOption";
import {FeatureFlagsService} from "../../../../services/featureFlag/feature-flags.service";
+import {SharedControllersService} from "../sharedControlles/shared.controllers.service";
class MockAppStore<T> {
getState(){
@@ -217,7 +218,8 @@ describe('VNF Group Control Generator', () => {
imports: [HttpClientTestingModule],
providers: [VnfGroupControlGenerator,
GenericFormService,
- BasicControlGenerator,
+ ControlGeneratorUtil,
+ SharedControllersService,
AaiService,
FormBuilder,
LogService,
diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGroupGenerator/vnfGroup.control.generator.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGroupGenerator/vnfGroup.control.generator.ts
index 45f5ffa63..0fee0c223 100644
--- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGroupGenerator/vnfGroup.control.generator.ts
+++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGroupGenerator/vnfGroup.control.generator.ts
@@ -1,7 +1,7 @@
import {Injectable} from "@angular/core";
import {AaiService} from "../../../../services/aaiService/aai.service";
import {NgRedux} from "@angular-redux/store";
-import {BasicControlGenerator} from "../basic.control.generator";
+import {ControlGeneratorUtil} from "../control.generator.util.service";
import {
FormControlModel,
ValidatorModel,
@@ -15,6 +15,7 @@ import {SelectOption} from "../../../../models/selectOption";
import {VnfGroupModel} from "../../../../models/vnfGroupModel";
import * as _ from 'lodash';
import {Observable, of} from "rxjs";
+import {SharedControllersService} from "../sharedControlles/shared.controllers.service";
export enum FormControlNames {
@@ -22,14 +23,12 @@ export enum FormControlNames {
ROLLBACK_ON_FAILURE = 'rollbackOnFailure',
}
-enum InputType {
- ROLLBACK = "rollbackOnFailure"
-}
-
@Injectable()
export class VnfGroupControlGenerator {
aaiService: AaiService;
- constructor(private _basicControlGenerator: BasicControlGenerator,
+
+ constructor(private _basicControlGenerator: ControlGeneratorUtil,
+ private _sharedControllersService: SharedControllersService,
private store: NgRedux<AppState>,
private _aaiService: AaiService,
private _logService: LogService) {
@@ -80,19 +79,14 @@ export class VnfGroupControlGenerator {
return result;
}
- isInputShouldBeShown = (inputType: any): boolean => {
- let vnfGroupInputs = [InputType.ROLLBACK];
- return vnfGroupInputs.indexOf(inputType) > -1;
- };
-
- getDefaultInstanceName(instance : any, serviceId : string, vnfGroupName : string) : string {
+ getDefaultInstanceName(instance: any, serviceId: string, vnfGroupName: string): string {
const vnfGroupModel: VnfGroupModel = this.store.getState().service.serviceHierarchy[serviceId].vnfGroups[vnfGroupName];
return this._basicControlGenerator.getDefaultInstanceName(instance, vnfGroupModel);
}
- getInstanceName(instance : any, serviceId : string, vnfGroupName : string, isEcompGeneratedNaming: boolean): FormControlModel {
- const vnfGroupModel : VnfGroupModel = this.store.getState().service.serviceHierarchy[serviceId].vnfGroups[vnfGroupName];
- return this._basicControlGenerator.getInstanceNameController(instance, serviceId, isEcompGeneratedNaming, vnfGroupModel);
+ getInstanceName(instance: any, serviceId: string, vnfGroupName: string, isEcompGeneratedNaming: boolean): FormControlModel {
+ const vnfGroupModel: VnfGroupModel = this.store.getState().service.serviceHierarchy[serviceId].vnfGroups[vnfGroupName];
+ return this._sharedControllersService.getInstanceNameController(instance, serviceId, isEcompGeneratedNaming, vnfGroupModel);
}
getRollbackOnFailureControl = (instance: any, controls: FormControlModel[]): DropdownFormControl => {
diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.service.spec.ts
index 514b9bfef..ac417ed6e 100644
--- a/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.service.spec.ts
+++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.service.spec.ts
@@ -5,7 +5,7 @@ import {GenericFormPopupService} from "./generic-form-popup.service";
import {IframeService} from "../../utils/iframe.service";
import {NgRedux} from "@angular-redux/store";
import {ServicePopupService} from "./genericFormServices/service/service.popup.service";
-import {BasicControlGenerator} from "../genericForm/formControlsServices/basic.control.generator";
+import {ControlGeneratorUtil} from "../genericForm/formControlsServices/control.generator.util.service";
import {AaiService} from "../../services/aaiService/aai.service";
import {ServiceControlGenerator} from "../genericForm/formControlsServices/service.control.generator";
import {GenericFormService} from "../genericForm/generic-form.service";
@@ -21,6 +21,7 @@ import {VfModulePopupService} from "./genericFormServices/vfModule/vfModule.popu
import {VfModuleControlGenerator} from "../genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator";
import {FeatureFlagsService} from "../../services/featureFlag/feature-flags.service";
import {VfModuleUpgradePopupService} from "./genericFormServices/vfModuleUpgrade/vfModule.upgrade.popuop.service";
+import {SharedControllersService} from "../genericForm/formControlsServices/sharedControlles/shared.controllers.service";
class MockAppStore<T>{
getState() {
@@ -958,7 +959,8 @@ describe('Generic Form popup Service', () => {
FormBuilder,
IframeService,
ServicePopupService,
- BasicControlGenerator,
+ ControlGeneratorUtil,
+ SharedControllersService,
ServiceControlGenerator,
GenericFormService,
LogService,
diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/basic.popup.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/basic.popup.service.spec.ts
index ebabc89b7..9bcc02d73 100644
--- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/basic.popup.service.spec.ts
+++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/basic.popup.service.spec.ts
@@ -1,7 +1,7 @@
import {NetworkPopupService} from "./network/network.popup.service";
import {LogService} from "../../../utils/log/log.service";
import {NgRedux} from "@angular-redux/store";
-import {BasicControlGenerator} from "../../genericForm/formControlsServices/basic.control.generator";
+import {ControlGeneratorUtil} from "../../genericForm/formControlsServices/control.generator.util.service";
import {AaiService} from "../../../services/aaiService/aai.service";
import {HttpClient} from "@angular/common/http";
import {NetworkControlGenerator} from "../../genericForm/formControlsServices/networkGenerator/network.control.generator";
@@ -1984,7 +1984,7 @@ describe('Basic popup service', () => {
TestBed.configureTestingModule({
providers : [
NetworkPopupService,
- BasicControlGenerator,
+ ControlGeneratorUtil,
NetworkControlGenerator,
DefaultDataGeneratorService,
GenericFormService,
diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/basic.popup.service.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/basic.popup.service.ts
index f8b40dd99..9340a155a 100644
--- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/basic.popup.service.ts
+++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/basic.popup.service.ts
@@ -5,7 +5,7 @@ import {AppState} from "../../../store/reducers";
import {NgRedux} from "@angular-redux/store";
import {FormControlModel} from "../../../models/formControlModels/formControl.model";
import {DefaultDataGeneratorService} from "../../../services/defaultDataServiceGenerator/default.data.generator.service";
-import {BasicControlGenerator} from "../../genericForm/formControlsServices/basic.control.generator";
+import {ControlGeneratorUtil} from "../../genericForm/formControlsServices/control.generator.util.service";
import * as _ from 'lodash';
import {VfModule} from "../../../models/vfModule";
import {VNFModel} from "../../../models/vnfModel";
@@ -18,7 +18,7 @@ import {Constants} from "../../../utils/constants";
export class BasicPopupService {
constructor(private _store: NgRedux<AppState>,
private _defaultDataGeneratorService : DefaultDataGeneratorService,
- private _basicControlGenerator : BasicControlGenerator){}
+ private _basicControlGenerator : ControlGeneratorUtil){}
extractSubscriberNameBySubscriberId(subsriberId: string) {
let result: string = null;
diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/network/network.popup.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/network/network.popup.service.spec.ts
index 67c371212..34d6850eb 100644
--- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/network/network.popup.service.spec.ts
+++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/network/network.popup.service.spec.ts
@@ -2,7 +2,7 @@ import {NetworkPopupService} from "./network.popup.service";
import {LogService} from "../../../../utils/log/log.service";
import {SdcUiServices} from "onap-ui-angular";
import {NgRedux} from "@angular-redux/store";
-import {BasicControlGenerator} from "../../../genericForm/formControlsServices/basic.control.generator";
+import {ControlGeneratorUtil} from "../../../genericForm/formControlsServices/control.generator.util.service";
import {AaiService} from "../../../../services/aaiService/aai.service";
import {HttpClient} from "@angular/common/http";
import {NetworkControlGenerator} from "../../../genericForm/formControlsServices/networkGenerator/network.control.generator";
@@ -13,6 +13,7 @@ import {DefaultDataGeneratorService} from "../../../../services/defaultDataServi
import {BasicPopupService} from "../basic.popup.service";
import {FeatureFlagsService} from "../../../../services/featureFlag/feature-flags.service";
import {getTestBed, TestBed} from "@angular/core/testing";
+import {SharedControllersService} from "../../../genericForm/formControlsServices/sharedControlles/shared.controllers.service";
class MockAppStore<T> {}
@@ -1987,7 +1988,8 @@ describe('Network popup service', () => {
TestBed.configureTestingModule({
providers : [
NetworkPopupService,
- BasicControlGenerator,
+ ControlGeneratorUtil,
+ SharedControllersService,
NetworkControlGenerator,
DefaultDataGeneratorService,
GenericFormService,
diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/network/network.popup.service.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/network/network.popup.service.ts
index a352e770f..ff444f087 100644
--- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/network/network.popup.service.ts
+++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/network/network.popup.service.ts
@@ -1,6 +1,6 @@
import {Injectable} from "@angular/core";
import {FormPopupDetails, PopupType} from "../../../../models/formControlModels/formPopupDetails.model";
-import {BasicControlGenerator} from "../../../genericForm/formControlsServices/basic.control.generator";
+import {ControlGeneratorUtil} from "../../../genericForm/formControlsServices/control.generator.util.service";
import {NetworkInstance} from "../../../../models/networkInstance";
import {AppState} from "../../../../store/reducers";
import {NgRedux} from "@angular-redux/store";
@@ -33,7 +33,7 @@ export class NetworkPopupService implements GenericPopupInterface {
isUpdateMode: boolean;
- constructor(private _basicControlGenerator: BasicControlGenerator,
+ constructor(private _basicControlGenerator: ControlGeneratorUtil,
private _networkControlGenerator: NetworkControlGenerator,
private _iframeService: IframeService,
private _defaultDataGeneratorService: DefaultDataGeneratorService,
diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/service/service.popup.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/service/service.popup.service.spec.ts
index ebea695f7..0ce051cf4 100644
--- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/service/service.popup.service.spec.ts
+++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/service/service.popup.service.spec.ts
@@ -1,6 +1,6 @@
import {LogService} from "../../../../utils/log/log.service";
import {NgRedux} from "@angular-redux/store";
-import {BasicControlGenerator} from "../../../genericForm/formControlsServices/basic.control.generator";
+import {ControlGeneratorUtil} from "../../../genericForm/formControlsServices/control.generator.util.service";
import {AaiService} from "../../../../services/aaiService/aai.service";
import {HttpClient} from "@angular/common/http";
import {GenericFormService} from "../../../genericForm/generic-form.service";
@@ -14,6 +14,7 @@ import {FormControlModel} from "../../../../models/formControlModels/formControl
import {SdcUiServices} from "onap-ui-angular";
import {FeatureFlagsService} from "../../../../services/featureFlag/feature-flags.service";
import {getTestBed, TestBed} from "@angular/core/testing";
+import {SharedControllersService} from "../../../genericForm/formControlsServices/sharedControlles/shared.controllers.service";
class MockModalService<T> {}
@@ -2053,8 +2054,9 @@ describe('Service popup service', () => {
TestBed.configureTestingModule({
providers : [
ServicePopupService,
- BasicControlGenerator,
+ ControlGeneratorUtil,
ServiceControlGenerator,
+ SharedControllersService,
DefaultDataGeneratorService,
GenericFormService,
FormBuilder,
diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/service/service.popup.service.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/service/service.popup.service.ts
index 3e7e8c1e5..d25ab2c7f 100644
--- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/service/service.popup.service.ts
+++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/service/service.popup.service.ts
@@ -5,7 +5,7 @@ import {ModelInformationItem} from "../../../model-information/model-information
import {Subject} from "rxjs";
import {ITreeNode} from "angular-tree-component/dist/defs/api";
import {FormPopupDetails, PopupType} from "../../../../models/formControlModels/formPopupDetails.model";
-import {BasicControlGenerator} from "../../../genericForm/formControlsServices/basic.control.generator";
+import {ControlGeneratorUtil} from "../../../genericForm/formControlsServices/control.generator.util.service";
import {IframeService} from "../../../../utils/iframe.service";
import {DefaultDataGeneratorService} from "../../../../services/defaultDataServiceGenerator/default.data.generator.service";
import {AaiService} from "../../../../services/aaiService/aai.service";
@@ -35,7 +35,7 @@ export class ServicePopupService implements GenericPopupInterface {
- constructor(private _basicControlGenerator: BasicControlGenerator,
+ constructor(private _basicControlGenerator: ControlGeneratorUtil,
private _serviceControlGenerator: ServiceControlGenerator,
private _iframeService: IframeService,
private _defaultDataGeneratorService: DefaultDataGeneratorService,
diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service.spec.ts
index 935454752..b16c5bdc0 100644
--- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service.spec.ts
+++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service.spec.ts
@@ -1,6 +1,6 @@
import {LogService} from "../../../../utils/log/log.service";
import {NgRedux} from "@angular-redux/store";
-import {BasicControlGenerator} from "../../../genericForm/formControlsServices/basic.control.generator";
+import {ControlGeneratorUtil} from "../../../genericForm/formControlsServices/control.generator.util.service";
import {AaiService} from "../../../../services/aaiService/aai.service";
import {HttpClient} from "@angular/common/http";
import {GenericFormService} from "../../../genericForm/generic-form.service";
@@ -13,6 +13,7 @@ import {VfModuleControlGenerator} from "../../../genericForm/formControlsService
import {SdcUiServices} from "onap-ui-angular";
import {FeatureFlagsService} from "../../../../services/featureFlag/feature-flags.service";
import {getTestBed, TestBed} from "@angular/core/testing";
+import {SharedControllersService} from "../../../genericForm/formControlsServices/sharedControlles/shared.controllers.service";
class MockModalService<T> {}
@@ -1982,7 +1983,8 @@ describe('VFModule popup service', () => {
TestBed.configureTestingModule({
providers : [
VfModulePopupService,
- BasicControlGenerator,
+ ControlGeneratorUtil,
+ SharedControllersService,
VfModuleControlGenerator,
DefaultDataGeneratorService,
GenericFormService,
diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service.ts
index 6a31bb7ee..18dc65590 100644
--- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service.ts
+++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service.ts
@@ -1,6 +1,6 @@
import {Injectable} from "@angular/core";
import {FormPopupDetails, PopupType} from "../../../../models/formControlModels/formPopupDetails.model";
-import {BasicControlGenerator} from "../../../genericForm/formControlsServices/basic.control.generator";
+import {ControlGeneratorUtil} from "../../../genericForm/formControlsServices/control.generator.util.service";
import {AppState} from "../../../../store/reducers";
import {NgRedux} from "@angular-redux/store";
import {ITreeNode} from "angular-tree-component/dist/defs/api";
@@ -20,6 +20,7 @@ import {VfModuleControlGenerator} from "../../../genericForm/formControlsService
import {FormControlModel} from "../../../../models/formControlModels/formControl.model";
import * as _ from 'lodash';
import {createVFModuleInstance, updateVFModuleInstance} from "../../../../storeUtil/utils/vfModule/vfModule.actions";
+import {SharedControllersService} from "../../../genericForm/formControlsServices/sharedControlles/shared.controllers.service";
export abstract class VfModulePopupServiceBase {
dynamicInputs: any;
@@ -43,7 +44,8 @@ export abstract class VfModulePopupServiceBase {
};
protected constructor(
- protected _basicControlGenerator: BasicControlGenerator,
+ protected _basicControlGenerator: ControlGeneratorUtil,
+ protected _sharedControllersService : SharedControllersService,
protected _vfModuleControlGenerator: VfModuleControlGenerator,
protected _iframeService: IframeService,
protected _defaultDataGeneratorService: DefaultDataGeneratorService,
@@ -156,14 +158,15 @@ export abstract class VfModulePopupServiceBase {
export class VfModulePopupService extends VfModulePopupServiceBase implements GenericPopupInterface {
- constructor(_basicControlGenerator: BasicControlGenerator,
+ constructor(_basicControlGenerator: ControlGeneratorUtil,
+ _sharedControllersService : SharedControllersService,
_vfModuleControlGenerator: VfModuleControlGenerator,
_iframeService: IframeService,
_defaultDataGeneratorService: DefaultDataGeneratorService,
_aaiService: AaiService,
_basicPopupService : BasicPopupService,
_store: NgRedux<AppState>) {
- super(_basicControlGenerator, _vfModuleControlGenerator, _iframeService, _defaultDataGeneratorService, _aaiService, _basicPopupService, _store);
+ super(_basicControlGenerator, _sharedControllersService, _vfModuleControlGenerator, _iframeService, _defaultDataGeneratorService, _aaiService, _basicPopupService, _store);
}
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 667e79678..5181318dc 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
@@ -6,7 +6,7 @@ import {upgradeVFModule} from "../../../../storeUtil/utils/vfModule/vfModule.act
import {SharedTreeService} from "../../../../../drawingBoard/service-planning/objectsToTree/shared.tree.service";
import {NgRedux} from "@angular-redux/store";
import {AppState} from "../../../../store/reducers";
-import {BasicControlGenerator} from "../../../genericForm/formControlsServices/basic.control.generator";
+import {ControlGeneratorUtil} from "../../../genericForm/formControlsServices/control.generator.util.service";
import {VfModuleControlGenerator} from "../../../genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator";
import {IframeService} from "../../../../utils/iframe.service";
import {DefaultDataGeneratorService} from "../../../../services/defaultDataServiceGenerator/default.data.generator.service";
@@ -18,6 +18,7 @@ import {FormControlType} from "../../../../models/formControlModels/formControlT
import {mergeObjectByPathAction} from "../../../../storeUtil/utils/general/general.actions";
import * as _ from "lodash";
import {VfModuleInstance} from "../../../../models/vfModuleInstance";
+import {SharedControllersService} from "../../../genericForm/formControlsServices/sharedControlles/shared.controllers.service";
export enum UpgradeFormControlNames {
RETAIN_VOLUME_GROUPS = 'retainVolumeGroups',
@@ -26,7 +27,8 @@ export enum UpgradeFormControlNames {
@Injectable()
export class VfModuleUpgradePopupService extends VfModulePopupServiceBase {
- constructor(protected _basicControlGenerator: BasicControlGenerator,
+ constructor(protected _basicControlGenerator: ControlGeneratorUtil,
+ protected _sharedControllersService : SharedControllersService,
protected _vfModuleControlGenerator: VfModuleControlGenerator,
protected _iframeService: IframeService,
protected _defaultDataGeneratorService: DefaultDataGeneratorService,
@@ -34,7 +36,7 @@ export class VfModuleUpgradePopupService extends VfModulePopupServiceBase {
protected _basicPopupService: BasicPopupService,
protected _store: NgRedux<AppState>,
private _sharedTreeService: SharedTreeService) {
- super(_basicControlGenerator, _vfModuleControlGenerator, _iframeService, _defaultDataGeneratorService, _aaiService, _basicPopupService, _store);
+ super(_basicControlGenerator, _sharedControllersService, _vfModuleControlGenerator, _iframeService, _defaultDataGeneratorService, _aaiService, _basicPopupService, _store);
}
node: ITreeNode;
@@ -44,7 +46,7 @@ export class VfModuleUpgradePopupService extends VfModulePopupServiceBase {
getControls(serviceId: string, vnfStoreKey: string, vfModuleStoreKey: string, isUpdateMode: boolean): FormControlModel[] {
let result: FormControlModel[] =[
this.getRetainAssignmentsControl(),
- this._basicControlGenerator.getSDNCControl(null)
+ this._sharedControllersService.getSDNCControl(null)
];
const vfModuleInstance :VfModuleInstance = this._vfModuleControlGenerator.getVfModuleInstance(serviceId, vnfStoreKey, this.uuidData, isUpdateMode);
if(this._store.getState().service.serviceHierarchy[serviceId].vfModules[this.uuidData['modelName']].volumeGroupAllowed){
diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popup.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popup.service.spec.ts
index 4003b4dcc..2ca992f08 100644
--- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popup.service.spec.ts
+++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popup.service.spec.ts
@@ -1,10 +1,10 @@
import {LogService} from "../../../../utils/log/log.service";
import {NgRedux} from "@angular-redux/store";
import {
- BasicControlGenerator,
+ ControlGeneratorUtil,
SDN_C_PRE_LOAD,
SUPPLEMENTARY_FILE
-} from "../../../genericForm/formControlsServices/basic.control.generator";
+} from "../../../genericForm/formControlsServices/control.generator.util.service";
import {AaiService} from "../../../../services/aaiService/aai.service";
import {HttpClient} from "@angular/common/http";
import {GenericFormService} from "../../../genericForm/generic-form.service";
@@ -25,6 +25,7 @@ import {VfModuleActions} from "../../../../storeUtil/utils/vfModule/vfModule.act
import {ServiceActions} from "../../../../storeUtil/utils/service/service.actions";
import {FormControlModel} from "../../../../models/formControlModels/formControl.model";
import * as _ from "lodash";
+import {SharedControllersService} from "../../../genericForm/formControlsServices/sharedControlles/shared.controllers.service";
class MockModalService<T> {}
@@ -72,7 +73,8 @@ describe('VFModule popup service', () => {
TestBed.configureTestingModule({
providers: [
VfModuleUpgradePopupService,
- BasicControlGenerator,
+ ControlGeneratorUtil,
+ SharedControllersService,
VfModuleControlGenerator,
DefaultDataGeneratorService,
GenericFormService,
diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service.spec.ts
index 60f0f361e..6d5cf7cfe 100644
--- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service.spec.ts
+++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service.spec.ts
@@ -9,12 +9,13 @@ import {AaiService} from "../../../../services/aaiService/aai.service";
import {LogService} from "../../../../utils/log/log.service";
import {HttpClient} from "@angular/common/http";
import {VnfPopupService} from "./vnf.popup.service";
-import {BasicControlGenerator} from "../../../genericForm/formControlsServices/basic.control.generator";
+import {ControlGeneratorUtil} from "../../../genericForm/formControlsServices/control.generator.util.service";
import {VnfControlGenerator} from "../../../genericForm/formControlsServices/vnfGenerator/vnf.control.generator";
import {UUIDData} from "../../generic-form-popup.component";
import {FeatureFlagsService} from "../../../../services/featureFlag/feature-flags.service";
import {getTestBed, TestBed} from "@angular/core/testing";
import {VfModuleUpgradePopupService} from "../vfModuleUpgrade/vfModule.upgrade.popuop.service";
+import {SharedControllersService} from "../../../genericForm/formControlsServices/sharedControlles/shared.controllers.service";
class MockAppStore<T> {}
@@ -2260,7 +2261,8 @@ describe('vnf new popup service', () => {
BasicPopupService,
VfModulePopupService,
VfModuleUpgradePopupService,
- BasicControlGenerator,
+ ControlGeneratorUtil,
+ SharedControllersService,
VnfControlGenerator,
{provide: NgRedux, useClass: MockReduxStore},
{provide: HttpClient, useClass: MockAppStore},
diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service.ts
index 3e117ca74..2748b04c9 100644
--- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service.ts
+++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service.ts
@@ -6,7 +6,7 @@ import {FormGroup} from "@angular/forms";
import {ModelInformationItem} from "../../../model-information/model-information.component";
import {ServiceModel} from "../../../../models/serviceModel";
import {Subject} from "rxjs/Subject";
-import {BasicControlGenerator} from "../../../genericForm/formControlsServices/basic.control.generator";
+import {ControlGeneratorUtil} from "../../../genericForm/formControlsServices/control.generator.util.service";
import {VnfControlGenerator} from "../../../genericForm/formControlsServices/vnfGenerator/vnf.control.generator";
import {IframeService} from "../../../../utils/iframe.service";
import {DefaultDataGeneratorService} from "../../../../services/defaultDataServiceGenerator/default.data.generator.service";
@@ -34,7 +34,7 @@ export class VnfPopupService implements GenericPopupInterface{
isUpdateMode: boolean;
constructor(
- private _basicControlGenerator: BasicControlGenerator,
+ private _basicControlGenerator: ControlGeneratorUtil,
private _vnfControlGenerator: VnfControlGenerator,
private _iframeService: IframeService,
private _defaultDataGeneratorService: DefaultDataGeneratorService,
diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnfGroup/vnfGroup.popup.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnfGroup/vnfGroup.popup.service.spec.ts
index 8ee48e675..4c6db2cb5 100644
--- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnfGroup/vnfGroup.popup.service.spec.ts
+++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnfGroup/vnfGroup.popup.service.spec.ts
@@ -8,13 +8,14 @@ import {BasicPopupService} from "../basic.popup.service";
import {AaiService} from "../../../../services/aaiService/aai.service";
import {LogService} from "../../../../utils/log/log.service";
import {HttpClient} from "@angular/common/http";
-import {BasicControlGenerator} from "../../../genericForm/formControlsServices/basic.control.generator";
+import {ControlGeneratorUtil} from "../../../genericForm/formControlsServices/control.generator.util.service";
import {UUIDData} from "../../generic-form-popup.component";
import {FeatureFlagsService} from "../../../../services/featureFlag/feature-flags.service";
import {VnfGroupPopupService} from "./vnfGroup.popup.service";
import {VnfGroupControlGenerator} from "../../../genericForm/formControlsServices/vnfGroupGenerator/vnfGroup.control.generator";
import {getTestBed, TestBed} from "@angular/core/testing";
import {VfModuleUpgradePopupService} from "../vfModuleUpgrade/vfModule.upgrade.popuop.service";
+import {SharedControllersService} from "../../../genericForm/formControlsServices/sharedControlles/shared.controllers.service";
class MockAppStore<T> {}
@@ -2257,7 +2258,8 @@ describe('vnf group new popup service', () => {
BasicPopupService,
VfModulePopupService,
VfModuleUpgradePopupService,
- BasicControlGenerator,
+ ControlGeneratorUtil,
+ SharedControllersService,
VnfGroupControlGenerator,
{provide: NgRedux, useClass: MockReduxStore},
{provide: HttpClient, useClass: MockAppStore}]
diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnfGroup/vnfGroup.popup.service.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnfGroup/vnfGroup.popup.service.ts
index 851d5d514..14512d3d8 100644
--- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnfGroup/vnfGroup.popup.service.ts
+++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnfGroup/vnfGroup.popup.service.ts
@@ -6,7 +6,7 @@ import {FormGroup} from "@angular/forms";
import {ModelInformationItem} from "../../../model-information/model-information.component";
import {ServiceModel} from "../../../../models/serviceModel";
import {Subject} from "rxjs/Subject";
-import {BasicControlGenerator} from "../../../genericForm/formControlsServices/basic.control.generator";
+import {ControlGeneratorUtil} from "../../../genericForm/formControlsServices/control.generator.util.service";
import {IframeService} from "../../../../utils/iframe.service";
import {DefaultDataGeneratorService} from "../../../../services/defaultDataServiceGenerator/default.data.generator.service";
import {AaiService} from "../../../../services/aaiService/aai.service";
@@ -34,7 +34,7 @@ export class VnfGroupPopupService implements GenericPopupInterface{
isUpdateMode: boolean;
constructor(
- private _basicControlGenerator: BasicControlGenerator,
+ private _basicControlGenerator: ControlGeneratorUtil,
private _vnfGroupControlGenerator: VnfGroupControlGenerator,
private _iframeService: IframeService,
private _defaultDataGeneratorService: DefaultDataGeneratorService,
diff --git a/vid-webpack-master/src/app/shared/shared.module.ts b/vid-webpack-master/src/app/shared/shared.module.ts
index 0f7c92060..f95f86149 100644
--- a/vid-webpack-master/src/app/shared/shared.module.ts
+++ b/vid-webpack-master/src/app/shared/shared.module.ts
@@ -32,7 +32,7 @@ import {CheckboxFormControlComponent} from "./components/formControls/component/
import {GenericFormService} from "./components/genericForm/generic-form.service";
import {GenericFormComponent} from "./components/genericForm/generic-form.component";
import {ServiceControlGenerator} from "./components/genericForm/formControlsServices/service.control.generator";
-import {BasicControlGenerator} from "./components/genericForm/formControlsServices/basic.control.generator";
+import {ControlGeneratorUtil} from "./components/genericForm/formControlsServices/control.generator.util.service";
import {CustomValidators} from "./validators/uniqueName/uniqueName.validator";
import {FileFormControlComponent} from "./components/formControls/component/file/file.formControl.component";
import {NumberFormControlComponent} from "./components/formControls/component/number/number.formControl.component";
@@ -79,6 +79,7 @@ import {InstantiationTemplatesModalService} from "./components/genericFormPopup/
import {SearchFilterPipe} from "./pipes/searchFilter/search-filter.pipe";
import {RecreateResolver} from "./resolvers/recreate/recreate.resolver";
import {InstantiationTemplatesService} from "./services/templateService/instantiationTemplates.service";
+import {SharedControllersService} from "./components/genericForm/formControlsServices/sharedControlles/shared.controllers.service";
@NgModule({
@@ -190,7 +191,8 @@ import {InstantiationTemplatesService} from "./services/templateService/instanti
ServicePopupService,
VnfControlGenerator,
VfModuleControlGenerator,
- BasicControlGenerator,
+ ControlGeneratorUtil,
+ SharedControllersService,
CustomValidators,
NetworkPopupService,
VfModulePopupService,