aboutsummaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator.ts
diff options
context:
space:
mode:
Diffstat (limited to 'vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator.ts')
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator.ts173
1 files changed, 17 insertions, 156 deletions
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'})
- ]);
- };
}