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 <barath.r@tataelxsi.co.in>
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 @@
/** 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 @@
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 @@
<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 @@
<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>
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 @@
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 @@
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 @@
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 @@
/** 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 @@
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 => {