You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datalab.apache.org by yt...@apache.org on 2021/04/28 07:45:43 UTC

[incubator-datalab] 01/01: [DATALAB-2376] Changed the way of displaying messages according to selected service during restarting

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

ytykhun pushed a commit to branch DATALAB-2376
in repository https://gitbox.apache.org/repos/asf/incubator-datalab.git

commit 64539ced1b1f26882a0537b3259ff86d0d13c6bd
Author: Yurii Tykhun <ty...@gmail.com>
AuthorDate: Wed Apr 28 10:43:49 2021 +0300

    [DATALAB-2376] Changed the way of displaying messages according to selected service during restarting
---
 .../configuration/configuration.component.ts       | 64 ++++++++++++++--------
 1 file changed, 42 insertions(+), 22 deletions(-)

diff --git a/services/self-service/src/main/resources/webapp/src/app/administration/configuration/configuration.component.ts b/services/self-service/src/main/resources/webapp/src/app/administration/configuration/configuration.component.ts
index eb29789..23063c6 100644
--- a/services/self-service/src/main/resources/webapp/src/app/administration/configuration/configuration.component.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/administration/configuration/configuration.component.ts
@@ -46,6 +46,11 @@ export class ConfigurationComponent implements OnInit, OnDestroy {
     'provisioning': {label: 'Provisioning', selected: false, config: '', serverConfig: '', isConfigChanged: false},
     'billing': {label: 'Billing', selected: false, config: '', serverConfig: '', isConfigChanged: false},
   };
+
+  public messagesStatus = {
+    success: [],
+    error: []
+  };
   
   public processingStatuses = [];
   public ingStatuses = ['creating', 'configuring', 'reconfiguring', 'creating image', 'stopping', 'starting', 'terminating'];
@@ -227,6 +232,20 @@ export class ConfigurationComponent implements OnInit, OnDestroy {
     this.services[service].selected = !this.services[service].selected;
   }
 
+  public restartSingleService(ui: boolean, prov: boolean, billing: boolean, serviceName) {
+    this.configurationService.restartServices(ui, prov, billing, this.activeEndpoint)
+      .pipe(
+        takeUntil(this.unsubscribe$),
+      )
+      .subscribe(res => {
+          this.messagesStatus.success.push(serviceName);
+        },
+        error => {
+          this.messagesStatus.error.push(serviceName);
+        }
+      );
+  }
+
   public restartServices(): void  {
     const selectedServices = [];
     for (const service in this.services) {
@@ -251,29 +270,30 @@ export class ConfigurationComponent implements OnInit, OnDestroy {
           if(this.processingStatuses.length && this.services['provisioning'].selected) {
             this.services['provisioning'].selected = false;
           }
-          
-          this.configurationService.restartServices(
-            this.services['self-service'].selected,
-            this.services['provisioning'].selected,
-            this.services['billing'].selected,
-            this.activeEndpoint
-          )
-          .pipe(
-            takeUntil(this.unsubscribe$),
-          )
-          .subscribe(res => {
-              this.clearSelectedServices();
-              this.toastr.success('Service restarting started!', 'Success!');
-            },
-            error => {
-            if (this.services['self-service'].selected) {
-              this.clearSelectedServices();
-              return this.toastr.success('Service restarting started!', 'Success!');
-            } else {
-              this.toastr.error('Service restarting failed', 'Oops!');
-            }
+
+          if(this.services['self-service'].selected) {
+            this.restartSingleService(true, false, false, 'Self-service')
+          } 
+          if(this.services['provisioning'].selected) {
+            this.restartSingleService(false, true, false, 'Provisioning service')
+          } 
+          if(this.services['billing'].selected) {
+            this.restartSingleService(false, false, true, 'Billing service')
+            
+          }
+
+          setTimeout(() => {
+            for(let key in this.messagesStatus) {
+              if(key === 'error' && this.messagesStatus[key].length > 0) {
+                this.toastr.error(`${this.messagesStatus[key].join(', ')} restarting failed`, 'Oops!');
+              } else if(key === 'success' && this.messagesStatus[key].length > 0) {
+                this.toastr.success(`${this.messagesStatus[key].join(', ')} restarting started!`, 'Success!');
+              }
             }
-          );
+            this.clearSelectedServices();
+            this.messagesStatus.success = [];
+            this.messagesStatus.error = [];
+          }, 500);
         } else {
           this.clearSelectedServices();
         }

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datalab.apache.org
For additional commands, e-mail: commits-help@datalab.apache.org