Fix bug 1565 to reset the project quotas count 81/10981/1 v10.0.0 v10.0.1 v10.0.2 v10.0.3
authorBarath Kumar R <barath.r@tataelxsi.co.in>
Wed, 9 Jun 2021 03:48:17 +0000 (09:18 +0530)
committerBarath Kumar R <barath.r@tataelxsi.co.in>
Wed, 9 Jun 2021 14:04:53 +0000 (19:34 +0530)
 * Able to empty the value which is entered as 0 or any

Change-Id: I6585a3bf91a46501d3dd60cd407e135e148ba8eb
Signed-off-by: Barath Kumar R <barath.r@tataelxsi.co.in>
src/app/projects/ProjectsComponent.ts
src/app/projects/project-create-update/ProjectCreateUpdateComponent.html
src/app/projects/project-create-update/ProjectCreateUpdateComponent.ts
src/app/utilities/projects-action/ProjectsActionComponent.ts
src/app/utilities/scaling/ScalingComponent.ts

index fe55271..052e639 100644 (file)
@@ -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
         };
     }
 
index b621a53..4e613fe 100644 (file)
@@ -34,14 +34,14 @@ Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.i
       <label class="col-sm-12 col-form-label mandatory-label"
         [ngClass]="{'text-danger': projectForm.invalid === true && submitted === true}">{{'MANDATORYCHECK' | translate}}</label>
       <label class="col-sm-4 col-form-label">{{'PROJECT' | translate}} {{'NAME' | translate}}*</label>
-      <div class="col-sm-8">
+      <div class="col-sm-4">
         <input placeholder="{{'PROJECT' | translate}} {{'NAME' | translate}}" type="text" class="form-control"
           formControlName="project_name" [ngClass]="{ 'is-invalid': submitted && f.project_name.errors }" required>
       </div>
     </div>
     <div class="form-group row" *ngIf="getProjectType === 'Add'">
       <label class="col-sm-4 col-form-label">{{'DOMAIN' | translate}} {{'NAME' | translate}}</label>
-      <div class="col-sm-8">
+      <div class="col-sm-4">
         <ng-select [clearable]="false" placeholder="{{'SELECT' | translate}}" [items]="domains" bindLabel="title"
           bindValue="value" formControlName="domain_name" id="domain_name"
           [ngClass]="{ 'is-invalid': submitted && f.domain_name.errors }"></ng-select>
@@ -50,15 +50,15 @@ Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.i
     <div class="form-check form-check-inline ml-2">
       <input class="form-check-input" type="checkbox" formControlName="enable_quota" (change)="checkQuota()"
         id="quotaCheck" *ngIf="getProjectType === 'Add' || quotaRefs === null">
-      <label class="form-check-label" for="quotaCheck">{{'PAGE.PROJECT.QUOTA' | translate}}</label>
+      <label class="form-check-label" for="quotaCheck"><b>{{'PAGE.PROJECT.QUOTA' | translate}}</b></label>
     </div>
     <div class="row mt-1" [ngbCollapse]="!f.enable_quota.value">
       <div class="form-group col-sm-6" *ngFor="let quota of quotaItems;">
         <div class="row">
           <label class="col-sm-7 col-form-label">{{quota.title | translate}}*</label>
           <div class="col-sm-5">
-            <input placeholder="{{'COUNT' | translate}}" type="number" min="{{quota.minValue}}"
-              class="form-control" [formControlName]="quota.value" [ngClass]="{ 'is-invalid': submitted && f[quota.value].errors }" required>
+            <input placeholder="{{'COUNT' | translate}}" type="number"
+              class="form-control" [formControlName]="quota.value" [ngClass]="{ 'is-invalid': submitted && f[quota.value].errors }">
           </div>
         </div>
       </div>
index 01f963e..5eb2d5d 100644 (file)
@@ -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)]));
             });
         }
     }
index 4ac0051..207d90c 100644 (file)
@@ -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) {
index 930eb86..111c3b8 100644 (file)
@@ -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 => {