Repository: ignite
Updated Branches:
  refs/heads/master fa56a584c -> 89d34f661


IGNITE-8744 Refactored cluster activation/deactivation logic.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/89d34f66
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/89d34f66
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/89d34f66

Branch: refs/heads/master
Commit: 89d34f6618907c121e94b7fdeccdf5fe5a51abd3
Parents: fa56a58
Author: Dmitriy Shabalin <dmitri...@gmail.com>
Authored: Wed Jul 11 15:12:52 2018 +0700
Committer: Alexey Kuznetsov <akuznet...@apache.org>
Committed: Wed Jul 11 15:12:52 2018 +0700

----------------------------------------------------------------------
 .../components/cluster-selector/controller.js   | 30 ++++++++++++++------
 .../app/modules/agent/AgentManager.service.js   |  6 ++--
 2 files changed, 25 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/89d34f66/modules/web-console/frontend/app/components/cluster-selector/controller.js
----------------------------------------------------------------------
diff --git 
a/modules/web-console/frontend/app/components/cluster-selector/controller.js 
b/modules/web-console/frontend/app/components/cluster-selector/controller.js
index d47432b..a4102f3 100644
--- a/modules/web-console/frontend/app/components/cluster-selector/controller.js
+++ b/modules/web-console/frontend/app/components/cluster-selector/controller.js
@@ -17,20 +17,32 @@
 
 import _ from 'lodash';
 
-export default class {
-    static $inject = ['$scope', 'AgentManager', 'IgniteConfirm'];
+import { BehaviorSubject } from 'rxjs/BehaviorSubject';
 
-    constructor($scope, agentMgr, Confirm) {
-        Object.assign(this, { $scope, agentMgr, Confirm });
+export default class {
+    static $inject = ['AgentManager', 'IgniteConfirm'];
 
+    /**
+     * @param agentMgr Agent manager.
+     * @param Confirm  Confirmation service.
+     */
+    constructor(agentMgr, Confirm) {
+        this.agentMgr = agentMgr;
+        this.Confirm = Confirm;
         this.clusters = [];
         this.isDemo = agentMgr.isDemoMode();
+        this._inProgressSubject = new BehaviorSubject(false);
     }
 
     $onInit() {
+        this.inProgress$ = this._inProgressSubject.asObservable();
+
         this.clusters$ = this.agentMgr.connectionSbj
-            .do(({ cluster, clusters }) => {
-                this.cluster = cluster;
+            .combineLatest(this.inProgress$)
+            .do(([sbj, inProgress]) => this.inProgress = inProgress)
+            .filter(([sbj, inProgress]) => !inProgress)
+            .do(([{ cluster, clusters }]) => {
+                this.cluster = cluster ? { ...cluster } : null;
                 this.clusters = _.orderBy(clusters, ['name'], ['asc']);
             })
             .subscribe(() => {});
@@ -48,10 +60,12 @@ export default class {
         $event.preventDefault();
 
         const toggleClusterState = () => {
-            this.inProgress = true;
+            this._inProgressSubject.next(true);
 
+            // IGNITE-8744 For some reason .finally() not working in Firefox, 
needed to be investigated later.
             return this.agentMgr.toggleClusterState()
-                .finally(() => this.inProgress = false);
+                .then(() => this._inProgressSubject.next(false))
+                .catch(() => this._inProgressSubject.next(false));
         };
 
         if (this.cluster.active) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/89d34f66/modules/web-console/frontend/app/modules/agent/AgentManager.service.js
----------------------------------------------------------------------
diff --git 
a/modules/web-console/frontend/app/modules/agent/AgentManager.service.js 
b/modules/web-console/frontend/app/modules/agent/AgentManager.service.js
index 4fd7bb8..4c8d95a 100644
--- a/modules/web-console/frontend/app/modules/agent/AgentManager.service.js
+++ b/modules/web-console/frontend/app/modules/agent/AgentManager.service.js
@@ -816,11 +816,11 @@ export default class AgentManager {
      * @returns {Promise}
      */
     toggleClusterState() {
-        const state = this.connectionSbj.getValue();
-        const active = !state.cluster.active;
+        const { cluster } = this.connectionSbj.getValue();
+        const active = !cluster.active;
 
         return this.visorTask('toggleClusterState', null, active)
-            .then(() => state.updateCluster(Object.assign(state.cluster, { 
active })));
+            .then(() => this.updateCluster({ ...cluster, active }));
     }
 
     hasCredentials(clusterId) {

Reply via email to