Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-843 1877a5532 -> c873d9850


# IGNITE-843 Restore selected item.


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

Branch: refs/heads/ignite-843
Commit: c873d98502a20517015299f64ef3fe251fe0a189
Parents: 1877a55
Author: AKuznetsov <akuznet...@gridgain.com>
Authored: Fri Jun 26 13:35:53 2015 +0700
Committer: AKuznetsov <akuznet...@gridgain.com>
Committed: Fri Jun 26 13:35:53 2015 +0700

----------------------------------------------------------------------
 .../public/javascripts/controllers/caches.js    | 21 +++++++++++++++-----
 .../public/javascripts/controllers/clusters.js  | 21 +++++++++++++++-----
 .../javascripts/controllers/persistences.js     | 13 +++++++++++-
 3 files changed, 44 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c873d985/modules/webconfig/nodejs/public/javascripts/controllers/caches.js
----------------------------------------------------------------------
diff --git a/modules/webconfig/nodejs/public/javascripts/controllers/caches.js 
b/modules/webconfig/nodejs/public/javascripts/controllers/caches.js
index 264ac47..741365a 100644
--- a/modules/webconfig/nodejs/public/javascripts/controllers/caches.js
+++ b/modules/webconfig/nodejs/public/javascripts/controllers/caches.js
@@ -89,7 +89,18 @@ configuratorModule.controller('cachesController', ['$scope', 
'$alert', '$http',
                 $scope.spaces = data.spaces;
                 $scope.caches = data.caches;
 
-                $scope.backupItem = 
angular.fromJson(sessionStorage.cacheBackupItem);
+                var restoredItem = 
angular.fromJson(sessionStorage.cacheBackupItem);
+
+                if (restoredItem) {
+                    var idx = _.findIndex($scope.caches, function (cache) {
+                        return cache._id == restoredItem._id;
+                    });
+
+                    if (idx >= 0)
+                        $scope.selectedItem = $scope.caches[idx];
+
+                    $scope.backupItem = restoredItem;
+                }
 
                 $scope.$watch('backupItem', function (val) {
                     if (val)
@@ -115,12 +126,12 @@ configuratorModule.controller('cachesController', 
['$scope', '$alert', '$http',
 
             $http.post('/rest/caches/save', item)
                 .success(function (_id) {
-                    var i = _.findIndex($scope.caches, function (cache) {
+                    var idx = _.findIndex($scope.caches, function (cache) {
                         return cache._id == _id;
                     });
 
-                    if (i >= 0)
-                        angular.extend($scope.caches[i], item);
+                    if (idx >= 0)
+                        angular.extend($scope.caches[idx], item);
                     else {
                         item._id = _id;
 
@@ -129,7 +140,7 @@ configuratorModule.controller('cachesController', 
['$scope', '$alert', '$http',
 
                     $scope.selectItem(item);
 
-                    $alert({type: "success", title: 'Cache saved.', duration: 
1, placement: "top", container: '#save-btn'});
+                    $alert({type: "success", title: 'Cache saved.', duration: 
2, container: '#save-btn'});
                 })
                 .error(function (errorMessage) {
                     $alert({title: errorMessage});

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c873d985/modules/webconfig/nodejs/public/javascripts/controllers/clusters.js
----------------------------------------------------------------------
diff --git 
a/modules/webconfig/nodejs/public/javascripts/controllers/clusters.js 
b/modules/webconfig/nodejs/public/javascripts/controllers/clusters.js
index fd2b976..438a67c 100644
--- a/modules/webconfig/nodejs/public/javascripts/controllers/clusters.js
+++ b/modules/webconfig/nodejs/public/javascripts/controllers/clusters.js
@@ -101,7 +101,18 @@ configuratorModule.controller('clustersController', 
['$scope', '$alert', '$http'
                 $scope.spaces = data.spaces;
                 $scope.clusters = data.clusters;
 
-                $scope.backupItem = 
angular.fromJson(sessionStorage.clusterBackupItem);
+                var restoredItem = 
angular.fromJson(sessionStorage.clusterBackupItem);
+
+                if (restoredItem) {
+                    var idx = _.findIndex($scope.clusters, function (cluster) {
+                        return cluster._id == restoredItem._id;
+                    });
+
+                    if (idx >= 0)
+                        $scope.selectedItem = $scope.clusters[idx];
+
+                    $scope.backupItem = restoredItem;
+                }
 
                 $scope.$watch('backupItem', function (val) {
                     if (val)
@@ -128,12 +139,12 @@ configuratorModule.controller('clustersController', 
['$scope', '$alert', '$http'
 
             $http.post('/rest/clusters/save', item)
                 .success(function(_id) {
-                    var i = _.findIndex($scope.clusters, function(cluster) {
+                    var idx = _.findIndex($scope.clusters, function(cluster) {
                         return cluster._id == _id;
                     });
 
-                    if (i >= 0)
-                        angular.extend($scope.clusters[i], item);
+                    if (idx >= 0)
+                        angular.extend($scope.clusters[idx], item);
                     else {
                         item._id = _id;
 
@@ -142,7 +153,7 @@ configuratorModule.controller('clustersController', 
['$scope', '$alert', '$http'
 
                     $scope.selectItem(item);
 
-                    $alert({type: "success", title: 'Cluster saved.', 
duration: 1, placement: "top", container: '#save-btn'});
+                    $alert({type: "success", title: 'Cluster saved.', 
duration: 2, container: '#save-btn'});
                 })
                 .error(function(errorMessage) {
                     $alert({title: errorMessage});

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c873d985/modules/webconfig/nodejs/public/javascripts/controllers/persistences.js
----------------------------------------------------------------------
diff --git 
a/modules/webconfig/nodejs/public/javascripts/controllers/persistences.js 
b/modules/webconfig/nodejs/public/javascripts/controllers/persistences.js
index 9fd3bc6..836561a 100644
--- a/modules/webconfig/nodejs/public/javascripts/controllers/persistences.js
+++ b/modules/webconfig/nodejs/public/javascripts/controllers/persistences.js
@@ -42,7 +42,18 @@ configuratorModule.controller('persistenceController', 
['$scope', '$alert', '$ht
                 $scope.spaces = data.spaces;
                 $scope.persistences = data.persistences;
 
-                $scope.backupItem = 
angular.fromJson(sessionStorage.persistenceBackupItem);
+                var restoredItem = 
angular.fromJson(sessionStorage.persistenceBackupItem);
+
+                if (restoredItem) {
+                    var idx = _.findIndex($scope.persistences, function 
(persistence) {
+                        return persistence._id == restoredItem._id;
+                    });
+
+                    if (idx >= 0)
+                        $scope.selectedItem = $scope.persistences[idx];
+
+                    $scope.backupItem = restoredItem;
+                }
 
                 $scope.$watch('backupItem', function (val) {
                     if (val)

Reply via email to