You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ak...@apache.org on 2015/08/28 06:28:20 UTC

ignite git commit: IGNITE-843 Implemented "Remove All" actions for clusters, caches, metadata.

Repository: ignite
Updated Branches:
  refs/heads/ignite-843 b7d2005c1 -> 0d7bd7276


IGNITE-843 Implemented "Remove All" actions for clusters, caches, metadata.


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

Branch: refs/heads/ignite-843
Commit: 0d7bd72763f67cb595979afa95025c93a6bdfcc0
Parents: b7d2005
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Fri Aug 28 11:28:43 2015 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Fri Aug 28 11:28:43 2015 +0700

----------------------------------------------------------------------
 .../main/js/controllers/caches-controller.js    | 23 +++++++++++++++
 .../main/js/controllers/clusters-controller.js  | 23 +++++++++++++++
 .../src/main/js/controllers/common-module.js    |  2 +-
 .../main/js/controllers/metadata-controller.js  | 24 ++++++++++++++++
 .../src/main/js/routes/caches.js                | 30 +++++++++++++++++---
 .../src/main/js/routes/clusters.js              | 27 ++++++++++++------
 .../src/main/js/routes/metadata.js              | 23 +++++++++++++++
 7 files changed, 139 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/0d7bd727/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 a788392..2fae5e8 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
@@ -515,5 +515,28 @@ controlCenterModule.controller('cachesController', [
                     }
                 );
             };
+
+            // Remove all caches from db.
+            $scope.removeAllItems = function () {
+                $table.tableReset();
+
+                $confirm.show('Are you sure you want to remove all caches?').then(
+                    function () {
+                        $common.markPristine($scope.ui.inputForm, 'cacheBackupItemChanged');
+
+                        $http.post('caches/remove/all')
+                            .success(function () {
+                                $common.showInfo('All caches have been removed');
+
+                                $scope.caches = [];
+
+                                $scope.selectItem(undefined, undefined);
+                            })
+                            .error(function (errMsg) {
+                                $common.showError(errMsg);
+                            });
+                    }
+                );
+            };
         }]
 );

http://git-wip-us.apache.org/repos/asf/ignite/blob/0d7bd727/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 863c8b4..9309330 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
@@ -452,5 +452,28 @@ controlCenterModule.controller('clustersController', ['$scope', '$controller', '
                 }
             );
         };
+
+        // Remove all clusters from db.
+        $scope.removeAllItems = function () {
+            $table.tableReset();
+
+            $confirm.show('Are you sure you want to remove all clusters?').then(
+                function () {
+                    $common.markPristine($scope.ui.inputForm, 'clusterBackupItemChanged');
+
+                    $http.post('clusters/remove/all')
+                        .success(function () {
+                            $common.showInfo('All clusters have been removed');
+
+                            $scope.clusters = [];
+
+                            $scope.selectItem(undefined, undefined);
+                        })
+                        .error(function (errMsg) {
+                            $common.showError(errMsg);
+                        });
+                }
+            );
+        };
     }]
 );

http://git-wip-us.apache.org/repos/asf/ignite/blob/0d7bd727/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 4f05c4e..c4b3c50 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
@@ -1323,5 +1323,5 @@ controlCenterModule.controller('notebooks', ['$scope', '$http', '$common', funct
 // Navigation bar controller.
 controlCenterModule.controller('save-remove', ['$scope', function ($scope) {
     $scope.saveDropdown = [{ 'text': 'Copy', 'click': 'copyItem()'}];
-    $scope.removeDropdown = [{ 'text': 'Remove All', 'click': 'removeAllItems'}];
+    $scope.removeDropdown = [{ 'text': 'Remove All', 'click': 'removeAllItems()'}];
 }]);

http://git-wip-us.apache.org/repos/asf/ignite/blob/0d7bd727/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 7b06367..064b3c5 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
@@ -730,6 +730,7 @@ controlCenterModule.controller('metadataController', [
                     });
             };
 
+            // Remove metadata from db.
             $scope.removeItem = function () {
                 $table.tableReset();
 
@@ -768,6 +769,29 @@ controlCenterModule.controller('metadataController', [
                     });
             };
 
+            // Remove all metadata from db.
+            $scope.removeAllItems = function () {
+                $table.tableReset();
+
+                $confirm.show('Are you sure you want to remove all metadata?').then(
+                    function () {
+                        $common.markPristine($scope.ui.inputForm, 'metadataBackupItemChanged');
+
+                        $http.post('metadata/remove/all')
+                            .success(function () {
+                                $common.showInfo('All metadata have been removed');
+
+                                $scope.metadata = [];
+
+                                $scope.selectItem(undefined, undefined);
+                            })
+                            .error(function (errMsg) {
+                                $common.showError(errMsg);
+                            });
+                    }
+                );
+            };
+
             $scope.tableSimpleValid = function (item, field, name, index) {
                 var model = item[field.model];
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/0d7bd727/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 3d2851c..a9a0402 100644
--- a/modules/control-center-web/src/main/js/routes/caches.js
+++ b/modules/control-center-web/src/main/js/routes/caches.js
@@ -101,9 +101,9 @@ router.post('/save', function (req, res) {
     if (params._id){
         db.Cache.update({_id: cacheId}, params, {upsert: true}, function (err) {
             if (db.processed(err, res))
-                db.Cluster.update({_id: {$in: clusters}}, {$addToSet: {caches: cacheId}}, {upsert: true, multi: true}, function(err) {
+                db.Cluster.update({_id: {$in: clusters}}, {$addToSet: {caches: cacheId}}, {multi: true}, function(err) {
                     if (db.processed(err, res))
-                        db.Cluster.update({_id: {$nin: clusters}}, {$pull: {caches: cacheId}}, {upsert: true, multi: true}, function(err) {
+                        db.Cluster.update({_id: {$nin: clusters}}, {$pull: {caches: cacheId}}, {multi: true}, function(err) {
                             if (db.processed(err, res))
                                 res.send(params._id);
                         });
@@ -120,12 +120,11 @@ router.post('/save', function (req, res) {
                     if (db.processed(err, res)) {
                         cacheId = cache._id;
 
-                        db.Cluster.update({_id: {$in: clusters}}, {$addToSet: {caches: cacheId}}, {upsert: true, multi: true}, function(err) {
+                        db.Cluster.update({_id: {$in: clusters}}, {$addToSet: {caches: cacheId}}, {multi: true}, function(err) {
                             if (db.processed(err, res))
                                 res.send(cacheId);
                         });
                     }
-
                 });
             }
         });
@@ -141,4 +140,27 @@ router.post('/remove', function (req, res) {
     })
 });
 
+/**
+ * Remove all caches.
+ */
+router.post('/remove/all', function (req, res) {
+    var user_id = req.currentUserId();
+
+    // Get owned space and all accessed space.
+    db.Space.find({$or: [{owner: user_id}, {usedBy: {$elemMatch: {account: user_id}}}]}, function (err, spaces) {
+        if (db.processed(err, res)) {
+            var space_ids = spaces.map(function (value) {
+                return value._id;
+            });
+
+            db.Cache.remove({space: {$in: space_ids}}, function (err) {
+                if (err)
+                    return res.status(500).send(err.message);
+
+                res.sendStatus(200);
+            })
+        }
+    });
+});
+
 module.exports = router;

http://git-wip-us.apache.org/repos/asf/ignite/blob/0d7bd727/modules/control-center-web/src/main/js/routes/clusters.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/routes/clusters.js b/modules/control-center-web/src/main/js/routes/clusters.js
index 5870ca4..21caee7 100644
--- a/modules/control-center-web/src/main/js/routes/clusters.js
+++ b/modules/control-center-web/src/main/js/routes/clusters.js
@@ -75,9 +75,9 @@ router.post('/save', function (req, res) {
     if (params._id)
         db.Cluster.update({_id: params._id}, params, {upsert: true}, function (err) {
             if (db.processed(err, res))
-                db.Cache.update({_id: {$in: caches}}, {$addToSet: {clusters: clusterId}}, {upsert: true, multi: true}, function(err) {
+                db.Cache.update({_id: {$in: caches}}, {$addToSet: {clusters: clusterId}}, {multi: true}, function(err) {
                     if (db.processed(err, res)) {
-                        db.Cache.update({_id: {$nin: caches}}, {$pull: {clusters: clusterId}}, {upsert: true, multi: true}, function(err) {
+                        db.Cache.update({_id: {$nin: caches}}, {$pull: {clusters: clusterId}}, {multi: true}, function(err) {
                             if (db.processed(err, res))
                                 res.send(params._id);
                         });
@@ -94,7 +94,7 @@ router.post('/save', function (req, res) {
                     if (db.processed(err, res)) {
                         clusterId = cluster._id;
 
-                        db.Cache.update({_id: {$in: caches}}, {$addToSet: {clusters: clusterId}}, {upsert: true, multi: true}, function (err) {
+                        db.Cache.update({_id: {$in: caches}}, {$addToSet: {clusters: clusterId}}, {multi: true}, function (err) {
                             if (db.processed(err, res))
                                 res.send(clusterId);
                         });
@@ -121,12 +121,23 @@ router.post('/remove', function (req, res) {
  * Remove all clusters.
  */
 router.post('/remove/all', function (req, res) {
-    db.Cluster.remove(req.body, function (err) {
-        if (err)
-            return res.status(500).send(err.message);
+    var user_id = req.currentUserId();
 
-        res.sendStatus(200);
-    })
+    // Get owned space and all accessed space.
+    db.Space.find({$or: [{owner: user_id}, {usedBy: {$elemMatch: {account: user_id}}}]}, function (err, spaces) {
+        if (db.processed(err, res)) {
+            var space_ids = spaces.map(function (value) {
+                return value._id;
+            });
+
+            db.Cluster.remove({space: {$in: space_ids}}, function (err) {
+                if (err)
+                    return res.status(500).send(err.message);
+
+                res.sendStatus(200);
+            })
+        }
+    });
 });
 
 module.exports = router;

http://git-wip-us.apache.org/repos/asf/ignite/blob/0d7bd727/modules/control-center-web/src/main/js/routes/metadata.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/routes/metadata.js b/modules/control-center-web/src/main/js/routes/metadata.js
index 6158f27..68b5922 100644
--- a/modules/control-center-web/src/main/js/routes/metadata.js
+++ b/modules/control-center-web/src/main/js/routes/metadata.js
@@ -89,4 +89,27 @@ router.post('/remove', function (req, res) {
     })
 });
 
+/**
+ * Remove all metadata.
+ */
+router.post('/remove/all', function (req, res) {
+    var user_id = req.currentUserId();
+
+    // Get owned space and all accessed space.
+    db.Space.find({$or: [{owner: user_id}, {usedBy: {$elemMatch: {account: user_id}}}]}, function (err, spaces) {
+        if (db.processed(err, res)) {
+            var space_ids = spaces.map(function (value) {
+                return value._id;
+            });
+
+            db.CacheTypeMetadata.remove({space: {$in: space_ids}}, function (err) {
+                if (err)
+                    return res.status(500).send(err.message);
+
+                res.sendStatus(200);
+            })
+        }
+    });
+});
+
 module.exports = router;