Web Console: Fixed logic on cluster lost.

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

Branch: refs/heads/master
Commit: 2a2c803039965e52ac5fc33be6cbccc5a27abd84
Parents: b3e6298
Author: Andrey Novikov <anovi...@gridgain.com>
Authored: Tue Jul 11 09:50:04 2017 +0700
Committer: Andrey Novikov <anovi...@gridgain.com>
Committed: Tue Jul 11 09:50:04 2017 +0700

----------------------------------------------------------------------
 modules/web-console/frontend/app/app.js         |  2 +
 .../cluster-select/cluster-select.controller.js | 72 ++++++++++----------
 .../cluster-select/cluster-select.pug           | 10 +--
 .../frontend/app/filters/id8.filter.js          | 20 ++++++
 .../app/modules/agent/AgentManager.service.js   |  4 +-
 .../views/templates/agent-download.tpl.pug      |  4 +-
 6 files changed, 68 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/2a2c8030/modules/web-console/frontend/app/app.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/app.js 
b/modules/web-console/frontend/app/app.js
index 7b8196e..c707810 100644
--- a/modules/web-console/frontend/app/app.js
+++ b/modules/web-console/frontend/app/app.js
@@ -104,6 +104,7 @@ import domainsValidation from 
'./filters/domainsValidation.filter';
 import duration from './filters/duration.filter';
 import hasPojo from './filters/hasPojo.filter';
 import uiGridSubcategories from './filters/uiGridSubcategories.filter';
+import id8 from './filters/id8.filter';
 
 // Controllers
 import profile from 'Controllers/profile-controller';
@@ -254,6 +255,7 @@ angular
 .filter('duration', duration)
 .filter('hasPojo', hasPojo)
 .filter('uiGridSubcategories', uiGridSubcategories)
+.filter('id8', id8)
 .config(['$translateProvider', '$stateProvider', '$locationProvider', 
'$urlRouterProvider', ($translateProvider, $stateProvider, $locationProvider, 
$urlRouterProvider) => {
     $translateProvider.translations('en', i18n);
     $translateProvider.preferredLanguage('en');

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a2c8030/modules/web-console/frontend/app/components/cluster-select/cluster-select.controller.js
----------------------------------------------------------------------
diff --git 
a/modules/web-console/frontend/app/components/cluster-select/cluster-select.controller.js
 
b/modules/web-console/frontend/app/components/cluster-select/cluster-select.controller.js
index 6d30e94..a2d8e1e 100644
--- 
a/modules/web-console/frontend/app/components/cluster-select/cluster-select.controller.js
+++ 
b/modules/web-console/frontend/app/components/cluster-select/cluster-select.controller.js
@@ -15,52 +15,50 @@
  * limitations under the License.
  */
 
-export default ['$scope', 'AgentManager', function($scope, agentMgr) {
-    const ctrl = this;
+export default class {
+    static $inject = ['AgentManager'];
 
-    ctrl.counter = 1;
+    constructor(agentMgr) {
+        const ctrl = this;
 
-    ctrl.cluster = null;
-    ctrl.clusters = [];
+        ctrl.counter = 1;
 
-    agentMgr.connectionSbj.subscribe({
-        next: ({cluster, clusters}) => {
-            if (_.isEmpty(clusters))
-                return ctrl.clusters.length = 0;
+        ctrl.cluster = null;
+        ctrl.clusters = [];
 
-            const removed = _.differenceBy(ctrl.clusters, clusters, 'id');
+        agentMgr.connectionSbj.subscribe({
+            next: ({cluster, clusters}) => {
+                if (_.isEmpty(clusters))
+                    return ctrl.clusters.length = 0;
 
-            if (_.nonEmpty(removed))
-                _.pullAll(ctrl.clusters, removed);
+                const removed = _.differenceBy(ctrl.clusters, clusters, 'id');
 
-            const added = _.differenceBy(clusters, ctrl.clusters, 'id');
+                if (_.nonEmpty(removed))
+                    _.pullAll(ctrl.clusters, removed);
 
-            _.forEach(added, (cluster) => {
-                ctrl.clusters.push({
-                    id: cluster.id,
-                    name: `Cluster ${cluster.id.substring(0, 
8).toUpperCase()}`,
-                    connected: true,
-                    click: () => {
-                        if (cluster.id === _.get(ctrl, 'cluster.id'))
-                            return;
+                const added = _.differenceBy(clusters, ctrl.clusters, 'id');
 
-                        if (_.get(ctrl, 'cluster.connected')) {
-                            agentMgr.saveToStorage(cluster);
+                _.forEach(added, (cluster) => {
+                    ctrl.clusters.push({
+                        id: cluster.id,
+                        connected: true,
+                        click: () => {
+                            if (cluster.id === _.get(ctrl, 'cluster.id'))
+                                return;
 
-                            window.open(window.location.href, '_blank');
+                            if (_.get(ctrl, 'cluster.connected')) {
+                                agentMgr.saveToStorage(cluster);
+
+                                window.open(window.location.href, '_blank');
+                            }
+                            else
+                                ctrl.cluster = _.find(ctrl.clusters, {id: 
cluster.id});
                         }
-                        else
-                            ctrl.cluster = _.find(ctrl.clusters, {id: 
cluster.id});
-                    }
+                    });
                 });
-            });
-
-            const item = _.find(ctrl.clusters, {id: cluster.id});
 
-            if (_.isNil(ctrl.cluster))
-                ctrl.cluster = item;
-            else
-                ctrl.cluster.connected = !!item;
-        }
-    });
-}];
+                ctrl.cluster = cluster;
+            }
+        });
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a2c8030/modules/web-console/frontend/app/components/cluster-select/cluster-select.pug
----------------------------------------------------------------------
diff --git 
a/modules/web-console/frontend/app/components/cluster-select/cluster-select.pug 
b/modules/web-console/frontend/app/components/cluster-select/cluster-select.pug
index bb81415..eb46e26 100644
--- 
a/modules/web-console/frontend/app/components/cluster-select/cluster-select.pug
+++ 
b/modules/web-console/frontend/app/components/cluster-select/cluster-select.pug
@@ -14,6 +14,8 @@
     See the License for the specific language governing permissions and
     limitations under the License.
 
+-var clusterName = 'Cluster {{ ctrl.cluster.id | id8 }}'
+
 ul.nav
     li.disabled(ng-if='ctrl.clusters.length === 0')
         a(ng-if='!ctrl.cluster')
@@ -21,24 +23,24 @@ ul.nav
             label.padding-left-dflt(bs-tooltip='' data-placement='bottom' 
data-title='Check that Web Agent(s) started and connected to cluster(s)') No 
clusters available
         a(ng-if='ctrl.cluster')
             i.icon-danger
-            label.padding-left-dflt(bs-tooltip='' data-placement='bottom' 
data-title='Connection to cluster was lost') {{ctrl.cluster.name}}
+            label.padding-left-dflt(bs-tooltip='' data-placement='bottom' 
data-title='Connection to cluster was lost') #{clusterName}
 
     li(ng-if='ctrl.clusters.length === 1 && ctrl.cluster.connected')
         a
             i.icon-cluster
-            label.padding-left-dflt {{ctrl.cluster.name}}
+            label.padding-left-dflt #{clusterName}
 
     li(ng-if='ctrl.clusters.length > 1 || ctrl.clusters.length === 1 && 
!ctrl.cluster.connected')
         a.dropdown-toggle(bs-dropdown='' data-placement='bottom-left' 
data-trigger='hover focus' data-container='self' 
ng-click='$event.stopPropagation()' aria-haspopup='true' 
aria-expanded='expanded')
             i(ng-class='{"icon-cluster": ctrl.cluster.connected, 
"icon-danger": !ctrl.cluster.connected}')
-            label.padding-left-dflt {{ctrl.cluster.name}}
+            label.padding-left-dflt #{clusterName}
             span.caret
             
         ul.dropdown-menu(role='menu')
             li(ng-repeat='item in ctrl.clusters' ng-class='{active: 
ctrl.cluster === item}')
                 div(ng-click='item.click()')
                     i.icon-cluster.pull-left(style='margin: 0; padding-left: 
10px;')
-                    div: a {{item.name}}
+                    div: a Cluster {{ item.id | id8 }}
 
 i.icon-help(bs-tooltip='' data-placement='bottom' data-html=true
     data-title='Multi-Cluster Support<br/>\

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a2c8030/modules/web-console/frontend/app/filters/id8.filter.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/filters/id8.filter.js 
b/modules/web-console/frontend/app/filters/id8.filter.js
new file mode 100644
index 0000000..ab4e920
--- /dev/null
+++ b/modules/web-console/frontend/app/filters/id8.filter.js
@@ -0,0 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+export default [() => {
+    return _.id8;
+}];

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a2c8030/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 3873567..bdd1fda 100644
--- a/modules/web-console/frontend/app/modules/agent/AgentManager.service.js
+++ b/modules/web-console/frontend/app/modules/agent/AgentManager.service.js
@@ -55,6 +55,8 @@ class ConnectionState {
         if (_.nonEmpty(this.clusters) && !this.cluster.connected) {
             this.cluster = _.head(this.clusters);
 
+            this.cluster.connected = true;
+
             this.state = State.CONNECTED;
         }
     }
@@ -368,7 +370,7 @@ export default class IgniteAgentManager {
      * @private
      */
     _rest(event, ...args) {
-        return this._emit(event, _.get(this, 'cluster.id'), ...args);
+        return this._emit(event, _.get(this.connectionSbj.getValue(), 
'cluster.id'), ...args);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a2c8030/modules/web-console/frontend/views/templates/agent-download.tpl.pug
----------------------------------------------------------------------
diff --git 
a/modules/web-console/frontend/views/templates/agent-download.tpl.pug 
b/modules/web-console/frontend/views/templates/agent-download.tpl.pug
index 0aec7e5..7829581 100644
--- a/modules/web-console/frontend/views/templates/agent-download.tpl.pug
+++ b/modules/web-console/frontend/views/templates/agent-download.tpl.pug
@@ -45,10 +45,10 @@
             .modal-header.header
                 h4.modal-title
                     i.fa.fa-download
-                    span Connection to Ignite Node is not established
+                    span Connection to cluster was lost or can't be established
 
             .modal-body.agent-download
-                p Connection to Ignite Web Agent is established, but agent 
failed to connect to Ignite Node
+                p Connection to Ignite Web Agent is established, but agent 
failed to connect to cluster
                 p Please check the following:
                 p
                     ul

Reply via email to