You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dlab.apache.org by dg...@apache.org on 2020/08/12 13:16:14 UTC
[incubator-dlab] 01/01: [DLAB-1990]: Fixed total quota shouldn't be
reset if only project quota is updated
This is an automated email from the ASF dual-hosted git repository.
dgnatyshyn pushed a commit to branch DLAB-1990
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git
commit c0aa8c91c85eeffb40b631244e8d3e743be821af
Author: Dmytro_Gnatyshyn <di...@ukr.net>
AuthorDate: Wed Aug 12 16:15:20 2020 +0300
[DLAB-1990]: Fixed total quota shouldn't be reset if only project quota is updated
---
.../manage-environment-dilog.component.ts | 10 ++++----
.../management/management.component.ts | 27 +++++++++++++++++-----
2 files changed, 27 insertions(+), 10 deletions(-)
diff --git a/services/self-service/src/main/resources/webapp/src/app/administration/management/manage-environment/manage-environment-dilog.component.ts b/services/self-service/src/main/resources/webapp/src/app/administration/management/manage-environment/manage-environment-dilog.component.ts
index 4aa2871..0c42312 100644
--- a/services/self-service/src/main/resources/webapp/src/app/administration/management/manage-environment/manage-environment-dilog.component.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/administration/management/manage-environment/manage-environment-dilog.component.ts
@@ -52,12 +52,16 @@ export class ManageEnvironmentComponent implements OnInit {
this.setProjectsControl();
this.manageUsersForm.controls['total'].setValue(this.data.total.conf_max_budget || '');
this.onFormChange();
+ this.manageUsersForm.value.total = +this.manageUsersForm.value.total;
+ if (this.manageUsersForm.value.total === 0) this.manageUsersForm.value.total = null;
this.initialFormState = this.manageUsersForm.value;
}
public onFormChange() {
this.manageUsersForm.valueChanges.subscribe(value => {
this.isFormChanged = JSON.stringify(this.initialFormState) === JSON.stringify(this.manageUsersForm.value);
+ console.log(JSON.stringify(this.initialFormState));
+ console.log(JSON.stringify(this.manageUsersForm.value));
if ((this.getCurrentTotalValue() && this.getCurrentTotalValue() >= this.getCurrentUsersTotal())) {
this.manageUsersForm.controls['projects']['controls'].forEach(v => {
v.controls['budget'].errors &&
@@ -79,10 +83,8 @@ export class ManageEnvironmentComponent implements OnInit {
value.projects = value.projects.filter((v, i) =>
this.initialFormState.projects[i].budget !== v.budget ||
this.initialFormState.projects[i].monthlyBudget !== v.monthlyBudget);
- if (this.initialFormState.total === value.total) {
- delete value.total;
- }
- this.dialogRef.close(value);
+ value.isTotalChanged = this.initialFormState.total !== value.total;
+ this.dialogRef.close(value);
} else {
this.manageUsersForm.controls['total'].setErrors({ overrun: true });
}
diff --git a/services/self-service/src/main/resources/webapp/src/app/administration/management/management.component.ts b/services/self-service/src/main/resources/webapp/src/app/administration/management/management.component.ts
index a0d0767..55ac108 100644
--- a/services/self-service/src/main/resources/webapp/src/app/administration/management/management.component.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/administration/management/management.component.ts
@@ -130,15 +130,30 @@ export class ManagementComponent implements OnInit {
// }
setBudgetLimits($event) {
- this.projectService.updateProjectsBudget($event.projects).subscribe((result: any) => {
+ if ($event.projects.length) {
+ this.projectService.updateProjectsBudget($event.projects).subscribe((result: any) => {
+ if ($event.isTotalChanged) {
+ this.healthStatusService.updateTotalBudgetData($event.total).subscribe((res: any) => {
+ result.status === HTTP_STATUS_CODES.OK
+ && res.status === HTTP_STATUS_CODES.NO_CONTENT
+ && this.toastr.success('Budget limits updated!', 'Success!');
+ this.buildGrid();
+ });
+ } else {
+ result.status === HTTP_STATUS_CODES.OK && this.toastr.success('Budget limits updated!', 'Success!');
+ this.buildGrid();
+ }
+
+ }, error => this.toastr.error(error.message, 'Oops!'));
+ } else {
this.healthStatusService.updateTotalBudgetData($event.total).subscribe((res: any) => {
- result.status === HTTP_STATUS_CODES.OK
- && res.status === HTTP_STATUS_CODES.NO_CONTENT
- && this.toastr.success('Budget limits updated!', 'Success!');
+ res.status === HTTP_STATUS_CODES.NO_CONTENT
+ && this.toastr.success('Budget limits updated!', 'Success!');
this.buildGrid();
});
- }, error => this.toastr.error(error.message, 'Oops!'));
- }
+ }
+ }
+
// manageEnvironment(event: { action: string, project: any }) {
// if (event.action === 'stop')
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@dlab.apache.org
For additional commands, e-mail: commits-help@dlab.apache.org