ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject incubator-ignite git commit: IGNITE-843: Cluster validation.
Date Mon, 17 Aug 2015 07:00:01 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-843 83e0457f1 -> 8eeb439a5


IGNITE-843: Cluster validation.


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

Branch: refs/heads/ignite-843
Commit: 8eeb439a50e5730654e7ba297a203291e2da7ed8
Parents: 83e0457
Author: AKuznetsov <akuznetsov@gridgain.com>
Authored: Mon Aug 17 14:00:16 2015 +0700
Committer: AKuznetsov <akuznetsov@gridgain.com>
Committed: Mon Aug 17 14:00:16 2015 +0700

----------------------------------------------------------------------
 .../main/js/controllers/clusters-controller.js  | 61 +++++++------------
 .../src/main/js/controllers/common-module.js    | 64 ++++++++++++++++----
 .../main/js/controllers/models/clusters.json    |  1 +
 .../src/main/js/views/includes/controls.jade    |  2 +-
 .../src/main/js/views/templates/popover.jade    | 10 ++-
 5 files changed, 81 insertions(+), 57 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8eeb439a/modules/control-center-web/src/main/js/controllers/clusters-controller.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/controllers/clusters-controller.js b/modules/control-center-web/src/main/js/controllers/clusters-controller.js
index ecfa699..e45d79c 100644
--- a/modules/control-center-web/src/main/js/controllers/clusters-controller.js
+++ b/modules/control-center-web/src/main/js/controllers/clusters-controller.js
@@ -15,8 +15,8 @@
  * limitations under the License.
  */
 
-controlCenterModule.controller('clustersController', ['$scope', '$http', '$popover', '$timeout',
'$common', '$focus', '$confirm', '$copy', '$table',
-    function ($scope, $http, $popover, $timeout, $common, $focus, $confirm, $copy, $table)
{
+controlCenterModule.controller('clustersController', ['$scope', '$http', '$common', '$focus',
'$confirm', '$copy', '$table',
+    function ($scope, $http, $common, $focus, $confirm, $copy, $table) {
         $scope.joinTip = $common.joinTip;
         $scope.getModel = $common.getModel;
 
@@ -102,6 +102,8 @@ controlCenterModule.controller('clustersController', ['$scope', '$http',
'$popov
 
         $scope.toggleExpanded = function () {
             $scope.ui.expanded = !$scope.ui.expanded;
+
+            $common.hidePopover();
         };
 
         $scope.panels = {activePanels: [0]};
@@ -222,64 +224,39 @@ controlCenterModule.controller('clustersController', ['$scope', '$http',
'$popov
             });
         };
 
-        var popover = null;
-
-        function showPopoverMessage(panelIndex, id, message) {
-            $common.ensureActivePanel($scope.panels, panelIndex);
-
-            var el = $('body').find('#' + id);
-
-            if (popover)
-                popover.hide();
-
-            var newPopover = $popover(el, {content: message});
-
-            $timeout(function () {
-                $focus(id);
-            }, 50);
-
-            $timeout(function () {
-                newPopover.show();
-
-                popover = newPopover;
-            }, 100);
-
-            $timeout(function () { newPopover.hide() }, 3000);
-
-            return false;
-        }
-
         // Check cluster logical consistency.
         function validate(item) {
+            var pnls = $scope.panels;
+
             if ($common.isEmptyString(item.name))
-                return showPopoverMessage(0, 'clusterName', 'Name should not be empty');
+                return $common.showPopoverMessage(pnls, 0, 'clusterName', 'Name should not
be empty');
 
             if (item.discovery.kind == 'Vm' && item.discovery.Vm.addresses.length
== 0)
-                return showPopoverMessage(0, 'addresses', 'Addresses are not specified');
+                return $common.showPopoverMessage(pnls, 0, 'addresses', 'Addresses are not
specified');
 
             if (item.discovery.kind == 'S3' && $common.isEmptyString(item.discovery.S3.bucketName))
-                return showPopoverMessage(0, 'bucketName', 'Bucket name should not be empty');
+                return $common.showPopoverMessage(pnls, 0, 'bucketName', 'Bucket name should
not be empty');
 
             if (item.discovery.kind == 'Cloud') {
                 if ($common.isEmptyString(item.discovery.Cloud.identity))
-                    return showPopoverMessage(0, 'identity', 'Identity should not be empty');
+                    return $common.showPopoverMessage(pnls, 0, 'identity', 'Identity should
not be empty');
 
                 if ($common.isEmptyString(item.discovery.Cloud.provider))
-                    return showPopoverMessage(0, 'provider', 'Provider should not be empty');
+                    return $common.showPopoverMessage(pnls, 0, 'provider', 'Provider should
not be empty');
             }
 
             if (item.discovery.kind == 'GoogleStorage') {
                 if ($common.isEmptyString(item.discovery.GoogleStorage.projectName))
-                    return showPopoverMessage(0, 'projectName', 'Project name should not
be empty');
+                    return $common.showPopoverMessage(pnls, 0, 'projectName', 'Project name
should not be empty');
 
                 if ($common.isEmptyString(item.discovery.GoogleStorage.bucketName))
-                    return showPopoverMessage(0, 'bucketName', 'Bucket name should not be
empty');
+                    return $common.showPopoverMessage(pnls, 0, 'bucketName', 'Bucket name
should not be empty');
 
                 if ($common.isEmptyString(item.discovery.GoogleStorage.serviceAccountP12FilePath))
-                    return showPopoverMessage(0, 'serviceAccountP12FilePath', 'Private key
path should not be empty');
+                    return $common.showPopoverMessage(pnls, 0, 'serviceAccountP12FilePath',
'Private key path should not be empty');
 
                 if ($common.isEmptyString(item.discovery.GoogleStorage.serviceAccountId))
-                    return showPopoverMessage(0, 'serviceAccountId', 'Account ID should not
be empty');
+                    return $common.showPopoverMessage(pnls, 0, 'serviceAccountId', 'Account
ID should not be empty');
             }
 
             if (!item.swapSpaceSpi || !item.swapSpaceSpi.kind && item.caches) {
@@ -289,8 +266,12 @@ controlCenterModule.controller('clustersController', ['$scope', '$http',
'$popov
                     if (idx >= 0) {
                         var cache = $scope.caches[idx];
 
-                        if (cache.swapEnabled)
-                            return $common.showError('Swap space SPI is not configured, but
cache "' + cache.label + '" configured to use swap!');
+                        if (cache.swapEnabled) {
+                            $scope.ui.expanded = true;
+
+                            return $common.showPopoverMessage(pnls, 8, 'swapSpaceSpi',
+                                'Swap space SPI is not configured, but cache "' + cache.label
+ '" configured to use swap!');
+                        }
                     }
                 }
             }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8eeb439a/modules/control-center-web/src/main/js/controllers/common-module.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/controllers/common-module.js b/modules/control-center-web/src/main/js/controllers/common-module.js
index 7c15038..68e6d97 100644
--- a/modules/control-center-web/src/main/js/controllers/common-module.js
+++ b/modules/control-center-web/src/main/js/controllers/common-module.js
@@ -68,7 +68,7 @@ controlCenterModule.config(function ($alertProvider) {
 
 // Common functions to be used in controllers.
 controlCenterModule.service('$common', [
-    '$alert', function ($alert) {
+    '$alert', '$popover', '$timeout', '$focus', function ($alert, $popover, $timeout, $focus)
{
         function isDefined(v) {
             return !(v === undefined || v === null);
         }
@@ -391,6 +391,24 @@ controlCenterModule.service('$common', [
             return width | 0;
         }
 
+        var popover = null;
+
+        function ensureActivePanel(panels, pnlIdx) {
+            if (panels) {
+                var activePanels = panels.activePanels;
+
+                if (!activePanels || activePanels.length < 1)
+                    panels.activePanels = [pnlIdx];
+                else if (!_.contains(activePanels, pnlIdx)) {
+                    var newActivePanels = activePanels.slice();
+
+                    newActivePanels.push(pnlIdx);
+
+                    panels.activePanels = newActivePanels;
+                }
+            }
+        }
+
         return {
             getModel: function (obj, field) {
                 var path = field.path;
@@ -514,19 +532,35 @@ controlCenterModule.service('$common', [
                 return result;
             },
             ensureActivePanel: function (panels, pnlIdx) {
-                if (panels) {
-                    var activePanels = panels.activePanels;
+                ensureActivePanel(panels, pnlIdx);
+            },
+            showPopoverMessage: function (panels, panelIndex, id, message) {
+                ensureActivePanel(panels, panelIndex);
 
-                    if (!activePanels || activePanels.length < 1)
-                        panels.activePanels = [pnlIdx];
-                    else if (!_.contains(activePanels, pnlIdx)) {
-                        var newActivePanels = activePanels.slice();
+                var el = $('body').find('#' + id);
 
-                        newActivePanels.push(pnlIdx);
+                if (popover)
+                    popover.hide();
 
-                        panels.activePanels = newActivePanels;
-                    }
-                }
+                var newPopover = $popover(el, {content: message});
+
+                $timeout(function () {
+                    $focus(id);
+                }, 50);
+
+                $timeout(function () {
+                    newPopover.show();
+
+                    popover = newPopover;
+                }, 100);
+
+                $timeout(function () { newPopover.hide() }, 3000);
+
+                return false;
+            },
+            hidePopover: function () {
+                if (popover)
+                    popover.hide();
             }
         }
     }]);
@@ -954,9 +988,13 @@ controlCenterModule.factory('$focus', function ($timeout) {
             if (elem.length > 0) {
                 var offset = elem.offset();
 
-                if(offset.top < window.pageYOffset)
+                var elemOffset = offset.top;
+
+                var winOffset = window.pageYOffset;
+
+                if(elemOffset - 20 < winOffset || elemOffset + elem.outerHeight(true)
+ 20 > winOffset + window.innerHeight)
                     $('html, body').animate({
-                        scrollTop: offset.top - 20
+                        scrollTop: elemOffset - 20
                     }, 10);
 
                 elem[0].focus();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8eeb439a/modules/control-center-web/src/main/js/controllers/models/clusters.json
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/controllers/models/clusters.json b/modules/control-center-web/src/main/js/controllers/models/clusters.json
index 1233f91..288800d 100644
--- a/modules/control-center-web/src/main/js/controllers/models/clusters.json
+++ b/modules/control-center-web/src/main/js/controllers/models/clusters.json
@@ -671,6 +671,7 @@
             "Provides a mechanism in grid for storing data on disk.",
             "Ignite cache uses swap space to overflow data to disk if it cannot fit in memory."
           ],
+          "id": "swapSpaceSpi",
           "details": {
             "FileSwapSpaceSpi": {
               "fields": [

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8eeb439a/modules/control-center-web/src/main/js/views/includes/controls.jade
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/views/includes/controls.jade b/modules/control-center-web/src/main/js/views/includes/controls.jade
index 74f11a0..b989a53 100644
--- a/modules/control-center-web/src/main/js/views/includes/controls.jade
+++ b/modules/control-center-web/src/main/js/views/includes/controls.jade
@@ -311,7 +311,7 @@ mixin form-row-custom(lblClasses, fieldClasses, dataSource)
             - var expanded = 'field.details[' + fieldMdl + '].expanded'
 
             label(class=lblClasses ng-class=fieldRequiredClass) {{::field.label}}:
-            div(class=fieldClasses)
+            div(class=fieldClasses id='{{::field.id}}')
                 +tipField('field.tip')
                 .input-tip
                     button.form-control(bs-select data-placeholder='{{::field.placeholder}}'
bs-options='item.value as item.label for item in {{field.items}}')&attributes(fieldCommon)

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8eeb439a/modules/control-center-web/src/main/js/views/templates/popover.jade
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/views/templates/popover.jade b/modules/control-center-web/src/main/js/views/templates/popover.jade
index 3770482..5c8f1d0 100644
--- a/modules/control-center-web/src/main/js/views/templates/popover.jade
+++ b/modules/control-center-web/src/main/js/views/templates/popover.jade
@@ -15,6 +15,10 @@
     limitations under the License.
 
 .popover-arrow.popover
-        .popover-content
-            label {{content}}
-            button.close(type='button' ng-click='$hide()') &times;
+    table
+        tr
+            td
+                .popover-content
+                    label {{content}}
+            td
+                button.close(type='button' ng-click='$hide()') &times;


Mime
View raw message