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 14:29:15 UTC

[incubator-dlab] branch develop updated: [DLAB-1990]: Fixed total quota shouldn't be reset if only project quota is updated (#857)

This is an automated email from the ASF dual-hosted git repository.

dgnatyshyn pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git


The following commit(s) were added to refs/heads/develop by this push:
     new 0b754e8  [DLAB-1990]: Fixed total quota shouldn't be reset if only project quota is updated (#857)
0b754e8 is described below

commit 0b754e8d1cb952d574726f5e64de8a90a709e85a
Author: Dmytro Gnatyshyn <42...@users.noreply.github.com>
AuthorDate: Wed Aug 12 17:29:03 2020 +0300

    [DLAB-1990]: Fixed total quota shouldn't be reset if only project quota is updated (#857)
---
 .../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