aboutsummaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/shared/components/genericFormPopup
diff options
context:
space:
mode:
authorMateusz Gołuchowski <mateusz.goluchowski@nokia.com>2020-10-07 12:06:13 +0200
committerMateusz Gołuchowski <mateusz.goluchowski@nokia.com>2020-10-08 13:45:58 +0200
commit1b93f300bda8e435954d93bc4088429ec28c34c0 (patch)
treeea1172a667d32ea9a890212bf0650230b0c0e559 /vid-webpack-master/src/app/shared/components/genericFormPopup
parent226ef715d7afe3758fbc88c05cf4d752c6bed51b (diff)
VID - Feature flag for PNF in modern UI
This task is about introducing new feature flag: FLAG_EXTENDED_MACRO_PNF_CONFIG, which will allow to choose different PNF implementations. Main changes when flag is ON: - Modern UI will be used for instantiation of macro service with pnfs - There will be possibility to add instance of PNF in drawing board but this concerns only macro services For now "plus" icon on PNF generates new popup window but it is still impossible to add it as a new resource to service. This functionality will be implemented soon. Issue-ID: VID-694 Change-Id: I375db2104687f1f634adac31d4d1af3675f5911c Signed-off-by: Mateusz Goluchowski <mateusz.goluchowski@nokia.com>
Diffstat (limited to 'vid-webpack-master/src/app/shared/components/genericFormPopup')
-rw-r--r--vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.component.ts1
-rw-r--r--vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.service.ts10
-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/pnf/pnf.popup.service.ts139
-rw-r--r--vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service.spec.ts2
5 files changed, 156 insertions, 0 deletions
diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.component.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.component.ts
index 1d8d827df..d43434e52 100644
--- a/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.component.ts
+++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.component.ts
@@ -27,6 +27,7 @@ export interface PopupModel {
export enum PopupType {
SERVICE = 'service',
VNF = 'vnf',
+ PNF = 'pnf',
NETWORK = 'network',
VF_MODULE = 'vf_module',
VF_MODULE_UPGRADE = 'vf_module_upgrade',
diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.service.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.service.ts
index e3cdaef85..f8ff222f7 100644
--- a/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.service.ts
+++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.service.ts
@@ -54,6 +54,16 @@ export class GenericFormPopupService {
isUpdateMode
);
}
+ case 'PNF' : {
+ return uuidData.popupService.getGenericFormPopupDetails(
+ uuidData['serviceId'],
+ uuidData['modelName'],
+ uuidData['pnfStoreKey'],
+ node,
+ uuidData,
+ isUpdateMode
+ );
+ }
case 'VnfGroup' : {
return uuidData.popupService.getGenericFormPopupDetails(
uuidData['serviceId'],
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 9340a155a..dfc9a9d9d 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
@@ -13,6 +13,7 @@ import {VnfGroupModel} from "../../../models/vnfGroupModel";
import {FeatureFlagsService} from "../../../services/featureFlag/feature-flags.service";
import {ModelInformationItem} from "../../model-information/model-information.component";
import {Constants} from "../../../utils/constants";
+import {PNFModel} from "../../../models/pnfModel";
@Injectable()
export class BasicPopupService {
@@ -39,6 +40,9 @@ export class BasicPopupService {
case 'vnfs' : {
return new VNFModel(rawModel, flags);
}
+ case 'pnfs' : {
+ return new PNFModel(rawModel);
+ }
case 'vfModules' : {
return new VfModule(rawModel, flags);
}
diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/pnf/pnf.popup.service.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/pnf/pnf.popup.service.ts
new file mode 100644
index 000000000..c4f1b2eea
--- /dev/null
+++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/pnf/pnf.popup.service.ts
@@ -0,0 +1,139 @@
+import {Injectable} from '@angular/core';
+import {GenericPopupInterface} from "../generic-popup.interface";
+import {ITreeNode} from "angular-tree-component/dist/defs/api";
+import {FormPopupDetails, PopupType} from "../../../../models/formControlModels/formPopupDetails.model";
+import {FormGroup} from "@angular/forms";
+import {ModelInformationItem} from "../../../model-information/model-information.component";
+import {ServiceModel} from "../../../../models/serviceModel";
+import {Subject} from "rxjs/Subject";
+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";
+import {BasicPopupService} from "../basic.popup.service";
+import {NgRedux} from "@angular-redux/store";
+import {AppState} from "../../../../store/reducers";
+import {Subscriber} from "../../../../models/subscriber";
+import {Constants} from "../../../../utils/constants";
+import {PnfInstance} from "../../../../models/pnfInstance";
+import * as _ from 'lodash';
+
+@Injectable()
+export class PnfPopupService implements GenericPopupInterface{
+ dynamicInputs: any;
+ instance: any;
+ model:any;
+ serviceModel:ServiceModel;
+ modelInformations: ModelInformationItem[] = [];
+ uuidData: Object;
+ closeDialogEvent: Subject<any> = new Subject<any>();
+ isUpdateMode: boolean;
+
+ constructor(
+ private _basicControlGenerator: ControlGeneratorUtil,
+ private _iframeService: IframeService,
+ private _defaultDataGeneratorService: DefaultDataGeneratorService,
+ private _aaiService: AaiService,
+ private _basicPopupService: BasicPopupService,
+ private _store: NgRedux<AppState>) {
+ }
+
+ getGenericFormPopupDetails(serviceId: string, modelName: string, pnfStoreKey: string, node: ITreeNode, uuidData: Object, isUpdateMode: boolean): FormPopupDetails {
+ this.uuidData = uuidData;
+ this.isUpdateMode = isUpdateMode;
+ this.instance = this.getInstance(serviceId, modelName, pnfStoreKey);
+ this.getModelInformation(serviceId, modelName);
+
+ return new FormPopupDetails(this,
+ PopupType.PNF_MACRO,
+ uuidData,
+ this.getTitle(isUpdateMode),
+ this.getSubLeftTitle(),
+ this.getSubRightTitle(),
+ this.getControls(serviceId, modelName, pnfStoreKey),
+ this._basicPopupService.getDynamicInputs(serviceId, modelName, pnfStoreKey, 'pnfs'),
+ this.modelInformations,
+ (that, form: FormGroup) => {that.onSubmit(that, form);},
+ (that: any, form: FormGroup) => {that.onCancel(that, form); }
+ )
+ }
+
+ getControls(serviceId: string, modelName: string, pnfStoreKey: string){
+ return [];
+ }
+
+ getInstance(serviceId: string, modelName: string, pnfStoreKey: string): any {
+ if(_.isNil(pnfStoreKey)){
+ return new PnfInstance();
+ }
+ return this._store.getState().service.serviceInstance[serviceId].pnfs[pnfStoreKey];
+ }
+
+ getModelInformation(serviceId: string, modelName: string): void {
+ this._aaiService.getServiceModelById(serviceId).subscribe((result: any) => {
+ this.serviceModel = new ServiceModel(result);
+ this.model = this._basicPopupService.getModelFromResponse(result, 'pnfs', modelName);
+ const serviceInstance = this._store.getState().service.serviceInstance[serviceId];
+ this.modelInformations = [
+ new ModelInformationItem("Subscriber Name", "subscriberName", [this.extractSubscriberNameBySubscriberId(serviceInstance.globalSubscriberId, this._store)], "", true),
+ new ModelInformationItem("Service Name", "serviceModelName", [this.serviceModel.name], "", true),
+ new ModelInformationItem("Service Instance Name", "serviceName", [serviceInstance.instanceName], "", false),
+ new ModelInformationItem("Model Name", "modelName", [this.model.name], "", true),
+ new ModelInformationItem("Model version", "modelVersion", [this.model.version], "", true),
+ new ModelInformationItem("Description", "description", [this.model.description]),
+ new ModelInformationItem("Category", "category", [this.model.category]),
+ new ModelInformationItem("Sub Category", "subCategory", [this.model.subCategory]),
+ new ModelInformationItem("UUID", "uuid", [this.model.uuid], Constants.ServicePopup.TOOLTIP_UUID, true),
+ new ModelInformationItem("Invariant UUID", "invariantUuid", [this.model.invariantUuid], Constants.ServicePopup.TOOLTIP_INVARIANT_UUID, true),
+ new ModelInformationItem("Service type", "serviceType", [this.serviceModel.serviceType]),
+ new ModelInformationItem("Service role", "serviceRole", [this.serviceModel.serviceRole]),
+ new ModelInformationItem("Minimum to instantiate", "min", [!_.isNil(this.model.min) ? this.model.min.toString() : '0'], "", false),
+ this._basicPopupService.createMaximumToInstantiateModelInformationItem(this.model)
+ ];
+ })
+ }
+
+ getSubLeftTitle(): string {
+ return "PNF MODEL: " + this._store.getState().service.serviceHierarchy[this.uuidData['serviceId']].pnfs[this.uuidData['modelName']].name;
+ }
+
+ getSubRightTitle(): string {
+ return "PNF Instance Details";
+ }
+
+ storePNF = (that, formValues: any): void => {};
+
+ getTitle(isUpdateMode: boolean): string {
+ return isUpdateMode ? "Edit PNF instance": "Set a new PNF" ;
+ }
+
+ onCancel(that, form): void {
+ form.reset();
+ that._iframeService.removeClassCloseModal('content');
+ this.closeDialogEvent.next(that);
+ }
+
+ onSubmit(that, form: FormGroup, ...args): void {
+ form.value['instanceParams'] = form.value['instanceParams'] && [form.value['instanceParams']];
+ that.storePNF(that, form.value);
+ window.parent.postMessage( {
+ eventId: 'submitIframe',
+ data: {
+ serviceModelId: that.uuidData.serviceId
+ }
+ }, "*");
+ that.onCancel(that, form);
+ }
+
+ extractSubscriberNameBySubscriberId(subscriberId: string, store: NgRedux<AppState>) {
+ let result: string = null;
+ let filteredArray: any = _.filter(store.getState().service.subscribers, function (o: Subscriber) {
+ return o.id === subscriberId
+ });
+ if (filteredArray.length > 0) {
+ result = filteredArray[0].name;
+ }
+ return result;
+ }
+
+}
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 6d5cf7cfe..12ae813eb 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
@@ -16,6 +16,7 @@ import {FeatureFlagsService} from "../../../../services/featureFlag/feature-flag
import {getTestBed, TestBed} from "@angular/core/testing";
import {VfModuleUpgradePopupService} from "../vfModuleUpgrade/vfModule.upgrade.popuop.service";
import {SharedControllersService} from "../../../genericForm/formControlsServices/sharedControlles/shared.controllers.service";
+import { PnfPopupService } from "../pnf/pnf.popup.service";
class MockAppStore<T> {}
@@ -2251,6 +2252,7 @@ describe('vnf new popup service', () => {
TestBed.configureTestingModule({
providers : [
VnfPopupService,
+ PnfPopupService,
DefaultDataGeneratorService,
GenericFormService,
FormBuilder,