Repository: incubator-ignite Updated Branches: refs/heads/ignite-1121 2e814bd59 -> 386c223f5
IGNITE-843: Added remove confirmation for cluster and cache. Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/14d8146d Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/14d8146d Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/14d8146d Branch: refs/heads/ignite-1121 Commit: 14d8146dc64772eb57617a2064b7ac2c067649ce Parents: 3abac23 Author: AKuznetsov <akuznet...@gridgain.com> Authored: Wed Jul 15 20:08:47 2015 +0700 Committer: AKuznetsov <akuznet...@gridgain.com> Committed: Wed Jul 15 20:08:47 2015 +0700 ---------------------------------------------------------------------- .../nodejs/controllers/admin-controller.js | 80 ++++++++++---------- .../nodejs/controllers/caches-controller.js | 48 +++++++----- .../nodejs/controllers/clusters-controller.js | 50 +++++++----- 3 files changed, 100 insertions(+), 78 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/14d8146d/modules/web-control-center/nodejs/controllers/admin-controller.js ---------------------------------------------------------------------- diff --git a/modules/web-control-center/nodejs/controllers/admin-controller.js b/modules/web-control-center/nodejs/controllers/admin-controller.js index e6065c0..b67d7d9 100644 --- a/modules/web-control-center/nodejs/controllers/admin-controller.js +++ b/modules/web-control-center/nodejs/controllers/admin-controller.js @@ -16,53 +16,53 @@ */ controlCenterModule.controller('adminController', ['$scope', '$http', '$confirm', 'commonFunctions', function ($scope, $http, $confirm, commonFunctions) { - $scope.users = null; + $scope.users = null; - function reload() { - $http.post('admin/list') - .success(function (data) { - $scope.users = data; - }) - .error(function (errMsg) { - commonFunctions.showError(commonFunctions.errorMessage(errMsg)); - }); - } + function reload() { + $http.post('admin/list') + .success(function (data) { + $scope.users = data; + }) + .error(function (errMsg) { + commonFunctions.showError(commonFunctions.errorMessage(errMsg)); + }); + } - reload(); + reload(); - $scope.removeUser = function (user) { - $confirm.show("Are you sure you want to delete user: '" + user.username + "'?").then(function() { - $http.post('admin/remove', {userId: user._id}).success( - function () { - var i = _.findIndex($scope.users, function (u) { - return u._id == user._id; - }); + $scope.removeUser = function (user) { + $confirm.show('Are you sure you want to remove user: "' + user.username + '"?').then(function () { + $http.post('admin/remove', {userId: user._id}).success( + function () { + var i = _.findIndex($scope.users, function (u) { + return u._id == user._id; + }); - if (i >= 0) - $scope.users.splice(i, 1); + if (i >= 0) + $scope.users.splice(i, 1); - commonFunctions.showInfo("User has been removed: '" + user.username + "'"); - }).error(function (errMsg) { - commonFunctions.showError("Failed to remove user: " + commonFunctions.errorMessage(errMsg)); - }); - }); - }; + commonFunctions.showInfo('User has been removed: "' + user.username + '"'); + }).error(function (errMsg) { + commonFunctions.showError('Failed to remove user: "' + commonFunctions.errorMessage(errMsg) + '"'); + }); + }); + }; - $scope.toggleAdmin = function (user) { - if (user.adminChanging) - return; + $scope.toggleAdmin = function (user) { + if (user.adminChanging) + return; - user.adminChanging = true; + user.adminChanging = true; - $http.post('admin/save', {userId: user._id, adminFlag: !user.admin}).success( - function () { - commonFunctions.showInfo("Admin right was successfully toggled for user: '" + user.username + "'"); + $http.post('admin/save', {userId: user._id, adminFlag: !user.admin}).success( + function () { + commonFunctions.showInfo('Admin right was successfully toggled for user: "' + user.username + '"'); - user.adminChanging = false; - }).error(function (errMsg) { - commonFunctions.showError("Failed to toggle admin right for user: " + commonFunctions.errorMessage(errMsg)); + user.adminChanging = false; + }).error(function (errMsg) { + commonFunctions.showError('Failed to toggle admin right for user: "' + commonFunctions.errorMessage(errMsg) + '"'); - user.adminChanging = false; - }); - } - }]); \ No newline at end of file + user.adminChanging = false; + }); + } +}]); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/14d8146d/modules/web-control-center/nodejs/controllers/caches-controller.js ---------------------------------------------------------------------- diff --git a/modules/web-control-center/nodejs/controllers/caches-controller.js b/modules/web-control-center/nodejs/controllers/caches-controller.js index 5c9a793..7d81595 100644 --- a/modules/web-control-center/nodejs/controllers/caches-controller.js +++ b/modules/web-control-center/nodejs/controllers/caches-controller.js @@ -15,7 +15,7 @@ * limitations under the License. */ -controlCenterModule.controller('cachesController', ['$scope', '$http', 'commonFunctions', function ($scope, $http, commonFunctions) { +controlCenterModule.controller('cachesController', ['$scope', '$http', '$confirm', 'commonFunctions', function ($scope, $http, $confirm, commonFunctions) { $scope.swapSimpleItems = commonFunctions.swapSimpleItems; $scope.joinTip = commonFunctions.joinTip; $scope.getModel = commonFunctions.getModel; @@ -202,25 +202,37 @@ controlCenterModule.controller('cachesController', ['$scope', '$http', 'commonFu }); }; - $scope.removeItem = function () { - var _id = $scope.selectedItem._id; - - $http.post('caches/remove', {_id: _id}) - .success(function () { - var i = _.findIndex($scope.caches, function (cache) { - return cache._id == _id; - }); + // Save cache in db with new name. + $scope.saveItemAs = function () { - if (i >= 0) { - $scope.caches.splice(i, 1); + }; - $scope.selectedItem = undefined; - $scope.backupItem = undefined; - } - }) - .error(function (errMsg) { - commonFunctions.showError(errMsg); - }); + // Remove cache from db. + $scope.removeItem = function () { + $confirm.show('Are you sure you want to remove cache: "' + $scope.selectedItem.name + '"?').then( + function () { + var _id = $scope.selectedItem._id; + + $http.post('caches/remove', {_id: _id}) + .success(function () { + var idx = _.findIndex($scope.caches, function (cache) { + return cache._id == _id; + }); + + if (idx >= 0) { + $scope.caches.splice(idx, 1); + + $scope.selectedItem = undefined; + $scope.backupItem = undefined; + } + + commonFunctions.showInfo('Cache has been removed: ' + $scope.selectedItem.label); + }) + .error(function (errMsg) { + commonFunctions.showError(errMsg); + }); + } + ); }; $scope.checkIndexedTypes = function (keyCls, valCls) { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/14d8146d/modules/web-control-center/nodejs/controllers/clusters-controller.js ---------------------------------------------------------------------- diff --git a/modules/web-control-center/nodejs/controllers/clusters-controller.js b/modules/web-control-center/nodejs/controllers/clusters-controller.js index 54a5a27..0d1948d 100644 --- a/modules/web-control-center/nodejs/controllers/clusters-controller.js +++ b/modules/web-control-center/nodejs/controllers/clusters-controller.js @@ -15,7 +15,7 @@ * limitations under the License. */ -controlCenterModule.controller('clustersController', ['$scope', '$http', 'commonFunctions', function ($scope, $http, commonFunctions) { +controlCenterModule.controller('clustersController', ['$scope', '$http', '$confirm', 'commonFunctions', function ($scope, $http, $confirm, commonFunctions) { $scope.swapSimpleItems = commonFunctions.swapSimpleItems; $scope.joinTip = commonFunctions.joinTip; $scope.getModel = commonFunctions.getModel; @@ -190,27 +190,37 @@ controlCenterModule.controller('clustersController', ['$scope', '$http', 'common }); }; - $scope.removeItem = function () { - var _id = $scope.selectedItem._id; - - $http.post('clusters/remove', {_id: _id}) - .success(function () { - var i = _.findIndex($scope.clusters, function (cluster) { - return cluster._id == _id; - }); + // Save cluster in db with new name. + $scope.saveItemAs = function () { - if (i >= 0) { - $scope.clusters.splice(i, 1); - - $scope.selectedItem = undefined; - $scope.backupItem = undefined; - } + }; - commonFunctions.showInfo("Cluster has been removed: " + $scope.selectedItem.label); - }) - .error(function (errMsg) { - commonFunctions.showError(errMsg); - }); + // Remove cluster from db. + $scope.removeItem = function () { + $confirm.show('Are you sure you want to remove cluster: "' + $scope.selectedItem.name + '"?').then( + function () { + var _id = $scope.selectedItem._id; + + $http.post('clusters/remove', {_id: _id}) + .success(function () { + var idx = _.findIndex($scope.clusters, function (cluster) { + return cluster._id == _id; + }); + + if (idx >= 0) { + $scope.clusters.splice(idx, 1); + + $scope.selectedItem = undefined; + $scope.backupItem = undefined; + } + + commonFunctions.showInfo('Cluster has been removed: ' + $scope.selectedItem.label); + }) + .error(function (errMsg) { + commonFunctions.showError(errMsg); + }); + } + ); }; }] ); \ No newline at end of file