From: Barath Kumar R Date: Wed, 9 Jun 2021 03:48:17 +0000 (+0530) Subject: Fix bug 1565 to reset the project quotas count X-Git-Tag: v10.0.0^0 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=3be46b807062e09875600bdeab39035bbbc96934;p=osm%2FNG-UI.git Fix bug 1565 to reset the project quotas count * Able to empty the value which is entered as 0 or any Change-Id: I6585a3bf91a46501d3dd60cd407e135e148ba8eb Signed-off-by: Barath Kumar R --- diff --git a/src/app/projects/ProjectsComponent.ts b/src/app/projects/ProjectsComponent.ts index fe55271..052e639 100644 --- a/src/app/projects/ProjectsComponent.ts +++ b/src/app/projects/ProjectsComponent.ts @@ -146,7 +146,7 @@ export class ProjectsComponent implements OnInit, OnDestroy { /** Modal service to initiate the project add @private */ public projectAdd(): void { - const modalRef: NgbModalRef = this.modalService.open(ProjectCreateUpdateComponent, { backdrop: 'static' }); + const modalRef: NgbModalRef = this.modalService.open(ProjectCreateUpdateComponent, { size: 'lg', backdrop: 'static' }); modalRef.componentInstance.projectType = 'Add'; modalRef.result.then((result: MODALCLOSERESPONSEDATA) => { if (result) { @@ -175,7 +175,7 @@ export class ProjectsComponent implements OnInit, OnDestroy { creationDate: this.sharedService.convertEpochTime(!isNullOrUndefined(projectData._admin) ? projectData._admin.created : null), id: projectData._id, project: projectData._id, - quotas: !isNullOrUndefined(projectData.quotas) ? projectData.quotas : null + quotas: !isNullOrUndefined(projectData.quotas) && Object.keys(projectData.quotas).length !== 0 ? projectData.quotas : null }; } diff --git a/src/app/projects/project-create-update/ProjectCreateUpdateComponent.html b/src/app/projects/project-create-update/ProjectCreateUpdateComponent.html index b621a53..4e613fe 100644 --- a/src/app/projects/project-create-update/ProjectCreateUpdateComponent.html +++ b/src/app/projects/project-create-update/ProjectCreateUpdateComponent.html @@ -34,14 +34,14 @@ Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.i -
+
-
+
@@ -50,15 +50,15 @@ Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.i
- +
- +
diff --git a/src/app/projects/project-create-update/ProjectCreateUpdateComponent.ts b/src/app/projects/project-create-update/ProjectCreateUpdateComponent.ts index 01f963e..5eb2d5d 100644 --- a/src/app/projects/project-create-update/ProjectCreateUpdateComponent.ts +++ b/src/app/projects/project-create-update/ProjectCreateUpdateComponent.ts @@ -197,11 +197,11 @@ export class ProjectCreateUpdateComponent implements OnInit { public checkQuota(): void { if (this.getFormControl('enable_quota').value) { this.quotaItems.forEach((quotaItem: QUOTAITEM): void => { - this.projectForm.addControl(quotaItem.value, new FormControl(quotaItem.minValue, Validators.required)); + this.projectForm.addControl(quotaItem.value, new FormControl('')); }); } else { this.quotaItems.forEach((quotaItem: QUOTAITEM): void => { - this.getFormControl(quotaItem.value).setValue(quotaItem.minValue); + this.getFormControl(quotaItem.value).setValue(''); }); } } @@ -247,8 +247,13 @@ export class ProjectCreateUpdateComponent implements OnInit { if (this.getFormControl('enable_quota').value) { payload.quotas = {}; this.quotaItems.forEach((quotaItem: QUOTAITEM): void => { - payload.quotas[quotaItem.value] = this.getFormControl(quotaItem.value).value; + if (this.getFormControl(quotaItem.value).value !== '') { + payload.quotas[quotaItem.value] = this.getFormControl(quotaItem.value).value; + } }); + if (Object.keys(payload.quotas).length === 0) { + delete payload.quotas; + } } } @@ -259,16 +264,15 @@ export class ProjectCreateUpdateComponent implements OnInit { this.quotaItems.forEach((quotaItem: QUOTAITEM): void => { if (!isNullOrUndefined(quotaRef[quotaItem.value])) { this.projectForm.addControl(quotaItem.value, new FormControl(quotaRef[quotaItem.value], - [Validators.required, Validators.min(quotaItem.minValue), Validators.max(quotaItem.maxValue)])); + [Validators.max(quotaItem.maxValue)])); } else { - this.projectForm.addControl(quotaItem.value, new FormControl(quotaItem.minValue, [Validators.required, - Validators.min(quotaItem.minValue), Validators.max(quotaItem.maxValue)])); + this.projectForm.addControl(quotaItem.value, new FormControl('', [Validators.max(quotaItem.maxValue)])); } }); } else { this.quotaItems.forEach((quotaItem: QUOTAITEM): void => { - this.projectForm.addControl(quotaItem.value, new FormControl(quotaItem.minValue, [Validators.required, - Validators.min(quotaItem.minValue), Validators.max(quotaItem.maxValue)])); + this.projectForm.addControl(quotaItem.value, new FormControl('', [Validators.min(quotaItem.minValue), + Validators.max(quotaItem.maxValue)])); }); } } diff --git a/src/app/utilities/projects-action/ProjectsActionComponent.ts b/src/app/utilities/projects-action/ProjectsActionComponent.ts index 4ac0051..207d90c 100644 --- a/src/app/utilities/projects-action/ProjectsActionComponent.ts +++ b/src/app/utilities/projects-action/ProjectsActionComponent.ts @@ -67,7 +67,7 @@ export class ProjectsActionComponent { /** Edit project @public */ public projectEdit(): void { - const modalRef: NgbModalRef = this.modalService.open(ProjectCreateUpdateComponent, { backdrop: 'static' }); + const modalRef: NgbModalRef = this.modalService.open(ProjectCreateUpdateComponent, { size: 'lg', backdrop: 'static' }); modalRef.componentInstance.projectType = 'Edit'; modalRef.result.then((result: MODALCLOSERESPONSEDATA) => { if (result) { diff --git a/src/app/utilities/scaling/ScalingComponent.ts b/src/app/utilities/scaling/ScalingComponent.ts index 930eb86..111c3b8 100644 --- a/src/app/utilities/scaling/ScalingComponent.ts +++ b/src/app/utilities/scaling/ScalingComponent.ts @@ -140,7 +140,6 @@ export class ScalingComponent implements OnInit { this.getFormControl('scalingname').setValue(null); const scalingGroupDescriptorName: SCALING[] = []; if (!isNullOrUndefined(this.params.data)) { - console.log(this.params.data); const vnfdPackageDetails: VNFD = this.params.data.filter((vnfdData: VNFD): boolean => vnfdData.id === vnfID)[0]; if (vnfdPackageDetails.df.length > 0) { vnfdPackageDetails.df.forEach((df: DF): void => {