ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject ignite git commit: IGNITE-843: Undo for groups.
Date Fri, 11 Sep 2015 08:39:26 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-843 3a7c11eff -> 7591c2143


IGNITE-843: Undo for groups.


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

Branch: refs/heads/ignite-843
Commit: 7591c2143a5a1036c4880306663f6d1d6233e1ea
Parents: 3a7c11e
Author: Alexey Kuznetsov <akuznetsov@apache.org>
Authored: Fri Sep 11 15:40:04 2015 +0700
Committer: Alexey Kuznetsov <akuznetsov@apache.org>
Committed: Fri Sep 11 15:40:04 2015 +0700

----------------------------------------------------------------------
 .../main/js/controllers/caches-controller.js    | 32 ++++---
 .../main/js/controllers/clusters-controller.js  | 32 +++++--
 .../src/main/js/controllers/common-module.js    | 87 ++++++++++++++++----
 .../main/js/controllers/metadata-controller.js  | 15 +++-
 .../src/main/js/public/stylesheets/style.scss   |  5 ++
 .../src/main/js/views/includes/controls.jade    |  1 +
 6 files changed, 135 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/7591c214/modules/control-center-web/src/main/js/controllers/caches-controller.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/controllers/caches-controller.js b/modules/control-center-web/src/main/js/controllers/caches-controller.js
index 0c8fe39..cf012ea 100644
--- a/modules/control-center-web/src/main/js/controllers/caches-controller.js
+++ b/modules/control-center-web/src/main/js/controllers/caches-controller.js
@@ -415,15 +415,8 @@ controlCenterModule.controller('cachesController', [
                     'Selected cache: ' + $scope.backupItem.name : 'New cache';
             };
 
-            // Add new cache.
-            $scope.createItem = function () {
-                $table.tableReset();
-
-                $timeout(function () {
-                    $common.ensureActivePanel($scope.panels, 'general', 'cacheName');
-                });
-
-                var newItem = {
+            function prepareNewItem() {
+                return {
                     space: $scope.spaces[0]._id,
                     cacheMode: 'PARTITIONED',
                     atomicityMode: 'ATOMIC',
@@ -432,8 +425,17 @@ controlCenterModule.controller('cachesController', [
                     clusters: [],
                     metadatas: []
                 };
+            }
 
-                $scope.selectItem(undefined, newItem);
+            // Add new cache.
+            $scope.createItem = function () {
+                $table.tableReset();
+
+                $timeout(function () {
+                    $common.ensureActivePanel($scope.panels, 'general', 'cacheName');
+                });
+
+                $scope.selectItem(undefined, prepareNewItem());
             };
 
             // Check cache logical consistency.
@@ -596,5 +598,15 @@ controlCenterModule.controller('cachesController', [
                     }
                 );
             };
+
+            $scope.resetItem = function (group) {
+                var resetTo = $scope.selectedItem;
+
+                if (!$common.isDefined(resetTo))
+                    resetTo = prepareNewItem();
+
+                $common.resetItem($scope.backupItem, resetTo, $scope.general, group);
+                $common.resetItem($scope.backupItem, resetTo, $scope.advanced, group);
+            }
         }]
 );

http://git-wip-us.apache.org/repos/asf/ignite/blob/7591c214/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 16919fa..55cef9b 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
@@ -313,14 +313,7 @@ controlCenterModule.controller('clustersController', ['$scope', '$controller',
'
                 'Selected cluster: ' + $scope.backupItem.name : 'New cluster';
         };
 
-        // Add new cluster.
-        $scope.createItem = function () {
-            $table.tableReset();
-
-            $timeout(function () {
-                $common.ensureActivePanel($scope.panels, "general", 'clusterName');
-            });
-
+        function prepareNewItem() {
             var newItem = {
                 discovery: {kind: 'Multicast', Vm: {addresses: ['127.0.0.1:47500..47510']},
Multicast: {}},
                 deploymentMode: 'SHARED'
@@ -329,7 +322,18 @@ controlCenterModule.controller('clustersController', ['$scope', '$controller',
'
             newItem.caches = [];
             newItem.space = $scope.spaces[0]._id;
 
-            $scope.selectItem(undefined, newItem);
+            return newItem;
+        }
+
+        // Add new cluster.
+        $scope.createItem = function () {
+            $table.tableReset();
+
+            $timeout(function () {
+                $common.ensureActivePanel($scope.panels, "general", 'clusterName');
+            });
+
+            $scope.selectItem(undefined, prepareNewItem());
         };
 
         $scope.indexOfCache = function (cacheId) {
@@ -503,5 +507,15 @@ controlCenterModule.controller('clustersController', ['$scope', '$controller',
'
                 }
             );
         };
+
+        $scope.resetItem = function (group) {
+            var resetTo = $scope.selectedItem;
+
+            if (!$common.isDefined(resetTo))
+                resetTo = prepareNewItem();
+
+            $common.resetItem($scope.backupItem, resetTo, $scope.general, group);
+            $common.resetItem($scope.backupItem, resetTo, $scope.advanced, group);
+        }
     }]
 );

http://git-wip-us.apache.org/repos/asf/ignite/blob/7591c214/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 2e88d84..9c3bf82 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
@@ -500,30 +500,32 @@ controlCenterModule.service('$common', [
             return isDefined(form) && form.$dirty;
         }
 
-        return {
-            getModel: function (obj, field) {
-                var path = field.path;
+        function getModel(obj, field) {
+            var path = field.path;
 
-                if (!isDefined(path))
-                    return obj;
+            if (!isDefined(path))
+                return obj;
 
-                path = path.replace(/\[(\w+)\]/g, '.$1'); // convert indexes to properties
-                path = path.replace(/^\./, '');           // strip a leading dot
+            path = path.replace(/\[(\w+)\]/g, '.$1'); // convert indexes to properties
+            path = path.replace(/^\./, '');           // strip a leading dot
 
-                var segs = path.split('.');
-                var root = obj;
+            var segs = path.split('.');
+            var root = obj;
 
-                while (segs.length > 0) {
-                    var pathStep = segs.shift();
+            while (segs.length > 0) {
+                var pathStep = segs.shift();
 
-                    if (typeof root[pathStep] === 'undefined')
-                        root[pathStep] = {};
+                if (typeof root[pathStep] === 'undefined')
+                    root[pathStep] = {};
 
-                    root = root[pathStep];
-                }
+                root = root[pathStep];
+            }
 
-                return root;
-            },
+            return root;
+        }
+
+        return {
+            getModel: getModel,
             joinTip: function (arr) {
                 if (!arr) {
                     return arr;
@@ -707,6 +709,57 @@ controlCenterModule.service('$common', [
                 file.click();
 
                 document.body.removeChild(file);
+            },
+            resetItem: function (backupItem, selectedItem, groups, group) {
+                function restoreFields(fields) {
+                    // Reset fields by one.
+                    for (var fldIx = 0; fldIx < fields.length; fldIx ++) {
+                        var field = fields[fldIx];
+
+                        var destMdl = getModel(backupItem, field);
+
+                        if (isDefined(destMdl)) {
+                            if (isDefined(selectedItem)) {
+                                var srcMdl = getModel(selectedItem, field);
+
+                                if (isDefined(srcMdl)) {
+                                    // For array create copy.
+                                    if ($.isArray(srcMdl[field.model]))
+                                        destMdl[field.model] = srcMdl[field.model].slice();
+                                    else
+                                        destMdl[field.model] = srcMdl[field.model];
+                                }
+                                else
+                                    destMdl[field.model] = undefined;
+                            }
+                            else
+                                destMdl[field.model] = undefined;
+
+                            // For kind field restore kind value and all configured kinds.
+                            if (field.model == 'kind') {
+                                var kind = getModel(backupItem, field)[field.model];
+
+                                var details = field.details;
+
+                                var keys = Object.keys(details);
+
+                                for (var detIx = 0; detIx < keys.length; detIx++)
+                                    restoreFields(details[keys[detIx]].fields);
+                            }
+                        }
+                    }
+                }
+
+                // Find group metadata to reset group values.
+                for (var grpIx = 0; grpIx < groups.length; grpIx ++) {
+                    if (groups[grpIx].group == group) {
+                        var fields = groups[grpIx].fields;
+
+                        restoreFields(fields);
+
+                        break;
+                    }
+                }
             }
         }
     }]);

http://git-wip-us.apache.org/repos/asf/ignite/blob/7591c214/modules/control-center-web/src/main/js/controllers/metadata-controller.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/controllers/metadata-controller.js b/modules/control-center-web/src/main/js/controllers/metadata-controller.js
index e8ac53d..df24a31 100644
--- a/modules/control-center-web/src/main/js/controllers/metadata-controller.js
+++ b/modules/control-center-web/src/main/js/controllers/metadata-controller.js
@@ -702,6 +702,10 @@ controlCenterModule.controller('metadataController', [
                     : 'New metadata';
             };
 
+            function prepareNewItem() {
+                return {space: $scope.spaces[0]._id, caches: []};
+            }
+
             // Add new metadata.
             $scope.createItem = function () {
                 $table.tableReset();
@@ -710,7 +714,7 @@ controlCenterModule.controller('metadataController', [
                     $common.ensureActivePanel($scope.panels, 'metadata', 'keyType');
                 });
 
-                $scope.selectItem(undefined, {space: $scope.spaces[0]._id, caches: []});
+                $scope.selectItem(undefined, prepareNewItem());
             };
 
             // Check metadata logical consistency.
@@ -1179,5 +1183,14 @@ controlCenterModule.controller('metadataController', [
                 // Dirty state do not change automatically.
                 $scope.ui.inputForm.$dirty = true;
             };
+
+            $scope.resetItem = function (group) {
+                var resetTo = $scope.selectedItem;
+
+                if (!$common.isDefined(resetTo))
+                    resetTo = prepareNewItem();
+
+                $common.resetItem($scope.backupItem, resetTo, $scope.metadata, group);
+            }
         }]
 );

http://git-wip-us.apache.org/repos/asf/ignite/blob/7591c214/modules/control-center-web/src/main/js/public/stylesheets/style.scss
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/public/stylesheets/style.scss b/modules/control-center-web/src/main/js/public/stylesheets/style.scss
index aaeaa1c..4931a51 100644
--- a/modules/control-center-web/src/main/js/public/stylesheets/style.scss
+++ b/modules/control-center-web/src/main/js/public/stylesheets/style.scss
@@ -522,6 +522,11 @@ h3 {
     a { color: black; }
 
     .btn-group { margin-left: 10px; }
+
+    .fa-undo {
+        margin-top: 5px;
+        font-size: 16px;
+    }
 }
 
 .theme-line .panel-heading:hover {

http://git-wip-us.apache.org/repos/asf/ignite/blob/7591c214/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 3966cfc..410ba11 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
@@ -440,6 +440,7 @@ mixin groups(groups, dataSource)
             label(id='{{::group.group + "-title"}}')
             i.tipLabel.fa.fa-question-circle(ng-if='group.tip' bs-tooltip='joinTip(group.tip)'
type='button')
             i.tipLabel.fa.fa-question-circle.blank(ng-if='!group.tip')
+            i.pull-right.fa.fa-undo(ng-click='resetItem(group.group);$event.stopPropagation()'
bs-tooltip data-title='Undo unsaved changes')
         .panel-collapse(role='tabpanel' bs-collapse-target id='{{::group.group}}' number='{{::group.number}}')
             .panel-body
                 .col-sm-6(id='{{::group.group + "-left"}}')


Mime
View raw message