summaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/shared
diff options
context:
space:
mode:
Diffstat (limited to 'vid-webpack-master/src/app/shared')
-rw-r--r--vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.component.html2
-rw-r--r--vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.component.scss2
-rw-r--r--vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.component.ts56
-rw-r--r--vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/basic.popup.service.ts2
-rw-r--r--vid-webpack-master/src/app/shared/models/vfModule.ts5
-rw-r--r--vid-webpack-master/src/app/shared/utils/util.spec.ts40
-rw-r--r--vid-webpack-master/src/app/shared/utils/utils.ts15
7 files changed, 71 insertions, 51 deletions
diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.component.html b/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.component.html
index f9da42607..f9a11eab1 100644
--- a/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.component.html
+++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.component.html
@@ -61,7 +61,7 @@
(click)="openTemplateModal()"
><span>Template</span></button>
<button
- *ngIf=isInstantiationStatusFilterFlagOn()
+ *ngIf="isShowPreviousInstantiationBtn"
[attr.data-tests-id]="'ShowPreviousInstancesButton'"
type="button" class="btn btn-success submit"
(click)="formPopupDetails.onOtherAction(formPopupDetails.that, dynamicForm)">
diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.component.scss b/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.component.scss
index 5057b44a5..18416dae6 100644
--- a/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.component.scss
+++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.component.scss
@@ -134,7 +134,7 @@ $grid-border: 1px #d2d2d2 solid;
}
.submit {
- width: 120px;
+ min-width: 120px;
height: 36px;
background: #009fdb;
border-radius: 2px;
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 159871f45..3939e44ff 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
@@ -46,6 +46,7 @@ export class GenericFormPopupComponent extends DialogComponent<PopupModel, boole
type: PopupType;
uuidData: UUIDData;
showTemplateBtn: boolean = false;
+ isShowPreviousInstantiationBtn: boolean = false;
isUpdateMode: boolean;
node: ITreeNode = null;
hasGeneralApiError: boolean = false;
@@ -85,29 +86,7 @@ export class GenericFormPopupComponent extends DialogComponent<PopupModel, boole
.subscribe(params => {
console.log('changed');
if (params['serviceModelId'] && params['isCreate'] == "true") {
- this._genericFormPopupService.initReduxOnCreateNewService().then((serviceModelId: string) => {
- this.uuidData = <any>{
- bulkSize: 1,
- isMacro: this._store.getState().service.serviceHierarchy[serviceModelId].service.vidNotions.instantiationType === 'Macro',
- type: PopupType.SERVICE,
- serviceId: serviceModelId,
- popupService: this._servicePopupService,
- };
- this.showTemplateBtn = !!this._store.getState().global.flags["FLAG_2004_INSTANTIATION_TEMPLATES_POPUP"];
-
- this.uuidData.popupService.closeDialogEvent.subscribe((that) => {
- this.closeDialog(that);
- });
-
- this.formPopupDetails = this.uuidData.popupService.getGenericFormPopupDetails(
- this.uuidData['serviceId'],
- null,
- null,
- this.node,
- this.uuidData,
- false
- );
- });
+ this.onInitForCreateNewServicePopup();
}
});
@@ -125,6 +104,34 @@ export class GenericFormPopupComponent extends DialogComponent<PopupModel, boole
}
}
+ private onInitForCreateNewServicePopup() {
+ this._genericFormPopupService.initReduxOnCreateNewService().then((serviceModelId: string) => {
+ this.uuidData = <any>{
+ bulkSize: 1,
+ isMacro: this._store.getState().service.serviceHierarchy[serviceModelId].service.vidNotions.instantiationType === 'Macro',
+ type: PopupType.SERVICE,
+ serviceId: serviceModelId,
+ popupService: this._servicePopupService,
+ };
+ this.showTemplateBtn = !!this._store.getState().global.flags["FLAG_2004_INSTANTIATION_TEMPLATES_POPUP"];
+
+ this.isShowPreviousInstantiationBtn = !!this._store.getState().global.flags["FLAG_2004_TEMP_BUTTON_TO_INSTANTIATION_STATUS_FILTER"];
+
+ this.uuidData.popupService.closeDialogEvent.subscribe((that) => {
+ this.closeDialog(that);
+ });
+
+ this.formPopupDetails = this.uuidData.popupService.getGenericFormPopupDetails(
+ this.uuidData['serviceId'],
+ null,
+ null,
+ this.node,
+ this.uuidData,
+ false
+ );
+ });
+ }
+
hasSomeError(formPopupDetails: FormPopupDetails, form: FormGroup): boolean {
if (_.isNil(formPopupDetails)) return false;
else {
@@ -148,9 +155,6 @@ export class GenericFormPopupComponent extends DialogComponent<PopupModel, boole
this._dialogService.addDialog(InstantiationTemplatesModalComponent, {});
}
- isInstantiationStatusFilterFlagOn() {
- return FeatureFlagsService.getFlagState(Features.FLAG_2004_TEMP_BUTTON_TO_INSTANTIATION_STATUS_FILTER, this._store);
- }
}
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 c18b20d7e..1d44a9e5e 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
@@ -38,7 +38,7 @@ export class BasicPopupService {
return new VNFModel(rawModel, flags);
}
case 'vfModules' : {
- return new VfModule(rawModel);
+ return new VfModule(rawModel, flags);
}
case 'networks' : {
return new NetworkModel(rawModel, flags);
diff --git a/vid-webpack-master/src/app/shared/models/vfModule.ts b/vid-webpack-master/src/app/shared/models/vfModule.ts
index c75202124..8f92ba428 100644
--- a/vid-webpack-master/src/app/shared/models/vfModule.ts
+++ b/vid-webpack-master/src/app/shared/models/vfModule.ts
@@ -1,4 +1,5 @@
import {NodeModel, NodeModelResponseInterface} from "./nodeModel";
+import {Utils} from "../utils/utils";
export interface Properties{
@@ -23,7 +24,7 @@ export class VfModule extends NodeModel {
modelCustomizationName: string;
volumeGroupAllowed : boolean;
- constructor(vf?: VFModuleResponseInterface) {
+ constructor(vf?: VFModuleResponseInterface, flags?: { [key: string]: boolean }) {
super(vf);
if(vf){
this.customizationUuid = vf.customizationUuid;
@@ -32,7 +33,7 @@ export class VfModule extends NodeModel {
}
if (vf && vf.properties) {
this.min = vf.properties.minCountInstances;
- this.max = vf.properties.maxCountInstances;
+ this.max = Utils.getMaxVfModule(vf.properties, flags);
this.initial = vf.properties.initialCount;
this.rollbackOnFailure = true
}
diff --git a/vid-webpack-master/src/app/shared/utils/util.spec.ts b/vid-webpack-master/src/app/shared/utils/util.spec.ts
index 4b39764f5..ae39238c2 100644
--- a/vid-webpack-master/src/app/shared/utils/util.spec.ts
+++ b/vid-webpack-master/src/app/shared/utils/util.spec.ts
@@ -1,24 +1,8 @@
import {Utils} from "./utils";
-import {TestBed} from "@angular/core/testing";
import each from "jest-each";
describe('Util', () => {
- let util: Utils;
-
- beforeAll(done => (async () => {
- TestBed.configureTestingModule({
-
- });
- await TestBed.compileComponents();
-
- util = new Utils();
-
- })().then(done).catch(done.fail));
-
- test('should be defined', () => {
- expect(util).toBeDefined();
- });
test('hasContents should return false if object is undefined or null or empty', () => {
expect(Utils.hasContents(undefined)).toBeFalsy();
@@ -40,4 +24,28 @@ describe('Util', () => {
expect(Utils.isALaCarte(instantiationType)).toEqual(expected);
});
+ each([
+ ["empty properties, empty flags",{}, {}, 1],
+ ["null properties, undefined flags",null, undefined, 1],
+ ["max_instances 3, flag is on", {max_instances:3}, {FLAG_2002_UNLIMITED_MAX: true}, 3],
+ ["max_instances 3, flag is off", {max_instances:3}, {FLAG_2002_UNLIMITED_MAX: false}, 3],
+ ["null properties, flag is on", null, {FLAG_2002_UNLIMITED_MAX: true}, null],
+ ["null properties, flag is off", null, {FLAG_2002_UNLIMITED_MAX: false}, 1],
+ ["undefined properties, flag is off", undefined, {FLAG_2002_UNLIMITED_MAX: false}, 1],
+ ]).test('getMaxFirstLevel %s', (desc, properties, flags, expected) => {
+ expect(Utils.getMaxFirstLevel(properties, flags)).toEqual(expected);
+ });
+
+ each([
+ ["empty properties, empty flags",{}, {}, 1],
+ ["null properties, undefined flags",null, undefined, 1],
+ ["wrong field, flag is on", {max_instances:3}, {FLAG_2002_UNLIMITED_MAX: true}, null],
+ ["maxCountInstances 3, flag is on", {maxCountInstances:3}, {FLAG_2002_UNLIMITED_MAX: true}, 3],
+ ["maxCountInstances 3, flag is off", {maxCountInstances:3}, {FLAG_2002_UNLIMITED_MAX: true}, 3],
+ ]).test('getMaxFirstLevel %s', (desc, properties, flags, expected) => {
+ expect(Utils.getMaxVfModule(properties, flags)).toEqual(expected);
+ });
+
+
+
});
diff --git a/vid-webpack-master/src/app/shared/utils/utils.ts b/vid-webpack-master/src/app/shared/utils/utils.ts
index cd7ebdff6..3db770738 100644
--- a/vid-webpack-master/src/app/shared/utils/utils.ts
+++ b/vid-webpack-master/src/app/shared/utils/utils.ts
@@ -3,11 +3,18 @@ import * as _ from 'lodash'
export class Utils {
static getMaxFirstLevel(properties, flags: { [key: string]: boolean }) : number | null{
- if (flags && !!flags['FLAG_2002_UNLIMITED_MAX']) {
- return !_.isNil(properties) && !_.isNil(properties.max_instances) ? properties.max_instances : null;
- } else {
- return properties.max_instances || 1;
+ return this.getMaxInstancesAllowed(properties, 'max_instances', flags)
+ }
+
+ static getMaxVfModule(properties, flags: { [key: string]: boolean }) : number | null{
+ return this.getMaxInstancesAllowed(properties, 'maxCountInstances', flags)
+ }
+
+ static getMaxInstancesAllowed(properties, filedName: string, flags: { [key: string]: boolean }) : number | null{
+ if (!_.isNil(properties) && !_.isNil(properties[filedName])) {
+ return properties[filedName];
}
+ return (flags && !!flags['FLAG_2002_UNLIMITED_MAX']) ? null : 1;
}
public static clampNumber = (number, min, max) => {