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 2016/02/12 10:54:39 UTC

[13/29] ignite git commit: IGNITE-843 Fixed eslint warnings.

IGNITE-843 Fixed eslint warnings.


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

Branch: refs/heads/ignite-843-rc3
Commit: 2023470c3400ca39fe611661e074ec808bdce3a5
Parents: 0e11d41
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Fri Feb 12 13:47:26 2016 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Fri Feb 12 13:47:26 2016 +0700

----------------------------------------------------------------------
 .../src/main/js/serve/routes/igfs.js            | 121 ++++++++++---------
 1 file changed, 61 insertions(+), 60 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/2023470c/modules/control-center-web/src/main/js/serve/routes/igfs.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/igfs.js b/modules/control-center-web/src/main/js/serve/routes/igfs.js
index f248531..f913b9b 100644
--- a/modules/control-center-web/src/main/js/serve/routes/igfs.js
+++ b/modules/control-center-web/src/main/js/serve/routes/igfs.js
@@ -15,6 +15,8 @@
  * limitations under the License.
  */
 
+'use strict';
+
 // Fire me up!
 
 module.exports = {
@@ -32,37 +34,36 @@ module.exports.factory = function(_, express, mongo) {
          * @param req Request.
          * @param res Response.
          */
-        router.post('/list', function(req, res) {
-            var user_id = req.currentUserId();
+        router.post('/list', (req, res) => {
+            const user_id = req.currentUserId();
 
             // Get owned space and all accessed space.
-            mongo.Space.find({$or: [{owner: user_id}, {usedBy: {$elemMatch: {account: user_id}}}]}, function(err, spaces) {
-                if (mongo.processed(err, res)) {
-                    var space_ids = spaces.map(function(value) {
-                        return value._id;
-                    });
+            mongo.Space.find({$or: [{owner: user_id}, {usedBy: {$elemMatch: {account: user_id}}}]}, (errSpace, spaces) => {
+                if (mongo.processed(errSpace, res)) {
+                    const space_ids = spaces.map((value) => value._id);
 
                     // Get all clusters for spaces.
-                    mongo.Cluster.find({space: {$in: space_ids}}, '_id name').sort('name').exec(function(err, clusters) {
-                        if (mongo.processed(err, res)) {
+                    mongo.Cluster.find({space: {$in: space_ids}}, '_id name').sort('name').exec((errCluster, clusters) => {
+                        if (mongo.processed(errCluster, res)) {
                             // Get all IGFSs for spaces.
-                            mongo.Igfs.find({space: {$in: space_ids}}).sort('name').exec(function(err, igfss) {
-                                if (mongo.processed(err, res)) {
-                                    _.forEach(igfss, function(igfs) {
+                            mongo.Igfs.find({space: {$in: space_ids}}).sort('name').exec((errIgfs, igfss) => {
+                                if (mongo.processed(errIgfs, res)) {
+                                    _.forEach(igfss, (igfs) => {
                                         // Remove deleted clusters.
-                                        igfs.clusters = _.filter(igfs.clusters, function(clusterId) {
-                                            return _.findIndex(clusters, function(cluster) {
-                                                    return cluster._id.equals(clusterId);
-                                                }) >= 0;
+                                        igfs.clusters = _.filter(igfs.clusters, (clusterId) => {
+                                            return _.findIndex(clusters, (cluster) => cluster._id.equals(clusterId)) >= 0;
                                         });
                                     });
 
                                     res.json({
-                                        spaces: spaces,
-                                        clusters: clusters.map(function(cluster) {
-                                            return {value: cluster._id, label: cluster.name};
+                                        spaces,
+                                        clusters: clusters.map((cluster) => {
+                                            return {
+                                                value: cluster._id,
+                                                label: cluster.name
+                                            };
                                         }),
-                                        igfss: igfss
+                                        igfss
                                     });
                                 }
                             });
@@ -75,75 +76,75 @@ module.exports.factory = function(_, express, mongo) {
         /**
          * Save IGFS.
          */
-        router.post('/save', function(req, res) {
-            var params = req.body;
-            var igfsId = params._id;
-            var clusters = params.clusters;
+        router.post('/save', (req, res) => {
+            const params = req.body;
+            const clusters = params.clusters;
+            let igfsId = params._id;
 
             if (params._id) {
-                mongo.Igfs.update({_id: igfsId}, params, {upsert: true}, function(err) {
-                    if (mongo.processed(err, res))
-                        mongo.Cluster.update({_id: {$in: clusters}}, {$addToSet: {igfss: igfsId}}, {multi: true}, function(err) {
-                            if (mongo.processed(err, res))
-                                mongo.Cluster.update({_id: {$nin: clusters}}, {$pull: {igfss: igfsId}}, {multi: true}, function(err) {
-                                    if (mongo.processed(err, res))
+                mongo.Igfs.update({_id: igfsId}, params, {upsert: true}, (errIgfs) => {
+                    if (mongo.processed(errIgfs, res)) {
+                        mongo.Cluster.update({_id: {$in: clusters}}, {$addToSet: {igfss: igfsId}}, {multi: true}, (errClusterAdd) => {
+                            if (mongo.processed(errClusterAdd, res)) {
+                                mongo.Cluster.update({_id: {$nin: clusters}}, {$pull: {igfss: igfsId}}, {multi: true}, (errClusterPull) => {
+                                    if (mongo.processed(errClusterPull, res))
                                         res.send(params._id);
                                 });
+                            }
                         });
-                })
+                    }
+                });
             }
-            else
-                mongo.Igfs.findOne({space: params.space, name: params.name}, function(err, igfs) {
-                    if (mongo.processed(err, res)) {
-                        if (igfs)
-                            return res.status(500).send('IGFS with name: "' + igfs.name + '" already exist.');
-
-                        (new mongo.Igfs(params)).save(function(err, igfs) {
-                            if (mongo.processed(err, res)) {
+            else {
+                mongo.Igfs.findOne({space: params.space, name: params.name}, (errIgfsFind, igfsFound) => {
+                    if (mongo.processed(errIgfsFind, res)) {
+                        if (igfsFound)
+                            return res.status(500).send('IGFS with name: "' + igfsFound.name + '" already exist.');
+
+                        (new mongo.Igfs(params)).save((errIgfsSave, igfs) => {
+                            if (mongo.processed(errIgfsSave, res)) {
                                 igfsId = igfs._id;
 
-                                mongo.Cluster.update({_id: {$in: clusters}}, {$addToSet: {igfss: igfsId}}, {multi: true}, function(err) {
-                                    if (mongo.processed(err, res))
+                                mongo.Cluster.update({_id: {$in: clusters}}, {$addToSet: {igfss: igfsId}}, {multi: true}, (errCluster) => {
+                                    if (mongo.processed(errCluster, res))
                                         res.send(igfsId);
                                 });
                             }
                         });
                     }
                 });
+            }
         });
 
         /**
          * Remove IGFS by ._id.
          */
-        router.post('/remove', function(req, res) {
-            mongo.Igfs.remove(req.body, function(err) {
+        router.post('/remove', (req, res) => {
+            mongo.Igfs.remove(req.body, (err) => {
                 if (mongo.processed(err, res))
                     res.sendStatus(200);
-            })
+            });
         });
 
         /**
          * Remove all IGFSs.
          */
-        router.post('/remove/all', function(req, res) {
-            var user_id = req.currentUserId();
+        router.post('/remove/all', (req, res) => {
+            const user_id = req.currentUserId();
 
             // Get owned space and all accessed space.
-            mongo.Space.find({$or: [{owner: user_id}, {usedBy: {$elemMatch: {account: user_id}}}]}, function(err, spaces) {
-                if (mongo.processed(err, res)) {
-                    var space_ids = spaces.map(function(value) {
-                        return value._id;
+            mongo.Space.find({$or: [{owner: user_id}, {usedBy: {$elemMatch: {account: user_id}}}]}, (errSpace, spaces) => {
+                if (mongo.processed(errSpace, res)) {
+                    const space_ids = spaces.map((value) => value._id);
+
+                    mongo.Igfs.remove({space: {$in: space_ids}}, (errIgfs) => {
+                        if (mongo.processed(errIgfs, res)) {
+                            mongo.Cluster.update({space: {$in: space_ids}}, {igfss: []}, {multi: true}, (errCluster) => {
+                                if (mongo.processed(errCluster, res))
+                                    res.sendStatus(200);
+                            });
+                        }
                     });
-
-                    mongo.Igfs.remove({space: {$in: space_ids}}, function(err) {
-                        if (err)
-                            return res.status(500).send(err.message);
-
-                        mongo.Cluster.update({space: {$in: space_ids}}, {igfss: []}, {multi: true}, function(err) {
-                            if (mongo.processed(err, res))
-                                res.sendStatus(200);
-                        });
-                    })
                 }
             });
         });