Repository: incubator-ignite Updated Branches: refs/heads/ignite-843 bf7c7b266 -> a02148f41
IGNITE-843 WIP bind caches and clusters. Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/a02148f4 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/a02148f4 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/a02148f4 Branch: refs/heads/ignite-843 Commit: a02148f41b5145cfcbc7c9837c0f99e6afb8a526 Parents: bf7c7b2 Author: AKuznetsov <akuznet...@gridgain.com> Authored: Tue Aug 18 07:50:57 2015 +0700 Committer: AKuznetsov <akuznet...@gridgain.com> Committed: Tue Aug 18 07:50:57 2015 +0700 ---------------------------------------------------------------------- .../main/js/controllers/caches-controller.js | 4 +- .../main/js/controllers/clusters-controller.js | 12 +++++- .../control-center-web/src/main/js/package.json | 2 +- .../src/main/js/routes/caches.js | 41 +++++++++++--------- .../src/main/js/views/configuration/caches.jade | 2 +- 5 files changed, 38 insertions(+), 23 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a02148f4/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 38a32ea..ac11049 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 @@ -240,9 +240,11 @@ controlCenterModule.controller('cachesController', [ readFromBackup: true, copyOnRead: true }; + + $scope.backupItem.space = $scope.spaces[0]._id; + $scope.backupItem.clusters = []; $scope.backupItem.queryMetadata = []; $scope.backupItem.spaceMetadata = []; - $scope.backupItem.space = $scope.spaces[0]._id; }; // Check cache logical consistency. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a02148f4/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 570722b..a128f02 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 @@ -173,6 +173,14 @@ controlCenterModule.controller('clustersController', ['$scope', '$http', '$commo }); if (idx >= 0) { + var cluster = $scope.clusters[idx]; + + var restoredSelectedItem = angular.fromJson(sessionStorage.clusterSelectedBackupItem); + + if (restoredSelectedItem) { + // TODO + } + // Remove deleted caches. restoredItem.caches = _.filter(restoredItem.caches, function (cacheId) { return _.findIndex($scope.caches, function (scopeCache) { @@ -180,7 +188,7 @@ controlCenterModule.controller('clustersController', ['$scope', '$http', '$commo }) >= 0; }); - $scope.selectedItem = $scope.clusters[idx]; + $scope.selectedItem = cluster; $scope.backupItem = restoredItem; } else @@ -206,6 +214,8 @@ controlCenterModule.controller('clustersController', ['$scope', '$http', '$commo $scope.selectedItem = item; $scope.backupItem = angular.copy(item); + + sessionStorage.slectedClusterBackupItem = angular.toJson(item); }; // Add new cluster. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a02148f4/modules/control-center-web/src/main/js/package.json ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/package.json b/modules/control-center-web/src/main/js/package.json index 1a1fcd7..331ef79 100644 --- a/modules/control-center-web/src/main/js/package.json +++ b/modules/control-center-web/src/main/js/package.json @@ -31,7 +31,7 @@ "express-session": "^1.11.1", "jade": "~1.11.0", "lodash": "3.10.1", - "mongoose": "^4.1.2", + "mongoose": "^4.1.3", "mongoose-deep-populate": "2.0.0", "nconf": "^0.7.2", "node-sass-middleware": "^0.9.0", http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a02148f4/modules/control-center-web/src/main/js/routes/caches.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/routes/caches.js b/modules/control-center-web/src/main/js/routes/caches.js index 35a82e2..a1fea66 100644 --- a/modules/control-center-web/src/main/js/routes/caches.js +++ b/modules/control-center-web/src/main/js/routes/caches.js @@ -99,24 +99,20 @@ router.post('/list', function (req, res) { router.post('/save', function (req, res) { var params = req.body; var cacheId = params._id; - - if (params._id) - db.Cache.update({_id: cacheId}, params, {upsert: true}, function (err, cache) { - if (_processed(err, res)) { - //_.forEach(params.clusters, function (cluster) { - // db.Cluster.findOne({_id: cluster}, function (err, cluster) { - // if (_processed(err, res)) - // cluster.caches.push(cacheId); - // - // db.Cluster.update({_id: params._id}, cluster, {upsert: true}, function(err) { - // _processed(err, res); - // }); - // }); - //}); - - res.send(params._id); - } + var clusters = params.clusters; + + if (params._id){ + db.Cache.update({_id: cacheId}, params, {upsert: true}, function (err) { + if (_processed(err, res)) + db.Cluster.update({_id: {$in: clusters}}, {$addToSet: {caches: cacheId}}, {upsert: true, multi: true}, function(err) { + if (_processed(err, res)) + db.Cluster.update({_id: {$nin: clusters}}, {$pull: {caches: cacheId}}, {upsert: true, multi: true}, function(err) { + if (_processed(err, res)) + res.send(params._id); + }); + }); }); + } else db.Cache.findOne({space: params.space, name: params.name}, function (err, cache) { if (_processed(err, res)) { @@ -124,8 +120,15 @@ router.post('/save', function (req, res) { return res.status(500).send('Cache with name: "' + cache.name + '" already exist.'); (new db.Cache(params)).save(function (err, cache) { - if (_processed(er, res)) - res.send(cache._id); + if (_processed(err, res)) { + cacheId = cache._id; + + db.Cluster.update({_id: {$in: clusters}}, {$addToSet: {caches: cacheId}}, {upsert: true, multi: true}, function(err) { + if (_processed(err, res)) + res.send(cacheId); + }); + } + }); } }); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a02148f4/modules/control-center-web/src/main/js/views/configuration/caches.jade ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/views/configuration/caches.jade b/modules/control-center-web/src/main/js/views/configuration/caches.jade index 4e1c9c4..3608ccb 100644 --- a/modules/control-center-web/src/main/js/views/configuration/caches.jade +++ b/modules/control-center-web/src/main/js/views/configuration/caches.jade @@ -29,7 +29,7 @@ block content +block-callout('{{screenTip.workflowTitle}}', 'joinTip(screenTip.workflowContent)', '{{screenTip.whatsNextTitle}}', 'joinTip(screenTip.whatsNextContent)') +main-table('Caches:', 'caches', 'cacheName', 'selectItem(row)', '{{$index + 1}}) {{row.name}}, {{row.mode | displayValue:modes:"Cache mode not set"}}, {{row.atomicityMode | displayValue:atomicities:"Cache atomicity not set"}}') .padding-top-dflt - button.btn.btn-primary(on-click-focus='defaultFocusId' ng-click='createItem()') Add cache + button.btn.btn-primary(on-click-focus='cacheName' ng-click='createItem()') Add cache hr form.form-horizontal(name='inputForm' ng-if='backupItem' novalidate) .panel-group(bs-collapse ng-model='panels.activePanels' data-allow-multiple='true')