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/16 16:14:18 UTC

[01/50] ignite git commit: IGNITE-843 Refactor serve to es6.

Repository: ignite
Updated Branches:
  refs/heads/ignite-843-rc3 3eb0be4c0 -> ddf268ca0


IGNITE-843 Refactor serve to es6.


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

Branch: refs/heads/ignite-843-rc3
Commit: b1020f4600945616301032cc1c79b574e153319e
Parents: 42c70d8
Author: Andrey <an...@gridgain.com>
Authored: Mon Feb 15 09:48:53 2016 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Mon Feb 15 09:48:53 2016 +0700

----------------------------------------------------------------------
 modules/control-center-web/src/main/js/serve/routes/profile.js | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/b1020f46/modules/control-center-web/src/main/js/serve/routes/profile.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/profile.js b/modules/control-center-web/src/main/js/serve/routes/profile.js
index 5ce9b81..5a22010 100644
--- a/modules/control-center-web/src/main/js/serve/routes/profile.js
+++ b/modules/control-center-web/src/main/js/serve/routes/profile.js
@@ -56,7 +56,7 @@ module.exports.factory = function(_, express, mongo) {
                         return Promise.resolve(user);
 
                     return new Promise((resolve, reject) => {
-                        mongo.Account.findOne({email: params.email}, function (err, _user) {
+                        mongo.Account.findOne({email: params.email}, (err, _user) => {
                             // TODO send error to admin
                             if (err)
                                 return reject('Failed to check e-mail!');
@@ -69,7 +69,7 @@ module.exports.factory = function(_, express, mongo) {
                     });
                 })
                 .then((user) => {
-                    for (var param in params) {
+                    for (const param in params) {
                         if (params.hasOwnProperty(param))
                             user[param] = params[param];
                     }


[39/50] ignite git commit: IGNITE-843 Changed mail message.

Posted by ak...@apache.org.
IGNITE-843 Changed mail message.


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

Branch: refs/heads/ignite-843-rc3
Commit: 3099e6b64d55b81bcadb5e48219f6d798b4b0b53
Parents: b4d86be
Author: Andrey <an...@gridgain.com>
Authored: Tue Feb 16 16:15:09 2016 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Tue Feb 16 16:15:09 2016 +0700

----------------------------------------------------------------------
 modules/control-center-web/src/main/js/serve/routes/admin.js  | 2 +-
 modules/control-center-web/src/main/js/serve/routes/public.js | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/3099e6b6/modules/control-center-web/src/main/js/serve/routes/admin.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/admin.js b/modules/control-center-web/src/main/js/serve/routes/admin.js
index c41a2f0..87f8bed 100644
--- a/modules/control-center-web/src/main/js/serve/routes/admin.js
+++ b/modules/control-center-web/src/main/js/serve/routes/admin.js
@@ -65,7 +65,7 @@ module.exports.factory = function(_, express, nodemailer, settings, mail, mongo)
                 })
                 .then((user) => mail.send(user, 'Your account was deleted',
                     `Hello ${user.username}!<br><br>` +
-                    `You are receiving this e-mail because "${req.user.username}" remove your account on <a href="http://${req.headers.host}">${settings.smtp.username}</a>.`,
+                    `You are receiving this e-mail because "${req.user.username}" removed your account on <a href="http://${req.headers.host}">${settings.smtp.username}</a>.`,
                     'Account was removed, but failed to send e-mail notification to user!')
                 )
                 .catch((err) => mongo.handleError(res, err));

http://git-wip-us.apache.org/repos/asf/ignite/blob/3099e6b6/modules/control-center-web/src/main/js/serve/routes/public.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/public.js b/modules/control-center-web/src/main/js/serve/routes/public.js
index 8eb1b6e..4195a41 100644
--- a/modules/control-center-web/src/main/js/serve/routes/public.js
+++ b/modules/control-center-web/src/main/js/serve/routes/public.js
@@ -195,8 +195,7 @@ module.exports.factory = function(express, passport, nodemailer, settings, mail,
                 .then((user) => {
                     return mail.send(user, 'Your password has been changed',
                         `Hello ${user.username}!<br><br>` +
-                        'This is a confirmation that the password for your account ' + user.email + ' has just been changed.<br><br>' +
-                        'Now you can login: http://' + req.headers.host,
+                        `This is a confirmation that the password for your account on <a href="http://${req.headers.host}">${settings.smtp.username}</a> has just been changed.<br><br>`,
                         'Password was changed, but failed to send confirmation e-mail!');
                 })
                 .then((user) => res.status(200).send(user.email))


[11/50] ignite git commit: IGNITE-843 Rename login -> signin

Posted by ak...@apache.org.
IGNITE-843 Rename login -> signin


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

Branch: refs/heads/ignite-843-rc3
Commit: bfd0dd95b58795e152c2e610f005010ac800e570
Parents: 82d7a38
Author: Andrey <an...@gridgain.com>
Authored: Mon Feb 15 16:20:40 2016 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Mon Feb 15 16:20:40 2016 +0700

----------------------------------------------------------------------
 .../src/main/js/app/modules/user/User.service.js                   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/bfd0dd95/modules/control-center-web/src/main/js/app/modules/user/User.service.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/app/modules/user/User.service.js b/modules/control-center-web/src/main/js/app/modules/user/User.service.js
index dc2117e..8e4ca60 100644
--- a/modules/control-center-web/src/main/js/app/modules/user/User.service.js
+++ b/modules/control-center-web/src/main/js/app/modules/user/User.service.js
@@ -36,7 +36,7 @@ export default ['User', ['$q', '$injector', '$rootScope', '$state', '$http', fun
 
                     Auth.authorized = false;
 
-                    $state.go('login');
+                    $state.go('signin');
                 }
 
                 try {


[38/50] ignite git commit: IGNITE-843 Minor.

Posted by ak...@apache.org.
IGNITE-843 Minor.


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

Branch: refs/heads/ignite-843-rc3
Commit: b4d86be9a13af8545d34f961e263ef2c1a1541a1
Parents: f1a6e31
Author: vsisko <vs...@gridgain.com>
Authored: Tue Feb 16 16:12:12 2016 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Tue Feb 16 16:12:12 2016 +0700

----------------------------------------------------------------------
 .../control-center-web/src/main/js/controllers/common-module.js    | 2 +-
 modules/control-center-web/src/main/js/serve/routes/admin.js       | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/b4d86be9/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 36b353d..cf51fa3 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
@@ -1095,7 +1095,7 @@ consoleModule.service('$common', [
                         cacheStoreFactory: {
                             kind: 'CacheJdbcPojoStoreFactory',
                             CacheJdbcPojoStoreFactory: {
-                                dataSourceBean: cache.name + 'DS',
+                                dataSourceBean: 'ds' + cache.name,
                                 dialect: 'Generic'
                             }
                         },

http://git-wip-us.apache.org/repos/asf/ignite/blob/b4d86be9/modules/control-center-web/src/main/js/serve/routes/admin.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/admin.js b/modules/control-center-web/src/main/js/serve/routes/admin.js
index 90021ae..c41a2f0 100644
--- a/modules/control-center-web/src/main/js/serve/routes/admin.js
+++ b/modules/control-center-web/src/main/js/serve/routes/admin.js
@@ -65,7 +65,7 @@ module.exports.factory = function(_, express, nodemailer, settings, mail, mongo)
                 })
                 .then((user) => mail.send(user, 'Your account was deleted',
                     `Hello ${user.username}!<br><br>` +
-                    `You are receiving this e-mail because "${req.user.username}" remove your account.`,
+                    `You are receiving this e-mail because "${req.user.username}" remove your account on <a href="http://${req.headers.host}">${settings.smtp.username}</a>.`,
                     'Account was removed, but failed to send e-mail notification to user!')
                 )
                 .catch((err) => mongo.handleError(res, err));


[17/50] ignite git commit: IGNITE-843 Rework cluster remove.

Posted by ak...@apache.org.
IGNITE-843 Rework cluster remove.


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

Branch: refs/heads/ignite-843-rc3
Commit: d29110fb5113aa9a1aa55eccccc00c88880efba6
Parents: 053ba44
Author: AKuznetsov <ak...@gridgain.com>
Authored: Mon Feb 15 17:44:57 2016 +0700
Committer: AKuznetsov <ak...@gridgain.com>
Committed: Mon Feb 15 17:44:57 2016 +0700

----------------------------------------------------------------------
 .../src/main/js/serve/routes/clusters.js        | 26 ++++++++++++++------
 1 file changed, 18 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/d29110fb/modules/control-center-web/src/main/js/serve/routes/clusters.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/clusters.js b/modules/control-center-web/src/main/js/serve/routes/clusters.js
index 9410ffc..acfb2aa 100644
--- a/modules/control-center-web/src/main/js/serve/routes/clusters.js
+++ b/modules/control-center-web/src/main/js/serve/routes/clusters.js
@@ -137,14 +137,24 @@ module.exports.factory = function(_, express, mongo) {
          * Remove cluster by ._id.
          */
         router.post('/remove', (req, res) => {
-            mongo.Cluster.remove(req.body, (err) => {
-                if (err)
-                    return res.status(500).send(err.message);
-
-                // TODO add IGFS and caches cleanup
-
-                res.sendStatus(200);
-            });
+            const userId = req.currentUserId();
+            const clusterId = req.body;
+
+            let spacesIds = [];
+
+            mongo.Cluster.remove(clusterId)
+                .then(() => mongo.Space.find({$or: [{owner: userId}, {usedBy: {$elemMatch: {account: userId}}}]}))
+                .then((spaces) => {
+                    spacesIds = spaces.map((value) => value._id);
+
+                    return mongo.Cache.update(mongo.Cache.update({space: {$in: spacesIds}}, {$pull: {clusters: clusterId}}, {multi: true}));
+                })
+                .then(() => mongo.Cache.update(mongo.Igfs.update({space: {$in: spacesIds}}, {$pull: {clusters: clusterId}}, {multi: true})))
+                .then(() => res.sendStatus(200))
+                .catch((err) => {
+                    // TODO IGNITE-843 Send error to admin
+                    res.status(500).send(err.message);
+                });
         });
 
         /**


[44/50] ignite git commit: IGNITE-843 Fixed message on duplicate name.

Posted by ak...@apache.org.
IGNITE-843 Fixed message on duplicate name.


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

Branch: refs/heads/ignite-843-rc3
Commit: 1921dcd1b7ddd2a23583902de439270132e49510
Parents: 3a421b8
Author: Andrey <an...@gridgain.com>
Authored: Tue Feb 16 17:38:56 2016 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Tue Feb 16 17:38:56 2016 +0700

----------------------------------------------------------------------
 modules/control-center-web/src/main/js/serve/routes/igfs.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/1921dcd1/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 1eacc72..0291728 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
@@ -78,7 +78,7 @@ module.exports.factory = function(_, express, mongo) {
                 mongo.Igfs.findOne({space: params.space, name: params.name}).exec()
                     .then((igfs) => {
                         if (igfs)
-                            throw new Error('IGFS with name: "' + igfs + '" already exist.');
+                            throw new Error('IGFS with name: "' + params.name + '" already exist.');
 
                         return (new mongo.Igfs(params)).save();
                     })


[46/50] ignite git commit: IGNITE-843 Fixed domain save.

Posted by ak...@apache.org.
IGNITE-843 Fixed domain save.


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

Branch: refs/heads/ignite-843-rc3
Commit: 11f7aba143dd39f6b32a7df5f7930735f3a8fe4f
Parents: aa8c1a9
Author: Andrey <an...@gridgain.com>
Authored: Tue Feb 16 17:53:23 2016 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Tue Feb 16 17:53:23 2016 +0700

----------------------------------------------------------------------
 modules/control-center-web/src/main/js/serve/routes/domains.js | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/11f7aba1/modules/control-center-web/src/main/js/serve/routes/domains.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/domains.js b/modules/control-center-web/src/main/js/serve/routes/domains.js
index d1cd8d0..09298b5 100644
--- a/modules/control-center-web/src/main/js/serve/routes/domains.js
+++ b/modules/control-center-web/src/main/js/serve/routes/domains.js
@@ -125,7 +125,7 @@ module.exports.factory = (_, express, mongo) => {
                                     // Cache already exists, just save domain model.
                                     domain.caches = [cache._id];
 
-                                    promises.push(_saveDomainModel(domain, savedDomains))
+                                    promises.push(_saveDomainModel(domain, savedDomains));
                                 }
                                 else {
                                     // If cache not found, then create it and associate with domain model.
@@ -142,7 +142,7 @@ module.exports.factory = (_, express, mongo) => {
 
                                             return mongo.Cluster.update({_id: {$in: generatedCache.clusters}}, {$addToSet: {caches: cacheId}}, {multi: true}).exec();
                                         })
-                                        .then(() => promises.push(_saveDomainModel(domain, savedDomains)))
+                                        .then(() => promises.push(_saveDomainModel(domain, savedDomains)));
                                 }
                             });
                     }


[21/50] ignite git commit: IGNITE-843 Rework cluster remove.

Posted by ak...@apache.org.
IGNITE-843 Rework cluster remove.


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

Branch: refs/heads/ignite-843-rc3
Commit: 5158cc20d49d14e9fbbe9875a153b8733606438a
Parents: 6fc1865
Author: AKuznetsov <ak...@gridgain.com>
Authored: Mon Feb 15 17:55:33 2016 +0700
Committer: AKuznetsov <ak...@gridgain.com>
Committed: Mon Feb 15 17:55:33 2016 +0700

----------------------------------------------------------------------
 modules/control-center-web/src/main/js/serve/routes/igfs.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/5158cc20/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 2a0aed4..c9ce238 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
@@ -111,7 +111,7 @@ module.exports.factory = function(_, express, mongo) {
 
             mongo.Space.find({$or: [{owner: userId}, {usedBy: {$elemMatch: {account: userId}}}]})
                 .then((spaces) => mongo.Cluster.update({space: {$in: spacesIds}}, {$pull: {igfss: igfsId}}, {multi: true}))
-                .then(mongo.Igfs.remove(req.body))
+                .then(mongo.Igfs.remove(igfsId))
                 .then(() => res.sendStatus(200))
                 .catch((err) => {
                     // TODO IGNITE-843 Send error to admin


[13/50] ignite git commit: IGNITE-843 Refactor serve to es6.

Posted by ak...@apache.org.
IGNITE-843 Refactor serve to es6.


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

Branch: refs/heads/ignite-843-rc3
Commit: 53b9b52ee44d0a5a0fe31178da8dd2bb9489d126
Parents: e2f7d42
Author: Andrey <an...@gridgain.com>
Authored: Mon Feb 15 17:03:44 2016 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Mon Feb 15 17:03:44 2016 +0700

----------------------------------------------------------------------
 .../src/main/js/serve/routes/igfs.js            |  6 +--
 .../src/main/js/serve/routes/profile.js         |  6 +--
 .../src/main/js/serve/routes/public.js          | 41 ++++++++++++--------
 3 files changed, 31 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/53b9b52e/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 630a75d..78c49b6 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
@@ -84,9 +84,9 @@ module.exports.factory = function(_, express, mongo) {
             }
             else {
                 mongo.Igfs.findOne({space: params.space, name: params.name}).exec()
-                    .then((_igfs) => {
-                        if (_igfs)
-                            throw new Error('IGFS with name: "' + _igfs + '" already exist.');
+                    .then((igfs) => {
+                        if (igfs)
+                            throw new Error('IGFS with name: "' + igfs + '" already exist.');
 
                         return (new mongo.Igfs(params)).save();
                     })

http://git-wip-us.apache.org/repos/asf/ignite/blob/53b9b52e/modules/control-center-web/src/main/js/serve/routes/profile.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/profile.js b/modules/control-center-web/src/main/js/serve/routes/profile.js
index 079b360..d611df4 100644
--- a/modules/control-center-web/src/main/js/serve/routes/profile.js
+++ b/modules/control-center-web/src/main/js/serve/routes/profile.js
@@ -57,14 +57,14 @@ module.exports.factory = function(_, express, mongo) {
                     if (!params.email || user.email === params.email)
                         return Promise.resolve(user);
 
-                    return new Promise((resolve) => {
+                    return new Promise((resolve, reject) => {
                         mongo.Account.findOne({email: params.email}, (err, _user) => {
                             // TODO send error to admin
                             if (err)
-                                throw new Error('Failed to check e-mail!');
+                                reject(new Error('Failed to check e-mail!'));
 
                             if (_user && _user._id !== user._id)
-                                throw new Error('User with this e-mail already registered!');
+                                reject(new Error('User with this e-mail already registered!'));
 
                             resolve(user);
                         });

http://git-wip-us.apache.org/repos/asf/ignite/blob/53b9b52e/modules/control-center-web/src/main/js/serve/routes/public.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/public.js b/modules/control-center-web/src/main/js/serve/routes/public.js
index 6f78d73..7cbdb8d 100644
--- a/modules/control-center-web/src/main/js/serve/routes/public.js
+++ b/modules/control-center-web/src/main/js/serve/routes/public.js
@@ -71,7 +71,7 @@ module.exports.factory = function(express, passport, nodemailer, settings, mongo
                     if (err)
                         return reject(sendErrMsg || err.message);
 
-                    resolve();
+                    resolve(user);
                 });
             });
         };
@@ -101,37 +101,45 @@ module.exports.factory = function(express, passport, nodemailer, settings, mongo
 
                     req.body.token = _randomString();
 
-                    const account = new mongo.Account(req.body);
-
-                    return Promise.resolve(account);
+                    return Promise.resolve(new mongo.Account(req.body));
                 })
                 .then((account) => {
                     return new Promise((resolve, reject) => {
                         mongo.Account.register(account, req.body.password, (err, _account) => {
                             if (err)
-                                return reject(err.message);
+                                reject(err);
 
-                            if (!account)
-                                return reject('Failed to create account.');
+                            if (!_account)
+                                reject(new Error('Failed to create account.'));
 
                             resolve(_account);
                         });
                     });
                 })
                 .then((account) => {
+                    return new Promise((resolve, reject) =>
+                        new mongo.Space({name: 'Personal space', owner: account._id}).save()
+                            .then(() => resolve(account))
+                            .catch(reject)
+                    );
+                })
+                .then((account) => {
                     return new Promise((resolve, reject) => {
                         req.logIn(account, {}, (err) => {
                             if (err)
-                                return reject(err.message);
+                                reject(err);
 
                             resolve(account);
                         });
                     });
                 })
-                .then((account) => new mongo.Space({name: 'Personal space', owner: account._id}).save())
-                .then(() => res.sendStatus(200))
-                .catch((errMsg) => {
-                    res.status(401).send(errMsg);
+                .then((account) => {
+                    res.sendStatus(200);
+
+                    //_sendMail(account, '', '');
+                })
+                .catch((err) => {
+                    res.status(401).send(err.message);
                 });
         });
 
@@ -177,14 +185,14 @@ module.exports.factory = function(express, passport, nodemailer, settings, mongo
 
                     return user.save();
                 })
-                .then((user) => {
-                    return _sendMail(user, 'Password Reset',
+                .then((user) =>
+                    _sendMail(user, 'Password Reset',
                         'You are receiving this because you (or someone else) have requested the reset of the password for your account.\n\n' +
                         'Please click on the following link, or paste this into your browser to complete the process:\n\n' +
                         'http://' + req.headers.host + '/password/reset?token=' + user.resetPasswordToken + '\n\n' +
                         'If you did not request this, please ignore this email and your password will remain unchanged.',
-                        'Failed to send e-mail with reset link!');
-                })
+                        'Failed to send e-mail with reset link!')
+                )
                 .then(() => res.status(200).send('An e-mail has been sent with further instructions.'))
                 .catch((errMsg) => {
                     // TODO IGNITE-843 Send email to admin
@@ -219,6 +227,7 @@ module.exports.factory = function(express, passport, nodemailer, settings, mongo
                         'Now you can login: http://' + req.headers.host,
                         'Password was changed, but failed to send confirmation e-mail!');
                 })
+                .then((user) => res.status(200).send(user.email))
                 .catch((errMsg) => {
                     res.status(500).send(errMsg);
                 });


[45/50] ignite git commit: IGNITE-843 Fixed domain save.

Posted by ak...@apache.org.
IGNITE-843 Fixed domain save.


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

Branch: refs/heads/ignite-843-rc3
Commit: aa8c1a9cd69f9813dd9a1a92ceea8866a688f545
Parents: 1921dcd
Author: Andrey <an...@gridgain.com>
Authored: Tue Feb 16 17:51:32 2016 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Tue Feb 16 17:51:32 2016 +0700

----------------------------------------------------------------------
 .../src/main/js/serve/routes/domains.js         | 70 ++++++++++----------
 1 file changed, 35 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/aa8c1a9c/modules/control-center-web/src/main/js/serve/routes/domains.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/domains.js b/modules/control-center-web/src/main/js/serve/routes/domains.js
index ff9a29b..d1cd8d0 100644
--- a/modules/control-center-web/src/main/js/serve/routes/domains.js
+++ b/modules/control-center-web/src/main/js/serve/routes/domains.js
@@ -74,7 +74,7 @@ module.exports.factory = (_, express, mongo) => {
         }
 
         function _saveDomainModel(domain, savedDomains) {
-            return new Promise((resolve) => {
+            return new Promise((resolve, reject) => {
                 const caches = domain.caches;
                 const cacheStoreChanges = domain.cacheStoreChanges;
                 const domainId = domain._id;
@@ -88,7 +88,8 @@ module.exports.factory = (_, express, mongo) => {
 
                             _updateCacheStore(cacheStoreChanges);
                         })
-                        .then(() => resolve());
+                        .then(resolve)
+                        .catch(reject);
                 }
                 else {
                     mongo.DomainModel.findOne({space: domain.space, valueType: domain.valueType}).exec()
@@ -104,7 +105,8 @@ module.exports.factory = (_, express, mongo) => {
                             return mongo.Cache.update({_id: {$in: caches}}, {$addToSet: {domains: savedDomain._id}}, {multi: true}).exec();
                         })
                         .then(() => _updateCacheStore(cacheStoreChanges))
-                        .then(() => resolve());
+                        .then(resolve)
+                        .catch(reject);
                 }
             });
         }
@@ -116,38 +118,36 @@ module.exports.factory = (_, express, mongo) => {
                 const promises = [];
 
                 _.forEach(domains, (domain) => {
-                    promises.push(new Promise((resolve) => {
-                        if (domain.newCache) {
-                            mongo.Cache.findOne({space: domain.space, name: domain.newCache.name}).exec()
-                                .then((cache) => {
-                                    if (cache) {
-                                        // Cache already exists, just save domain model.
-                                        domain.caches = [cache._id];
-
-                                        _saveDomainModel(domain, savedDomains).then(() => resolve());
-                                    }
-                                    else {
-                                        // If cache not found, then create it and associate with domain model.
-                                        const newCache = domain.newCache;
-                                        newCache.space = domain.space;
-
-                                        (new mongo.Cache(newCache)).save()
-                                            .then((generatedCache) => {
-                                                const cacheId = generatedCache._id;
-
-                                                generatedCaches.push(generatedCache);
-
-                                                domain.caches = [cacheId];
-
-                                                return mongo.Cluster.update({_id: {$in: generatedCache.clusters}}, {$addToSet: {caches: cacheId}}, {multi: true}).exec();
-                                            })
-                                            .then(() => _saveDomainModel(domain, savedDomains).then(() => resolve()));
-                                    }
-                                });
-                        }
-                        else
-                            _saveDomainModel(domain, savedDomains).then(() => resolve());
-                    }));
+                    if (domain.newCache) {
+                        mongo.Cache.findOne({space: domain.space, name: domain.newCache.name}).exec()
+                            .then((cache) => {
+                                if (cache) {
+                                    // Cache already exists, just save domain model.
+                                    domain.caches = [cache._id];
+
+                                    promises.push(_saveDomainModel(domain, savedDomains))
+                                }
+                                else {
+                                    // If cache not found, then create it and associate with domain model.
+                                    const newCache = domain.newCache;
+                                    newCache.space = domain.space;
+
+                                    (new mongo.Cache(newCache)).save()
+                                        .then((generatedCache) => {
+                                            const cacheId = generatedCache._id;
+
+                                            generatedCaches.push(generatedCache);
+
+                                            domain.caches = [cacheId];
+
+                                            return mongo.Cluster.update({_id: {$in: generatedCache.clusters}}, {$addToSet: {caches: cacheId}}, {multi: true}).exec();
+                                        })
+                                        .then(() => promises.push(_saveDomainModel(domain, savedDomains)))
+                                }
+                            });
+                    }
+                    else
+                        promises.push(_saveDomainModel(domain, savedDomains));
                 });
 
                 Promise.all(promises)


[22/50] ignite git commit: IGNITE-843 Default state.

Posted by ak...@apache.org.
IGNITE-843 Default state.


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

Branch: refs/heads/ignite-843-rc3
Commit: ae86c525e47cd8206efba440c904fa25c51051e2
Parents: 5158cc2
Author: Vasiliy Sisko <vs...@gridgain.com>
Authored: Mon Feb 15 17:57:05 2016 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Mon Feb 15 17:57:05 2016 +0700

----------------------------------------------------------------------
 .../src/main/js/helpers/generator/generator-java.js                | 2 +-
 .../src/main/js/helpers/generator/generator-xml.js                 | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/ae86c525/modules/control-center-web/src/main/js/helpers/generator/generator-java.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/helpers/generator/generator-java.js b/modules/control-center-web/src/main/js/helpers/generator/generator-java.js
index da1074b..4416e15 100644
--- a/modules/control-center-web/src/main/js/helpers/generator/generator-java.js
+++ b/modules/control-center-web/src/main/js/helpers/generator/generator-java.js
@@ -972,7 +972,7 @@ $generatorJava.clusterTransactions = function (cluster, res) {
 
     $generatorJava.beanProperty(res, 'cfg', cluster.transactionConfiguration, 'transactionConfiguration',
         'transactionConfiguration', $generatorCommon.TRANSACTION_CONFIGURATION.className,
-        $generatorCommon.TRANSACTION_CONFIGURATION.fields, true);
+        $generatorCommon.TRANSACTION_CONFIGURATION.fields, false);
 
     return res;
 };

http://git-wip-us.apache.org/repos/asf/ignite/blob/ae86c525/modules/control-center-web/src/main/js/helpers/generator/generator-xml.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/helpers/generator/generator-xml.js b/modules/control-center-web/src/main/js/helpers/generator/generator-xml.js
index 5eb5758..dcacae9 100644
--- a/modules/control-center-web/src/main/js/helpers/generator/generator-xml.js
+++ b/modules/control-center-web/src/main/js/helpers/generator/generator-xml.js
@@ -690,7 +690,7 @@ $generatorXml.clusterTransactions = function (cluster, res) {
     if (!res)
         res = $generatorCommon.builder();
 
-    $generatorXml.beanProperty(res, cluster.transactionConfiguration, 'transactionConfiguration', $generatorCommon.TRANSACTION_CONFIGURATION, true);
+    $generatorXml.beanProperty(res, cluster.transactionConfiguration, 'transactionConfiguration', $generatorCommon.TRANSACTION_CONFIGURATION, false);
 
     res.needEmptyLine = true;
 


[32/50] ignite git commit: IGNITE-843 Optimize getting data from server side.

Posted by ak...@apache.org.
IGNITE-843 Optimize getting data from server side.


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

Branch: refs/heads/ignite-843-rc3
Commit: 7d539d7ce7af77954f4ac40ae82fa9d08ee430b1
Parents: 3e9942e
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Tue Feb 16 14:14:01 2016 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Tue Feb 16 14:14:01 2016 +0700

----------------------------------------------------------------------
 modules/control-center-web/src/main/js/serve/mongo.js        | 2 +-
 modules/control-center-web/src/main/js/serve/routes/admin.js | 2 +-
 .../control-center-web/src/main/js/serve/routes/caches.js    | 6 +++---
 .../control-center-web/src/main/js/serve/routes/clusters.js  | 8 ++++----
 .../control-center-web/src/main/js/serve/routes/domains.js   | 6 +++---
 modules/control-center-web/src/main/js/serve/routes/igfs.js  | 4 ++--
 .../control-center-web/src/main/js/serve/routes/notebooks.js | 2 +-
 7 files changed, 15 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/7d539d7c/modules/control-center-web/src/main/js/serve/mongo.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/mongo.js b/modules/control-center-web/src/main/js/serve/mongo.js
index 5dc1209..9021016 100644
--- a/modules/control-center-web/src/main/js/serve/mongo.js
+++ b/modules/control-center-web/src/main/js/serve/mongo.js
@@ -541,7 +541,7 @@ module.exports.factory = function(deepPopulatePlugin, passportMongo, settings, p
      * @returns {Promise}
      */
     result.spaces = function(userId) {
-        return result.Space.find({owner: userId}).exec();
+        return result.Space.find({owner: userId}).lean().exec();
     };
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/7d539d7c/modules/control-center-web/src/main/js/serve/routes/admin.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/admin.js b/modules/control-center-web/src/main/js/serve/routes/admin.js
index 50488b1..a7972ef 100644
--- a/modules/control-center-web/src/main/js/serve/routes/admin.js
+++ b/modules/control-center-web/src/main/js/serve/routes/admin.js
@@ -32,7 +32,7 @@ module.exports.factory = function(_, express, nodemailer, settings, mongo) {
          * Get list of user accounts.
          */
         router.post('/list', (req, res) => {
-            mongo.Account.find({}).sort('username').exec()
+            mongo.Account.find({}).sort('username').lean().exec()
                 .then((users) => res.json(users))
                 .catch((err) => mongo.handleError(res, err));
         });

http://git-wip-us.apache.org/repos/asf/ignite/blob/7d539d7c/modules/control-center-web/src/main/js/serve/routes/caches.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/caches.js b/modules/control-center-web/src/main/js/serve/routes/caches.js
index 4411a61..69a37e2 100644
--- a/modules/control-center-web/src/main/js/serve/routes/caches.js
+++ b/modules/control-center-web/src/main/js/serve/routes/caches.js
@@ -44,17 +44,17 @@ module.exports.factory = function(_, express, mongo) {
                     result.spaces = spaces;
                     spacesIds = mongo.spacesIds(spaces);
 
-                    return mongo.Cluster.find({space: {$in: spacesIds}}).sort('name').exec();
+                    return mongo.Cluster.find({space: {$in: spacesIds}}).sort('name').lean().exec();
                 })
                 .then((clusters) => {
                     result.clusters = clusters;
 
-                    return mongo.DomainModel.find({space: {$in: spacesIds}}).sort('name').exec();
+                    return mongo.DomainModel.find({space: {$in: spacesIds}}).sort('name').lean().exec();
                 })
                 .then((domains) => {
                     result.domains = domains;
 
-                    return mongo.Cache.find({space: {$in: spacesIds}}).sort('name').exec();
+                    return mongo.Cache.find({space: {$in: spacesIds}}).sort('name').lean().exec();
                 })
                 .then((caches) => {
                     result.caches = caches;

http://git-wip-us.apache.org/repos/asf/ignite/blob/7d539d7c/modules/control-center-web/src/main/js/serve/routes/clusters.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/clusters.js b/modules/control-center-web/src/main/js/serve/routes/clusters.js
index 08d0051..fd936a1 100644
--- a/modules/control-center-web/src/main/js/serve/routes/clusters.js
+++ b/modules/control-center-web/src/main/js/serve/routes/clusters.js
@@ -43,12 +43,12 @@ module.exports.factory = function(_, express, mongo) {
                     result.spaces = spaces;
                     spacesIds = mongo.spacesIds(spaces);
 
-                    return mongo.DomainModel.find({space: {$in: spacesIds}}).sort('valueType').exec();
+                    return mongo.DomainModel.find({space: {$in: spacesIds}}).sort('valueType').lean().exec();
                 })
                 .then((domains) => {
                     result.domains = domains;
 
-                    return mongo.Cache.find({space: {$in: spacesIds}}).sort('name').exec();
+                    return mongo.Cache.find({space: {$in: spacesIds}}).sort('name').lean().exec();
                 })
                 .then((caches) => {
                     _.forEach(caches, (cache) => {
@@ -59,12 +59,12 @@ module.exports.factory = function(_, express, mongo) {
 
                     result.caches = caches;
 
-                    return mongo.Igfs.find({space: {$in: spacesIds}}).sort('name').exec();
+                    return mongo.Igfs.find({space: {$in: spacesIds}}).sort('name').lean().exec();
                 })
                 .then((igfss) => {
                     result.igfss = igfss;
 
-                    return mongo.Cluster.find({space: {$in: spacesIds}}).sort('name').deepPopulate(mongo.ClusterDefaultPopulate).exec();
+                    return mongo.Cluster.find({space: {$in: spacesIds}}).sort('name').deepPopulate(mongo.ClusterDefaultPopulate).lean().exec();
                 })
                 .then((clusters) => {
                     result.clusters = clusters;

http://git-wip-us.apache.org/repos/asf/ignite/blob/7d539d7c/modules/control-center-web/src/main/js/serve/routes/domains.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/domains.js b/modules/control-center-web/src/main/js/serve/routes/domains.js
index 3953665..1b3d1d1 100644
--- a/modules/control-center-web/src/main/js/serve/routes/domains.js
+++ b/modules/control-center-web/src/main/js/serve/routes/domains.js
@@ -43,17 +43,17 @@ module.exports.factory = function(_, express, mongo) {
                     result.spaces = spaces;
                     spacesIds = mongo.spacesIds(spaces);
 
-                    return mongo.Cluster.find({space: {$in: spacesIds}}, '_id name').sort('name').exec();
+                    return mongo.Cluster.find({space: {$in: spacesIds}}, '_id name').sort('name').lean().exec();
                 })
                 .then((clusters) => {
                     result.clusters = clusters;
 
-                    return mongo.Cache.find({space: {$in: spacesIds}}).sort('name').exec();
+                    return mongo.Cache.find({space: {$in: spacesIds}}).sort('name').lean().exec();
                 })
                 .then((caches) => {
                     result.caches = caches;
 
-                    return mongo.DomainModel.find({space: {$in: spacesIds}}).sort('valueType').exec();
+                    return mongo.DomainModel.find({space: {$in: spacesIds}}).sort('valueType').lean().exec();
                 })
                 .then((domains) => {
                     result.domains = domains;

http://git-wip-us.apache.org/repos/asf/ignite/blob/7d539d7c/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 39cc978..c44620d 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
@@ -44,12 +44,12 @@ module.exports.factory = function(_, express, mongo) {
                     result.spaces = spaces;
                     spacesIds = mongo.spacesIds(spaces);
 
-                    return mongo.Cluster.find({space: {$in: spacesIds}}, '_id name').sort('name').exec();
+                    return mongo.Cluster.find({space: {$in: spacesIds}}, '_id name').sort('name').lean().exec();
                 })
                 .then((clusters) => {
                     result.clusters = clusters;
 
-                    return mongo.Igfs.find({space: {$in: spacesIds}}).sort('name').exec();
+                    return mongo.Igfs.find({space: {$in: spacesIds}}).sort('name').lean().exec();
                 })
                 .then((igfss) => {
                     result.igfss = igfss;

http://git-wip-us.apache.org/repos/asf/ignite/blob/7d539d7c/modules/control-center-web/src/main/js/serve/routes/notebooks.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/notebooks.js b/modules/control-center-web/src/main/js/serve/routes/notebooks.js
index 5070bcc..67dbaf7 100644
--- a/modules/control-center-web/src/main/js/serve/routes/notebooks.js
+++ b/modules/control-center-web/src/main/js/serve/routes/notebooks.js
@@ -36,7 +36,7 @@ module.exports.factory = function(express, mongo) {
          */
         router.post('/list', (req, res) => {
             mongo.spaces(req.currentUserId())
-                .then((spaces) => mongo.Notebook.find({space: {$in: spaces.map((value) => value._id)}}).select('_id name').sort('name').exec())
+                .then((spaces) => mongo.Notebook.find({space: {$in: spaces.map((value) => value._id)}}).select('_id name').sort('name').lean().exec())
                 .then((notebooks) => res.json(notebooks))
                 .catch((err) => mongo.handleError(res, err));
 


[48/50] ignite git commit: IGNITE-843 Check name duplicate.

Posted by ak...@apache.org.
IGNITE-843 Check name duplicate.


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

Branch: refs/heads/ignite-843-rc3
Commit: 09d6538d5ecb82cae8aeb606e33261375d1d9290
Parents: a170c4e
Author: Vasiliy Sisko <vs...@gridgain.com>
Authored: Tue Feb 16 18:56:48 2016 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Tue Feb 16 18:56:48 2016 +0700

----------------------------------------------------------------------
 .../src/main/js/serve/routes/caches.js          | 52 +++++++++---------
 .../src/main/js/serve/routes/clusters.js        | 56 ++++++++++----------
 .../src/main/js/serve/routes/domains.js         | 54 ++++++++++---------
 .../src/main/js/serve/routes/igfs.js            | 46 ++++++++--------
 4 files changed, 107 insertions(+), 101 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/09d6538d/modules/control-center-web/src/main/js/serve/routes/caches.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/caches.js b/modules/control-center-web/src/main/js/serve/routes/caches.js
index aed7f10..17fef2d 100644
--- a/modules/control-center-web/src/main/js/serve/routes/caches.js
+++ b/modules/control-center-web/src/main/js/serve/routes/caches.js
@@ -73,32 +73,32 @@ module.exports.factory = function(_, express, mongo) {
             const domains = params.domains;
             let cacheId = params._id;
 
-            if (params._id) {
-                mongo.Cache.update({_id: cacheId}, params, {upsert: true}).exec()
-                    .then(() => mongo.Cluster.update({_id: {$in: clusters}}, {$addToSet: {caches: cacheId}}, {multi: true}).exec())
-                    .then(() => mongo.Cluster.update({_id: {$nin: clusters}}, {$pull: {caches: cacheId}}, {multi: true}).exec())
-                    .then(() => mongo.DomainModel.update({_id: {$in: domains}}, {$addToSet: {caches: cacheId}}, {multi: true}).exec())
-                    .then(() => mongo.DomainModel.update({_id: {$nin: domains}}, {$pull: {caches: cacheId}}, {multi: true}).exec())
-                    .then(() => res.send(cacheId))
-                    .catch((err) => mongo.handleError(res, err));
-            }
-            else {
-                mongo.Cache.findOne({space: params.space, name: params.name}).exec()
-                    .then((cache) => {
-                        if (cache)
-                            throw new Error('Cache with name: "' + cache.name + '" already exist.');
-
-                        return (new mongo.Cache(params)).save();
-                    })
-                    .then((cache) => {
-                        cacheId = cache._id;
-
-                        return mongo.Cluster.update({_id: {$in: clusters}}, {$addToSet: {caches: cacheId}}, {multi: true}).exec();
-                    })
-                    .then(() => mongo.DomainModel.update({_id: {$in: domains}}, {$addToSet: {caches: cacheId}}, {multi: true}).exec())
-                    .then(() => res.send(cacheId))
-                    .catch((err) => mongo.handleError(res, err));
-            }
+            mongo.Cache.findOne({space: params.space, name: params.name}).exec()
+                .then((_cache) => {
+                    if (_cache && cacheId !== _cache._id.toString())
+                        return res.status(500).send('Cache with name: "' + _cache.name + '" already exist.');
+
+                    if (cacheId) {
+                        return mongo.Cache.update({_id: cacheId}, params, {upsert: true}).exec()
+                            .then(() => mongo.Cluster.update({_id: {$in: clusters}}, {$addToSet: {caches: cacheId}}, {multi: true}).exec())
+                            .then(() => mongo.Cluster.update({_id: {$nin: clusters}}, {$pull: {caches: cacheId}}, {multi: true}).exec())
+                            .then(() => mongo.DomainModel.update({_id: {$in: domains}}, {$addToSet: {caches: cacheId}}, {multi: true}).exec())
+                            .then(() => mongo.DomainModel.update({_id: {$nin: domains}}, {$pull: {caches: cacheId}}, {multi: true}).exec())
+                            .then(() => res.send(cacheId))
+                            .catch((err) => mongo.handleError(res, err));
+                    }
+                    else {
+                        return (new mongo.Cache(params)).save()
+                            .then((cache) => {
+                                cacheId = cache._id;
+
+                                return mongo.Cluster.update({_id: {$in: clusters}}, {$addToSet: {caches: cacheId}}, {multi: true}).exec();
+                            })
+                            .then(() => mongo.DomainModel.update({_id: {$in: domains}}, {$addToSet: {caches: cacheId}}, {multi: true}).exec())
+                            .then(() => res.send(cacheId))
+                            .catch((err) => mongo.handleError(res, err));
+                    }
+                });
         });
 
         /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/09d6538d/modules/control-center-web/src/main/js/serve/routes/clusters.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/clusters.js b/modules/control-center-web/src/main/js/serve/routes/clusters.js
index b6af923..6bbf4c0 100644
--- a/modules/control-center-web/src/main/js/serve/routes/clusters.js
+++ b/modules/control-center-web/src/main/js/serve/routes/clusters.js
@@ -83,34 +83,34 @@ module.exports.factory = function(_, express, mongo) {
             const igfss = params.igfss;
             let clusterId = params._id;
 
-            if (params._id) {
-                mongo.Cluster.update({_id: params._id}, params, {upsert: true}).exec()
-                    .then(() => mongo.Cache.update({_id: {$in: caches}}, {$addToSet: {clusters: clusterId}}, {multi: true}).exec())
-                    .then(() => mongo.Cache.update({_id: {$nin: caches}}, {$pull: {clusters: clusterId}}, {multi: true}).exec())
-                    .then(() => mongo.Igfs.update({_id: {$in: igfss}}, {$addToSet: {clusters: clusterId}}, {multi: true}).exec())
-                    .then(() => mongo.Igfs.update({_id: {$nin: igfss}}, {$pull: {clusters: clusterId}}, {multi: true}).exec())
-                    .then(() => res.send(clusterId))
-                    .catch((err) => mongo.handleError(res, err));
-            }
-            else {
-                mongo.Cluster.findOne({space: params.space, name: params.name}).exec()
-                    .then((cluster) => {
-                        if (cluster)
-                            return res.status(500).send('Cluster with name: "' + cluster.name + '" already exist.');
-
-                        return (new mongo.Cluster(params)).save();
-                    })
-                    .then((cluster) => {
-                        clusterId = cluster._id;
-
-                        return mongo.Cache.update({_id: {$in: caches}}, {$addToSet: {clusters: clusterId}}, {multi: true}).exec();
-                    })
-                    .then(() => mongo.Cache.update({_id: {$nin: caches}}, {$pull: {clusters: clusterId}}, {multi: true}).exec())
-                    .then(() => mongo.Igfs.update({_id: {$in: igfss}}, {$addToSet: {clusters: clusterId}}, {multi: true}).exec())
-                    .then(() => mongo.Igfs.update({_id: {$nin: igfss}}, {$pull: {clusters: clusterId}}, {multi: true}).exec())
-                    .then(() => res.send(clusterId))
-                    .catch((err) => mongo.handleError(res, err));
-            }
+            mongo.Cluster.findOne({space: params.space, name: params.name}).exec()
+                .then((_cluster) => {
+                    if (_cluster && clusterId !== _cluster._id.toString())
+                        return res.status(500).send('Cluster with name: "' + _cluster.name + '" already exist.');
+
+                    if (clusterId) {
+                        return mongo.Cluster.update({_id: clusterId}, params, {upsert: true}).exec()
+                            .then(() => mongo.Cache.update({_id: {$in: caches}}, {$addToSet: {clusters: clusterId}}, {multi: true}).exec())
+                            .then(() => mongo.Cache.update({_id: {$nin: caches}}, {$pull: {clusters: clusterId}}, {multi: true}).exec())
+                            .then(() => mongo.Igfs.update({_id: {$in: igfss}}, {$addToSet: {clusters: clusterId}}, {multi: true}).exec())
+                            .then(() => mongo.Igfs.update({_id: {$nin: igfss}}, {$pull: {clusters: clusterId}}, {multi: true}).exec())
+                            .then(() => res.send(clusterId))
+                            .catch((err) => mongo.handleError(res, err));
+                    }
+                    else {
+                        return (new mongo.Cluster(params)).save()
+                            .then((cluster) => {
+                                clusterId = cluster._id;
+
+                                return mongo.Cache.update({_id: {$in: caches}}, {$addToSet: {clusters: clusterId}}, {multi: true}).exec();
+                            })
+                            .then(() => mongo.Cache.update({_id: {$nin: caches}}, {$pull: {clusters: clusterId}}, {multi: true}).exec())
+                            .then(() => mongo.Igfs.update({_id: {$in: igfss}}, {$addToSet: {clusters: clusterId}}, {multi: true}).exec())
+                            .then(() => mongo.Igfs.update({_id: {$nin: igfss}}, {$pull: {clusters: clusterId}}, {multi: true}).exec())
+                            .then(() => res.send(clusterId))
+                            .catch((err) => mongo.handleError(res, err));
+                    }
+                });
         });
 
         /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/09d6538d/modules/control-center-web/src/main/js/serve/routes/domains.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/domains.js b/modules/control-center-web/src/main/js/serve/routes/domains.js
index 5d4acac..6fe64b3 100644
--- a/modules/control-center-web/src/main/js/serve/routes/domains.js
+++ b/modules/control-center-web/src/main/js/serve/routes/domains.js
@@ -78,30 +78,31 @@ module.exports.factory = (_, express, mongo) => {
             const cacheStoreChanges = domain.cacheStoreChanges;
             const domainId = domain._id;
 
-            if (domainId) {
-                return mongo.DomainModel.update({_id: domain._id}, domain, {upsert: true}).exec()
-                    .then(() => mongo.Cache.update({_id: {$in: caches}}, {$addToSet: {domains: domainId}}, {multi: true}).exec())
-                    .then(() => mongo.Cache.update({_id: {$nin: caches}}, {$pull: {domains: domainId}}, {multi: true}).exec())
-                    .then(() => {
-                        savedDomains.push(domain);
-
-                        return _updateCacheStore(cacheStoreChanges);
-                    });
-            }
-
             return mongo.DomainModel.findOne({space: domain.space, valueType: domain.valueType}).exec()
-                .then((found) => {
-                    if (found)
-                        throw new Error('Domain model with value type: "' + found.valueType + '" already exist.');
-
-                    return (new mongo.DomainModel(domain)).save();
-                })
-                .then((savedDomain) => {
-                    savedDomains.push(savedDomain);
-
-                    return mongo.Cache.update({_id: {$in: caches}}, {$addToSet: {domains: savedDomain._id}}, {multi: true}).exec();
-                })
-                .then(() => _updateCacheStore(cacheStoreChanges));
+                .then((_domain) => {
+                    if (_domain && domainId !== _domain._id.toString())
+                        throw new Error('Domain model with value type: "' + _domain.valueType + '" already exist.');
+
+                    if (domainId) {
+                        return mongo.DomainModel.update({_id: domain._id}, domain, {upsert: true}).exec()
+                            .then(() => mongo.Cache.update({_id: {$in: caches}}, {$addToSet: {domains: domainId}}, {multi: true}).exec())
+                            .then(() => mongo.Cache.update({_id: {$nin: caches}}, {$pull: {domains: domainId}}, {multi: true}).exec())
+                            .then(() => {
+                                savedDomains.push(domain);
+
+                                return _updateCacheStore(cacheStoreChanges);
+                            });
+                    }
+                    else {
+                        return (new mongo.DomainModel(domain)).save()
+                            .then((savedDomain) => {
+                                savedDomains.push(savedDomain);
+
+                                return mongo.Cache.update({_id: {$in: caches}}, {$addToSet: {domains: savedDomain._id}}, {multi: true}).exec();
+                            })
+                            .then(() => _updateCacheStore(cacheStoreChanges));
+                    }
+                });
         };
 
         const _save = (domains, res) => {
@@ -123,7 +124,12 @@ module.exports.factory = (_, express, mongo) => {
                                     newCache.space = domain.space;
 
                                     return (new mongo.Cache(newCache)).save()
-                                        .then((_cache) => mongo.Cluster.update({_id: {$in: _cache.clusters}}, {$addToSet: {caches: _cache._id}}, {multi: true}).exec());
+                                        .then((_cache) => {
+                                            generatedCaches.push(_cache);
+
+                                            return mongo.Cluster.update({_id: {$in: _cache.clusters}}, {$addToSet: {caches: _cache._id}}, {multi: true}).exec()
+                                                .then(() => Promise.resolve(_cache));
+                                        });
                                 })
                                 .then((cache) => {
                                     domain.caches = [cache._id];

http://git-wip-us.apache.org/repos/asf/ignite/blob/09d6538d/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 0291728..baadfe6 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
@@ -67,29 +67,29 @@ module.exports.factory = function(_, express, mongo) {
             const clusters = params.clusters;
             let igfsId = params._id;
 
-            if (params._id) {
-                mongo.Igfs.update({_id: igfsId}, params, {upsert: true}).exec()
-                    .then(() => mongo.Cluster.update({_id: {$in: clusters}}, {$addToSet: {igfss: igfsId}}, {multi: true}).exec())
-                    .then(() => mongo.Cluster.update({_id: {$nin: clusters}}, {$pull: {igfss: igfsId}}, {multi: true}).exec())
-                    .then(() => res.send(igfsId))
-                    .catch((err) => mongo.handleError(res, err));
-            }
-            else {
-                mongo.Igfs.findOne({space: params.space, name: params.name}).exec()
-                    .then((igfs) => {
-                        if (igfs)
-                            throw new Error('IGFS with name: "' + params.name + '" already exist.');
-
-                        return (new mongo.Igfs(params)).save();
-                    })
-                    .then((igfs) => {
-                        igfsId = igfs._id;
-
-                        return mongo.Cluster.update({_id: {$in: clusters}}, {$addToSet: {igfss: igfsId}}, {multi: true}).exec();
-                    })
-                    .then(() => res.send(igfsId))
-                    .catch((err) => mongo.handleError(res, err));
-            }
+            mongo.Igfs.findOne({space: params.space, name: params.name}).exec()
+                .then((_igfs) => {
+                    if (_igfs && igfsId !== _igfs._id.toString())
+                        return res.status(500).send('IGFS with name: "' + params.name + '" already exist.');
+
+                    if (params._id) {
+                        return mongo.Igfs.update({_id: igfsId}, params, {upsert: true}).exec()
+                            .then(() => mongo.Cluster.update({_id: {$in: clusters}}, {$addToSet: {igfss: igfsId}}, {multi: true}).exec())
+                            .then(() => mongo.Cluster.update({_id: {$nin: clusters}}, {$pull: {igfss: igfsId}}, {multi: true}).exec())
+                            .then(() => res.send(igfsId))
+                            .catch((err) => mongo.handleError(res, err));
+                    }
+                    else {
+                        return (new mongo.Igfs(params)).save()
+                            .then((igfs) => {
+                                igfsId = igfs._id;
+
+                                return mongo.Cluster.update({_id: {$in: clusters}}, {$addToSet: {igfss: igfsId}}, {multi: true}).exec();
+                            })
+                            .then(() => res.send(igfsId))
+                            .catch((err) => mongo.handleError(res, err));
+                    }
+                })
         });
 
         /**


[15/50] ignite git commit: IGNITE-2648 Add send email.

Posted by ak...@apache.org.
IGNITE-2648 Add send email.


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

Branch: refs/heads/ignite-843-rc3
Commit: 053ba4479339d558e7cd128896bf6826e52df9c9
Parents: 77fdb37
Author: Andrey <an...@gridgain.com>
Authored: Mon Feb 15 17:33:54 2016 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Mon Feb 15 17:33:54 2016 +0700

----------------------------------------------------------------------
 .../src/main/js/serve/routes/public.js                   | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/053ba447/modules/control-center-web/src/main/js/serve/routes/public.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/public.js b/modules/control-center-web/src/main/js/serve/routes/public.js
index 7cbdb8d..829e9d6 100644
--- a/modules/control-center-web/src/main/js/serve/routes/public.js
+++ b/modules/control-center-web/src/main/js/serve/routes/public.js
@@ -136,7 +136,16 @@ module.exports.factory = function(express, passport, nodemailer, settings, mongo
                 .then((account) => {
                     res.sendStatus(200);
 
-                    //_sendMail(account, '', '');
+                    account.resetPasswordToken = _randomString();
+
+                    account.save()
+                        .then(() =>
+                            _sendMail(account, `Thanks for signing up for ${settings.smtp.username}.`,
+                                `Hello ${account.username}!\n\n` +
+                                `You are receiving this e-mail because you (or someone else) signing up on the ${settings.smtp.username}.\n\n` +
+                                'If you did not request this, please ignore this email.\n' +
+                                'You may reset password by clicking on the following link, or paste this into your browser:\n\n' +
+                                'http://' + req.headers.host + '/password/reset?token=' + account.resetPasswordToken));
                 })
                 .catch((err) => {
                     res.status(401).send(err.message);


[35/50] ignite git commit: IGNITE-843 WIP Rework server side to Promises.

Posted by ak...@apache.org.
IGNITE-843 WIP Rework server side to Promises.


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

Branch: refs/heads/ignite-843-rc3
Commit: 4d75119c4f8480d203bf7645d377999aa39c5371
Parents: 87f3c80
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Tue Feb 16 14:25:03 2016 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Tue Feb 16 14:25:03 2016 +0700

----------------------------------------------------------------------
 modules/control-center-web/src/main/js/serve/routes/caches.js | 4 ++--
 modules/control-center-web/src/main/js/serve/routes/igfs.js   | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/4d75119c/modules/control-center-web/src/main/js/serve/routes/caches.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/caches.js b/modules/control-center-web/src/main/js/serve/routes/caches.js
index 69a37e2..aa57c4e 100644
--- a/modules/control-center-web/src/main/js/serve/routes/caches.js
+++ b/modules/control-center-web/src/main/js/serve/routes/caches.js
@@ -125,9 +125,9 @@ module.exports.factory = function(_, express, mongo) {
                 .then((spaces) => {
                     spacesIds = mongo.spacesIds(spaces);
 
-                    return mongo.Cluster.update({space: {$in: spacesIds}}, {caches: []}, {multi: true});
+                    return mongo.Cluster.update({space: {$in: spacesIds}}, {caches: []}, {multi: true}).exec();
                 })
-                .then(() => mongo.DomainModel.update({space: {$in: spacesIds}}, {caches: []}, {multi: true}))
+                .then(() => mongo.DomainModel.update({space: {$in: spacesIds}}, {caches: []}, {multi: true}).exec())
                 .then(() => mongo.Cache.remove({space: {$in: spacesIds}}))
                 .catch((err) => mongo.handleError(res, err));
         });

http://git-wip-us.apache.org/repos/asf/ignite/blob/4d75119c/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 c44620d..144a577 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
@@ -85,7 +85,7 @@ module.exports.factory = function(_, express, mongo) {
                     .then((igfs) => {
                         igfsId = igfs._id;
 
-                        return mongo.Cluster.update({_id: {$in: clusters}}, {$addToSet: {igfss: igfsId}}, {multi: true});
+                        return mongo.Cluster.update({_id: {$in: clusters}}, {$addToSet: {igfss: igfsId}}, {multi: true}).exec();
                     })
                     .then(() => res.send(igfsId))
                     .catch((err) => mongo.handleError(res, err));
@@ -116,9 +116,9 @@ module.exports.factory = function(_, express, mongo) {
                 .then((spaces) => {
                     spacesIds = mongo.spacesIds(spaces);
 
-                    return mongo.Igfs.remove({space: {$in: spacesIds}});
+                    return mongo.Cluster.update({space: {$in: spacesIds}}, {igfss: []}, {multi: true}).exec();
                 })
-                .then(() => mongo.Cluster.update({space: {$in: spacesIds}}, {igfss: []}, {multi: true}))
+                .then(() => mongo.Igfs.remove({space: {$in: spacesIds}}))
                 .then(() => res.sendStatus(200))
                 .catch((err) => mongo.handleError(res, err));
         });


[24/50] ignite git commit: IGNITE-843 Deep merge of objects.

Posted by ak...@apache.org.
IGNITE-843 Deep merge of objects.


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

Branch: refs/heads/ignite-843-rc3
Commit: 2cb3d9cafee6cb17dd0057f688923a513beee890
Parents: e5bfc4c
Author: Vasiliy Sisko <vs...@gridgain.com>
Authored: Mon Feb 15 18:17:13 2016 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Mon Feb 15 18:17:13 2016 +0700

----------------------------------------------------------------------
 .../src/main/js/controllers/clusters-controller.js             | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/2cb3d9ca/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 f07c91d..8f44788 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
@@ -192,7 +192,7 @@ consoleModule.controller('clustersController', function ($http, $timeout, $scope
                 else
                     $scope.backupItem = undefined;
 
-                $scope.backupItem = angular.extend({}, blank, $scope.backupItem);
+                $scope.backupItem = angular.merge({}, blank, $scope.backupItem);
 
                 __original_value = JSON.stringify($cleanup($scope.backupItem));
 
@@ -218,7 +218,7 @@ consoleModule.controller('clustersController', function ($http, $timeout, $scope
                 }
             };
 
-            newItem = angular.extend({},  blank, newItem);
+            newItem = angular.merge({}, blank, newItem);
 
             newItem.caches = id && _.find($scope.caches, {value: id}) ? [id] : [];
             newItem.igfss = id && _.find($scope.igfss, {value: id}) ? [id] : [];
@@ -424,7 +424,7 @@ consoleModule.controller('clustersController', function ($http, $timeout, $scope
                     });
 
                     if (idx >= 0)
-                        angular.extend($scope.clusters[idx], item);
+                        angular.merge($scope.clusters[idx], item);
                     else {
                         item._id = _id;
                         $scope.clusters.push(item);


[33/50] ignite git commit: Merge remote-tracking branch 'origin/ignite-843-rc2' into ignite-843-rc2

Posted by ak...@apache.org.
Merge remote-tracking branch 'origin/ignite-843-rc2' into ignite-843-rc2


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

Branch: refs/heads/ignite-843-rc3
Commit: 31c6d78f83990fe2c5ebcb68716ae89420e6dbed
Parents: 7d539d7 f80a038
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Tue Feb 16 14:14:35 2016 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Tue Feb 16 14:14:35 2016 +0700

----------------------------------------------------------------------
 .../src/main/js/serve/mail.js                   | 71 +++++++++++++++++
 .../src/main/js/serve/routes/admin.js           | 83 ++++++--------------
 .../src/main/js/serve/routes/public.js          | 69 ++++------------
 .../src/main/js/serve/settings.js               |  1 +
 4 files changed, 114 insertions(+), 110 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/31c6d78f/modules/control-center-web/src/main/js/serve/routes/admin.js
----------------------------------------------------------------------


[02/50] ignite git commit: IGNITE-843 Refactor serve to es6.

Posted by ak...@apache.org.
IGNITE-843 Refactor serve to es6.


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

Branch: refs/heads/ignite-843-rc3
Commit: 4220afa5a2b3d1be680d0ea0126089303b321fd5
Parents: b1020f4
Author: Andrey <an...@gridgain.com>
Authored: Mon Feb 15 10:35:47 2016 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Mon Feb 15 10:35:47 2016 +0700

----------------------------------------------------------------------
 .../src/main/js/serve/mongo.js                  |   3 +
 .../src/main/js/serve/routes/notebooks.js       |  10 +-
 .../src/main/js/serve/routes/profile.js         |   2 +-
 .../src/main/js/serve/routes/public.js          | 191 ++++++++++---------
 4 files changed, 105 insertions(+), 101 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/4220afa5/modules/control-center-web/src/main/js/serve/mongo.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/mongo.js b/modules/control-center-web/src/main/js/serve/mongo.js
index c0d5228..f6ff790 100644
--- a/modules/control-center-web/src/main/js/serve/mongo.js
+++ b/modules/control-center-web/src/main/js/serve/mongo.js
@@ -27,6 +27,9 @@ module.exports = {
 module.exports.factory = function(deepPopulatePlugin, passportMongo, settings, pluginMongo) {
     const mongoose = require('mongoose');
 
+    // Use native promises
+    mongoose.Promise = global.Promise;
+
     const deepPopulate = deepPopulatePlugin(mongoose);
 
     // Connect to mongoDB database.

http://git-wip-us.apache.org/repos/asf/ignite/blob/4220afa5/modules/control-center-web/src/main/js/serve/routes/notebooks.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/notebooks.js b/modules/control-center-web/src/main/js/serve/routes/notebooks.js
index e700921..48e9a5c 100644
--- a/modules/control-center-web/src/main/js/serve/routes/notebooks.js
+++ b/modules/control-center-web/src/main/js/serve/routes/notebooks.js
@@ -33,19 +33,17 @@ module.exports.factory = function(express, mongo) {
          * @param res Response.
          */
         router.post('/list', function(req, res) {
-            var user_id = req.currentUserId();
+            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) {
+            mongo.Space.find({$or: [{owner: user_id}, {usedBy: {$elemMatch: {account: user_id}}}]}, (err, spaces) => {
                 if (err)
                     return res.status(500).send(err.message);
 
-                var space_ids = spaces.map(function(value) {
-                    return value._id;
-                });
+                const space_ids = spaces.map((value) => value._id);
 
                 // Get all metadata for spaces.
-                mongo.Notebook.find({space: {$in: space_ids}}).select('_id name').sort('name').exec(function(err, notebooks) {
+                mongo.Notebook.find({space: {$in: space_ids}}).select('_id name').sort('name').exec((err, notebooks) => {
                     if (err)
                         return res.status(500).send(err.message);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/4220afa5/modules/control-center-web/src/main/js/serve/routes/profile.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/profile.js b/modules/control-center-web/src/main/js/serve/routes/profile.js
index 5a22010..e080ce3 100644
--- a/modules/control-center-web/src/main/js/serve/routes/profile.js
+++ b/modules/control-center-web/src/main/js/serve/routes/profile.js
@@ -24,7 +24,7 @@ module.exports = {
 
 module.exports.factory = function(_, express, mongo) {
     return new Promise((resolveFactory) => {
-        const router = express.Router();
+        const router = new express.Router();
 
         /**
          * Save user profile.

http://git-wip-us.apache.org/repos/asf/ignite/blob/4220afa5/modules/control-center-web/src/main/js/serve/routes/public.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/public.js b/modules/control-center-web/src/main/js/serve/routes/public.js
index 476ded2..9c06015 100644
--- a/modules/control-center-web/src/main/js/serve/routes/public.js
+++ b/modules/control-center-web/src/main/js/serve/routes/public.js
@@ -25,8 +25,8 @@ module.exports = {
 };
 
 module.exports.factory = function(express, passport, nodemailer, settings, mongo) {
-    return new Promise(function(resolve) {
-        const router = express.Router();
+    return new Promise(function(factoryResolve) {
+        const router = new express.Router();
 
         const _randomString = () => {
             const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
@@ -42,9 +42,9 @@ module.exports.factory = function(express, passport, nodemailer, settings, mongo
 
         // GET user.
         router.post('/user', function(req, res) {
-            var becomeUsed = req.session.viewedUser && req.user.admin;
+            const becomeUsed = req.session.viewedUser && req.user.admin;
 
-            var user = req.user;
+            let user = req.user;
 
             if (becomeUsed) {
                 user = req.session.viewedUser;
@@ -59,28 +59,28 @@ module.exports.factory = function(express, passport, nodemailer, settings, mongo
          * Register new account.
          */
         router.post('/register', function(req, res) {
-            mongo.Account.count(function(err, cnt) {
-                if (err)
-                    return res.status(401).send(err.message);
+            mongo.Account.count(function(errCount, cnt) {
+                if (errCount)
+                    return res.status(401).send(errCount.message);
 
                 req.body.admin = cnt === 0;
 
-                var account = new mongo.Account(req.body);
+                const _account = new mongo.Account(req.body);
 
-                account.token = _randomString();
+                _account.token = _randomString();
 
-                mongo.Account.register(account, req.body.password, function(err, account) {
-                    if (err)
-                        return res.status(401).send(err.message);
+                mongo.Account.register(_account, req.body.password, function(errRegister, account) {
+                    if (errRegister)
+                        return res.status(401).send(errRegister.message);
 
                     if (!account)
                         return res.status(500).send('Failed to create account.');
 
                     new mongo.Space({name: 'Personal space', owner: account._id}).save();
 
-                    req.logIn(account, {}, function(err) {
-                        if (err)
-                            return res.status(401).send(err.message);
+                    req.logIn(account, {}, function(errLogIn) {
+                        if (errLogIn)
+                            return res.status(401).send(errLogIn.message);
 
                         return res.sendStatus(200);
                     });
@@ -92,16 +92,16 @@ module.exports.factory = function(express, passport, nodemailer, settings, mongo
          * Login in exist account.
          */
         router.post('/login', function(req, res, next) {
-            passport.authenticate('local', function(err, user) {
-                if (err)
-                    return res.status(401).send(err.message);
+            passport.authenticate('local', function(errAuth, user) {
+                if (errAuth)
+                    return res.status(401).send(errAuth.message);
 
                 if (!user)
                     return res.status(401).send('Invalid email or password');
 
-                req.logIn(user, {}, function(err) {
-                    if (err)
-                        return res.status(401).send(err.message);
+                req.logIn(user, {}, function(errLogIn) {
+                    if (errLogIn)
+                        return res.status(401).send(errLogIn.message);
 
                     return res.sendStatus(200);
                 });
@@ -121,7 +121,7 @@ module.exports.factory = function(express, passport, nodemailer, settings, mongo
          * Send e-mail to user with reset token.
          */
         router.post('/password/forgot', function(req, res) {
-            var transporter = {
+            const transporter = {
                 service: settings.smtp.service,
                 auth: {
                     user: settings.smtp.email,
@@ -132,26 +132,21 @@ module.exports.factory = function(express, passport, nodemailer, settings, mongo
             if (transporter.service === '' || transporter.auth.user === '' || transporter.auth.pass === '')
                 return res.status(401).send('Can\'t send e-mail with instructions to reset password. Please ask webmaster to setup SMTP server!');
 
-            var token = _randomString();
+            const token = _randomString();
 
-            mongo.Account.findOne({email: req.body.email}, function(err, user) {
-                if (!user)
-                    return res.status(401).send('No account with that email address exists!');
-
-                // TODO IGNITE-843 Send email to admin
-                if (err)
-                    return res.status(401).send('Failed to reset password!');
+            mongo.Account.findOne({email: req.body.email}).exec()
+                .then((user) => {
+                    if (!user)
+                        return Promise.reject('Account with that email address does not exists!');
 
-                user.resetPasswordToken = token;
-
-                user.save(function(err) {
-                    // TODO IGNITE-843 Send email to admin
-                    if (err)
-                        return res.status(401).send('Failed to reset password!');
+                    user.resetPasswordToken = token;
 
-                    var mailer = nodemailer.createTransport(transporter);
+                    return user.save();
+                })
+                .then((user) => {
+                    const mailer = nodemailer.createTransport(transporter);
 
-                    var mailOptions = {
+                    const mailOptions = {
                         from: settings.smtp.address(settings.smtp.username, settings.smtp.email),
                         to: settings.smtp.address(user.username, user.email),
                         subject: 'Password Reset',
@@ -163,88 +158,96 @@ module.exports.factory = function(express, passport, nodemailer, settings, mongo
                         settings.smtp.username + '\n'
                     };
 
-                    mailer.sendMail(mailOptions, function(err) {
-                        if (err)
-                            return res.status(401).send('Failed to send e-mail with reset link! ' + err);
+                    return new Promise((resolve, reject) => {
+                        mailer.sendMail(mailOptions, (err) => {
+                            if (err)
+                                return reject();
 
-                        return res.status(200).send('An e-mail has been sent with further instructions.');
+                            resolve(res.status(200).send('An e-mail has been sent with further instructions.'));
+                        });
                     });
+                })
+                .catch((err) => {
+                    // TODO IGNITE-843 Send email to admin
+                    return res.status(401).send('Failed to send e-mail with reset link!' + (err ? '<br>' + err : ''));
                 });
-            });
         });
 
         /**
          * Change password with given token.
          */
         router.post('/password/reset', function(req, res) {
-            mongo.Account.findOne({resetPasswordToken: req.body.token}, function(err, user) {
-                if (!user)
-                    return res.status(500).send('Invalid token for password reset!');
+            mongo.Account.findOne({resetPasswordToken: req.body.token}).exec()
+                .then((user) => {
+                    return new Promise((resolve, reject) => {
+                        if (!user)
+                            return reject();
 
-                // TODO IGNITE-843 Send email to admin
-                if (err)
-                    return res.status(500).send('Failed to reset password!');
+                        user.setPassword(req.body.password, (err, _user) => {
+                            if (err) {
+                                console.log('Failed to reset password: ' + err.message);
 
-                user.setPassword(req.body.password, function(err, updatedUser) {
-                    if (err)
-                        return res.status(500).send(err.message);
+                                return reject();
+                            }
 
-                    updatedUser.resetPasswordToken = undefined;
+                            _user.resetPasswordToken = undefined;
 
-                    updatedUser.save(function(err) {
-                        if (err)
-                            return res.status(500).send(err.message);
+                            resolve(_user.save());
+                        });
+                    });
+                })
+                .then((user) => {
+                    const transporter = {
+                        service: settings.smtp.service,
+                        auth: {
+                            user: settings.smtp.email,
+                            pass: settings.smtp.password
+                        }
+                    };
 
-                        var transporter = {
-                            service: settings.smtp.service,
-                            auth: {
-                                user: settings.smtp.email,
-                                pass: settings.smtp.password
-                            }
-                        };
-
-                        var mailer = nodemailer.createTransport(transporter);
-
-                        var mailOptions = {
-                            from: settings.smtp.address(settings.smtp.username, settings.smtp.email),
-                            to: settings.smtp.address(user.username, user.email),
-                            subject: 'Your password has been changed',
-                            text: 'Hello,\n\n' +
-                            'This is a confirmation that the password for your account ' + user.email + ' has just been changed.\n\n' +
-                            'Now you can login: http://' + req.headers.host + '\n\n' +
-                            '--------------\n' +
-                            'Apache Ignite Web Console\n'
-                        };
-
-                        mailer.sendMail(mailOptions, function(err) {
+                    const mailer = nodemailer.createTransport(transporter);
+
+                    const mailOptions = {
+                        from: settings.smtp.address(settings.smtp.username, settings.smtp.email),
+                        to: settings.smtp.address(user.username, user.email),
+                        subject: 'Your password has been changed',
+                        text: 'Hello,\n\n' +
+                        'This is a confirmation that the password for your account ' + user.email + ' has just been changed.\n\n' +
+                        'Now you can login: http://' + req.headers.host + '\n\n' +
+                        '--------------\n' +
+                        'Apache Ignite Web Console\n'
+                    };
+
+                    return new Promise((resolve) => {
+                        mailer.sendMail(mailOptions, (err) => {
                             if (err)
-                                return res.status(503).send('Password was changed, but failed to send confirmation e-mail!<br />' + err);
+                                return resolve(res.status(500).send('Password was changed, but failed to send confirmation e-mail!'));
 
-                            return res.status(200).send(user.email);
+                            resolve(res.status(200).send(user.email));
                         });
                     });
+                })
+                .catch(() => {
+                    res.status(500).send('Failed to reset password! Please check link from e-mail.');
                 });
-            });
         });
 
         /* GET reset password page. */
         router.post('/validate/token', function(req, res) {
-            var token = req.body.token;
-
-            var data = {token};
+            const token = req.body.token;
 
-            mongo.Account.findOne({resetPasswordToken: token}, function(err, user) {
-                if (!user)
-                    data.error = 'Invalid token for password reset!';
-                else if (err)
-                    data.error = err;
-                else
-                    data.email = user.email;
+            mongo.Account.findOne({resetPasswordToken: token}).exec()
+                .then((user) => {
+                    return new Promise((resolve, reject) => {
+                        if (!user)
+                            return reject('Invalid token for password reset!');
 
-                res.json(data);
-            });
+                        resolve(res.json({token, email: user.email}));
+                    });
+                })
+                .catch((error) => res.json({error}));
         });
 
-        resolve(router);
+        factoryResolve(router);
     });
 };


[42/50] ignite git commit: IGNITE-843 Fixed restore selection order.

Posted by ak...@apache.org.
IGNITE-843 Fixed restore selection order.


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

Branch: refs/heads/ignite-843-rc3
Commit: 0fa2c01712878df8f4b538e8df5b382b6b6b1e73
Parents: 877a1fc
Author: Vasiliy Sisko <vs...@gridgain.com>
Authored: Tue Feb 16 17:07:49 2016 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Tue Feb 16 17:07:49 2016 +0700

----------------------------------------------------------------------
 .../src/main/js/controllers/domains-controller.js                | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/0fa2c017/modules/control-center-web/src/main/js/controllers/domains-controller.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/controllers/domains-controller.js b/modules/control-center-web/src/main/js/controllers/domains-controller.js
index 142e76c..cc108bc 100644
--- a/modules/control-center-web/src/main/js/controllers/domains-controller.js
+++ b/modules/control-center-web/src/main/js/controllers/domains-controller.js
@@ -97,9 +97,9 @@ consoleModule.controller('domainsController', function ($filter, $http, $timeout
                                     _.forEach($scope.clusters, function (cluster) {
                                         $scope.ui.generatedCachesClusters.push(cluster.value);
                                     });
-                                });
 
-                            restoreSelection();
+                                    restoreSelection();
+                                });
                         })
                         .error(function (errMsg) {
                             $common.showError(errMsg);


[19/50] ignite git commit: Merge remote-tracking branch 'origin/ignite-843-rc2' into ignite-843-rc2

Posted by ak...@apache.org.
Merge remote-tracking branch 'origin/ignite-843-rc2' into ignite-843-rc2


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

Branch: refs/heads/ignite-843-rc3
Commit: 5110d98dc191a2cef030c9b0be5935f0d014224b
Parents: d29110f 02d4c1e
Author: AKuznetsov <ak...@gridgain.com>
Authored: Mon Feb 15 17:45:18 2016 +0700
Committer: AKuznetsov <ak...@gridgain.com>
Committed: Mon Feb 15 17:45:18 2016 +0700

----------------------------------------------------------------------
 .../form-field-java-class.jade                      | 10 +++++-----
 .../js/app/modules/form/field/input/number.jade     |  2 +-
 .../states/configuration/clusters/deployment.jade   | 16 ++++++++--------
 .../modules/states/configuration/clusters/igfs.jade |  2 +-
 4 files changed, 15 insertions(+), 15 deletions(-)
----------------------------------------------------------------------



[12/50] ignite git commit: IGNITE-843 Rework IGFS server side to Promises.

Posted by ak...@apache.org.
IGNITE-843 Rework IGFS server side to Promises.


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

Branch: refs/heads/ignite-843-rc3
Commit: e2f7d427e228989a53d86cacd858e76a591cb594
Parents: bfd0dd9
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Mon Feb 15 16:25:32 2016 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Mon Feb 15 16:25:32 2016 +0700

----------------------------------------------------------------------
 .../src/main/js/serve/routes/clusters.js        |  2 +
 .../src/main/js/serve/routes/igfs.js            | 93 +++++++++-----------
 .../src/main/js/serve/routes/profile.js         | 12 +--
 3 files changed, 49 insertions(+), 58 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/e2f7d427/modules/control-center-web/src/main/js/serve/routes/clusters.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/clusters.js b/modules/control-center-web/src/main/js/serve/routes/clusters.js
index 98db693..9410ffc 100644
--- a/modules/control-center-web/src/main/js/serve/routes/clusters.js
+++ b/modules/control-center-web/src/main/js/serve/routes/clusters.js
@@ -141,6 +141,8 @@ module.exports.factory = function(_, express, mongo) {
                 if (err)
                     return res.status(500).send(err.message);
 
+                // TODO add IGFS and caches cleanup
+
                 res.sendStatus(200);
             });
         });

http://git-wip-us.apache.org/repos/asf/ignite/blob/e2f7d427/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 b10e5ac..630a75d 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
@@ -45,19 +45,12 @@ module.exports.factory = function(_, express, mongo) {
 
                     return mongo.Cluster.find({space: {$in: result.spacesIds}}, '_id name').sort('name').exec();
                 })
-                .then(clusters => {
+                .then((clusters) => {
                     result.clusters = clusters;
 
                     return mongo.Igfs.find({space: {$in: result.spacesIds}}).sort('name').exec();
                 })
                 .then((igfss) => {
-                    _.forEach(igfss, (igfs) => {
-                        // Remove deleted clusters.
-                        igfs.clusters = _.filter(igfs.clusters, (clusterId) => {
-                            return _.findIndex(result.clusters, (cluster) => cluster._id.equals(clusterId)) >= 0;
-                        });
-                    });
-
                     res.json({
                         spaces: result.spaces,
                         clusters: result.clusters.map((cluster) => ({value: cluster._id, label: cluster.name})),
@@ -76,40 +69,37 @@ module.exports.factory = function(_, express, mongo) {
         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}, (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);
-                                });
-                            }
-                        });
-                    }
-                });
+                mongo.Igfs.update({_id: igfsId}, params, {upsert: true}).exec()
+                    .then(() => mongo.Cluster.update({_id: {$in: clusters}}, {$addToSet: {igfss: igfsId}}, {multi: true}).exec())
+                    .then(() => mongo.Cluster.update({_id: {$nin: clusters}}, {$pull: {igfss: igfsId}}, {multi: true}).exec())
+                    .then(() => res.send(igfsId))
+                    .catch((err) => {
+                        // TODO IGNITE-843 Send error to admin
+                        res.status(500).send(err.message);
+                    });
             }
             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}, (errCluster) => {
-                                    if (mongo.processed(errCluster, res))
-                                        res.send(igfsId);
-                                });
-                            }
-                        });
-                    }
-                });
+                mongo.Igfs.findOne({space: params.space, name: params.name}).exec()
+                    .then((_igfs) => {
+                        if (_igfs)
+                            throw new Error('IGFS with name: "' + _igfs + '" already exist.');
+
+                        return (new mongo.Igfs(params)).save();
+                    })
+                    .then((igfs) => {
+                        igfsId = igfs._id;
+
+                        return mongo.Cluster.update({_id: {$in: clusters}}, {$addToSet: {igfss: igfsId}}, {multi: true});
+                    })
+                    .then(() => res.send(igfsId))
+                    .catch((err) => {
+                        // TODO IGNITE-843 Send error to admin
+                        res.status(500).send(err.message);
+                    });
             }
         });
 
@@ -127,23 +117,22 @@ module.exports.factory = function(_, express, mongo) {
          * Remove all IGFSs.
          */
         router.post('/remove/all', (req, res) => {
-            const user_id = req.currentUserId();
+            const userId = req.currentUserId();
+            let spacesIds = [];
 
             // Get owned space and all accessed space.
-            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.Space.find({$or: [{owner: userId}, {usedBy: {$elemMatch: {account: userId}}}]})
+                .then((spaces) => {
+                    spacesIds = spaces.map((value) => value._id);
+
+                    return mongo.Igfs.remove({space: {$in: spacesIds}});
+                })
+                .then(() => mongo.Cluster.update({space: {$in: spacesIds}}, {igfss: []}, {multi: true}))
+                .then(() => res.sendStatus(200))
+                .catch((err) => {
+                    // TODO IGNITE-843 Send error to admin
+                    res.status(500).send(err.message);
+                });
         });
 
         resolve(router);

http://git-wip-us.apache.org/repos/asf/ignite/blob/e2f7d427/modules/control-center-web/src/main/js/serve/routes/profile.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/profile.js b/modules/control-center-web/src/main/js/serve/routes/profile.js
index bf227a2..079b360 100644
--- a/modules/control-center-web/src/main/js/serve/routes/profile.js
+++ b/modules/control-center-web/src/main/js/serve/routes/profile.js
@@ -45,7 +45,7 @@ module.exports.factory = function(_, express, mongo) {
                     return new Promise((resolve, reject) => {
                         user.setPassword(params.password, (err, _user) => {
                             if (err)
-                                return reject(err.message);
+                                return reject(err);
 
                             delete params.password;
 
@@ -57,14 +57,14 @@ module.exports.factory = function(_, express, mongo) {
                     if (!params.email || user.email === params.email)
                         return Promise.resolve(user);
 
-                    return new Promise((resolve, reject) => {
+                    return new Promise((resolve) => {
                         mongo.Account.findOne({email: params.email}, (err, _user) => {
                             // TODO send error to admin
                             if (err)
-                                return reject('Failed to check e-mail!');
+                                throw new Error('Failed to check e-mail!');
 
                             if (_user && _user._id !== user._id)
-                                return reject('User with this e-mail already registered!');
+                                throw new Error('User with this e-mail already registered!');
 
                             resolve(user);
                         });
@@ -79,9 +79,9 @@ module.exports.factory = function(_, express, mongo) {
                     return user.save();
                 })
                 .then(() => res.sendStatus(200))
-                .catch((errMsg) => {
+                .catch((err) => {
                     // TODO IGNITE-843 Send error to admin
-                    res.status(500).send(errMsg);
+                    res.status(500).send(err.message);
                 });
         });
 


[03/50] ignite git commit: IGNITE-843 Refactor serve to es6.

Posted by ak...@apache.org.
IGNITE-843 Refactor serve to es6.


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

Branch: refs/heads/ignite-843-rc3
Commit: 0cd0471565f7c13c0e39ad05eda307e1b8dfe643
Parents: 4220afa
Author: Andrey <an...@gridgain.com>
Authored: Mon Feb 15 10:44:29 2016 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Mon Feb 15 10:44:29 2016 +0700

----------------------------------------------------------------------
 modules/control-center-web/src/main/js/serve/routes/public.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/0cd04715/modules/control-center-web/src/main/js/serve/routes/public.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/public.js b/modules/control-center-web/src/main/js/serve/routes/public.js
index 9c06015..638bda6 100644
--- a/modules/control-center-web/src/main/js/serve/routes/public.js
+++ b/modules/control-center-web/src/main/js/serve/routes/public.js
@@ -190,7 +190,7 @@ module.exports.factory = function(express, passport, nodemailer, settings, mongo
                                 return reject();
                             }
 
-                            _user.resetPasswordToken = undefined;
+                            _user.resetPasswordToken = undefined; // eslint-disable-line no-undefined
 
                             resolve(_user.save());
                         });


[29/50] ignite git commit: IGNITE-843 WIP Rework server side to Promises.

Posted by ak...@apache.org.
IGNITE-843 WIP Rework server side to Promises.


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

Branch: refs/heads/ignite-843-rc3
Commit: 3e9942e07368ab8a89bed4632feb4c83cee6cf18
Parents: 63bd2c0
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Tue Feb 16 11:05:18 2016 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Tue Feb 16 11:05:18 2016 +0700

----------------------------------------------------------------------
 .../src/main/js/controllers/igfs-controller.js                | 7 ++++++-
 modules/control-center-web/src/main/js/serve/routes/caches.js | 2 +-
 .../control-center-web/src/main/js/serve/routes/clusters.js   | 4 ++--
 .../control-center-web/src/main/js/serve/routes/domains.js    | 7 ++++++-
 4 files changed, 15 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/3e9942e0/modules/control-center-web/src/main/js/controllers/igfs-controller.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/controllers/igfs-controller.js b/modules/control-center-web/src/main/js/controllers/igfs-controller.js
index 4644c3d..de45a55 100644
--- a/modules/control-center-web/src/main/js/controllers/igfs-controller.js
+++ b/modules/control-center-web/src/main/js/controllers/igfs-controller.js
@@ -167,7 +167,12 @@ consoleModule.controller('igfsController', [
                 .success(function (data) {
                     $scope.spaces = data.spaces;
                     $scope.igfss = data.igfss;
-                    $scope.clusters = data.clusters;
+                    $scope.clusters = _.map(data.clusters, function (cluster) {
+                        return {
+                            value: cluster._id,
+                            label: cluster.name
+                        };
+                    });
 
                     // Load page descriptor.
                     $http.get('/models/igfs.json')

http://git-wip-us.apache.org/repos/asf/ignite/blob/3e9942e0/modules/control-center-web/src/main/js/serve/routes/caches.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/caches.js b/modules/control-center-web/src/main/js/serve/routes/caches.js
index 581b5f7..4411a61 100644
--- a/modules/control-center-web/src/main/js/serve/routes/caches.js
+++ b/modules/control-center-web/src/main/js/serve/routes/caches.js
@@ -44,7 +44,7 @@ module.exports.factory = function(_, express, mongo) {
                     result.spaces = spaces;
                     spacesIds = mongo.spacesIds(spaces);
 
-                    return mongo.Cluster.find({space: {$in: result.spacesIds}}).sort('name').exec();
+                    return mongo.Cluster.find({space: {$in: spacesIds}}).sort('name').exec();
                 })
                 .then((clusters) => {
                     result.clusters = clusters;

http://git-wip-us.apache.org/repos/asf/ignite/blob/3e9942e0/modules/control-center-web/src/main/js/serve/routes/clusters.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/clusters.js b/modules/control-center-web/src/main/js/serve/routes/clusters.js
index a04844a..08d0051 100644
--- a/modules/control-center-web/src/main/js/serve/routes/clusters.js
+++ b/modules/control-center-web/src/main/js/serve/routes/clusters.js
@@ -138,10 +138,10 @@ module.exports.factory = function(_, express, mongo) {
                 .then((spaces) => {
                     spacesIds = mongo.spacesIds(spaces);
 
-                    return mongo.Cluster.remove({space: {$in: spacesIds}});
+                    return mongo.Cache.update({space: {$in: spacesIds}}, {clusters: []}, {multi: true}).exec();
                 })
-                .then(() => mongo.Cache.update({space: {$in: spacesIds}}, {clusters: []}, {multi: true}).exec())
                 .then(() => mongo.Igfs.update({space: {$in: spacesIds}}, {clusters: []}, {multi: true}).exec())
+                .then(() => mongo.Cluster.remove({space: {$in: spacesIds}}))
                 .then(() => res.sendStatus(200))
                 .catch((err) => mongo.handleError(res, err));
         });

http://git-wip-us.apache.org/repos/asf/ignite/blob/3e9942e0/modules/control-center-web/src/main/js/serve/routes/domains.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/domains.js b/modules/control-center-web/src/main/js/serve/routes/domains.js
index f757910..3953665 100644
--- a/modules/control-center-web/src/main/js/serve/routes/domains.js
+++ b/modules/control-center-web/src/main/js/serve/routes/domains.js
@@ -176,7 +176,12 @@ module.exports.factory = function(_, express, mongo) {
          * Remove domain model by ._id.
          */
         router.post('/remove', (req, res) => {
-            mongo.DomainModel.remove(req.body)
+            const params = req.body;
+            const domainId = params._id;
+
+            mongo.DomainModel.findOne(params).exec()
+                .then((domain) => mongo.Cache.update({_id: {$in: domain.caches}}, {$pull: {domain: domainId}}, {multi: true}).exec())
+                .then(() => mongo.DomainModel.remove(params))
                 .then(() => res.sendStatus(200))
                 .catch((err) => mongo.handleError(res, err));
         });


[49/50] ignite git commit: IGNITE-843 Minor fixes.

Posted by ak...@apache.org.
IGNITE-843 Minor fixes.


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

Branch: refs/heads/ignite-843-rc3
Commit: f06c1953e42d76ad4be2cdc53ec094f02e7b0d5f
Parents: 09d6538
Author: AKuznetsov <ak...@gridgain.com>
Authored: Tue Feb 16 20:39:53 2016 +0700
Committer: AKuznetsov <ak...@gridgain.com>
Committed: Tue Feb 16 20:39:53 2016 +0700

----------------------------------------------------------------------
 .../control-center-web/src/main/js/package.json |  1 +
 .../src/main/js/serve/mongo.js                  | 10 ++++-----
 .../src/main/js/serve/routes/caches.js          | 19 ++++++++--------
 .../src/main/js/serve/routes/clusters.js        | 23 ++++++++++----------
 .../src/main/js/serve/routes/domains.js         | 17 +++++++--------
 .../src/main/js/serve/routes/igfs.js            | 19 ++++++++--------
 6 files changed, 43 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/f06c1953/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 9eef666..a4f820e 100644
--- a/modules/control-center-web/src/main/js/package.json
+++ b/modules/control-center-web/src/main/js/package.json
@@ -21,6 +21,7 @@
     "node": ">=0.12.4"
   },
   "dependencies": {
+    "async": "1.5.2",
     "babel-eslint": "^4.1.6",
     "body-parser": "~1.14.1",
     "bootstrap-sass": "^3.3.6",

http://git-wip-us.apache.org/repos/asf/ignite/blob/f06c1953/modules/control-center-web/src/main/js/serve/mongo.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/mongo.js b/modules/control-center-web/src/main/js/serve/mongo.js
index 9021016..0ea72d9 100644
--- a/modules/control-center-web/src/main/js/serve/mongo.js
+++ b/modules/control-center-web/src/main/js/serve/mongo.js
@@ -90,7 +90,7 @@ module.exports.factory = function(deepPopulatePlugin, passportMongo, settings, p
 
     // Define Domain model schema.
     const DomainModelSchema = new Schema({
-        space: {type: ObjectId, ref: 'Space'},
+        space: {type: ObjectId, ref: 'Space', index: true},
         caches: [{type: ObjectId, ref: 'Cache'}],
         queryMetadata: {type: String, enum: ['Annotations', 'Configuration']},
         kind: {type: String, enum: ['query', 'store', 'both']},
@@ -125,7 +125,7 @@ module.exports.factory = function(deepPopulatePlugin, passportMongo, settings, p
 
     // Define Cache schema.
     const CacheSchema = new Schema({
-        space: {type: ObjectId, ref: 'Space'},
+        space: {type: ObjectId, ref: 'Space', index: true},
         name: String,
         clusters: [{type: ObjectId, ref: 'Cluster'}],
         domains: [{type: ObjectId, ref: 'DomainModel'}],
@@ -258,7 +258,7 @@ module.exports.factory = function(deepPopulatePlugin, passportMongo, settings, p
     result.Cache = mongoose.model('Cache', CacheSchema);
 
     const IgfsSchema = new Schema({
-        space: {type: ObjectId, ref: 'Space'},
+        space: {type: ObjectId, ref: 'Space', index: true},
         name: String,
         clusters: [{type: ObjectId, ref: 'Cluster'}],
         affinnityGroupSize: Number,
@@ -304,7 +304,7 @@ module.exports.factory = function(deepPopulatePlugin, passportMongo, settings, p
 
     // Define Cluster schema.
     const ClusterSchema = new Schema({
-        space: {type: ObjectId, ref: 'Space'},
+        space: {type: ObjectId, ref: 'Space', index: true},
         name: String,
         localHost: String,
         discovery: {
@@ -506,7 +506,7 @@ module.exports.factory = function(deepPopulatePlugin, passportMongo, settings, p
 
     // Define Notebook schema.
     const NotebookSchema = new Schema({
-        space: {type: ObjectId, ref: 'Space'},
+        space: {type: ObjectId, ref: 'Space', index: true},
         name: String,
         expandedParagraphs: [Number],
         paragraphs: [{

http://git-wip-us.apache.org/repos/asf/ignite/blob/f06c1953/modules/control-center-web/src/main/js/serve/routes/caches.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/caches.js b/modules/control-center-web/src/main/js/serve/routes/caches.js
index 17fef2d..0122864 100644
--- a/modules/control-center-web/src/main/js/serve/routes/caches.js
+++ b/modules/control-center-web/src/main/js/serve/routes/caches.js
@@ -87,17 +87,16 @@ module.exports.factory = function(_, express, mongo) {
                             .then(() => res.send(cacheId))
                             .catch((err) => mongo.handleError(res, err));
                     }
-                    else {
-                        return (new mongo.Cache(params)).save()
-                            .then((cache) => {
-                                cacheId = cache._id;
 
-                                return mongo.Cluster.update({_id: {$in: clusters}}, {$addToSet: {caches: cacheId}}, {multi: true}).exec();
-                            })
-                            .then(() => mongo.DomainModel.update({_id: {$in: domains}}, {$addToSet: {caches: cacheId}}, {multi: true}).exec())
-                            .then(() => res.send(cacheId))
-                            .catch((err) => mongo.handleError(res, err));
-                    }
+                    return (new mongo.Cache(params)).save()
+                        .then((cache) => {
+                            cacheId = cache._id;
+
+                            return mongo.Cluster.update({_id: {$in: clusters}}, {$addToSet: {caches: cacheId}}, {multi: true}).exec();
+                        })
+                        .then(() => mongo.DomainModel.update({_id: {$in: domains}}, {$addToSet: {caches: cacheId}}, {multi: true}).exec())
+                        .then(() => res.send(cacheId))
+                        .catch((err) => mongo.handleError(res, err));
                 });
         });
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/f06c1953/modules/control-center-web/src/main/js/serve/routes/clusters.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/clusters.js b/modules/control-center-web/src/main/js/serve/routes/clusters.js
index 6bbf4c0..bca0735 100644
--- a/modules/control-center-web/src/main/js/serve/routes/clusters.js
+++ b/modules/control-center-web/src/main/js/serve/routes/clusters.js
@@ -97,19 +97,18 @@ module.exports.factory = function(_, express, mongo) {
                             .then(() => res.send(clusterId))
                             .catch((err) => mongo.handleError(res, err));
                     }
-                    else {
-                        return (new mongo.Cluster(params)).save()
-                            .then((cluster) => {
-                                clusterId = cluster._id;
 
-                                return mongo.Cache.update({_id: {$in: caches}}, {$addToSet: {clusters: clusterId}}, {multi: true}).exec();
-                            })
-                            .then(() => mongo.Cache.update({_id: {$nin: caches}}, {$pull: {clusters: clusterId}}, {multi: true}).exec())
-                            .then(() => mongo.Igfs.update({_id: {$in: igfss}}, {$addToSet: {clusters: clusterId}}, {multi: true}).exec())
-                            .then(() => mongo.Igfs.update({_id: {$nin: igfss}}, {$pull: {clusters: clusterId}}, {multi: true}).exec())
-                            .then(() => res.send(clusterId))
-                            .catch((err) => mongo.handleError(res, err));
-                    }
+                    return (new mongo.Cluster(params)).save()
+                        .then((cluster) => {
+                            clusterId = cluster._id;
+
+                            return mongo.Cache.update({_id: {$in: caches}}, {$addToSet: {clusters: clusterId}}, {multi: true}).exec();
+                        })
+                        .then(() => mongo.Cache.update({_id: {$nin: caches}}, {$pull: {clusters: clusterId}}, {multi: true}).exec())
+                        .then(() => mongo.Igfs.update({_id: {$in: igfss}}, {$addToSet: {clusters: clusterId}}, {multi: true}).exec())
+                        .then(() => mongo.Igfs.update({_id: {$nin: igfss}}, {$pull: {clusters: clusterId}}, {multi: true}).exec())
+                        .then(() => res.send(clusterId))
+                        .catch((err) => mongo.handleError(res, err));
                 });
         });
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/f06c1953/modules/control-center-web/src/main/js/serve/routes/domains.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/domains.js b/modules/control-center-web/src/main/js/serve/routes/domains.js
index 6fe64b3..d98398b 100644
--- a/modules/control-center-web/src/main/js/serve/routes/domains.js
+++ b/modules/control-center-web/src/main/js/serve/routes/domains.js
@@ -93,15 +93,14 @@ module.exports.factory = (_, express, mongo) => {
                                 return _updateCacheStore(cacheStoreChanges);
                             });
                     }
-                    else {
-                        return (new mongo.DomainModel(domain)).save()
-                            .then((savedDomain) => {
-                                savedDomains.push(savedDomain);
-
-                                return mongo.Cache.update({_id: {$in: caches}}, {$addToSet: {domains: savedDomain._id}}, {multi: true}).exec();
-                            })
-                            .then(() => _updateCacheStore(cacheStoreChanges));
-                    }
+
+                    return (new mongo.DomainModel(domain)).save()
+                        .then((savedDomain) => {
+                            savedDomains.push(savedDomain);
+
+                            return mongo.Cache.update({_id: {$in: caches}}, {$addToSet: {domains: savedDomain._id}}, {multi: true}).exec();
+                        })
+                        .then(() => _updateCacheStore(cacheStoreChanges));
                 });
         };
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/f06c1953/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 baadfe6..255220a 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
@@ -79,17 +79,16 @@ module.exports.factory = function(_, express, mongo) {
                             .then(() => res.send(igfsId))
                             .catch((err) => mongo.handleError(res, err));
                     }
-                    else {
-                        return (new mongo.Igfs(params)).save()
-                            .then((igfs) => {
-                                igfsId = igfs._id;
 
-                                return mongo.Cluster.update({_id: {$in: clusters}}, {$addToSet: {igfss: igfsId}}, {multi: true}).exec();
-                            })
-                            .then(() => res.send(igfsId))
-                            .catch((err) => mongo.handleError(res, err));
-                    }
-                })
+                    return (new mongo.Igfs(params)).save()
+                        .then((igfs) => {
+                            igfsId = igfs._id;
+
+                            return mongo.Cluster.update({_id: {$in: clusters}}, {$addToSet: {igfss: igfsId}}, {multi: true}).exec();
+                        })
+                        .then(() => res.send(igfsId))
+                        .catch((err) => mongo.handleError(res, err));
+                });
         });
 
         /**


[36/50] ignite git commit: IGNITE-843 Refactor serve to es6.

Posted by ak...@apache.org.
IGNITE-843 Refactor serve to es6.


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

Branch: refs/heads/ignite-843-rc3
Commit: 28f33ca99519e4980081e05354892b0afc41eaff
Parents: 4d75119
Author: Andrey <an...@gridgain.com>
Authored: Tue Feb 16 15:44:14 2016 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Tue Feb 16 15:44:14 2016 +0700

----------------------------------------------------------------------
 modules/control-center-web/src/main/js/serve.js |  2 +-
 .../src/main/js/serve/routes/caches.js          |  4 ++--
 .../src/main/js/serve/routes/clusters.js        |  4 ++--
 .../src/main/js/serve/routes/domains.js         | 22 +++++++++++++-------
 .../src/main/js/serve/routes/igfs.js            |  4 ++--
 .../src/main/js/serve/routes/notebooks.js       |  2 +-
 6 files changed, 23 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/28f33ca9/modules/control-center-web/src/main/js/serve.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve.js b/modules/control-center-web/src/main/js/serve.js
index a962539..59ea9e8 100644
--- a/modules/control-center-web/src/main/js/serve.js
+++ b/modules/control-center-web/src/main/js/serve.js
@@ -80,7 +80,7 @@ Promise.all([fireUp('settings'), fireUp('app'), fireUp('agent')])
         server.on('listening', _onListening.bind(null, server.address()));
 
         // Create HTTPS server if needed.
-        if (settings.serverSSLOptions) {
+        if (settings.server.SSLOptions) {
             const httpsServer = https.createServer(settings.server.SSLOptions, app);
 
             const httpsPort = settings.server.SSLOptions.port;

http://git-wip-us.apache.org/repos/asf/ignite/blob/28f33ca9/modules/control-center-web/src/main/js/serve/routes/caches.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/caches.js b/modules/control-center-web/src/main/js/serve/routes/caches.js
index aa57c4e..aed7f10 100644
--- a/modules/control-center-web/src/main/js/serve/routes/caches.js
+++ b/modules/control-center-web/src/main/js/serve/routes/caches.js
@@ -110,7 +110,7 @@ module.exports.factory = function(_, express, mongo) {
 
             mongo.Cluster.update({caches: {$in: [cacheId]}}, {$pull: {caches: cacheId}}, {multi: true}).exec()
                 .then(() => mongo.DomainModel.update({caches: {$in: [cacheId]}}, {$pull: {caches: cacheId}}, {multi: true}).exec())
-                .then(() => mongo.Cache.remove(params))
+                .then(() => mongo.Cache.remove(params).exec())
                 .then(() => res.sendStatus(200))
                 .catch((err) => mongo.handleError(res, err));
         });
@@ -128,7 +128,7 @@ module.exports.factory = function(_, express, mongo) {
                     return mongo.Cluster.update({space: {$in: spacesIds}}, {caches: []}, {multi: true}).exec();
                 })
                 .then(() => mongo.DomainModel.update({space: {$in: spacesIds}}, {caches: []}, {multi: true}).exec())
-                .then(() => mongo.Cache.remove({space: {$in: spacesIds}}))
+                .then(() => mongo.Cache.remove({space: {$in: spacesIds}}).exec())
                 .catch((err) => mongo.handleError(res, err));
         });
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/28f33ca9/modules/control-center-web/src/main/js/serve/routes/clusters.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/clusters.js b/modules/control-center-web/src/main/js/serve/routes/clusters.js
index fd936a1..b6af923 100644
--- a/modules/control-center-web/src/main/js/serve/routes/clusters.js
+++ b/modules/control-center-web/src/main/js/serve/routes/clusters.js
@@ -122,7 +122,7 @@ module.exports.factory = function(_, express, mongo) {
 
             mongo.Cache.update({clusters: {$in: [clusterId]}}, {$pull: {clusters: clusterId}}, {multi: true}).exec()
                 .then(() => mongo.Igfs.update({clusters: {$in: [clusterId]}}, {$pull: {clusters: clusterId}}, {multi: true}).exec())
-                .then(() => mongo.Cluster.remove(params))
+                .then(() => mongo.Cluster.remove(params).exec())
                 .then(() => res.sendStatus(200))
                 .catch((err) => mongo.handleError(res, err));
         });
@@ -141,7 +141,7 @@ module.exports.factory = function(_, express, mongo) {
                     return mongo.Cache.update({space: {$in: spacesIds}}, {clusters: []}, {multi: true}).exec();
                 })
                 .then(() => mongo.Igfs.update({space: {$in: spacesIds}}, {clusters: []}, {multi: true}).exec())
-                .then(() => mongo.Cluster.remove({space: {$in: spacesIds}}))
+                .then(() => mongo.Cluster.remove({space: {$in: spacesIds}}).exec())
                 .then(() => res.sendStatus(200))
                 .catch((err) => mongo.handleError(res, err));
         });

http://git-wip-us.apache.org/repos/asf/ignite/blob/28f33ca9/modules/control-center-web/src/main/js/serve/routes/domains.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/domains.js b/modules/control-center-web/src/main/js/serve/routes/domains.js
index 1b3d1d1..b0df059 100644
--- a/modules/control-center-web/src/main/js/serve/routes/domains.js
+++ b/modules/control-center-web/src/main/js/serve/routes/domains.js
@@ -24,7 +24,7 @@ module.exports = {
     inject: ['require(lodash)', 'require(express)', 'mongo']
 };
 
-module.exports.factory = function(_, express, mongo) {
+module.exports.factory = function (_, express, mongo) {
     return new Promise((factoryResolve) => {
         const router = new express.Router();
 
@@ -181,7 +181,7 @@ module.exports.factory = function(_, express, mongo) {
 
             mongo.DomainModel.findOne(params).exec()
                 .then((domain) => mongo.Cache.update({_id: {$in: domain.caches}}, {$pull: {domain: domainId}}, {multi: true}).exec())
-                .then(() => mongo.DomainModel.remove(params))
+                .then(() => mongo.DomainModel.remove(params).exec())
                 .then(() => res.sendStatus(200))
                 .catch((err) => mongo.handleError(res, err));
         });
@@ -207,17 +207,25 @@ module.exports.factory = function(_, express, mongo) {
          * Remove all generated demo domain models and caches.
          */
         router.post('/remove/demo', (req, res) => {
-            let spacesIds = [];
+            let spaceIds = [];
+            let domainIds = [];
+            let cacheIds = [];
 
             // TODO IGNITE-843 also remove from links: Cache -> DomainModel ; DomainModel -> Cache; Cluster -> Cache.
 
             mongo.spaces(req.currentUserId())
                 .then((spaces) => {
-                    spacesIds = mongo.spacesIds(spaces);
-
-                    return mongo.DomainModel.remove({$and: [{space: {$in: spacesIds}}, {demo: true}]});
+                    spaceIds = mongo.spacesIds(spaces)
                 })
-                .then(() => mongo.Cache.remove({$and: [{space: {$in: spacesIds}}, {demo: true}]}))
+                .then(() => mongo.DomainModel.find({$and: [{space: {$in: spaceIds}}, {demo: true}]}).lean().exec())
+                .then((domains) => domainIds = _.map(domains, (domain) => domain._id))
+                .then(() => mongo.Cache.update({domains: {$in: domainIds}}, {$pull: {domains: {$in: domainIds}}}, {multi: true}).exec())
+                .then(() => mongo.DomainModel.remove({_id: {$in: domainIds}}).exec())
+                .then(() => mongo.Cache.find({$and: [{space: {$in: spaceIds}}, {demo: true}]}).lean().exec())
+                .then((caches) => cacheIds = _.map(caches, (cache) => cache._id))
+                .then(() => mongo.Cluster.update({caches: {$in: cacheIds}}, {$pull: {caches: {$in: cacheIds}}}, {multi: true}).exec())
+                .then(() => mongo.DomainModel.update({$and: [{caches: {$in: cacheIds}}, {demo: false}]}, {$pull: {$in: {caches: cacheIds}}}, {multi: true}).exec())
+                .then(() => mongo.Cache.remove({$and: [{space: {$in: spaceIds}}, {demo: true}]}).exec())
                 .then(() => res.sendStatus(200))
                 .catch((err) => mongo.handleError(res, err));
         });

http://git-wip-us.apache.org/repos/asf/ignite/blob/28f33ca9/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 144a577..1eacc72 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
@@ -100,7 +100,7 @@ module.exports.factory = function(_, express, mongo) {
             const igfsId = params._id;
 
             mongo.Cluster.update({igfss: {$in: [igfsId]}}, {$pull: {igfss: igfsId}}, {multi: true}).exec()
-                .then(mongo.Igfs.remove(params))
+                .then(mongo.Igfs.remove(params).exec())
                 .then(() => res.sendStatus(200))
                 .catch((err) => mongo.handleError(res, err));
         });
@@ -118,7 +118,7 @@ module.exports.factory = function(_, express, mongo) {
 
                     return mongo.Cluster.update({space: {$in: spacesIds}}, {igfss: []}, {multi: true}).exec();
                 })
-                .then(() => mongo.Igfs.remove({space: {$in: spacesIds}}))
+                .then(() => mongo.Igfs.remove({space: {$in: spacesIds}}).exec())
                 .then(() => res.sendStatus(200))
                 .catch((err) => mongo.handleError(res, err));
         });

http://git-wip-us.apache.org/repos/asf/ignite/blob/28f33ca9/modules/control-center-web/src/main/js/serve/routes/notebooks.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/notebooks.js b/modules/control-center-web/src/main/js/serve/routes/notebooks.js
index 67dbaf7..8e79ec1 100644
--- a/modules/control-center-web/src/main/js/serve/routes/notebooks.js
+++ b/modules/control-center-web/src/main/js/serve/routes/notebooks.js
@@ -90,7 +90,7 @@ module.exports.factory = function(express, mongo) {
          * @param res Response.
          */
         router.post('/remove', (req, res) => {
-            mongo.Notebook.remove(req.body)
+            mongo.Notebook.remove(req.body).exec()
                 .then(() => res.sendStatus(200))
                 .catch((err) => mongo.handleError(res, err));
         });


[47/50] ignite git commit: IGNITE-843 Fixed domain save.

Posted by ak...@apache.org.
IGNITE-843 Fixed domain save.


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

Branch: refs/heads/ignite-843-rc3
Commit: a170c4e4a28fe72a35a109afa39b4cf1305021da
Parents: 11f7aba
Author: Andrey <an...@gridgain.com>
Authored: Tue Feb 16 18:32:49 2016 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Tue Feb 16 18:32:49 2016 +0700

----------------------------------------------------------------------
 .../src/main/js/serve/routes/domains.js         | 104 ++++++++-----------
 1 file changed, 45 insertions(+), 59 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/a170c4e4/modules/control-center-web/src/main/js/serve/routes/domains.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/domains.js b/modules/control-center-web/src/main/js/serve/routes/domains.js
index 09298b5..5d4acac 100644
--- a/modules/control-center-web/src/main/js/serve/routes/domains.js
+++ b/modules/control-center-web/src/main/js/serve/routes/domains.js
@@ -73,45 +73,38 @@ module.exports.factory = (_, express, mongo) => {
             return Promise.all(promises);
         }
 
-        function _saveDomainModel(domain, savedDomains) {
-            return new Promise((resolve, reject) => {
-                const caches = domain.caches;
-                const cacheStoreChanges = domain.cacheStoreChanges;
-                const domainId = domain._id;
-
-                if (domainId) {
-                    mongo.DomainModel.update({_id: domain._id}, domain, {upsert: true}).exec()
-                        .then(() => mongo.Cache.update({_id: {$in: caches}}, {$addToSet: {domains: domainId}}, {multi: true}).exec())
-                        .then(() => mongo.Cache.update({_id: {$nin: caches}}, {$pull: {domains: domainId}}, {multi: true}).exec())
-                        .then(() => {
-                            savedDomains.push(domain);
-
-                            _updateCacheStore(cacheStoreChanges);
-                        })
-                        .then(resolve)
-                        .catch(reject);
-                }
-                else {
-                    mongo.DomainModel.findOne({space: domain.space, valueType: domain.valueType}).exec()
-                        .then((found) => {
-                            if (found)
-                                throw new Error('Domain model with value type: "' + found.valueType + '" already exist.');
-
-                            return (new mongo.DomainModel(domain)).save();
-                        })
-                        .then((savedDomain) => {
-                            savedDomains.push(savedDomain);
-
-                            return mongo.Cache.update({_id: {$in: caches}}, {$addToSet: {domains: savedDomain._id}}, {multi: true}).exec();
-                        })
-                        .then(() => _updateCacheStore(cacheStoreChanges))
-                        .then(resolve)
-                        .catch(reject);
-                }
-            });
-        }
+        const _saveDomainModel = (domain, savedDomains) => {
+            const caches = domain.caches;
+            const cacheStoreChanges = domain.cacheStoreChanges;
+            const domainId = domain._id;
+
+            if (domainId) {
+                return mongo.DomainModel.update({_id: domain._id}, domain, {upsert: true}).exec()
+                    .then(() => mongo.Cache.update({_id: {$in: caches}}, {$addToSet: {domains: domainId}}, {multi: true}).exec())
+                    .then(() => mongo.Cache.update({_id: {$nin: caches}}, {$pull: {domains: domainId}}, {multi: true}).exec())
+                    .then(() => {
+                        savedDomains.push(domain);
+
+                        return _updateCacheStore(cacheStoreChanges);
+                    });
+            }
+
+            return mongo.DomainModel.findOne({space: domain.space, valueType: domain.valueType}).exec()
+                .then((found) => {
+                    if (found)
+                        throw new Error('Domain model with value type: "' + found.valueType + '" already exist.');
+
+                    return (new mongo.DomainModel(domain)).save();
+                })
+                .then((savedDomain) => {
+                    savedDomains.push(savedDomain);
+
+                    return mongo.Cache.update({_id: {$in: caches}}, {$addToSet: {domains: savedDomain._id}}, {multi: true}).exec();
+                })
+                .then(() => _updateCacheStore(cacheStoreChanges));
+        };
 
-        function _save(domains, res) {
+        const _save = (domains, res) => {
             if (domains && domains.length > 0) {
                 const savedDomains = [];
                 const generatedCaches = [];
@@ -119,32 +112,25 @@ module.exports.factory = (_, express, mongo) => {
 
                 _.forEach(domains, (domain) => {
                     if (domain.newCache) {
-                        mongo.Cache.findOne({space: domain.space, name: domain.newCache.name}).exec()
-                            .then((cache) => {
-                                if (cache) {
-                                    // Cache already exists, just save domain model.
-                                    domain.caches = [cache._id];
+                        promises.push(
+                            mongo.Cache.findOne({space: domain.space, name: domain.newCache.name}).exec()
+                                .then((cache) => {
+                                    if (cache)
+                                        return Promise.resolve(cache);
 
-                                    promises.push(_saveDomainModel(domain, savedDomains));
-                                }
-                                else {
                                     // If cache not found, then create it and associate with domain model.
                                     const newCache = domain.newCache;
                                     newCache.space = domain.space;
 
-                                    (new mongo.Cache(newCache)).save()
-                                        .then((generatedCache) => {
-                                            const cacheId = generatedCache._id;
-
-                                            generatedCaches.push(generatedCache);
-
-                                            domain.caches = [cacheId];
+                                    return (new mongo.Cache(newCache)).save()
+                                        .then((_cache) => mongo.Cluster.update({_id: {$in: _cache.clusters}}, {$addToSet: {caches: _cache._id}}, {multi: true}).exec());
+                                })
+                                .then((cache) => {
+                                    domain.caches = [cache._id];
 
-                                            return mongo.Cluster.update({_id: {$in: generatedCache.clusters}}, {$addToSet: {caches: cacheId}}, {multi: true}).exec();
-                                        })
-                                        .then(() => promises.push(_saveDomainModel(domain, savedDomains)));
-                                }
-                            });
+                                    return _saveDomainModel(domain, savedDomains);
+                                })
+                        );
                     }
                     else
                         promises.push(_saveDomainModel(domain, savedDomains));
@@ -156,7 +142,7 @@ module.exports.factory = (_, express, mongo) => {
             }
             else
                 res.status(500).send('Nothing to save!');
-        }
+        };
 
         /**
          * Save domain model.


[40/50] ignite git commit: IGNITE-843 Minor fix.

Posted by ak...@apache.org.
IGNITE-843 Minor fix.


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

Branch: refs/heads/ignite-843-rc3
Commit: 62fc8e738ef4a76eebe2147ea50078ce11a95d0a
Parents: 3099e6b
Author: Andrey <an...@gridgain.com>
Authored: Tue Feb 16 16:53:10 2016 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Tue Feb 16 16:53:10 2016 +0700

----------------------------------------------------------------------
 modules/control-center-web/src/main/js/serve/routes/domains.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/62fc8e73/modules/control-center-web/src/main/js/serve/routes/domains.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/domains.js b/modules/control-center-web/src/main/js/serve/routes/domains.js
index 196a926..6d8b87f 100644
--- a/modules/control-center-web/src/main/js/serve/routes/domains.js
+++ b/modules/control-center-web/src/main/js/serve/routes/domains.js
@@ -222,7 +222,7 @@ module.exports.factory = (_, express, mongo) => {
                 .then(() => mongo.Cache.find({$and: [{space: {$in: spaceIds}}, {demo: true}]}).lean().exec())
                 .then((caches) => cacheIds = _.map(caches, (cache) => cache._id))
                 .then(() => mongo.Cluster.update({caches: {$in: cacheIds}}, {$pull: {caches: {$in: cacheIds}}}, {multi: true}).exec())
-                .then(() => mongo.DomainModel.update({$and: [{caches: {$in: cacheIds}}, {demo: false}]}, {$pull: {$in: {caches: cacheIds}}}, {multi: true}).exec())
+                .then(() => mongo.DomainModel.update({caches: {$in: cacheIds}}, {$pull: {caches: {$in: cacheIds}}}, {multi: true}).exec())
                 .then(() => mongo.Cache.remove({$and: [{space: {$in: spaceIds}}, {demo: true}]}).exec())
                 .then(() => res.sendStatus(200))
                 .catch((err) => mongo.handleError(res, err));


[34/50] ignite git commit: IGNITE-843 Fixed eslint warnings.

Posted by ak...@apache.org.
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/87f3c808
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/87f3c808
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/87f3c808

Branch: refs/heads/ignite-843-rc3
Commit: 87f3c808cfca380a89b87c20d00899d24006b581
Parents: 31c6d78
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Tue Feb 16 14:16:05 2016 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Tue Feb 16 14:16:05 2016 +0700

----------------------------------------------------------------------
 modules/control-center-web/src/main/js/serve/routes/admin.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/87f3c808/modules/control-center-web/src/main/js/serve/routes/admin.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/admin.js b/modules/control-center-web/src/main/js/serve/routes/admin.js
index f5ec2b1..90021ae 100644
--- a/modules/control-center-web/src/main/js/serve/routes/admin.js
+++ b/modules/control-center-web/src/main/js/serve/routes/admin.js
@@ -61,7 +61,7 @@ module.exports.factory = function(_, express, nodemailer, settings, mail, mongo)
                             console.error(`Failed to cleanup spaces [user=${user.username}, err=${err}`);
                         });
 
-                    return Promise.resolve(user)
+                    return Promise.resolve(user);
                 })
                 .then((user) => mail.send(user, 'Your account was deleted',
                     `Hello ${user.username}!<br><br>` +


[37/50] ignite git commit: IGNITE-843 Refactor serve to es6.

Posted by ak...@apache.org.
IGNITE-843 Refactor serve to es6.


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

Branch: refs/heads/ignite-843-rc3
Commit: f1a6e31d0294163dfccbfda25e11dc8f99037505
Parents: 28f33ca
Author: Andrey <an...@gridgain.com>
Authored: Tue Feb 16 15:53:53 2016 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Tue Feb 16 15:53:53 2016 +0700

----------------------------------------------------------------------
 modules/control-center-web/src/main/js/serve/routes/domains.js | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/f1a6e31d/modules/control-center-web/src/main/js/serve/routes/domains.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/domains.js b/modules/control-center-web/src/main/js/serve/routes/domains.js
index b0df059..196a926 100644
--- a/modules/control-center-web/src/main/js/serve/routes/domains.js
+++ b/modules/control-center-web/src/main/js/serve/routes/domains.js
@@ -24,7 +24,7 @@ module.exports = {
     inject: ['require(lodash)', 'require(express)', 'mongo']
 };
 
-module.exports.factory = function (_, express, mongo) {
+module.exports.factory = (_, express, mongo) => {
     return new Promise((factoryResolve) => {
         const router = new express.Router();
 
@@ -214,9 +214,7 @@ module.exports.factory = function (_, express, mongo) {
             // TODO IGNITE-843 also remove from links: Cache -> DomainModel ; DomainModel -> Cache; Cluster -> Cache.
 
             mongo.spaces(req.currentUserId())
-                .then((spaces) => {
-                    spaceIds = mongo.spacesIds(spaces)
-                })
+                .then((spaces) => spaceIds = mongo.spacesIds(spaces))
                 .then(() => mongo.DomainModel.find({$and: [{space: {$in: spaceIds}}, {demo: true}]}).lean().exec())
                 .then((domains) => domainIds = _.map(domains, (domain) => domain._id))
                 .then(() => mongo.Cache.update({domains: {$in: domainIds}}, {$pull: {domains: {$in: domainIds}}}, {multi: true}).exec())


[06/50] ignite git commit: IGNITE-843 Refactor serve to es6.

Posted by ak...@apache.org.
IGNITE-843 Refactor serve to es6.


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

Branch: refs/heads/ignite-843-rc3
Commit: 4f90db196b350bb90d486c61f7b3935be421330e
Parents: 471ac27
Author: Andrey <an...@gridgain.com>
Authored: Mon Feb 15 15:08:11 2016 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Mon Feb 15 15:08:11 2016 +0700

----------------------------------------------------------------------
 .../src/main/js/controllers/common-module.js    |   2 +-
 modules/control-center-web/src/main/js/serve.js |   2 +
 .../control-center-web/src/main/js/serve/app.js |   2 +
 .../src/main/js/serve/routes/notebooks.js       |   2 +
 .../src/main/js/serve/routes/profile.js         |   2 +
 .../src/main/js/serve/routes/public.js          | 182 +++++++++----------
 .../src/main/js/views/login.jade                |  28 +--
 7 files changed, 110 insertions(+), 110 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/4f90db19/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 585cd1a..2686690 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
@@ -2020,7 +2020,7 @@ consoleModule.controller('resetPassword', [
     '$scope', '$modal', '$http', '$common', '$focus', 'Auth', '$state',
     function ($scope, $modal, $http, $common, $focus, Auth, $state) {
         if ($state.params.token)
-            $http.post('/api/v1/validate/token', {token: $state.params.token})
+            $http.post('/api/v1/password/validate/token', {token: $state.params.token})
                 .success(function (res) {
                     $scope.email = res.email;
                     $scope.token = res.token;

http://git-wip-us.apache.org/repos/asf/ignite/blob/4f90db19/modules/control-center-web/src/main/js/serve.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve.js b/modules/control-center-web/src/main/js/serve.js
index b5897a2..a962539 100644
--- a/modules/control-center-web/src/main/js/serve.js
+++ b/modules/control-center-web/src/main/js/serve.js
@@ -15,6 +15,8 @@
  * limitations under the License.
  */
 
+'use strict';
+
 const http = require('http'),
     https = require('https'),
     path = require('path');

http://git-wip-us.apache.org/repos/asf/ignite/blob/4f90db19/modules/control-center-web/src/main/js/serve/app.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/app.js b/modules/control-center-web/src/main/js/serve/app.js
index 6d19b44..5f4e4fb 100644
--- a/modules/control-center-web/src/main/js/serve/app.js
+++ b/modules/control-center-web/src/main/js/serve/app.js
@@ -15,6 +15,8 @@
  * limitations under the License.
  */
 
+'use strict';
+
 // Fire me up!
 
 module.exports = {

http://git-wip-us.apache.org/repos/asf/ignite/blob/4f90db19/modules/control-center-web/src/main/js/serve/routes/notebooks.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/notebooks.js b/modules/control-center-web/src/main/js/serve/routes/notebooks.js
index a595303..a12dacf 100644
--- a/modules/control-center-web/src/main/js/serve/routes/notebooks.js
+++ b/modules/control-center-web/src/main/js/serve/routes/notebooks.js
@@ -15,6 +15,8 @@
  * limitations under the License.
  */
 
+'use strict';
+
 // Fire me up!
 
 module.exports = {

http://git-wip-us.apache.org/repos/asf/ignite/blob/4f90db19/modules/control-center-web/src/main/js/serve/routes/profile.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/profile.js b/modules/control-center-web/src/main/js/serve/routes/profile.js
index e080ce3..7deff37 100644
--- a/modules/control-center-web/src/main/js/serve/routes/profile.js
+++ b/modules/control-center-web/src/main/js/serve/routes/profile.js
@@ -15,6 +15,8 @@
  * limitations under the License.
  */
 
+'use strict';
+
 // Fire me up!
 
 module.exports = {

http://git-wip-us.apache.org/repos/asf/ignite/blob/4f90db19/modules/control-center-web/src/main/js/serve/routes/public.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/public.js b/modules/control-center-web/src/main/js/serve/routes/public.js
index 638bda6..6f78d73 100644
--- a/modules/control-center-web/src/main/js/serve/routes/public.js
+++ b/modules/control-center-web/src/main/js/serve/routes/public.js
@@ -40,6 +40,42 @@ module.exports.factory = function(express, passport, nodemailer, settings, mongo
             return res;
         };
 
+        /**
+         * Send mail to user.
+         * @private
+         * @return {Promise}
+         */
+        const _sendMail = (user, subject, text, sendErrMsg) => {
+            const transporter = {
+                service: settings.smtp.service,
+                auth: {
+                    user: settings.smtp.email,
+                    pass: settings.smtp.password
+                }
+            };
+
+            if (transporter.service === '' || transporter.auth.user === '' || transporter.auth.pass === '')
+                return Promise.reject('Can\'t send e-mail because not configured SMTP server. Please ask webmaster to setup SMTP server!');
+
+            const mailer = nodemailer.createTransport(transporter);
+
+            const mail = {
+                from: settings.smtp.address(settings.smtp.username, settings.smtp.email),
+                to: settings.smtp.address(user.username, user.email),
+                subject,
+                text: text + (settings.smtp.username ? `\n\n--------------\n${settings.smtp.username}\n` : '')
+            };
+
+            return new Promise((resolve, reject) => {
+                mailer.sendMail(mail, (err) => {
+                    if (err)
+                        return reject(sendErrMsg || err.message);
+
+                    resolve();
+                });
+            });
+        };
+
         // GET user.
         router.post('/user', function(req, res) {
             const becomeUsed = req.session.viewedUser && req.user.admin;
@@ -58,40 +94,51 @@ module.exports.factory = function(express, passport, nodemailer, settings, mongo
         /**
          * Register new account.
          */
-        router.post('/register', function(req, res) {
-            mongo.Account.count(function(errCount, cnt) {
-                if (errCount)
-                    return res.status(401).send(errCount.message);
-
-                req.body.admin = cnt === 0;
-
-                const _account = new mongo.Account(req.body);
+        router.post('/signup', function(req, res) {
+            mongo.Account.count().exec()
+                .then((cnt) => {
+                    req.body.admin = cnt === 0;
 
-                _account.token = _randomString();
+                    req.body.token = _randomString();
 
-                mongo.Account.register(_account, req.body.password, function(errRegister, account) {
-                    if (errRegister)
-                        return res.status(401).send(errRegister.message);
+                    const account = new mongo.Account(req.body);
 
-                    if (!account)
-                        return res.status(500).send('Failed to create account.');
+                    return Promise.resolve(account);
+                })
+                .then((account) => {
+                    return new Promise((resolve, reject) => {
+                        mongo.Account.register(account, req.body.password, (err, _account) => {
+                            if (err)
+                                return reject(err.message);
 
-                    new mongo.Space({name: 'Personal space', owner: account._id}).save();
+                            if (!account)
+                                return reject('Failed to create account.');
 
-                    req.logIn(account, {}, function(errLogIn) {
-                        if (errLogIn)
-                            return res.status(401).send(errLogIn.message);
+                            resolve(_account);
+                        });
+                    });
+                })
+                .then((account) => {
+                    return new Promise((resolve, reject) => {
+                        req.logIn(account, {}, (err) => {
+                            if (err)
+                                return reject(err.message);
 
-                        return res.sendStatus(200);
+                            resolve(account);
+                        });
                     });
+                })
+                .then((account) => new mongo.Space({name: 'Personal space', owner: account._id}).save())
+                .then(() => res.sendStatus(200))
+                .catch((errMsg) => {
+                    res.status(401).send(errMsg);
                 });
-            });
         });
 
         /**
          * Login in exist account.
          */
-        router.post('/login', function(req, res, next) {
+        router.post('/signin', function(req, res, next) {
             passport.authenticate('local', function(errAuth, user) {
                 if (errAuth)
                     return res.status(401).send(errAuth.message);
@@ -121,55 +168,27 @@ module.exports.factory = function(express, passport, nodemailer, settings, mongo
          * Send e-mail to user with reset token.
          */
         router.post('/password/forgot', function(req, res) {
-            const transporter = {
-                service: settings.smtp.service,
-                auth: {
-                    user: settings.smtp.email,
-                    pass: settings.smtp.password
-                }
-            };
-
-            if (transporter.service === '' || transporter.auth.user === '' || transporter.auth.pass === '')
-                return res.status(401).send('Can\'t send e-mail with instructions to reset password. Please ask webmaster to setup SMTP server!');
-
-            const token = _randomString();
-
             mongo.Account.findOne({email: req.body.email}).exec()
                 .then((user) => {
                     if (!user)
                         return Promise.reject('Account with that email address does not exists!');
 
-                    user.resetPasswordToken = token;
+                    user.resetPasswordToken = _randomString();
 
                     return user.save();
                 })
                 .then((user) => {
-                    const mailer = nodemailer.createTransport(transporter);
-
-                    const mailOptions = {
-                        from: settings.smtp.address(settings.smtp.username, settings.smtp.email),
-                        to: settings.smtp.address(user.username, user.email),
-                        subject: 'Password Reset',
-                        text: 'You are receiving this because you (or someone else) have requested the reset of the password for your account.\n\n' +
+                    return _sendMail(user, 'Password Reset',
+                        'You are receiving this because you (or someone else) have requested the reset of the password for your account.\n\n' +
                         'Please click on the following link, or paste this into your browser to complete the process:\n\n' +
-                        'http://' + req.headers.host + '/password/reset?token=' + token + '\n\n' +
-                        'If you did not request this, please ignore this email and your password will remain unchanged.\n\n' +
-                        '--------------\n' +
-                        settings.smtp.username + '\n'
-                    };
-
-                    return new Promise((resolve, reject) => {
-                        mailer.sendMail(mailOptions, (err) => {
-                            if (err)
-                                return reject();
-
-                            resolve(res.status(200).send('An e-mail has been sent with further instructions.'));
-                        });
-                    });
+                        'http://' + req.headers.host + '/password/reset?token=' + user.resetPasswordToken + '\n\n' +
+                        'If you did not request this, please ignore this email and your password will remain unchanged.',
+                        'Failed to send e-mail with reset link!');
                 })
-                .catch((err) => {
+                .then(() => res.status(200).send('An e-mail has been sent with further instructions.'))
+                .catch((errMsg) => {
                     // TODO IGNITE-843 Send email to admin
-                    return res.status(401).send('Failed to send e-mail with reset link!' + (err ? '<br>' + err : ''));
+                    return res.status(401).send(errMsg);
                 });
         });
 
@@ -181,14 +200,11 @@ module.exports.factory = function(express, passport, nodemailer, settings, mongo
                 .then((user) => {
                     return new Promise((resolve, reject) => {
                         if (!user)
-                            return reject();
+                            return reject('Failed to find account with this token! Please check link from e-mail.');
 
                         user.setPassword(req.body.password, (err, _user) => {
-                            if (err) {
-                                console.log('Failed to reset password: ' + err.message);
-
-                                return reject();
-                            }
+                            if (err)
+                                return reject('Failed to reset password: ' + err.message);
 
                             _user.resetPasswordToken = undefined; // eslint-disable-line no-undefined
 
@@ -197,43 +213,19 @@ module.exports.factory = function(express, passport, nodemailer, settings, mongo
                     });
                 })
                 .then((user) => {
-                    const transporter = {
-                        service: settings.smtp.service,
-                        auth: {
-                            user: settings.smtp.email,
-                            pass: settings.smtp.password
-                        }
-                    };
-
-                    const mailer = nodemailer.createTransport(transporter);
-
-                    const mailOptions = {
-                        from: settings.smtp.address(settings.smtp.username, settings.smtp.email),
-                        to: settings.smtp.address(user.username, user.email),
-                        subject: 'Your password has been changed',
-                        text: 'Hello,\n\n' +
+                    return _sendMail(user, 'Your password has been changed',
+                        'Hello,\n\n' +
                         'This is a confirmation that the password for your account ' + user.email + ' has just been changed.\n\n' +
-                        'Now you can login: http://' + req.headers.host + '\n\n' +
-                        '--------------\n' +
-                        'Apache Ignite Web Console\n'
-                    };
-
-                    return new Promise((resolve) => {
-                        mailer.sendMail(mailOptions, (err) => {
-                            if (err)
-                                return resolve(res.status(500).send('Password was changed, but failed to send confirmation e-mail!'));
-
-                            resolve(res.status(200).send(user.email));
-                        });
-                    });
+                        'Now you can login: http://' + req.headers.host,
+                        'Password was changed, but failed to send confirmation e-mail!');
                 })
-                .catch(() => {
-                    res.status(500).send('Failed to reset password! Please check link from e-mail.');
+                .catch((errMsg) => {
+                    res.status(500).send(errMsg);
                 });
         });
 
         /* GET reset password page. */
-        router.post('/validate/token', function(req, res) {
+        router.post('/password/validate/token', function(req, res) {
             const token = req.body.token;
 
             mongo.Account.findOne({resetPasswordToken: token}).exec()

http://git-wip-us.apache.org/repos/asf/ignite/blob/4f90db19/modules/control-center-web/src/main/js/views/login.jade
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/views/login.jade b/modules/control-center-web/src/main/js/views/login.jade
index 4908002..35767f4 100644
--- a/modules/control-center-web/src/main/js/views/login.jade
+++ b/modules/control-center-web/src/main/js/views/login.jade
@@ -34,28 +34,28 @@ header#header.header
             .col-xs-12.col-md-6
                 form(name='loginForm' novalidate)
                     .modal-body.row(style='padding-bottom: 10px; margin: 0')
-                        .settings-row(ng-if='action == "register"')
+                        .settings-row(ng-if='action == "signup"')
                             h3.login-header Sign Up
-                        .settings-row(ng-if='action == "login"')
+                        .settings-row(ng-if='action == "signin"')
                             h3.login-header Sign In
                         .settings-row(ng-if='action == "password/forgot"')
                             h3.login-header Forgot password?
                         .settings-row
                             p.col-xs-12.col-md-11(ng-show='action == "password/forgot"')
                                 | That's ok! Simply enter your email below and a reset password link will be sent to you via email. You can then follow that link and select a new password.
-                        .settings-row(ng-show='action == "register"')
+                        .settings-row(ng-show='action == "signup"')
                             +lblRequired('Full Name:')
                             .col-xs-9.col-md-8
-                                input#user_name.form-control(enter-focus-next='user_email' type='text' ng-model='user_info.username' placeholder='John Smith' ng-required='action=="register"')
+                                input#user_name.form-control(enter-focus-next='user_email' type='text' ng-model='user_info.username' placeholder='John Smith' ng-required='action=="signup"')
                         .settings-row
                             +lblRequired('Email:')
                             .col-xs-9.col-md-8
                                 input#user_email.form-control(enter-focus-next='company' type='email' ng-model='user_info.email' placeholder='you@domain.com' required)
-                        .settings-row(ng-show='action == "register"')
+                        .settings-row(ng-show='action == "signup"')
                             +lbl('Company:')
                             .col-xs-9.col-md-8
                                 input#company.form-control(enter-focus-next='country' type='text' ng-model='user_info.company' placeholder='Your company name')
-                        .settings-row(ng-show='action == "register"')
+                        .settings-row(ng-show='action == "signup"')
                             +lbl('Country:')
                             .col-xs-9.col-md-8
                                 button#country.select-toggle.form-control(bs-select bs-options='item for item in countries' enter-focus-next='user_password' type='text' ng-model='user_info.country' placeholder='Choose your country')
@@ -63,28 +63,28 @@ header#header.header
                             +lblRequired('Password:')
                             .col-xs-9.col-md-8
                                 input#user_password.form-control(enter-focus-next='user_confirm' type='password' ng-model='user_info.password' placeholder='Password' ng-required='action != "password/forgot"' on-enter='action == "login" && loginForm.$valid && auth(action, user_info)')
-                        .settings-row(ng-if='action == "register"')
+                        .settings-row(ng-if='action == "signup"')
                             +lblRequired('Confirm:')
                             .col-xs-9.col-md-8
-                                input#user_confirm.form-control(type='password' ng-model='user_info.confirm' match='user_info.password' placeholder='Confirm password' ng-required='action == "register"' on-enter='loginForm.$valid && auth(action, user_info)')
+                                input#user_confirm.form-control(type='password' ng-model='user_info.confirm' match='user_info.password' placeholder='Confirm password' ng-required='action == "signup"' on-enter='loginForm.$valid && auth(action, user_info)')
                         .settings-row(ignite-terms)
-                            .col-md-offset-3(ng-if='action == "register" && terms.termsState')
+                            .col-md-offset-3(ng-if='action == "signup" && terms.termsState')
                                 label
                                     input(type='checkbox' ng-model='user_info.agree', ng-required='true')
                                     | I agree to the #[a(ui-sref='{{::terms.termsState}}' target='_blank') terms and conditions]
                     .col-xs-12.col-md-11
-                        .login-footer(ng-show='action == "register"')
+                        .login-footer(ng-show='action == "signup"')
                             a.labelField(ng-click='action = "password/forgot"' on-click-focus='user_email') Forgot password?
-                            a.labelLogin(ng-click='action = "login"' on-click-focus='user_email') Sign In
+                            a.labelLogin(ng-click='action = "signin"' on-click-focus='user_email') Sign In
                             button#signup.btn.btn-primary(ng-click='auth(action, user_info)' ng-disabled='loginForm.$invalid') Sign Up
                     .col-xs-12.col-md-11
                         .login-footer(ng-show='action == "password/forgot"')
-                            a.labelField(ng-click='action = "login"' on-click-focus='user_email') Sign In
+                            a.labelField(ng-click='action = "signin"' on-click-focus='user_email') Sign In
                             button#forgot.btn.btn-primary(ng-click='auth(action, user_info)' ng-disabled='loginForm.$invalid') Send it to me
                     .col-xs-12.col-md-11
-                        .login-footer(ng-show='action == "login"')
+                        .login-footer(ng-show='action == "signin"')
                             a.labelField(ng-click='action = "password/forgot"' on-click-focus='user_email') Forgot password?
-                            a.labelLogin(ng-click='action = "register"' on-click-focus='user_name') Sign Up
+                            a.labelLogin(ng-click='action = "signup"' on-click-focus='user_name') Sign Up
                             button#login.btn.btn-primary(ng-click='auth(action, user_info)' ng-disabled='loginForm.$invalid') Sign In
 
                 .col-xs-12.col-md-11.home-panel


[08/50] ignite git commit: IGNITE-843 Rename login -> signin

Posted by ak...@apache.org.
IGNITE-843 Rename login -> signin


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

Branch: refs/heads/ignite-843-rc3
Commit: 540acaa4d736ac69926d3b4c06ac37cae91b782e
Parents: 8007e76
Author: Andrey <an...@gridgain.com>
Authored: Mon Feb 15 15:37:04 2016 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Mon Feb 15 15:37:04 2016 +0700

----------------------------------------------------------------------
 .../control-center-web/src/main/js/app/index.js |   2 +-
 .../main/js/app/modules/states/login/index.js   |  12 +-
 .../main/js/app/modules/user/Auth.service.js    |   2 +-
 .../src/main/js/controllers/common-module.js    |   2 +-
 .../src/main/js/serve/routes/profile.js         |   4 +-
 .../src/main/js/views/login.jade                | 157 -------------------
 .../src/main/js/views/signin.jade               | 157 +++++++++++++++++++
 7 files changed, 168 insertions(+), 168 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/540acaa4/modules/control-center-web/src/main/js/app/index.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/app/index.js b/modules/control-center-web/src/main/js/app/index.js
index 6e1b172..efa2d7d 100644
--- a/modules/control-center-web/src/main/js/app/index.js
+++ b/modules/control-center-web/src/main/js/app/index.js
@@ -162,7 +162,7 @@ angular
             templateUrl: '/base.html'
         });
 
-    $urlRouterProvider.when('/', '/login');
+    $urlRouterProvider.when('/', '/signin');
 
     $locationProvider.html5Mode(true);
 }])

http://git-wip-us.apache.org/repos/asf/ignite/blob/540acaa4/modules/control-center-web/src/main/js/app/modules/states/login/index.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/app/modules/states/login/index.js b/modules/control-center-web/src/main/js/app/modules/states/login/index.js
index e0632b4..feaf76a 100644
--- a/modules/control-center-web/src/main/js/app/modules/states/login/index.js
+++ b/modules/control-center-web/src/main/js/app/modules/states/login/index.js
@@ -26,9 +26,9 @@ angular
 .config(['$stateProvider', function($stateProvider) {
     // set up the states
     $stateProvider
-    .state('login', {
-        url: '/login',
-        templateUrl: '/login.html',
+    .state('signin', {
+        url: '/signin',
+        templateUrl: '/signin.html',
         resolve: {
             $title: () => {
                 return 'Sign In';
@@ -41,12 +41,12 @@ angular
         if (toState.name === IgniteTerms.termsState)
             return;
 
-        if (!Auth.authorized && (toState.name !== 'login' && !_.startsWith(toState.name, 'password.'))) {
+        if (!Auth.authorized && (toState.name !== 'signin' && !_.startsWith(toState.name, 'password.'))) {
             event.preventDefault();
 
-            $state.go('login');
+            $state.go('signin');
         }
-        else if (Auth.authorized && toState.name === 'login') {
+        else if (Auth.authorized && toState.name === 'signin') {
             event.preventDefault();
 
             $state.go('base.configuration.clusters');

http://git-wip-us.apache.org/repos/asf/ignite/blob/540acaa4/modules/control-center-web/src/main/js/app/modules/user/Auth.service.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/app/modules/user/Auth.service.js b/modules/control-center-web/src/main/js/app/modules/user/Auth.service.js
index 0690cfa..55bae1c 100644
--- a/modules/control-center-web/src/main/js/app/modules/user/Auth.service.js
+++ b/modules/control-center-web/src/main/js/app/modules/user/Auth.service.js
@@ -65,7 +65,7 @@ export default ['Auth', ['$http', '$rootScope', '$state', '$common', 'IgniteGett
 
                         _authorized(false);
 
-                        $state.go('login');
+                        $state.go('signin');
                     })
                     .catch((errMsg) => $common.showError(errMsg));
             }

http://git-wip-us.apache.org/repos/asf/ignite/blob/540acaa4/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 2686690..36b353d 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
@@ -2053,7 +2053,7 @@ consoleModule.controller('resetPassword', [
 consoleModule.controller('auth', ['$scope', '$focus', 'Auth', 'IgniteCountries', function ($scope, $focus, Auth, countries) {
     $scope.auth = Auth.auth;
 
-    $scope.action = 'login';
+    $scope.action = 'signin';
     $scope.countries = countries;
 
     $focus('user_email');

http://git-wip-us.apache.org/repos/asf/ignite/blob/540acaa4/modules/control-center-web/src/main/js/serve/routes/profile.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/profile.js b/modules/control-center-web/src/main/js/serve/routes/profile.js
index 7deff37..bf227a2 100644
--- a/modules/control-center-web/src/main/js/serve/routes/profile.js
+++ b/modules/control-center-web/src/main/js/serve/routes/profile.js
@@ -79,9 +79,9 @@ module.exports.factory = function(_, express, mongo) {
                     return user.save();
                 })
                 .then(() => res.sendStatus(200))
-                .catch((err) => {
+                .catch((errMsg) => {
                     // TODO IGNITE-843 Send error to admin
-                    res.status(500).send(err);
+                    res.status(500).send(errMsg);
                 });
         });
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/540acaa4/modules/control-center-web/src/main/js/views/login.jade
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/views/login.jade b/modules/control-center-web/src/main/js/views/login.jade
deleted file mode 100644
index 35767f4..0000000
--- a/modules/control-center-web/src/main/js/views/login.jade
+++ /dev/null
@@ -1,157 +0,0 @@
-//-
-    Licensed to the Apache Software Foundation (ASF) under one or more
-    contributor license agreements.  See the NOTICE file distributed with
-    this work for additional information regarding copyright ownership.
-    The ASF licenses this file to You under the Apache License, Version 2.0
-    (the "License"); you may not use this file except in compliance with
-    the License.  You may obtain a copy of the License at
-
-         http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing, software
-    distributed under the License is distributed on an "AS IS" BASIS,
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-    See the License for the specific language governing permissions and
-    limitations under the License.
-
-mixin lbl(txt)
-    label.col-xs-3.col-md-3 #{txt}
-
-mixin lblRequired(txt)
-    label.col-xs-3.col-md-3.required #{txt}
-
-header#header.header
-    table.container
-        tr
-            td.col-xs-3.col-sm-3.col-md-2
-                ignite-logo
-            td
-                ignite-title
-
-.container.body-container
-    .main-content(ng-controller='auth')
-        .row.greedy.home
-            .col-xs-12.col-md-6
-                form(name='loginForm' novalidate)
-                    .modal-body.row(style='padding-bottom: 10px; margin: 0')
-                        .settings-row(ng-if='action == "signup"')
-                            h3.login-header Sign Up
-                        .settings-row(ng-if='action == "signin"')
-                            h3.login-header Sign In
-                        .settings-row(ng-if='action == "password/forgot"')
-                            h3.login-header Forgot password?
-                        .settings-row
-                            p.col-xs-12.col-md-11(ng-show='action == "password/forgot"')
-                                | That's ok! Simply enter your email below and a reset password link will be sent to you via email. You can then follow that link and select a new password.
-                        .settings-row(ng-show='action == "signup"')
-                            +lblRequired('Full Name:')
-                            .col-xs-9.col-md-8
-                                input#user_name.form-control(enter-focus-next='user_email' type='text' ng-model='user_info.username' placeholder='John Smith' ng-required='action=="signup"')
-                        .settings-row
-                            +lblRequired('Email:')
-                            .col-xs-9.col-md-8
-                                input#user_email.form-control(enter-focus-next='company' type='email' ng-model='user_info.email' placeholder='you@domain.com' required)
-                        .settings-row(ng-show='action == "signup"')
-                            +lbl('Company:')
-                            .col-xs-9.col-md-8
-                                input#company.form-control(enter-focus-next='country' type='text' ng-model='user_info.company' placeholder='Your company name')
-                        .settings-row(ng-show='action == "signup"')
-                            +lbl('Country:')
-                            .col-xs-9.col-md-8
-                                button#country.select-toggle.form-control(bs-select bs-options='item for item in countries' enter-focus-next='user_password' type='text' ng-model='user_info.country' placeholder='Choose your country')
-                        .settings-row(ng-show='action != "password/forgot"')
-                            +lblRequired('Password:')
-                            .col-xs-9.col-md-8
-                                input#user_password.form-control(enter-focus-next='user_confirm' type='password' ng-model='user_info.password' placeholder='Password' ng-required='action != "password/forgot"' on-enter='action == "login" && loginForm.$valid && auth(action, user_info)')
-                        .settings-row(ng-if='action == "signup"')
-                            +lblRequired('Confirm:')
-                            .col-xs-9.col-md-8
-                                input#user_confirm.form-control(type='password' ng-model='user_info.confirm' match='user_info.password' placeholder='Confirm password' ng-required='action == "signup"' on-enter='loginForm.$valid && auth(action, user_info)')
-                        .settings-row(ignite-terms)
-                            .col-md-offset-3(ng-if='action == "signup" && terms.termsState')
-                                label
-                                    input(type='checkbox' ng-model='user_info.agree', ng-required='true')
-                                    | I agree to the #[a(ui-sref='{{::terms.termsState}}' target='_blank') terms and conditions]
-                    .col-xs-12.col-md-11
-                        .login-footer(ng-show='action == "signup"')
-                            a.labelField(ng-click='action = "password/forgot"' on-click-focus='user_email') Forgot password?
-                            a.labelLogin(ng-click='action = "signin"' on-click-focus='user_email') Sign In
-                            button#signup.btn.btn-primary(ng-click='auth(action, user_info)' ng-disabled='loginForm.$invalid') Sign Up
-                    .col-xs-12.col-md-11
-                        .login-footer(ng-show='action == "password/forgot"')
-                            a.labelField(ng-click='action = "signin"' on-click-focus='user_email') Sign In
-                            button#forgot.btn.btn-primary(ng-click='auth(action, user_info)' ng-disabled='loginForm.$invalid') Send it to me
-                    .col-xs-12.col-md-11
-                        .login-footer(ng-show='action == "signin"')
-                            a.labelField(ng-click='action = "password/forgot"' on-click-focus='user_email') Forgot password?
-                            a.labelLogin(ng-click='action = "signup"' on-click-focus='user_name') Sign Up
-                            button#login.btn.btn-primary(ng-click='auth(action, user_info)' ng-disabled='loginForm.$invalid') Sign In
-
-                .col-xs-12.col-md-11.home-panel
-                    p Web Console is an interactive management tool which allows to:
-                    ul
-                        li Create and download cluster configurations
-                        li Automatically import domain model from any RDBMS
-                        li Connect to cluster and run SQL analytics on it
-            .col-xs-12.col-md-6
-                #carousel.carousel.slide
-                    // Indicators
-                    ol.carousel-indicators
-                        li.active(data-target='#carousel', data-slide-to='0')
-                        li(data-target='#carousel', data-slide-to='1')
-                        li(data-target='#carousel', data-slide-to='2')
-                        li(data-target='#carousel', data-slide-to='3')
-                        li(data-target='#carousel', data-slide-to='4')
-                        li(data-target='#carousel', data-slide-to='5')
-                        li(data-target='#carousel', data-slide-to='6')
-                    // Wrapper for slides
-                    .carousel-inner(role='listbox')
-                        .item.active
-                            img(src='/images/cluster.png', alt='Clusters screen')
-                            .carousel-caption
-                                h3 Clusters screen
-                                p Configure clusters, link clusters to caches
-                        .item
-                            img(src='/images/cache.png', alt='Caches screen')
-                            .carousel-caption
-                                h3 Caches screen
-                                p Configure caches, link domain models to caches, link caches to clusters
-                        .item
-                            img(src='/images/domains.png', alt='Domain model screen')
-                            .carousel-caption
-                                h3 Domain model screen
-                                p Manually enter domain model or import from database
-                        .item
-                            img(src='/images/summary.png', alt='Summary screen')
-                            .carousel-caption
-                                h3 Summary screen
-                                p Preview XML config, JAVA code,Docker file and download project
-                        .item
-                            img(src='/images/query-table.png', alt='Query')
-                            .carousel-caption
-                                h3 Query
-                                p Explain SQL, execute, scan queries
-                        .item
-                            img(src='/images/query-metadata.png', alt='Cache metadata')
-                            .carousel-caption
-                                h3 Cache metadata
-                                p View cache type metadata
-                        .item
-                            img(src='/images/query-chart.png', alt='Query chart')
-                            .carousel-caption
-                                h3 Query chart
-                                p View data in tabular form and as charts
-                    // Controls
-                    a.left.carousel-control(href='#carousel', role='button', data-slide='prev')
-                        span.fa.fa-chevron-left(aria-hidden='true')
-                        span.sr-only Previous
-                    a.right.carousel-control(href='#carousel', role='button', data-slide='next')
-                        span.fa.fa-chevron-right(aria-hidden='true')
-                        span.sr-only Next
-
-include includes/footer
-
-script.
-    $('.carousel').carousel()
-
-

http://git-wip-us.apache.org/repos/asf/ignite/blob/540acaa4/modules/control-center-web/src/main/js/views/signin.jade
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/views/signin.jade b/modules/control-center-web/src/main/js/views/signin.jade
new file mode 100644
index 0000000..b0f7ebe
--- /dev/null
+++ b/modules/control-center-web/src/main/js/views/signin.jade
@@ -0,0 +1,157 @@
+//-
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+mixin lbl(txt)
+    label.col-xs-3.col-md-3 #{txt}
+
+mixin lblRequired(txt)
+    label.col-xs-3.col-md-3.required #{txt}
+
+header#header.header
+    table.container
+        tr
+            td.col-xs-3.col-sm-3.col-md-2
+                ignite-logo
+            td
+                ignite-title
+
+.container.body-container
+    .main-content(ng-controller='auth')
+        .row.greedy.home
+            .col-xs-12.col-md-6
+                form(name='form' novalidate)
+                    .modal-body.row(style='padding-bottom: 10px; margin: 0')
+                        .settings-row(ng-if='action == "signup"')
+                            h3.login-header Sign Up
+                        .settings-row(ng-if='action == "signin"')
+                            h3.login-header Sign In
+                        .settings-row(ng-if='action == "password/forgot"')
+                            h3.login-header Forgot password?
+                        .settings-row
+                            p.col-xs-12.col-md-11(ng-show='action == "password/forgot"')
+                                | That's ok! Simply enter your email below and a reset password link will be sent to you via email. You can then follow that link and select a new password.
+                        .settings-row(ng-show='action == "signup"')
+                            +lblRequired('Full Name:')
+                            .col-xs-9.col-md-8
+                                input#user_name.form-control(enter-focus-next='user_email' type='text' ng-model='user_info.username' placeholder='John Smith' ng-required='action=="signup"')
+                        .settings-row
+                            +lblRequired('Email:')
+                            .col-xs-9.col-md-8
+                                input#user_email.form-control(enter-focus-next='company' type='email' ng-model='user_info.email' placeholder='you@domain.com' required)
+                        .settings-row(ng-show='action == "signup"')
+                            +lbl('Company:')
+                            .col-xs-9.col-md-8
+                                input#company.form-control(enter-focus-next='country' type='text' ng-model='user_info.company' placeholder='Your company name')
+                        .settings-row(ng-show='action == "signup"')
+                            +lbl('Country:')
+                            .col-xs-9.col-md-8
+                                button#country.select-toggle.form-control(bs-select bs-options='item for item in countries' enter-focus-next='user_password' type='text' ng-model='user_info.country' placeholder='Choose your country')
+                        .settings-row(ng-show='action != "password/forgot"')
+                            +lblRequired('Password:')
+                            .col-xs-9.col-md-8
+                                input#user_password.form-control(enter-focus-next='user_confirm' type='password' ng-model='user_info.password' placeholder='Password' ng-required='action != "password/forgot"' on-enter='action == "login" && form.$valid && auth(action, user_info)')
+                        .settings-row(ng-if='action == "signup"')
+                            +lblRequired('Confirm:')
+                            .col-xs-9.col-md-8
+                                input#user_confirm.form-control(type='password' ng-model='user_info.confirm' match='user_info.password' placeholder='Confirm password' ng-required='action == "signup"' on-enter='form.$valid && auth(action, user_info)')
+                        .settings-row(ignite-terms)
+                            .col-md-offset-3(ng-if='action == "signup" && terms.termsState')
+                                label
+                                    input(type='checkbox' ng-model='user_info.agree', ng-required='true')
+                                    | I agree to the #[a(ui-sref='{{::terms.termsState}}' target='_blank') terms and conditions]
+                    .col-xs-12.col-md-11
+                        .login-footer(ng-show='action == "signup"')
+                            a.labelField(ng-click='action = "password/forgot"' on-click-focus='user_email') Forgot password?
+                            a.labelLogin(ng-click='action = "signin"' on-click-focus='user_email') Sign In
+                            button#signup.btn.btn-primary(ng-click='auth(action, user_info)' ng-disabled='form.$invalid') Sign Up
+                    .col-xs-12.col-md-11
+                        .login-footer(ng-show='action == "password/forgot"')
+                            a.labelField(ng-click='action = "signin"' on-click-focus='user_email') Sign In
+                            button#forgot.btn.btn-primary(ng-click='auth(action, user_info)' ng-disabled='form.$invalid') Send it to me
+                    .col-xs-12.col-md-11
+                        .login-footer(ng-show='action == "signin"')
+                            a.labelField(ng-click='action = "password/forgot"' on-click-focus='user_email') Forgot password?
+                            a.labelLogin(ng-click='action = "signup"' on-click-focus='user_name') Sign Up
+                            button#login.btn.btn-primary(ng-click='auth(action, user_info)' ng-disabled='form.$invalid') Sign In
+
+                .col-xs-12.col-md-11.home-panel
+                    p Web Console is an interactive management tool which allows to:
+                    ul
+                        li Create and download cluster configurations
+                        li Automatically import domain model from any RDBMS
+                        li Connect to cluster and run SQL analytics on it
+            .col-xs-12.col-md-6
+                #carousel.carousel.slide
+                    // Indicators
+                    ol.carousel-indicators
+                        li.active(data-target='#carousel', data-slide-to='0')
+                        li(data-target='#carousel', data-slide-to='1')
+                        li(data-target='#carousel', data-slide-to='2')
+                        li(data-target='#carousel', data-slide-to='3')
+                        li(data-target='#carousel', data-slide-to='4')
+                        li(data-target='#carousel', data-slide-to='5')
+                        li(data-target='#carousel', data-slide-to='6')
+                    // Wrapper for slides
+                    .carousel-inner(role='listbox')
+                        .item.active
+                            img(src='/images/cluster.png', alt='Clusters screen')
+                            .carousel-caption
+                                h3 Clusters screen
+                                p Configure clusters, link clusters to caches
+                        .item
+                            img(src='/images/cache.png', alt='Caches screen')
+                            .carousel-caption
+                                h3 Caches screen
+                                p Configure caches, link domain models to caches, link caches to clusters
+                        .item
+                            img(src='/images/domains.png', alt='Domain model screen')
+                            .carousel-caption
+                                h3 Domain model screen
+                                p Manually enter domain model or import from database
+                        .item
+                            img(src='/images/summary.png', alt='Summary screen')
+                            .carousel-caption
+                                h3 Summary screen
+                                p Preview XML config, JAVA code,Docker file and download project
+                        .item
+                            img(src='/images/query-table.png', alt='Query')
+                            .carousel-caption
+                                h3 Query
+                                p Explain SQL, execute, scan queries
+                        .item
+                            img(src='/images/query-metadata.png', alt='Cache metadata')
+                            .carousel-caption
+                                h3 Cache metadata
+                                p View cache type metadata
+                        .item
+                            img(src='/images/query-chart.png', alt='Query chart')
+                            .carousel-caption
+                                h3 Query chart
+                                p View data in tabular form and as charts
+                    // Controls
+                    a.left.carousel-control(href='#carousel', role='button', data-slide='prev')
+                        span.fa.fa-chevron-left(aria-hidden='true')
+                        span.sr-only Previous
+                    a.right.carousel-control(href='#carousel', role='button', data-slide='next')
+                        span.fa.fa-chevron-right(aria-hidden='true')
+                        span.sr-only Next
+
+include includes/footer
+
+script.
+    $('.carousel').carousel()
+
+


[50/50] ignite git commit: IGNITE-843 Optimize server side.

Posted by ak...@apache.org.
IGNITE-843 Optimize server side.


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

Branch: refs/heads/ignite-843-rc3
Commit: ddf268ca01a67422a44b03f78a9f7a985f99435d
Parents: f06c195
Author: AKuznetsov <ak...@gridgain.com>
Authored: Tue Feb 16 22:06:02 2016 +0700
Committer: AKuznetsov <ak...@gridgain.com>
Committed: Tue Feb 16 22:06:02 2016 +0700

----------------------------------------------------------------------
 .../src/main/js/serve/routes/clusters.js               | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/ddf268ca/modules/control-center-web/src/main/js/serve/routes/clusters.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/clusters.js b/modules/control-center-web/src/main/js/serve/routes/clusters.js
index bca0735..aae7e42 100644
--- a/modules/control-center-web/src/main/js/serve/routes/clusters.js
+++ b/modules/control-center-web/src/main/js/serve/routes/clusters.js
@@ -37,6 +37,7 @@ module.exports.factory = function(_, express, mongo) {
         router.post('/list', (req, res) => {
             const result = {};
             let spacesIds = [];
+            let domains = {};
 
             mongo.spaces(req.currentUserId())
                 .then((spaces) => {
@@ -45,16 +46,18 @@ module.exports.factory = function(_, express, mongo) {
 
                     return mongo.DomainModel.find({space: {$in: spacesIds}}).sort('valueType').lean().exec();
                 })
-                .then((domains) => {
-                    result.domains = domains;
+                .then((_domains) => {
+                    domains = _domains.reduce((map, obj) => {
+                        map[obj._id] = obj;
+
+                        return map;
+                    }, {});
 
                     return mongo.Cache.find({space: {$in: spacesIds}}).sort('name').lean().exec();
                 })
                 .then((caches) => {
                     _.forEach(caches, (cache) => {
-                        cache.domains = _.map(cache.domains, (domainId) => {
-                            return _.find(result.domains, {_id: domainId});
-                        });
+                        cache.domains = _.map(cache.domains, (domainId) => domains[domainId]);
                     });
 
                     result.caches = caches;


[04/50] ignite git commit: IGNITE-843 Fixed typo in class name.

Posted by ak...@apache.org.
IGNITE-843 Fixed typo in class name.


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

Branch: refs/heads/ignite-843-rc3
Commit: b0d4bee32123a5a4f30d48337e45660956f5f935
Parents: 0cd0471
Author: vsisko <vs...@gridgain.com>
Authored: Mon Feb 15 10:48:54 2016 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Mon Feb 15 10:48:54 2016 +0700

----------------------------------------------------------------------
 .../src/main/js/helpers/generator/generator-xml.js                 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/b0d4bee3/modules/control-center-web/src/main/js/helpers/generator/generator-xml.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/helpers/generator/generator-xml.js b/modules/control-center-web/src/main/js/helpers/generator/generator-xml.js
index 7d89026..5eb5758 100644
--- a/modules/control-center-web/src/main/js/helpers/generator/generator-xml.js
+++ b/modules/control-center-web/src/main/js/helpers/generator/generator-xml.js
@@ -860,7 +860,7 @@ $generatorXml.cacheStore = function(cache, domains, res) {
             }
             else if (factoryKind === 'CacheJdbcBlobStoreFactory') {
                 res.startBlock('<property name="cacheStoreFactory">');
-                res.startBlock('<bean class="org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStoreFactory">');
+                res.startBlock('<bean class="org.apache.ignite.cache.store.jdbc.CacheJdbcBlobStoreFactory">');
 
                 if (storeFactory.connectVia === 'DataSource')
                     $generatorXml.property(res, storeFactory, 'dataSourceBean');


[43/50] ignite git commit: IGNITE-843 Minor fix.

Posted by ak...@apache.org.
IGNITE-843 Minor fix.


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

Branch: refs/heads/ignite-843-rc3
Commit: 3a421b8be97fc979b7a3ad6c616957d71ca88dec
Parents: 0fa2c01
Author: Andrey <an...@gridgain.com>
Authored: Tue Feb 16 17:17:27 2016 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Tue Feb 16 17:17:27 2016 +0700

----------------------------------------------------------------------
 modules/control-center-web/src/main/js/serve/routes/domains.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/3a421b8b/modules/control-center-web/src/main/js/serve/routes/domains.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/domains.js b/modules/control-center-web/src/main/js/serve/routes/domains.js
index 6d8b87f..ff9a29b 100644
--- a/modules/control-center-web/src/main/js/serve/routes/domains.js
+++ b/modules/control-center-web/src/main/js/serve/routes/domains.js
@@ -180,7 +180,7 @@ module.exports.factory = (_, express, mongo) => {
             const domainId = params._id;
 
             mongo.DomainModel.findOne(params).exec()
-                .then((domain) => mongo.Cache.update({_id: {$in: domain.caches}}, {$pull: {domain: domainId}}, {multi: true}).exec())
+                .then((domain) => mongo.Cache.update({_id: {$in: domain.caches}}, {$pull: {domains: domainId}}, {multi: true}).exec())
                 .then(() => mongo.DomainModel.remove(params).exec())
                 .then(() => res.sendStatus(200))
                 .catch((err) => mongo.handleError(res, err));


[25/50] ignite git commit: IGNITE-843 WIP rework server side to promises.

Posted by ak...@apache.org.
IGNITE-843 WIP rework server side to promises.


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

Branch: refs/heads/ignite-843-rc3
Commit: 389c66256c827df16cf5c9ac3d28e40779e0b8eb
Parents: 2cb3d9c
Author: AKuznetsov <ak...@gridgain.com>
Authored: Mon Feb 15 23:37:51 2016 +0700
Committer: AKuznetsov <ak...@gridgain.com>
Committed: Mon Feb 15 23:37:51 2016 +0700

----------------------------------------------------------------------
 .../control-center-web/src/main/js/package.json |   1 -
 .../src/main/js/serve/mongo.js                  |  31 +-
 .../src/main/js/serve/routes/admin.js           | 140 +++----
 .../src/main/js/serve/routes/agent.js           |  32 +-
 .../src/main/js/serve/routes/caches.js          | 197 ++++------
 .../src/main/js/serve/routes/clusters.js        | 178 ++++-----
 .../src/main/js/serve/routes/domains.js         | 365 ++++++++-----------
 .../src/main/js/serve/routes/igfs.js            |  55 +--
 .../src/main/js/serve/routes/notebooks.js       | 104 ++----
 .../src/main/js/serve/routes/profile.js         |   7 +-
 .../src/main/js/serve/routes/public.js          |  20 +-
 11 files changed, 451 insertions(+), 679 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/389c6625/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 7910f35..9eef666 100644
--- a/modules/control-center-web/src/main/js/package.json
+++ b/modules/control-center-web/src/main/js/package.json
@@ -21,7 +21,6 @@
     "node": ">=0.12.4"
   },
   "dependencies": {
-    "async": "1.5.0",
     "babel-eslint": "^4.1.6",
     "body-parser": "~1.14.1",
     "bootstrap-sass": "^3.3.6",

http://git-wip-us.apache.org/repos/asf/ignite/blob/389c6625/modules/control-center-web/src/main/js/serve/mongo.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/mongo.js b/modules/control-center-web/src/main/js/serve/mongo.js
index f6ff790..83d3b67 100644
--- a/modules/control-center-web/src/main/js/serve/mongo.js
+++ b/modules/control-center-web/src/main/js/serve/mongo.js
@@ -39,6 +39,8 @@ module.exports.factory = function(deepPopulatePlugin, passportMongo, settings, p
     const ObjectId = mongoose.Schema.Types.ObjectId;
     const result = { connection: mongoose.connection };
 
+    result.ObjectId = ObjectId;
+
     // Define Account schema.
     const AccountSchema = new Schema({
         username: String,
@@ -527,26 +529,19 @@ module.exports.factory = function(deepPopulatePlugin, passportMongo, settings, p
     // Define Notebook model.
     result.Notebook = mongoose.model('Notebook', NotebookSchema);
 
-    result.upsert = function(Model, data, cb) {
-        if (data._id) {
-            const id = data._id;
-
-            delete data._id;
-
-            Model.findOneAndUpdate({_id: id}, data, cb);
-        }
-        else
-            new Model(data).save(cb);
+    result.handleError = function(res, err) {
+        // TODO IGNITE-843 Send error to admin
+        res.status(err.code || 500).send(err.message);
     };
 
-    result.processed = function(err, res) {
-        if (err) {
-            res.status(500).send(err);
-
-            return false;
-        }
-
-        return true;
+    /**
+     * Query for user spaces.
+     *
+     * @param userId User ID.
+     * @returns {Promise}
+     */
+    result.spaces = function(userId) {
+        return result.Space.find({owner: userId}).exec();
     };
 
     // Registering the routes of all plugin modules

http://git-wip-us.apache.org/repos/asf/ignite/blob/389c6625/modules/control-center-web/src/main/js/serve/routes/admin.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/admin.js b/modules/control-center-web/src/main/js/serve/routes/admin.js
index 2f26f7a..0736277 100644
--- a/modules/control-center-web/src/main/js/serve/routes/admin.js
+++ b/modules/control-center-web/src/main/js/serve/routes/admin.js
@@ -25,104 +25,106 @@ module.exports = {
 };
 
 module.exports.factory = function(_, express, nodemailer, settings, mongo) {
-    return new Promise((resolve) => {
+    return new Promise((factoryResolve) => {
         const router = new express.Router();
 
         /**
          * Get list of user accounts.
          */
-        router.post('/list', function(req, res) {
-            mongo.Account.find({}).sort('username').exec(function(err, users) {
-                if (err)
-                    return res.status(500).send(err.message);
-
-                res.json(users);
-            });
+        router.post('/list', (req, res) => {
+            mongo.Account.find({}).sort('username').exec()
+                .then((users) => res.json(users))
+                .catch((err) => mongo.handleError(res, err));
         });
 
         // Remove user.
-        router.post('/remove', function(req, res) {
+        router.post('/remove', (req, res) => {
             const userId = req.body.userId;
 
-            mongo.Account.findByIdAndRemove(userId, function(errAccount, user) {
-                if (errAccount)
-                    return res.status(500).send(errAccount.message);
+            mongo.Account.findByIdAndRemove(userId).exec()
+                .then(() => mongo.spaces(userId))
+                .then((spaces) => {
+                    const promises = [];
 
-                mongo.Space.find({owner: userId}, function(errSpace, spaces) {
                     _.forEach(spaces, (space) => {
-                        mongo.Cluster.remove({space: space._id}).exec();
-                        mongo.Cache.remove({space: space._id}).exec();
-                        mongo.DomainModel.remove({space: space._id}).exec();
-                        mongo.Notebook.remove({space: space._id}).exec();
-                        mongo.Space.remove({owner: space._id}).exec();
+                        promises.push(mongo.Cluster.remove({space: space._id}).exec());
+                        promises.push(mongo.Cache.remove({space: space._id}).exec());
+                        promises.push(mongo.DomainModel.remove({space: space._id}).exec());
+                        promises.push(mongo.Notebook.remove({space: space._id}).exec());
+                        promises.push(mongo.Space.remove({owner: space._id}).exec());
                     });
-                });
-
-                const transporter = {
-                    service: settings.smtp.service,
-                    auth: {
-                        user: settings.smtp.email,
-                        pass: settings.smtp.password
-                    }
-                };
-
-                if (transporter.service !== '' || transporter.auth.user !== '' || transporter.auth.pass !== '') {
-                    const mailer = nodemailer.createTransport(transporter);
-
-                    const mailOptions = {
-                        from: settings.smtp.address(settings.smtp.username, settings.smtp.email),
-                        to: settings.smtp.address(user.username, user.email),
-                        subject: 'Your account was deleted',
-                        text: 'You are receiving this e-mail because admin remove your account.\n\n' +
-                        '--------------\n' +
-                        'Apache Ignite Web Console http://' + req.headers.host + '\n'
-                    };
-
-                    mailer.sendMail(mailOptions, function(errMailer) {
-                        if (errMailer)
-                            return res.status(503).send('Account was removed, but failed to send e-mail notification to user!<br />' + errMailer);
-
-                        res.sendStatus(200);
+
+                    return Promise.all(promises);
+                })
+                .then(() => {
+                    return new Promise((resolveMail, rejectMail) => {
+                        const transporter = {
+                            service: settings.smtp.service,
+                            auth: {
+                                user: settings.smtp.email,
+                                pass: settings.smtp.password
+                            }
+                        };
+
+                        if (transporter.service !== '' || transporter.auth.user !== '' || transporter.auth.pass !== '') {
+                            const mailer = nodemailer.createTransport(transporter);
+
+                            const mailOptions = {
+                                from: settings.smtp.address(settings.smtp.username, settings.smtp.email),
+                                to: settings.smtp.address(user.username, user.email),
+                                subject: 'Your account was deleted',
+                                text: 'You are receiving this e-mail because admin remove your account.\n\n' +
+                                '--------------\n' +
+                                settings.smtp.username + ' http://' + req.headers.host + '\n'
+                            };
+
+                            mailer.sendMail(mailOptions, (errMailer) => {
+                                if (errMailer) {
+                                    rejectMail({
+                                        code: 503,
+                                        message: 'Account was removed, but failed to send e-mail notification to user!<br />' + errMailer
+                                    });
+                                }
+                                else
+                                    resolveMail();
+                            });
+                        }
+                        else
+                            rejectMail({code: 503, message: 'Account was removed, but failed to send e-mail notification to user, because mailer is not configured!'});
                     });
-                }
-                else
-                    res.sendStatus(200);
-            });
+                })
+                .then(() => res.sendStatus(200))
+                .catch((err) => mongo.handleError(res, err));
         });
 
         // Save user.
-        router.post('/save', function(req, res) {
-            const userId = req.body.userId;
-            const adminFlag = req.body.adminFlag;
+        router.post('/save', (req, res) => {
+            const params = req.body;
 
-            mongo.Account.findByIdAndUpdate(userId, {admin: adminFlag}, function(err) {
-                if (err)
-                    return res.status(500).send(err.message);
-
-                res.sendStatus(200);
-            });
+            mongo.Account.findByIdAndUpdate(params.userId, {admin: params.adminFlag}).exec()
+                .then(() => res.sendStatus(200))
+                .catch((err) => mongo.handleError(res, err));
         });
 
         // Become user.
-        router.get('/become', function(req, res) {
-            mongo.Account.findById(req.query.viewedUserId).exec(function(err, viewedUser) {
-                if (err)
-                    return res.sendStatus(404);
-
-                req.session.viewedUser = viewedUser;
+        router.get('/become', (req, res) => {
+            mongo.Account.findById(req.query.viewedUserId).exec()
+                .then((viewedUser) => {
+                    req.session.viewedUser = viewedUser;
 
-                return res.sendStatus(200);
-            });
+                    res.sendStatus(200);
+                })
+                .catch(() => res.sendStatus(404));
         });
 
-        // Become user.
-        router.get('/revert/identity', function(req, res) {
+        // Revert to your identity.
+        router.get('/revert/identity', (req, res) => {
             req.session.viewedUser = null;
 
             return res.sendStatus(200);
         });
 
-        resolve(router);
+        factoryResolve(router);
     });
 };
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/389c6625/modules/control-center-web/src/main/js/serve/routes/agent.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/agent.js b/modules/control-center-web/src/main/js/serve/routes/agent.js
index 40e0c82..0451e52 100644
--- a/modules/control-center-web/src/main/js/serve/routes/agent.js
+++ b/modules/control-center-web/src/main/js/serve/routes/agent.js
@@ -57,7 +57,7 @@ module.exports.factory = function(_, express, apacheIgnite, fs, JSZip, settings,
         };
 
         const _handleException = (res) => {
-            return function(error) {
+            return (error) => {
                 if (_.isObject(error))
                     return res.status(error.code).send(error.message);
 
@@ -66,17 +66,17 @@ module.exports.factory = function(_, express, apacheIgnite, fs, JSZip, settings,
         };
 
         /* Get grid topology. */
-        router.get('/download/zip', function(req, res) {
+        router.get('/download/zip', (req, res) => {
             const agentFld = settings.agent.file;
             const agentZip = agentFld + '.zip';
             const agentPathZip = 'public/agent/' + agentFld + '.zip';
 
-            fs.stat(agentPathZip, function(err, stats) {
+            fs.stat(agentPathZip, (err, stats) => {
                 if (err)
                     return res.download(agentPathZip, agentZip);
 
                 // Read a zip file.
-                fs.readFile(agentPathZip, function(errFs, data) {
+                fs.readFile(agentPathZip, (errFs, data) => {
                     if (errFs)
                         return res.download(agentPathZip, agentZip);
 
@@ -108,7 +108,7 @@ module.exports.factory = function(_, express, apacheIgnite, fs, JSZip, settings,
         });
 
         /* Get grid topology. */
-        router.post('/topology', function(req, res) {
+        router.post('/topology', (req, res) => {
             _client(req.currentUserId())
                 .then((client) => client.ignite(req.body.demo).cluster(req.body.attr, req.body.mtr))
                 .then((clusters) => res.json(clusters))
@@ -116,7 +116,7 @@ module.exports.factory = function(_, express, apacheIgnite, fs, JSZip, settings,
         });
 
         /* Execute query. */
-        router.post('/query', function(req, res) {
+        router.post('/query', (req, res) => {
             _client(req.currentUserId())
                 .then((client) => {
                     // Create sql query.
@@ -136,7 +136,7 @@ module.exports.factory = function(_, express, apacheIgnite, fs, JSZip, settings,
         });
 
         /* Execute query getAll. */
-        router.post('/query/getAll', function(req, res) {
+        router.post('/query/getAll', (req, res) => {
             _client(req.currentUserId())
                 .then((client) => {
                     // Create sql query.
@@ -148,7 +148,7 @@ module.exports.factory = function(_, express, apacheIgnite, fs, JSZip, settings,
                     // Get query cursor.
                     const cursor = client.ignite(req.body.demo).cache(req.body.cacheName).query(qry);
 
-                    return new Promise(function(resolve) {
+                    return new Promise((resolve) => {
                         cursor.getAll().then((rows) => resolve({meta: cursor.fieldsMetadata(), rows}));
                     });
                 })
@@ -157,7 +157,7 @@ module.exports.factory = function(_, express, apacheIgnite, fs, JSZip, settings,
         });
 
         /* Execute query. */
-        router.post('/scan', function(req, res) {
+        router.post('/scan', (req, res) => {
             _client(req.currentUserId())
                 .then((client) => {
                     // Create sql query.
@@ -178,7 +178,7 @@ module.exports.factory = function(_, express, apacheIgnite, fs, JSZip, settings,
         });
 
         /* Get next query page. */
-        router.post('/query/fetch', function(req, res) {
+        router.post('/query/fetch', (req, res) => {
             _client(req.currentUserId())
                 .then((client) => {
                     const cache = client.ignite(req.body.demo).cache(req.body.cacheName);
@@ -194,7 +194,7 @@ module.exports.factory = function(_, express, apacheIgnite, fs, JSZip, settings,
         });
 
         /* Close query cursor by id. */
-        router.post('/query/close', function(req, res) {
+        router.post('/query/close', (req, res) => {
             _client(req.currentUserId())
                 .then((client) => {
                     const cache = client.ignite(req.body.demo).cache(req.body.cacheName);
@@ -206,7 +206,7 @@ module.exports.factory = function(_, express, apacheIgnite, fs, JSZip, settings,
         });
 
         /* Get metadata for cache. */
-        router.post('/cache/metadata', function(req, res) {
+        router.post('/cache/metadata', (req, res) => {
             _client(req.currentUserId())
                 .then((client) => client.ignite(req.body.demo).cache(req.body.cacheName).metadata())
                 .then((caches) => {
@@ -292,14 +292,14 @@ module.exports.factory = function(_, express, apacheIgnite, fs, JSZip, settings,
         });
 
         /* Ping client. */
-        router.post('/ping', function(req, res) {
+        router.post('/ping', (req, res) => {
             _client(req.currentUserId())
                 .then(() => res.sendStatus(200))
                 .catch(_handleException(res));
         });
 
         /* Get JDBC drivers list. */
-        router.post('/drivers', function(req, res) {
+        router.post('/drivers', (req, res) => {
             _client(req.currentUserId())
                 .then((client) => client.availableDrivers())
                 .then((arr) => res.json(arr))
@@ -307,7 +307,7 @@ module.exports.factory = function(_, express, apacheIgnite, fs, JSZip, settings,
         });
 
         /** Get database schemas. */
-        router.post('/schemas', function(req, res) {
+        router.post('/schemas', (req, res) => {
             _client(req.currentUserId())
                 .then((client) => {
                     const args = req.body;
@@ -321,7 +321,7 @@ module.exports.factory = function(_, express, apacheIgnite, fs, JSZip, settings,
         });
 
         /** Get database tables. */
-        router.post('/tables', function(req, res) {
+        router.post('/tables', (req, res) => {
             _client(req.currentUserId())
                 .then((client) => {
                     const args = req.body;

http://git-wip-us.apache.org/repos/asf/ignite/blob/389c6625/modules/control-center-web/src/main/js/serve/routes/caches.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/caches.js b/modules/control-center-web/src/main/js/serve/routes/caches.js
index 1f5a01c..77c3943 100644
--- a/modules/control-center-web/src/main/js/serve/routes/caches.js
+++ b/modules/control-center-web/src/main/js/serve/routes/caches.js
@@ -25,7 +25,7 @@ module.exports = {
 };
 
 module.exports.factory = function(_, express, mongo) {
-    return new Promise((resolve) => {
+    return new Promise((factoryResolve) => {
         const router = new express.Router();
 
         /**
@@ -35,70 +35,33 @@ module.exports.factory = function(_, express, mongo) {
          * @param res Response.
          */
         router.post('/list', (req, res) => {
-            const user_id = req.currentUserId();
+            const result = {};
+            let spacesIds = [];
 
             // Get owned space and all accessed space.
-            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 caches').sort('name').exec((errCluster, clusters) => {
-                        if (mongo.processed(errCluster, res)) {
-                            // Get all domain models for spaces.
-                            mongo.DomainModel.find({space: {$in: space_ids}}).sort('name').exec((errDomainModel, domains) => {
-                                if (mongo.processed(errDomainModel, res)) {
-                                    // Get all caches for spaces.
-                                    mongo.Cache.find({space: {$in: space_ids}}).sort('name').exec((err, caches) => {
-                                        if (mongo.processed(err, res)) {
-                                            _.forEach(clusters, (cluster) => {
-                                                cluster.caches = _.filter(cluster.caches, (cacheId) => {
-                                                    return _.find(caches, {_id: cacheId});
-                                                });
-                                            });
-
-                                            _.forEach(domains, (domain) => {
-                                                domain.caches = _.filter(domain.caches, (cacheId) => {
-                                                    return _.find(caches, {_id: cacheId});
-                                                });
-                                            });
-
-                                            _.forEach(caches, (cache) => {
-                                                // Remove deleted clusters.
-                                                cache.clusters = _.filter(cache.clusters, (clusterId) => {
-                                                    return _.findIndex(clusters, (cluster) => {
-                                                        return cluster._id.equals(clusterId);
-                                                    }) >= 0;
-                                                });
-
-                                                // Remove deleted domain models.
-                                                cache.domains = _.filter(cache.domains, (metaId) => {
-                                                    return _.findIndex(domains, (domain) => {
-                                                        return domain._id.equals(metaId);
-                                                    }) >= 0;
-                                                });
-                                            });
-
-                                            res.json({
-                                                spaces,
-                                                clusters: clusters.map((cluster) => {
-                                                    return {
-                                                        value: cluster._id,
-                                                        label: cluster.name,
-                                                        caches: cluster.caches
-                                                    };
-                                                }),
-                                                domains,
-                                                caches
-                                            });
-                                        }
-                                    });
-                                }
-                            });
-                        }
-                    });
-                }
-            });
+            mongo.spaces(req.currentUserId())
+                .then((spaces) => {
+                    result.spaces = spaces;
+                    spacesIds = spaces.map((value) => value._id);
+
+                    return mongo.Cluster.find({space: {$in: result.spacesIds}}).sort('name').exec();
+                })
+                .then((clusters) => {
+                    result.clusters = clusters;
+
+                    return mongo.DomainModel.find({space: {$in: spacesIds}}).sort('name').exec();
+                })
+                .then((domains) => {
+                    result.domains = domains;
+
+                    return mongo.Cache.find({space: {$in: spacesIds}}).sort('name').exec();
+                })
+                .then((caches) => {
+                    result.caches = caches;
+
+                    res.json(result);
+                })
+                .catch((err) => mongo.handleError(res, err));
         });
 
         /**
@@ -111,49 +74,30 @@ module.exports.factory = function(_, express, mongo) {
             let cacheId = params._id;
 
             if (params._id) {
-                mongo.Cache.update({_id: cacheId}, params, {upsert: true}, (errCache) => {
-                    if (mongo.processed(errCache, res)) {
-                        mongo.Cluster.update({_id: {$in: clusters}}, {$addToSet: {caches: cacheId}}, {multi: true}, (errClusterAdd) => {
-                            if (mongo.processed(errClusterAdd, res)) {
-                                mongo.Cluster.update({_id: {$nin: clusters}}, {$pull: {caches: cacheId}}, {multi: true}, (errClusterPull) => {
-                                    if (mongo.processed(errClusterPull, res)) {
-                                        mongo.DomainModel.update({_id: {$in: domains}}, {$addToSet: {caches: cacheId}}, {multi: true}, (errDomainModelAdd) => {
-                                            if (mongo.processed(errDomainModelAdd, res)) {
-                                                mongo.DomainModel.update({_id: {$nin: domains}}, {$pull: {caches: cacheId}}, {multi: true}, (errDomainModelPull) => {
-                                                    if (mongo.processed(errDomainModelPull, res))
-                                                        res.send(params._id);
-                                                });
-                                            }
-                                        });
-                                    }
-                                });
-                            }
-                        });
-                    }
-                });
+                mongo.Cache.update({_id: cacheId}, params, {upsert: true}).exec()
+                    .then(() => mongo.Cluster.update({_id: {$in: clusters}}, {$addToSet: {caches: cacheId}}, {multi: true}).exec())
+                    .then(() => mongo.Cluster.update({_id: {$nin: clusters}}, {$pull: {caches: cacheId}}, {multi: true}).exec())
+                    .then(() => mongo.DomainModel.update({_id: {$in: domains}}, {$addToSet: {caches: cacheId}}, {multi: true}).exec())
+                    .then(() => mongo.DomainModel.update({_id: {$nin: domains}}, {$pull: {caches: cacheId}}, {multi: true}).exec())
+                    .then(() => res.send(cacheId))
+                    .catch((err) => mongo.handleError(res, err));
             }
             else {
-                mongo.Cache.findOne({space: params.space, name: params.name}, (errCacheFind, cacheFound) => {
-                    if (mongo.processed(errCacheFind, res)) {
-                        if (cacheFound)
-                            return res.status(500).send('Cache with name: "' + cacheFound.name + '" already exist.');
-
-                        (new mongo.Cache(params)).save((errCacheSave, cache) => {
-                            if (mongo.processed(errCacheSave, res)) {
-                                cacheId = cache._id;
-
-                                mongo.Cluster.update({_id: {$in: clusters}}, {$addToSet: {caches: cacheId}}, {multi: true}, (errCluster) => {
-                                    if (mongo.processed(errCluster, res)) {
-                                        mongo.DomainModel.update({_id: {$in: domains}}, {$addToSet: {caches: cacheId}}, {multi: true}, (errDomainModel) => {
-                                            if (mongo.processed(errDomainModel, res))
-                                                res.send(cacheId);
-                                        });
-                                    }
-                                });
-                            }
-                        });
-                    }
-                });
+                mongo.Cache.findOne({space: params.space, name: params.name}).exec()
+                    .then((cache) => {
+                        if (cache)
+                            throw new Error('Cache with name: "' + cache.name + '" already exist.');
+
+                        return (new mongo.Cache(params)).save();
+                    })
+                    .then((cache) => {
+                        cacheId = cache._id;
+
+                        return mongo.Cluster.update({_id: {$in: clusters}}, {$addToSet: {caches: cacheId}}, {multi: true}).exec();
+                    })
+                    .then(() => mongo.DomainModel.update({_id: {$in: domains}}, {$addToSet: {caches: cacheId}}, {multi: true}).exec())
+                    .then(() => res.send(cacheId))
+                    .catch((err) => mongo.handleError(res, err));
             }
         });
 
@@ -161,41 +105,34 @@ module.exports.factory = function(_, express, mongo) {
          * Remove cache by ._id.
          */
         router.post('/remove', (req, res) => {
-            mongo.Cache.remove(req.body, (err) => {
-                if (mongo.processed(err, res))
-                    res.sendStatus(200);
-            });
+            const params = req.body;
+            const cacheId = params._id;
+
+            mongo.Cluster.update({caches: {$in: [cacheId]}}, {$pull: {caches: cacheId}}, {multi: true}).exec()
+                .then(() => mongo.DomainModel.update({caches: {$in: [cacheId]}}, {$pull: {caches: cacheId}}, {multi: true}).exec())
+                .then(() => mongo.Cache.remove(params))
+                .then(() => res.sendStatus(200))
+                .catch((err) => mongo.handleError(res, err));
         });
 
         /**
          * Remove all caches.
          */
         router.post('/remove/all', (req, res) => {
-            const user_id = req.currentUserId();
+            let spacesIds = [];
 
-            // Get owned space and all accessed space.
-            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.Cache.remove({space: {$in: space_ids}}, (errCache) => {
-                        if (errCache)
-                            return res.status(500).send(errCache.message);
-
-                        mongo.Cluster.update({space: {$in: space_ids}}, {caches: []}, {multi: true}, (errCluster) => {
-                            if (mongo.processed(errCluster, res)) {
-                                mongo.DomainModel.update({space: {$in: space_ids}}, {caches: []}, {multi: true}, (errDomainModel) => {
-                                    if (mongo.processed(errDomainModel, res))
-                                        res.sendStatus(200);
-                                });
-                            }
-                        });
-                    });
-                }
-            });
+            mongo.spaces(req.currentUserId())
+                .then((spaces) => {
+                    spacesIds = spaces.map((value) => value._id);
+
+                    return mongo.Cluster.update({space: {$in: spacesIds}}, {caches: []}, {multi: true});
+                })
+                .then(() => mongo.DomainModel.update({space: {$in: spacesIds}}, {caches: []}, {multi: true}))
+                .then(() => mongo.Cache.remove({space: {$in: spacesIds}}))
+                .catch((err) => mongo.handleError(res, err));
         });
 
-        resolve(router);
+        factoryResolve(router);
     });
 };
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/389c6625/modules/control-center-web/src/main/js/serve/routes/clusters.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/clusters.js b/modules/control-center-web/src/main/js/serve/routes/clusters.js
index 256de5d..468e912 100644
--- a/modules/control-center-web/src/main/js/serve/routes/clusters.js
+++ b/modules/control-center-web/src/main/js/serve/routes/clusters.js
@@ -25,7 +25,7 @@ module.exports = {
 };
 
 module.exports.factory = function(_, express, mongo) {
-    return new Promise((resolve) => {
+    return new Promise((factoryResolve) => {
         const router = new express.Router();
 
         /**
@@ -35,59 +35,32 @@ module.exports.factory = function(_, express, mongo) {
          * @param res Response.
          */
         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}}}]}, (errSpace, spaces) => {
-                if (mongo.processed(errSpace, res)) {
-                    const space_ids = spaces.map((value) => value._id);
-
-                    // Get all caches for spaces.
-                    mongo.Cache.find({space: {$in: space_ids}}).sort('name').deepPopulate('domains').exec((errCache, caches) => {
-                        if (mongo.processed(errCache, res)) {
-                            // Get all IGFSs for spaces.
-                            mongo.Igfs.find({space: {$in: space_ids}}).sort('name').exec((errIgfs, igfss) => {
-                                if (mongo.processed(errIgfs, res)) {
-                                    // Get all clusters for spaces.
-                                    mongo.Cluster.find({space: {$in: space_ids}}).sort('name').deepPopulate(mongo.ClusterDefaultPopulate).exec((errCluster, clusters) => {
-                                        if (mongo.processed(errCluster, res)) {
-                                            _.forEach(caches, (cache) => {
-                                                // Remove deleted caches.
-                                                cache.clusters = _.filter(cache.clusters, (clusterId) => {
-                                                    return _.find(clusters, {_id: clusterId});
-                                                });
-                                            });
-
-                                            _.forEach(igfss, (igfs) => {
-                                                // Remove deleted caches.
-                                                igfs.clusters = _.filter(igfs.clusters, (clusterId) => {
-                                                    return _.find(clusters, {_id: clusterId});
-                                                });
-                                            });
-
-                                            _.forEach(clusters, (cluster) => {
-                                                // Remove deleted caches.
-                                                cluster.caches = _.filter(cluster.caches, (cacheId) => {
-                                                    return _.find(caches, {_id: cacheId});
-                                                });
-
-                                                // Remove deleted IGFS.
-                                                cluster.igfss = _.filter(cluster.igfss, (igfsId) => {
-                                                    return _.findIndex(igfss, (igfs) => {
-                                                        return igfs._id.equals(igfsId);
-                                                    }) >= 0;
-                                                });
-                                            });
-
-                                            res.json({ spaces, caches, igfss, clusters });
-                                        }
-                                    });
-                                }
-                            });
-                        }
-                    });
-                }
-            });
+            const result = {};
+            let spacesIds = [];
+
+            mongo.spaces(req.currentUserId())
+                .then((spaces) => {
+                    result.spaces = spaces;
+                    spacesIds = spaces.map((value) => value._id);
+
+                    return mongo.Cache.find({space: {$in: spacesIds}}).sort('name').exec();
+                })
+                .then((caches) => {
+                    result.caches = caches;
+
+                    return mongo.Igfs.find({space: {$in: spacesIds}}).sort('name').exec();
+                })
+                .then((igfss) => {
+                    result.igfss = igfss;
+
+                    return mongo.Cluster.find({space: {$in: spacesIds}}).sort('name').deepPopulate(mongo.ClusterDefaultPopulate).exec();
+                })
+                .then((clusters) => {
+                    result.clusters = clusters;
+
+                    res.json(result);
+                })
+                .catch((err) => mongo.handleError(res, err));
         });
 
         /**
@@ -96,40 +69,36 @@ module.exports.factory = function(_, express, mongo) {
         router.post('/save', (req, res) => {
             const params = req.body;
             const caches = params.caches;
+            const igfss = params.igfss;
             let clusterId = params._id;
 
             if (params._id) {
-                mongo.Cluster.update({_id: params._id}, params, {upsert: true}, (errCluster) => {
-                    if (mongo.processed(errCluster, res)) {
-                        mongo.Cache.update({_id: {$in: caches}}, {$addToSet: {clusters: clusterId}}, {multi: true}, (errCacheAdd) => {
-                            if (mongo.processed(errCacheAdd, res)) {
-                                mongo.Cache.update({_id: {$nin: caches}}, {$pull: {clusters: clusterId}}, {multi: true}, (errCachePull) => {
-                                    if (mongo.processed(errCachePull, res))
-                                        res.send(params._id);
-                                });
-                            }
-                        });
-                    }
-                });
+                mongo.Cluster.update({_id: params._id}, params, {upsert: true}).exec()
+                    .then(() => mongo.Cache.update({_id: {$in: caches}}, {$addToSet: {clusters: clusterId}}, {multi: true}).exec())
+                    .then(() => mongo.Cache.update({_id: {$nin: caches}}, {$pull: {clusters: clusterId}}, {multi: true}).exec())
+                    .then(() => mongo.Igfs.update({_id: {$in: igfss}}, {$addToSet: {clusters: clusterId}}, {multi: true}).exec())
+                    .then(() => mongo.Igfs.update({_id: {$nin: igfss}}, {$pull: {clusters: clusterId}}, {multi: true}).exec())
+                    .then(() => res.send(clusterId))
+                    .catch((err) => mongo.handleError(res, err));
             }
             else {
-                mongo.Cluster.findOne({space: params.space, name: params.name}, (errClusterFound, clusterFound) => {
-                    if (mongo.processed(errClusterFound, res)) {
-                        if (clusterFound)
-                            return res.status(500).send('Cluster with name: "' + clusterFound.name + '" already exist.');
-
-                        (new mongo.Cluster(params)).save((errCluster, cluster) => {
-                            if (mongo.processed(errCluster, res)) {
-                                clusterId = cluster._id;
-
-                                mongo.Cache.update({_id: {$in: caches}}, {$addToSet: {clusters: clusterId}}, {multi: true}, (errCacheAdd) => {
-                                    if (mongo.processed(errCacheAdd, res))
-                                        res.send(clusterId);
-                                });
-                            }
-                        });
-                    }
-                });
+                mongo.Cluster.findOne({space: params.space, name: params.name}).exec()
+                    .then((cluster) => {
+                        if (cluster)
+                            return res.status(500).send('Cluster with name: "' + cluster.name + '" already exist.');
+
+                        return (new mongo.Cluster(params)).save();
+                    })
+                    .then((cluster) => {
+                        clusterId = cluster._id;
+
+                        return mongo.Cache.update({_id: {$in: caches}}, {$addToSet: {clusters: clusterId}}, {multi: true}).exec();
+                    })
+                    .then(() => mongo.Cache.update({_id: {$nin: caches}}, {$pull: {clusters: clusterId}}, {multi: true}).exec())
+                    .then(() => mongo.Igfs.update({_id: {$in: igfss}}, {$addToSet: {clusters: clusterId}}, {multi: true}).exec())
+                    .then(() => mongo.Igfs.update({_id: {$nin: igfss}}, {$pull: {clusters: clusterId}}, {multi: true}).exec())
+                    .then(() => res.send(clusterId))
+                    .catch((err) => mongo.handleError(res, err));
             }
         });
 
@@ -137,46 +106,35 @@ module.exports.factory = function(_, express, mongo) {
          * Remove cluster by ._id.
          */
         router.post('/remove', (req, res) => {
-            const clusterId = req.body;
+            const params = req.body;
+            const clusterId = params._id;
 
             mongo.Cache.update({clusters: {$in: [clusterId]}}, {$pull: {clusters: clusterId}}, {multi: true}).exec()
                 .then(() => mongo.Igfs.update({clusters: {$in: [clusterId]}}, {$pull: {clusters: clusterId}}, {multi: true}).exec())
-                .then(() => mongo.Cluster.remove(clusterId))
+                .then(() => mongo.Cluster.remove(params))
                 .then(() => res.sendStatus(200))
-                .catch((err) => {
-                    // TODO IGNITE-843 Send error to admin
-                    res.status(500).send(err.message);
-                });
+                .catch((err) => mongo.handleError(res, err));
         });
 
         /**
          * Remove all clusters.
          */
         router.post('/remove/all', (req, res) => {
-            const user_id = req.currentUserId();
+            let spacesIds = [];
 
             // Get owned space and all accessed space.
-            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.Cluster.remove({space: {$in: space_ids}}, (errCluster) => {
-                        if (errCluster)
-                            return res.status(500).send(errCluster.message);
-
-                        mongo.Cache.update({space: {$in: space_ids}}, {clusters: []}, {multi: true}, (errCache) => {
-                            if (mongo.processed(errCache, res)) {
-                                mongo.Igfs.update({space: {$in: space_ids}}, {clusters: []}, {multi: true}, (errIgfs) => {
-                                    if (mongo.processed(errIgfs, res))
-                                        res.sendStatus(200);
-                                });
-                            }
-                        });
-                    });
-                }
-            });
+            mongo.spaces(req.currentUserId())
+                .then((spaces) => {
+                    spacesIds = spaces.map((value) => value._id);
+
+                    return mongo.Cluster.remove({space: {$in: spacesIds}});
+                })
+                .then(() => mongo.Cache.update({space: {$in: spacesIds}}, {clusters: []}, {multi: true}).exec())
+                .then(() => mongo.Igfs.update({space: {$in: spacesIds}}, {clusters: []}, {multi: true}).exec())
+                .then(() => res.sendStatus(200))
+                .catch((err) => mongo.handleError(res, err));
         });
 
-        resolve(router);
+        factoryResolve(router);
     });
 };

http://git-wip-us.apache.org/repos/asf/ignite/blob/389c6625/modules/control-center-web/src/main/js/serve/routes/domains.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/domains.js b/modules/control-center-web/src/main/js/serve/routes/domains.js
index 368258e..922fff2 100644
--- a/modules/control-center-web/src/main/js/serve/routes/domains.js
+++ b/modules/control-center-web/src/main/js/serve/routes/domains.js
@@ -21,11 +21,11 @@
 
 module.exports = {
     implements: 'domains-routes',
-    inject: ['require(lodash)', 'require(express)', 'require(async)', 'mongo']
+    inject: ['require(lodash)', 'require(express)', 'mongo']
 };
 
 module.exports.factory = function(_, express, async, mongo) {
-    return new Promise((resolve) => {
+    return new Promise((factoryResolve) => {
         const router = new express.Router();
 
         /**
@@ -35,251 +35,198 @@ module.exports.factory = function(_, express, async, mongo) {
          * @param res Response.
          */
         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}}}]}, (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((errCluster, clusters) => {
-                        if (mongo.processed(errCluster, res)) {
-                            // Get all caches for spaces.
-                            mongo.Cache.find({space: {$in: space_ids}}).sort('name').exec((errCache, caches) => {
-                                if (mongo.processed(errCache, res)) {
-                                    // Get all domain models for spaces.
-                                    mongo.DomainModel.find({space: {$in: space_ids}}).sort('valueType').exec((errDomainModel, domains) => {
-                                        if (mongo.processed(errDomainModel, res)) {
-                                            _.forEach(caches, (cache) => {
-                                                cache.domains = _.filter(cache.domains, (metaId) => {
-                                                    return _.find(domains, {_id: metaId});
-                                                });
-                                            });
-
-                                            // Remove deleted caches.
-                                            _.forEach(domains, (domain) => {
-                                                domain.caches = _.filter(domain.caches, (cacheId) => {
-                                                    return _.find(caches, {_id: cacheId});
-                                                });
-                                            });
-
-                                            res.json({
-                                                spaces,
-                                                clusters: clusters.map((cluster) => ({value: cluster._id, label: cluster.name})),
-                                                caches,
-                                                domains
-                                            });
-                                        }
-                                    });
-                                }
-                            });
-                        }
-                    });
-                }
-            });
+            const result = {};
+            let spacesIds = [];
+
+            mongo.spaces(req.currentUserId())
+                .then((spaces) => {
+                    result.spaces = spaces;
+                    spacesIds = spaces.map((value) => value._id);
+
+                    return mongo.Cluster.find({space: {$in: spacesIds}}, '_id name').sort('name').exec();
+                })
+                .then((clusters) => {
+                    result.clusters = clusters;
+
+                    return mongo.Cache.find({space: {$in: spacesIds}}).sort('name').exec();
+                })
+                .then((caches) => {
+                    result.caches = caches;
+
+                    return mongo.DomainModel.find({space: {$in: spacesIds}}).sort('valueType').exec();
+                })
+                .then((domains) => {
+                    result.domains = domains;
+
+                    res.json(result);
+                })
+                .catch((err) => mongo.handleError(res, err));
         });
 
-        function _saveDomainModel(domain, savedDomains, callback) {
-            const caches = domain.caches;
-            let domainId = domain._id;
-
-            const cacheStoreChanges = domain.cacheStoreChanges;
-
-            if (domainId) {
-                mongo.DomainModel.update({_id: domain._id}, domain, {upsert: true}, (errDomainModel) => {
-                    if (errDomainModel)
-                        callback(errDomainModel);
-                    else {
-                        mongo.Cache.update({_id: {$in: caches}}, {$addToSet: {domains: domainId}}, {multi: true}, (errCacheAdd) => {
-                            if (errCacheAdd)
-                                callback(errCacheAdd);
-                            else {
-                                mongo.Cache.update({_id: {$nin: caches}}, {$pull: {domains: domainId}}, {multi: true}, (errCachePull) => {
-                                    if (errCachePull)
-                                        callback(errCachePull);
-                                    else {
-                                        savedDomains.push(domain);
-
-                                        _updateCacheStore(cacheStoreChanges, callback);
-                                    }
-                                });
-                            }
-                        });
-                    }
-                });
-            }
-            else {
-                mongo.DomainModel.findOne({space: domain.space, valueType: domain.valueType}, (errDomainModelFind, found) => {
-                    if (errDomainModelFind)
-                        callback(errDomainModelFind);
-                    else if (found)
-                        return callback('Domain model with value type: "' + found.valueType + '" already exist.');
-
-                    (new mongo.DomainModel(domain)).save((errDomainModel, domainSaved) => {
-                        if (errDomainModel)
-                            callback(errDomainModel);
-                        else {
-                            domainId = domainSaved._id;
-
-                            mongo.Cache.update({_id: {$in: caches}}, {$addToSet: {domains: domainId}}, {multi: true}, (errCache) => {
-                                if (errCache)
-                                    callback(errCache);
-                                else {
-                                    savedDomains.push(domainSaved);
-
-                                    _updateCacheStore(cacheStoreChanges, callback);
-                                }
-                            });
-                        }
-                    });
-                });
-            }
-        }
-
-        function _updateCacheStore(cacheStoreChanges, callback) {
-            if (cacheStoreChanges && cacheStoreChanges.length > 0) {
-                async.forEachOf(cacheStoreChanges, (change, idx, cb) => {
-                    mongo.Cache.update({_id: {$eq: change.cacheId}}, change.change, {}, (err) => {
-                        if (err)
-                            cb(err);
-                        else
-                            cb();
-                    });
-                }, callback);
-            }
-            else
-                callback();
-        }
-
-        function _save(domains, res) {
-            const savedDomains = [];
-            const generatedCaches = [];
-
-            if (domains && domains.length > 0) {
-                async.forEachOf(domains, (domain, idx, callback) => {
-                    if (domain.newCache) {
-                        mongo.Cache.findOne({space: domain.space, name: domain.newCache.name}, (errCacheFind, cacheFound) => {
-                            if (mongo.processed(errCacheFind, res)) {
-                                if (cacheFound) {
-                                    // Cache already exists, just save domain model.
-                                    domain.caches = [cacheFound._id];
-
-                                    _saveDomainModel(domain, savedDomains, callback);
-                                }
-                                else {
-                                    // If cache not found, then create it and associate with domain model.
-                                    const newCache = domain.newCache;
-                                    newCache.space = domain.space;
-
-                                    (new mongo.Cache(newCache)).save((errCache, cache) => {
-                                        const cacheId = cache._id;
-
-                                        if (mongo.processed(errCache, res)) {
-                                            mongo.Cluster.update({_id: {$in: cache.clusters}}, {$addToSet: {caches: cacheId}}, {multi: true}, (errCluster) => {
-                                                if (mongo.processed(errCluster, res)) {
-                                                    domain.caches = [cacheId];
-                                                    generatedCaches.push(cache);
-
-                                                    _saveDomainModel(domain, savedDomains, callback);
-                                                }
-                                            });
-                                        }
-                                    });
-                                }
-                            }
-                        });
-                    }
-                    else
-                        _saveDomainModel(domain, savedDomains, callback);
-                }, (err) => {
-                    if (err)
-                        res.status(500).send(err.message);
-                    else
-                        res.send({savedDomains, generatedCaches});
-                });
-            }
-            else
-                res.status(500).send('Nothing to save!');
-        }
+        // function _saveDomainModel(domain, savedDomains, callback) {
+        //    const caches = domain.caches;
+        //    const cacheStoreChanges = domain.cacheStoreChanges;
+        //    let domainId = domain._id;
+        //
+        //    if (domainId) {
+        //        Promise.all([
+        //            mongo.DomainModel.update({_id: domain._id}, domain, {upsert: true}).exec(),
+        //            mongo.Cache.update({_id: {$in: caches}}, {$addToSet: {domains: domainId}}, {multi: true}).exec(),
+        //            mongo.Cache.update({_id: {$nin: caches}}, {$pull: {domains: domainId}}, {multi: true}).exec()
+        //        ]).then(() => {
+        //                savedDomains.push(domain);
+        //
+        //                _updateCacheStore(cacheStoreChanges, callback);
+        //        });
+        //    }
+        //    else {
+        //        mongo.DomainModel.findOne({space: domain.space, valueType: domain.valueType}).exec()
+        //            .then((found) => {
+        //                if (found)
+        //                    reject(new Error('Domain model with value type: "' + found.valueType + '" already exist.'));
+        //
+        //                return (new mongo.DomainModel(domain)).save();
+        //            })
+        //            .then((domainSaved) => {
+        //                savedDomains.push(domainSaved);
+        //
+        //                return mongo.Cache.update({_id: {$in: caches}}, {$addToSet: {domains: domainSaved._id}}, {multi: true}).exec();
+        //            }).then(() => _updateCacheStore(cacheStoreChanges));
+        //    }
+        // }
+
+        // function _updateCacheStore(cacheStoreChanges, callback) {
+        //    if (cacheStoreChanges && cacheStoreChanges.length > 0) {
+        //        async.forEachOf(cacheStoreChanges, (change, idx, cb) => {
+        //            mongo.Cache.update({_id: {$eq: change.cacheId}}, change.change, {}, (err) => {
+        //                if (err)
+        //                    cb(err);
+        //                else
+        //                    cb();
+        //            });
+        //        }, callback);
+        //    }
+        //    else
+        //        callback();
+        // }
+
+        // function _save(domains, res) {
+        //    if (domains && domains.length > 0) {
+        //        const savedDomains = [];
+        //        const generatedCaches = [];
+        //        const promises = [];
+        //
+        //        _.forEach(domains, (domain) => {
+        //            promises.push();
+        //        });
+        //
+        //        Promise.all(promises)
+        //            .then(() => res.send({savedDomains, generatedCaches}))
+        //            .catch((err) => mongo.handleError(res, err));
+        //
+        //        //async.forEachOf(domains, (domain, idx, callback) => {
+        //        //    if (domain.newCache) {
+        //        //        mongo.Cache.findOne({space: domain.space, name: domain.newCache.name}, (errCacheFind, cacheFound) => {
+        //        //            if (mongo.processed(errCacheFind, res)) {
+        //        //                if (cacheFound) {
+        //        //                    // Cache already exists, just save domain model.
+        //        //                    domain.caches = [cacheFound._id];
+        //        //
+        //        //                    _saveDomainModel(domain, savedDomains, callback);
+        //        //                }
+        //        //                else {
+        //        //                    // If cache not found, then create it and associate with domain model.
+        //        //                    const newCache = domain.newCache;
+        //        //                    newCache.space = domain.space;
+        //        //
+        //        //                    (new mongo.Cache(newCache)).save((errCache, cache) => {
+        //        //                        const cacheId = cache._id;
+        //        //
+        //        //                        if (mongo.processed(errCache, res)) {
+        //        //                            mongo.Cluster.update({_id: {$in: cache.clusters}}, {$addToSet: {caches: cacheId}}, {multi: true}, (errCluster) => {
+        //        //                                if (mongo.processed(errCluster, res)) {
+        //        //                                    domain.caches = [cacheId];
+        //        //                                    generatedCaches.push(cache);
+        //        //
+        //        //                                    _saveDomainModel(domain, savedDomains, callback);
+        //        //                                }
+        //        //                            });
+        //        //                        }
+        //        //                    });
+        //        //                }
+        //        //            }
+        //        //        });
+        //        //    }
+        //        //    else
+        //        //        _saveDomainModel(domain, savedDomains, callback);
+        //        //}
+        //    }
+        //    else
+        //        res.status(500).send('Nothing to save!');
+        // }
 
         /**
          * Save domain model.
          */
         router.post('/save', (req, res) => {
-            _save([req.body], res);
+            res.status(500).send('Not ready!');
+            // _save([req.body], res);
         });
 
         /**
          * Batch save domain models.
          */
         router.post('/save/batch', (req, res) => {
-            _save(req.body, res);
+            res.status(500).send('Not ready!');
+            // _save(req.body, res);
         });
 
         /**
          * Remove domain model by ._id.
          */
         router.post('/remove', (req, res) => {
-            mongo.DomainModel.remove(req.body, (err) => {
-                if (mongo.processed(err, res))
-                    res.sendStatus(200);
-            });
+            mongo.DomainModel.remove(req.body)
+                .then(() => res.sendStatus(200))
+                .catch((err) => mongo.handleError(res, err));
         });
 
         /**
          * Remove all domain models.
          */
         router.post('/remove/all', (req, res) => {
-            const user_id = req.currentUserId();
+            let spacesIds = [];
 
-            // Get owned space and all accessed space.
-            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.spaces(req.currentUserId())
+                .then((spaces) => {
+                    spacesIds = spaces.map((value) => value._id);
 
-                    mongo.DomainModel.remove({space: {$in: space_ids}}, (errDomainModel) => {
-                        if (errDomainModel)
-                            return res.status(500).send(errDomainModel.message);
-
-                        mongo.Cache.update({space: {$in: space_ids}}, {domains: []}, {multi: true}, (errCache) => {
-                            if (mongo.processed(errCache, res))
-                                res.sendStatus(200);
-                        });
-                    });
-                }
-            });
+                    return mongo.Cache.update({space: {$in: spacesIds}}, {domains: []}, {multi: true}).exec();
+                })
+                .then(() => mongo.DomainModel.remove({space: {$in: spacesIds}}).exec())
+                .then(() => res.sendStatus(200))
+                .catch((err) => mongo.handleError(res, err));
         });
 
         /**
          * Remove all generated demo domain models and caches.
          */
         router.post('/remove/demo', (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}}}]}, (errSpace, spaces) => {
-                if (mongo.processed(errSpace, res)) {
-                    const space_ids = spaces.map((value) => value._id);
+            let spacesIds = [];
 
-                    // Remove all demo domain models.
-                    mongo.DomainModel.remove({$and: [{space: {$in: space_ids}}, {demo: true}]}, (errDomainModel) => {
-                        if (errDomainModel)
-                            return res.status(500).send(errDomainModel.message);
+            // TODO IGNITE-843 also remove from links: Cache -> DomainModel ; DomainModel -> Cache; Cluster -> Cache.
 
-                        // Remove all demo caches.
-                        mongo.Cache.remove({$and: [{space: {$in: space_ids}}, {demo: true}]}, (errCache) => {
-                            if (errCache)
-                                return res.status(500).send(errCache.message);
+            mongo.spaces(req.currentUserId())
+                .then((spaces) => {
+                    spacesIds = spaces.map((value) => value._id);
 
-                            res.sendStatus(200);
-                        });
-                    });
-                }
-            });
+                    return mongo.DomainModel.remove({$and: [{space: {$in: spacesIds}}, {demo: true}]});
+                })
+                .then(() => mongo.Cache.remove({$and: [{space: {$in: spacesIds}}, {demo: true}]}))
+                .then(() => res.sendStatus(200))
+                .catch((err) => mongo.handleError(res, err));
         });
 
-        resolve(router);
+        factoryResolve(router);
     });
 };
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/389c6625/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 7508f9a..1df089e 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
@@ -25,7 +25,7 @@ module.exports = {
 };
 
 module.exports.factory = function(_, express, mongo) {
-    return new Promise((resolve) => {
+    return new Promise((factoryResolve) => {
         const router = new express.Router();
 
         /**
@@ -36,31 +36,27 @@ module.exports.factory = function(_, express, mongo) {
          */
         router.post('/list', (req, res) => {
             const result = {};
+            let spacesIds = [];
 
             // Get owned space and all accessed space.
-            mongo.Space.find({$or: [{owner: req.currentUserId()}, {usedBy: {$elemMatch: {account: req.currentUserId()}}}]}).exec()
+            mongo.spaces(req.currentUserId())
                 .then((spaces) => {
                     result.spaces = spaces;
-                    result.spacesIds = spaces.map((value) => value._id);
+                    spacesIds = spaces.map((value) => value._id);
 
-                    return mongo.Cluster.find({space: {$in: result.spacesIds}}, '_id name').sort('name').exec();
+                    return mongo.Cluster.find({space: {$in: spacesIds}}, '_id name').sort('name').exec();
                 })
                 .then((clusters) => {
                     result.clusters = clusters;
 
-                    return mongo.Igfs.find({space: {$in: result.spacesIds}}).sort('name').exec();
+                    return mongo.Igfs.find({space: {$in: spacesIds}}).sort('name').exec();
                 })
                 .then((igfss) => {
-                    res.json({
-                        spaces: result.spaces,
-                        clusters: result.clusters.map((cluster) => ({value: cluster._id, label: cluster.name})),
-                        igfss
-                    });
+                    result.igfss = igfss;
+
+                    res.json(result);
                 })
-                .catch((err) => {
-                    // TODO IGNITE-843 Send error to admin
-                    res.status(500).send(err.message);
-                });
+                .catch((err) => mongo.handleError(res, err));
         });
 
         /**
@@ -69,7 +65,6 @@ module.exports.factory = function(_, express, mongo) {
         router.post('/save', (req, res) => {
             const params = req.body;
             const clusters = params.clusters;
-
             let igfsId = params._id;
 
             if (params._id) {
@@ -77,10 +72,7 @@ module.exports.factory = function(_, express, mongo) {
                     .then(() => mongo.Cluster.update({_id: {$in: clusters}}, {$addToSet: {igfss: igfsId}}, {multi: true}).exec())
                     .then(() => mongo.Cluster.update({_id: {$nin: clusters}}, {$pull: {igfss: igfsId}}, {multi: true}).exec())
                     .then(() => res.send(igfsId))
-                    .catch((err) => {
-                        // TODO IGNITE-843 Send error to admin
-                        res.status(500).send(err.message);
-                    });
+                    .catch((err) => mongo.handleError(res, err));
             }
             else {
                 mongo.Igfs.findOne({space: params.space, name: params.name}).exec()
@@ -96,10 +88,7 @@ module.exports.factory = function(_, express, mongo) {
                         return mongo.Cluster.update({_id: {$in: clusters}}, {$addToSet: {igfss: igfsId}}, {multi: true});
                     })
                     .then(() => res.send(igfsId))
-                    .catch((err) => {
-                        // TODO IGNITE-843 Send error to admin
-                        res.status(500).send(err.message);
-                    });
+                    .catch((err) => mongo.handleError(res, err));
             }
         });
 
@@ -107,26 +96,23 @@ module.exports.factory = function(_, express, mongo) {
          * Remove IGFS by ._id.
          */
         router.post('/remove', (req, res) => {
-            const igfsId = req.body;
+            const params = req.body;
+            const igfsId = params._id;
 
             mongo.Cluster.update({igfss: {$in: [igfsId]}}, {$pull: {igfss: igfsId}}, {multi: true}).exec()
-                .then(mongo.Igfs.remove(igfsId))
+                .then(mongo.Igfs.remove(params))
                 .then(() => res.sendStatus(200))
-                .catch((err) => {
-                    // TODO IGNITE-843 Send error to admin
-                    res.status(500).send(err.message);
-                });
+                .catch((err) => mongo.handleError(res, err));
         });
 
         /**
          * Remove all IGFSs.
          */
         router.post('/remove/all', (req, res) => {
-            const userId = req.currentUserId();
             let spacesIds = [];
 
             // Get owned space and all accessed space.
-            mongo.Space.find({$or: [{owner: userId}, {usedBy: {$elemMatch: {account: userId}}}]})
+            mongo.spaces(req.currentUserId())
                 .then((spaces) => {
                     spacesIds = spaces.map((value) => value._id);
 
@@ -134,13 +120,10 @@ module.exports.factory = function(_, express, mongo) {
                 })
                 .then(() => mongo.Cluster.update({space: {$in: spacesIds}}, {igfss: []}, {multi: true}))
                 .then(() => res.sendStatus(200))
-                .catch((err) => {
-                    // TODO IGNITE-843 Send error to admin
-                    res.status(500).send(err.message);
-                });
+                .catch((err) => mongo.handleError(res, err));
         });
 
-        resolve(router);
+        factoryResolve(router);
     });
 };
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/389c6625/modules/control-center-web/src/main/js/serve/routes/notebooks.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/notebooks.js b/modules/control-center-web/src/main/js/serve/routes/notebooks.js
index e65f77d..5070bcc 100644
--- a/modules/control-center-web/src/main/js/serve/routes/notebooks.js
+++ b/modules/control-center-web/src/main/js/serve/routes/notebooks.js
@@ -25,7 +25,7 @@ module.exports = {
 };
 
 module.exports.factory = function(express, mongo) {
-    return new Promise((resolve) => {
+    return new Promise((factoryResolve) => {
         const router = new express.Router();
 
         /**
@@ -35,23 +35,11 @@ module.exports.factory = function(express, mongo) {
          * @param res Response.
          */
         router.post('/list', (req, res) => {
-            const user_id = req.currentUserId();
+            mongo.spaces(req.currentUserId())
+                .then((spaces) => mongo.Notebook.find({space: {$in: spaces.map((value) => value._id)}}).select('_id name').sort('name').exec())
+                .then((notebooks) => res.json(notebooks))
+                .catch((err) => mongo.handleError(res, err));
 
-            // Get owned space and all accessed space.
-            mongo.Space.find({$or: [{owner: user_id}, {usedBy: {$elemMatch: {account: user_id}}}]}, (errSpace, spaces) => {
-                if (errSpace)
-                    return res.status(500).send(errSpace.message);
-
-                const space_ids = spaces.map((value) => value._id);
-
-                // Get all metadata for spaces.
-                mongo.Notebook.find({space: {$in: space_ids}}).select('_id name').sort('name').exec((errNotebook, notebooks) => {
-                    if (errNotebook)
-                        return res.status(500).send(errNotebook.message);
-
-                    res.json(notebooks);
-                });
-            });
         });
 
         /**
@@ -61,23 +49,10 @@ module.exports.factory = function(express, mongo) {
          * @param res Response.
          */
         router.post('/get', (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}}}]}, (errSpace, spaces) => {
-                if (errSpace)
-                    return res.status(500).send(errSpace.message);
-
-                const space_ids = spaces.map((value) => value._id);
-
-                // Get all metadata for spaces.
-                mongo.Notebook.findOne({space: {$in: space_ids}, _id: req.body.noteId}).exec((errNotebook, notebook) => {
-                    if (errNotebook)
-                        return res.status(500).send(errNotebook.message);
-
-                    res.json(notebook);
-                });
-            });
+            mongo.spaces(req.currentUserId())
+                .then((spaces) => mongo.Notebook.findOne({space: {$in: spaces.map((value) => value._id)}, _id: req.body.noteId}).exec())
+                .then((notebook) => res.json(notebook))
+                .catch((err) => mongo.handleError(res, err));
         });
 
         /**
@@ -91,28 +66,20 @@ module.exports.factory = function(express, mongo) {
             const noteId = note._id;
 
             if (noteId) {
-                mongo.Notebook.update({_id: noteId}, note, {upsert: true}, (err) => {
-                    if (err)
-                        return res.status(500).send(err.message);
-
-                    res.send(noteId);
-                });
+                mongo.Notebook.update({_id: noteId}, note, {upsert: true}).exec()
+                    .then(() => res.send(noteId))
+                    .catch((err) => mongo.handleError(res, err));
             }
             else {
-                mongo.Notebook.findOne({space: note.space, name: note.name}, (errNotebookFind, notebookFoud) => {
-                    if (errNotebookFind)
-                        return res.status(500).send(errNotebookFind.message);
-
-                    if (notebookFoud)
-                        return res.status(500).send('Notebook with name: "' + notebookFoud.name + '" already exist.');
-
-                    (new mongo.Notebook(req.body)).save((errNotebook, noteNew) => {
-                        if (errNotebook)
-                            return res.status(500).send(errNotebook.message);
-
-                        res.send(noteNew._id);
-                    });
-                });
+                mongo.Notebook.findOne({space: note.space, name: note.name}).exec()
+                    .then((notebook) => {
+                        if (notebook)
+                            throw new Error('Notebook with name: "' + notebook.name + '" already exist.');
+
+                        return (new mongo.Notebook(req.body)).save();
+                    })
+                    .then((notebook) => res.send(notebook._id))
+                    .catch((err) => mongo.handleError(res, err));
             }
         });
 
@@ -123,12 +90,9 @@ module.exports.factory = function(express, mongo) {
          * @param res Response.
          */
         router.post('/remove', (req, res) => {
-            mongo.Notebook.remove(req.body, (err) => {
-                if (err)
-                    return res.status(500).send(err.message);
-
-                res.sendStatus(200);
-            });
+            mongo.Notebook.remove(req.body)
+                .then(() => res.sendStatus(200))
+                .catch((err) => mongo.handleError(res, err));
         });
 
         /**
@@ -138,22 +102,12 @@ module.exports.factory = function(express, mongo) {
          * @param res Response.
          */
         router.post('/new', (req, res) => {
-            const user_id = req.currentUserId();
-
-            // Get owned space and all accessed space.
-            mongo.Space.findOne({owner: user_id}, (errSpace, space) => {
-                if (errSpace)
-                    return res.status(500).send(errSpace.message);
-
-                (new mongo.Notebook({space: space.id, name: req.body.name})).save((errNotebook, note) => {
-                    if (errNotebook)
-                        return res.status(500).send(errNotebook.message);
-
-                    return res.send(note._id);
-                });
-            });
+            mongo.spaces(req.currentUserId())
+                .then((spaces) => (new mongo.Notebook({space: spaces[0].id, name: req.body.name})).save())
+                .then((notebook) => res.send(notebook._id))
+                .catch((err) => mongo.handleError(res, err));
         });
 
-        resolve(router);
+        factoryResolve(router);
     });
 };

http://git-wip-us.apache.org/repos/asf/ignite/blob/389c6625/modules/control-center-web/src/main/js/serve/routes/profile.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/profile.js b/modules/control-center-web/src/main/js/serve/routes/profile.js
index d611df4..6b166fd 100644
--- a/modules/control-center-web/src/main/js/serve/routes/profile.js
+++ b/modules/control-center-web/src/main/js/serve/routes/profile.js
@@ -31,7 +31,7 @@ module.exports.factory = function(_, express, mongo) {
         /**
          * Save user profile.
          */
-        router.post('/save', function(req, res) {
+        router.post('/save', (req, res) => {
             const params = req.body;
 
             if (params.password && _.isEmpty(params.password))
@@ -79,10 +79,7 @@ module.exports.factory = function(_, express, mongo) {
                     return user.save();
                 })
                 .then(() => res.sendStatus(200))
-                .catch((err) => {
-                    // TODO IGNITE-843 Send error to admin
-                    res.status(500).send(err.message);
-                });
+                .catch((err) => mongo.handleError(res, err));
         });
 
         resolveFactory(router);

http://git-wip-us.apache.org/repos/asf/ignite/blob/389c6625/modules/control-center-web/src/main/js/serve/routes/public.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/public.js b/modules/control-center-web/src/main/js/serve/routes/public.js
index 829e9d6..b83208d 100644
--- a/modules/control-center-web/src/main/js/serve/routes/public.js
+++ b/modules/control-center-web/src/main/js/serve/routes/public.js
@@ -25,7 +25,7 @@ module.exports = {
 };
 
 module.exports.factory = function(express, passport, nodemailer, settings, mongo) {
-    return new Promise(function(factoryResolve) {
+    return new Promise((factoryResolve) => {
         const router = new express.Router();
 
         const _randomString = () => {
@@ -77,7 +77,7 @@ module.exports.factory = function(express, passport, nodemailer, settings, mongo
         };
 
         // GET user.
-        router.post('/user', function(req, res) {
+        router.post('/user', (req, res) => {
             const becomeUsed = req.session.viewedUser && req.user.admin;
 
             let user = req.user;
@@ -94,7 +94,7 @@ module.exports.factory = function(express, passport, nodemailer, settings, mongo
         /**
          * Register new account.
          */
-        router.post('/signup', function(req, res) {
+        router.post('/signup', (req, res) => {
             mongo.Account.count().exec()
                 .then((cnt) => {
                     req.body.admin = cnt === 0;
@@ -155,15 +155,15 @@ module.exports.factory = function(express, passport, nodemailer, settings, mongo
         /**
          * Login in exist account.
          */
-        router.post('/signin', function(req, res, next) {
-            passport.authenticate('local', function(errAuth, user) {
+        router.post('/signin', (req, res, next) => {
+            passport.authenticate('local', (errAuth, user) => {
                 if (errAuth)
                     return res.status(401).send(errAuth.message);
 
                 if (!user)
                     return res.status(401).send('Invalid email or password');
 
-                req.logIn(user, {}, function(errLogIn) {
+                req.logIn(user, {}, (errLogIn) => {
                     if (errLogIn)
                         return res.status(401).send(errLogIn.message);
 
@@ -175,7 +175,7 @@ module.exports.factory = function(express, passport, nodemailer, settings, mongo
         /**
          * Logout.
          */
-        router.post('/logout', function(req, res) {
+        router.post('/logout', (req, res) => {
             req.logout();
 
             res.sendStatus(200);
@@ -184,7 +184,7 @@ module.exports.factory = function(express, passport, nodemailer, settings, mongo
         /**
          * Send e-mail to user with reset token.
          */
-        router.post('/password/forgot', function(req, res) {
+        router.post('/password/forgot', (req, res) => {
             mongo.Account.findOne({email: req.body.email}).exec()
                 .then((user) => {
                     if (!user)
@@ -212,7 +212,7 @@ module.exports.factory = function(express, passport, nodemailer, settings, mongo
         /**
          * Change password with given token.
          */
-        router.post('/password/reset', function(req, res) {
+        router.post('/password/reset', (req, res) => {
             mongo.Account.findOne({resetPasswordToken: req.body.token}).exec()
                 .then((user) => {
                     return new Promise((resolve, reject) => {
@@ -243,7 +243,7 @@ module.exports.factory = function(express, passport, nodemailer, settings, mongo
         });
 
         /* GET reset password page. */
-        router.post('/password/validate/token', function(req, res) {
+        router.post('/password/validate/token', (req, res) => {
             const token = req.body.token;
 
             mongo.Account.findOne({resetPasswordToken: token}).exec()


[28/50] ignite git commit: IGNITE-843 WIP Rework server side to Promises.

Posted by ak...@apache.org.
IGNITE-843 WIP Rework server side to Promises.


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

Branch: refs/heads/ignite-843-rc3
Commit: 63bd2c0a34581faa36c5e2b12e89ce9026a399b5
Parents: 3fc013a
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Tue Feb 16 10:39:41 2016 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Tue Feb 16 10:39:41 2016 +0700

----------------------------------------------------------------------
 .../main/js/controllers/caches-controller.js    |   8 +-
 .../main/js/controllers/domains-controller.js   |  14 +-
 .../src/main/js/serve/routes/clusters.js        |  11 +
 .../src/main/js/serve/routes/domains.js         | 203 +++++++++----------
 4 files changed, 127 insertions(+), 109 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/63bd2c0a/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 c1837c8..4a8ee53 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
@@ -296,7 +296,13 @@ consoleModule.controller('cachesController', [
                 });
 
                 $scope.caches = data.caches;
-                $scope.clusters = data.clusters;
+                $scope.clusters = _.map(data.clusters, function (cluster) {
+                    return {
+                        value: cluster._id,
+                        label: cluster.name,
+                        caches: cluster.caches
+                    };
+                });
                 $scope.domains = _.sortBy(_.map(validFilter(data.domains, true, false), function (domain) {
                     return {
                         value: domain._id,

http://git-wip-us.apache.org/repos/asf/ignite/blob/63bd2c0a/modules/control-center-web/src/main/js/controllers/domains-controller.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/controllers/domains-controller.js b/modules/control-center-web/src/main/js/controllers/domains-controller.js
index 03ebd97..142e76c 100644
--- a/modules/control-center-web/src/main/js/controllers/domains-controller.js
+++ b/modules/control-center-web/src/main/js/controllers/domains-controller.js
@@ -83,7 +83,12 @@ consoleModule.controller('domainsController', function ($filter, $http, $timeout
                             $http.post('/api/v1/configuration/domains/list')
                                 .success(function (data) {
                                     $scope.spaces = data.spaces;
-                                    $scope.clusters = data.clusters;
+                                    $scope.clusters = _.map(data.clusters, function (cluster) {
+                                        return {
+                                            value: cluster._id,
+                                            label: cluster.name
+                                        };
+                                    });
                                     $scope.caches = _mapCaches(data.caches);
                                     $scope.domains = data.domains;
 
@@ -1137,7 +1142,12 @@ consoleModule.controller('domainsController', function ($filter, $http, $timeout
         $http.post('/api/v1/configuration/domains/list')
             .success(function (data) {
                 $scope.spaces = data.spaces;
-                $scope.clusters = data.clusters;
+                $scope.clusters = _.map(data.clusters, function (cluster) {
+                    return {
+                        value: cluster._id,
+                        label: cluster.name
+                    };
+                });
                 $scope.caches = _mapCaches(data.caches);
                 $scope.domains = data.domains;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/63bd2c0a/modules/control-center-web/src/main/js/serve/routes/clusters.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/clusters.js b/modules/control-center-web/src/main/js/serve/routes/clusters.js
index c4260db..a04844a 100644
--- a/modules/control-center-web/src/main/js/serve/routes/clusters.js
+++ b/modules/control-center-web/src/main/js/serve/routes/clusters.js
@@ -43,9 +43,20 @@ module.exports.factory = function(_, express, mongo) {
                     result.spaces = spaces;
                     spacesIds = mongo.spacesIds(spaces);
 
+                    return mongo.DomainModel.find({space: {$in: spacesIds}}).sort('valueType').exec();
+                })
+                .then((domains) => {
+                    result.domains = domains;
+
                     return mongo.Cache.find({space: {$in: spacesIds}}).sort('name').exec();
                 })
                 .then((caches) => {
+                    _.forEach(caches, (cache) => {
+                        cache.domains = _.map(cache.domains, (domainId) => {
+                            return _.find(result.domains, {_id: domainId});
+                        });
+                    });
+
                     result.caches = caches;
 
                     return mongo.Igfs.find({space: {$in: spacesIds}}).sort('name').exec();

http://git-wip-us.apache.org/repos/asf/ignite/blob/63bd2c0a/modules/control-center-web/src/main/js/serve/routes/domains.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/domains.js b/modules/control-center-web/src/main/js/serve/routes/domains.js
index 3dc2116..f757910 100644
--- a/modules/control-center-web/src/main/js/serve/routes/domains.js
+++ b/modules/control-center-web/src/main/js/serve/routes/domains.js
@@ -24,7 +24,7 @@ module.exports = {
     inject: ['require(lodash)', 'require(express)', 'mongo']
 };
 
-module.exports.factory = function(_, express, async, mongo) {
+module.exports.factory = function(_, express, mongo) {
     return new Promise((factoryResolve) => {
         const router = new express.Router();
 
@@ -63,122 +63,113 @@ module.exports.factory = function(_, express, async, mongo) {
                 .catch((err) => mongo.handleError(res, err));
         });
 
-        // function _saveDomainModel(domain, savedDomains, callback) {
-        //    const caches = domain.caches;
-        //    const cacheStoreChanges = domain.cacheStoreChanges;
-        //    let domainId = domain._id;
-        //
-        //    if (domainId) {
-        //        Promise.all([
-        //            mongo.DomainModel.update({_id: domain._id}, domain, {upsert: true}).exec(),
-        //            mongo.Cache.update({_id: {$in: caches}}, {$addToSet: {domains: domainId}}, {multi: true}).exec(),
-        //            mongo.Cache.update({_id: {$nin: caches}}, {$pull: {domains: domainId}}, {multi: true}).exec()
-        //        ]).then(() => {
-        //                savedDomains.push(domain);
-        //
-        //                _updateCacheStore(cacheStoreChanges, callback);
-        //        });
-        //    }
-        //    else {
-        //        mongo.DomainModel.findOne({space: domain.space, valueType: domain.valueType}).exec()
-        //            .then((found) => {
-        //                if (found)
-        //                    reject(new Error('Domain model with value type: "' + found.valueType + '" already exist.'));
-        //
-        //                return (new mongo.DomainModel(domain)).save();
-        //            })
-        //            .then((domainSaved) => {
-        //                savedDomains.push(domainSaved);
-        //
-        //                return mongo.Cache.update({_id: {$in: caches}}, {$addToSet: {domains: domainSaved._id}}, {multi: true}).exec();
-        //            }).then(() => _updateCacheStore(cacheStoreChanges));
-        //    }
-        // }
-
-        // function _updateCacheStore(cacheStoreChanges, callback) {
-        //    if (cacheStoreChanges && cacheStoreChanges.length > 0) {
-        //        async.forEachOf(cacheStoreChanges, (change, idx, cb) => {
-        //            mongo.Cache.update({_id: {$eq: change.cacheId}}, change.change, {}, (err) => {
-        //                if (err)
-        //                    cb(err);
-        //                else
-        //                    cb();
-        //            });
-        //        }, callback);
-        //    }
-        //    else
-        //        callback();
-        // }
-
-        // function _save(domains, res) {
-        //    if (domains && domains.length > 0) {
-        //        const savedDomains = [];
-        //        const generatedCaches = [];
-        //        const promises = [];
-        //
-        //        _.forEach(domains, (domain) => {
-        //            promises.push();
-        //        });
-        //
-        //        Promise.all(promises)
-        //            .then(() => res.send({savedDomains, generatedCaches}))
-        //            .catch((err) => mongo.handleError(res, err));
-        //
-        //        //async.forEachOf(domains, (domain, idx, callback) => {
-        //        //    if (domain.newCache) {
-        //        //        mongo.Cache.findOne({space: domain.space, name: domain.newCache.name}, (errCacheFind, cacheFound) => {
-        //        //            if (mongo.processed(errCacheFind, res)) {
-        //        //                if (cacheFound) {
-        //        //                    // Cache already exists, just save domain model.
-        //        //                    domain.caches = [cacheFound._id];
-        //        //
-        //        //                    _saveDomainModel(domain, savedDomains, callback);
-        //        //                }
-        //        //                else {
-        //        //                    // If cache not found, then create it and associate with domain model.
-        //        //                    const newCache = domain.newCache;
-        //        //                    newCache.space = domain.space;
-        //        //
-        //        //                    (new mongo.Cache(newCache)).save((errCache, cache) => {
-        //        //                        const cacheId = cache._id;
-        //        //
-        //        //                        if (mongo.processed(errCache, res)) {
-        //        //                            mongo.Cluster.update({_id: {$in: cache.clusters}}, {$addToSet: {caches: cacheId}}, {multi: true}, (errCluster) => {
-        //        //                                if (mongo.processed(errCluster, res)) {
-        //        //                                    domain.caches = [cacheId];
-        //        //                                    generatedCaches.push(cache);
-        //        //
-        //        //                                    _saveDomainModel(domain, savedDomains, callback);
-        //        //                                }
-        //        //                            });
-        //        //                        }
-        //        //                    });
-        //        //                }
-        //        //            }
-        //        //        });
-        //        //    }
-        //        //    else
-        //        //        _saveDomainModel(domain, savedDomains, callback);
-        //        //}
-        //    }
-        //    else
-        //        res.status(500).send('Nothing to save!');
-        // }
+        function _updateCacheStore(cacheStoreChanges) {
+            const promises = [];
+
+            _.forEach(cacheStoreChanges, (change) =>
+                promises.push(mongo.Cache.update({_id: {$eq: change.cacheId}}, change.change, {}).exec())
+            );
+
+            return Promise.all(promises);
+        }
+
+        function _saveDomainModel(domain, savedDomains) {
+            return new Promise((resolve) => {
+                const caches = domain.caches;
+                const cacheStoreChanges = domain.cacheStoreChanges;
+                const domainId = domain._id;
+
+                if (domainId) {
+                    mongo.DomainModel.update({_id: domain._id}, domain, {upsert: true}).exec()
+                        .then(() => mongo.Cache.update({_id: {$in: caches}}, {$addToSet: {domains: domainId}}, {multi: true}).exec())
+                        .then(() => mongo.Cache.update({_id: {$nin: caches}}, {$pull: {domains: domainId}}, {multi: true}).exec())
+                        .then(() => {
+                            savedDomains.push(domain);
+
+                            _updateCacheStore(cacheStoreChanges);
+                        })
+                        .then(() => resolve());
+                }
+                else {
+                    mongo.DomainModel.findOne({space: domain.space, valueType: domain.valueType}).exec()
+                        .then((found) => {
+                            if (found)
+                                throw new Error('Domain model with value type: "' + found.valueType + '" already exist.');
+
+                            return (new mongo.DomainModel(domain)).save();
+                        })
+                        .then((savedDomain) => {
+                            savedDomains.push(savedDomain);
+
+                            return mongo.Cache.update({_id: {$in: caches}}, {$addToSet: {domains: savedDomain._id}}, {multi: true}).exec();
+                        })
+                        .then(() => _updateCacheStore(cacheStoreChanges))
+                        .then(() => resolve());
+                }
+            });
+        }
+
+        function _save(domains, res) {
+            if (domains && domains.length > 0) {
+                const savedDomains = [];
+                const generatedCaches = [];
+                const promises = [];
+
+                _.forEach(domains, (domain) => {
+                    promises.push(new Promise((resolve) => {
+                        if (domain.newCache) {
+                            mongo.Cache.findOne({space: domain.space, name: domain.newCache.name}).exec()
+                                .then((cache) => {
+                                    if (cache) {
+                                        // Cache already exists, just save domain model.
+                                        domain.caches = [cache._id];
+
+                                        _saveDomainModel(domain, savedDomains).then(() => resolve());
+                                    }
+                                    else {
+                                        // If cache not found, then create it and associate with domain model.
+                                        const newCache = domain.newCache;
+                                        newCache.space = domain.space;
+
+                                        (new mongo.Cache(newCache)).save()
+                                            .then((generatedCache) => {
+                                                const cacheId = generatedCache._id;
+
+                                                generatedCaches.push(generatedCache);
+
+                                                domain.caches = [cacheId];
+
+                                                return mongo.Cluster.update({_id: {$in: generatedCache.clusters}}, {$addToSet: {caches: cacheId}}, {multi: true}).exec();
+                                            })
+                                            .then(() => _saveDomainModel(domain, savedDomains).then(() => resolve()));
+                                    }
+                                });
+                        }
+                        else
+                            _saveDomainModel(domain, savedDomains).then(() => resolve());
+                    }));
+                });
+
+                Promise.all(promises)
+                    .then(() => res.send({savedDomains, generatedCaches}))
+                    .catch((err) => mongo.handleError(res, err));
+            }
+            else
+                res.status(500).send('Nothing to save!');
+        }
 
         /**
          * Save domain model.
          */
         router.post('/save', (req, res) => {
-            res.status(500).send('Not ready!');
-            // _save([req.body], res);
+            _save([req.body], res);
         });
 
         /**
          * Batch save domain models.
          */
         router.post('/save/batch', (req, res) => {
-            res.status(500).send('Not ready!');
-            // _save(req.body, res);
+            _save(req.body, res);
         });
 
         /**


[31/50] ignite git commit: Merge remote-tracking branch 'origin/ignite-843-rc2' into ignite-843-rc2

Posted by ak...@apache.org.
Merge remote-tracking branch 'origin/ignite-843-rc2' into ignite-843-rc2


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

Branch: refs/heads/ignite-843-rc3
Commit: f80a0384e72d49721b779d8d30fcb7e7882c00c2
Parents: 4287320 3e9942e
Author: Andrey <an...@gridgain.com>
Authored: Tue Feb 16 11:42:45 2016 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Tue Feb 16 11:42:45 2016 +0700

----------------------------------------------------------------------
 .../src/main/js/controllers/igfs-controller.js                | 7 ++++++-
 modules/control-center-web/src/main/js/serve/routes/caches.js | 2 +-
 .../control-center-web/src/main/js/serve/routes/clusters.js   | 4 ++--
 .../control-center-web/src/main/js/serve/routes/domains.js    | 7 ++++++-
 4 files changed, 15 insertions(+), 5 deletions(-)
----------------------------------------------------------------------



[26/50] ignite git commit: IGNITE-843 WIP rework server side to promises.

Posted by ak...@apache.org.
IGNITE-843 WIP rework server side to promises.


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

Branch: refs/heads/ignite-843-rc3
Commit: ba69d6345734445457f90bd705f8835862b82465
Parents: 389c662
Author: AKuznetsov <ak...@gridgain.com>
Authored: Tue Feb 16 07:09:54 2016 +0700
Committer: AKuznetsov <ak...@gridgain.com>
Committed: Tue Feb 16 07:09:54 2016 +0700

----------------------------------------------------------------------
 modules/control-center-web/src/main/js/serve/routes/admin.js | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/ba69d634/modules/control-center-web/src/main/js/serve/routes/admin.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/admin.js b/modules/control-center-web/src/main/js/serve/routes/admin.js
index 0736277..50488b1 100644
--- a/modules/control-center-web/src/main/js/serve/routes/admin.js
+++ b/modules/control-center-web/src/main/js/serve/routes/admin.js
@@ -40,9 +40,14 @@ module.exports.factory = function(_, express, nodemailer, settings, mongo) {
         // Remove user.
         router.post('/remove', (req, res) => {
             const userId = req.body.userId;
+            let user = {};
 
             mongo.Account.findByIdAndRemove(userId).exec()
-                .then(() => mongo.spaces(userId))
+                .then((removedUser) => {
+                    user = removedUser;
+
+                    return mongo.spaces(userId);
+                })
                 .then((spaces) => {
                     const promises = [];
 


[27/50] ignite git commit: IGNITE-843 WIP rework server side to promises.

Posted by ak...@apache.org.
IGNITE-843 WIP rework server side to promises.


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

Branch: refs/heads/ignite-843-rc3
Commit: 3fc013ae481df5df795f35bd5d3e017f310afdf6
Parents: ba69d63
Author: AKuznetsov <ak...@gridgain.com>
Authored: Tue Feb 16 07:57:26 2016 +0700
Committer: AKuznetsov <ak...@gridgain.com>
Committed: Tue Feb 16 07:57:26 2016 +0700

----------------------------------------------------------------------
 modules/control-center-web/src/main/js/serve/mongo.js     | 10 ++++++++++
 .../control-center-web/src/main/js/serve/routes/caches.js |  4 ++--
 .../src/main/js/serve/routes/clusters.js                  |  4 ++--
 .../src/main/js/serve/routes/domains.js                   |  6 +++---
 .../control-center-web/src/main/js/serve/routes/igfs.js   |  4 ++--
 5 files changed, 19 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/3fc013ae/modules/control-center-web/src/main/js/serve/mongo.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/mongo.js b/modules/control-center-web/src/main/js/serve/mongo.js
index 83d3b67..5dc1209 100644
--- a/modules/control-center-web/src/main/js/serve/mongo.js
+++ b/modules/control-center-web/src/main/js/serve/mongo.js
@@ -544,6 +544,16 @@ module.exports.factory = function(deepPopulatePlugin, passportMongo, settings, p
         return result.Space.find({owner: userId}).exec();
     };
 
+    /**
+     * Extract IDs from user spaces.
+     *
+     * @param spaces Array of user spaces.
+     * @returns {Array} of spaces ID.
+     */
+    result.spacesIds = function(spaces) {
+        return spaces.map((value) => value._id);
+    };
+
     // Registering the routes of all plugin modules
     for (const name in pluginMongo) {
         if (pluginMongo.hasOwnProperty(name))

http://git-wip-us.apache.org/repos/asf/ignite/blob/3fc013ae/modules/control-center-web/src/main/js/serve/routes/caches.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/caches.js b/modules/control-center-web/src/main/js/serve/routes/caches.js
index 77c3943..581b5f7 100644
--- a/modules/control-center-web/src/main/js/serve/routes/caches.js
+++ b/modules/control-center-web/src/main/js/serve/routes/caches.js
@@ -42,7 +42,7 @@ module.exports.factory = function(_, express, mongo) {
             mongo.spaces(req.currentUserId())
                 .then((spaces) => {
                     result.spaces = spaces;
-                    spacesIds = spaces.map((value) => value._id);
+                    spacesIds = mongo.spacesIds(spaces);
 
                     return mongo.Cluster.find({space: {$in: result.spacesIds}}).sort('name').exec();
                 })
@@ -123,7 +123,7 @@ module.exports.factory = function(_, express, mongo) {
 
             mongo.spaces(req.currentUserId())
                 .then((spaces) => {
-                    spacesIds = spaces.map((value) => value._id);
+                    spacesIds = mongo.spacesIds(spaces);
 
                     return mongo.Cluster.update({space: {$in: spacesIds}}, {caches: []}, {multi: true});
                 })

http://git-wip-us.apache.org/repos/asf/ignite/blob/3fc013ae/modules/control-center-web/src/main/js/serve/routes/clusters.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/clusters.js b/modules/control-center-web/src/main/js/serve/routes/clusters.js
index 468e912..c4260db 100644
--- a/modules/control-center-web/src/main/js/serve/routes/clusters.js
+++ b/modules/control-center-web/src/main/js/serve/routes/clusters.js
@@ -41,7 +41,7 @@ module.exports.factory = function(_, express, mongo) {
             mongo.spaces(req.currentUserId())
                 .then((spaces) => {
                     result.spaces = spaces;
-                    spacesIds = spaces.map((value) => value._id);
+                    spacesIds = mongo.spacesIds(spaces);
 
                     return mongo.Cache.find({space: {$in: spacesIds}}).sort('name').exec();
                 })
@@ -125,7 +125,7 @@ module.exports.factory = function(_, express, mongo) {
             // Get owned space and all accessed space.
             mongo.spaces(req.currentUserId())
                 .then((spaces) => {
-                    spacesIds = spaces.map((value) => value._id);
+                    spacesIds = mongo.spacesIds(spaces);
 
                     return mongo.Cluster.remove({space: {$in: spacesIds}});
                 })

http://git-wip-us.apache.org/repos/asf/ignite/blob/3fc013ae/modules/control-center-web/src/main/js/serve/routes/domains.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/domains.js b/modules/control-center-web/src/main/js/serve/routes/domains.js
index 922fff2..3dc2116 100644
--- a/modules/control-center-web/src/main/js/serve/routes/domains.js
+++ b/modules/control-center-web/src/main/js/serve/routes/domains.js
@@ -41,7 +41,7 @@ module.exports.factory = function(_, express, async, mongo) {
             mongo.spaces(req.currentUserId())
                 .then((spaces) => {
                     result.spaces = spaces;
-                    spacesIds = spaces.map((value) => value._id);
+                    spacesIds = mongo.spacesIds(spaces);
 
                     return mongo.Cluster.find({space: {$in: spacesIds}}, '_id name').sort('name').exec();
                 })
@@ -198,7 +198,7 @@ module.exports.factory = function(_, express, async, mongo) {
 
             mongo.spaces(req.currentUserId())
                 .then((spaces) => {
-                    spacesIds = spaces.map((value) => value._id);
+                    spacesIds = mongo.spacesIds(spaces);
 
                     return mongo.Cache.update({space: {$in: spacesIds}}, {domains: []}, {multi: true}).exec();
                 })
@@ -217,7 +217,7 @@ module.exports.factory = function(_, express, async, mongo) {
 
             mongo.spaces(req.currentUserId())
                 .then((spaces) => {
-                    spacesIds = spaces.map((value) => value._id);
+                    spacesIds = mongo.spacesIds(spaces);
 
                     return mongo.DomainModel.remove({$and: [{space: {$in: spacesIds}}, {demo: true}]});
                 })

http://git-wip-us.apache.org/repos/asf/ignite/blob/3fc013ae/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 1df089e..39cc978 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
@@ -42,7 +42,7 @@ module.exports.factory = function(_, express, mongo) {
             mongo.spaces(req.currentUserId())
                 .then((spaces) => {
                     result.spaces = spaces;
-                    spacesIds = spaces.map((value) => value._id);
+                    spacesIds = mongo.spacesIds(spaces);
 
                     return mongo.Cluster.find({space: {$in: spacesIds}}, '_id name').sort('name').exec();
                 })
@@ -114,7 +114,7 @@ module.exports.factory = function(_, express, mongo) {
             // Get owned space and all accessed space.
             mongo.spaces(req.currentUserId())
                 .then((spaces) => {
-                    spacesIds = spaces.map((value) => value._id);
+                    spacesIds = mongo.spacesIds(spaces);
 
                     return mongo.Igfs.remove({space: {$in: spacesIds}});
                 })


[41/50] ignite git commit: IGNITE-843 Minor fix.

Posted by ak...@apache.org.
IGNITE-843 Minor fix.


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

Branch: refs/heads/ignite-843-rc3
Commit: 877a1fcd94d302fb46b55880bad8685152f28e1e
Parents: 62fc8e7
Author: Andrey <an...@gridgain.com>
Authored: Tue Feb 16 17:03:52 2016 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Tue Feb 16 17:03:52 2016 +0700

----------------------------------------------------------------------
 modules/control-center-web/src/main/js/serve/mail.js      |  2 +-
 .../control-center-web/src/main/js/serve/routes/admin.js  |  6 +++---
 .../src/main/js/serve/routes/profile.js                   |  4 ++--
 .../control-center-web/src/main/js/serve/routes/public.js | 10 +++++-----
 4 files changed, 11 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/877a1fcd/modules/control-center-web/src/main/js/serve/mail.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/mail.js b/modules/control-center-web/src/main/js/serve/mail.js
index 817c5d1..05d0fe9 100644
--- a/modules/control-center-web/src/main/js/serve/mail.js
+++ b/modules/control-center-web/src/main/js/serve/mail.js
@@ -45,7 +45,7 @@ module.exports.factory = function(nodemailer, settings) {
             };
 
             if (transporter.service === '' || transporter.auth.user === '' || transporter.auth.pass === '')
-                return Promise.reject('Can\'t send e-mail because not configured SMTP server. Please ask webmaster to setup SMTP server!');
+                return Promise.reject('Can\'t send email because not configured SMTP server. Please ask webmaster to setup SMTP server!');
 
             const mailer = nodemailer.createTransport(transporter);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/877a1fcd/modules/control-center-web/src/main/js/serve/routes/admin.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/admin.js b/modules/control-center-web/src/main/js/serve/routes/admin.js
index 87f8bed..9b8cbee 100644
--- a/modules/control-center-web/src/main/js/serve/routes/admin.js
+++ b/modules/control-center-web/src/main/js/serve/routes/admin.js
@@ -54,7 +54,7 @@ module.exports.factory = function(_, express, nodemailer, settings, mail, mongo)
                                 mongo.Cache.remove({space: {$in: spacesIds}}).exec(),
                                 mongo.DomainModel.remove({space: {$in: spacesIds}}).exec(),
                                 mongo.Notebook.remove({space: {$in: spacesIds}}).exec(),
-                                mongo.Space.remove({owner: {$in: spacesIds}}).exec()
+                                mongo.Space.remove({owner: userId}).exec()
                             ]);
                         })
                         .catch((err) => {
@@ -65,8 +65,8 @@ module.exports.factory = function(_, express, nodemailer, settings, mail, mongo)
                 })
                 .then((user) => mail.send(user, 'Your account was deleted',
                     `Hello ${user.username}!<br><br>` +
-                    `You are receiving this e-mail because "${req.user.username}" removed your account on <a href="http://${req.headers.host}">${settings.smtp.username}</a>.`,
-                    'Account was removed, but failed to send e-mail notification to user!')
+                    `You are receiving this email because your account for ${settings.smtp.username} was removed.`,
+                    'Account was removed, but failed to send email notification to user!')
                 )
                 .catch((err) => mongo.handleError(res, err));
         });

http://git-wip-us.apache.org/repos/asf/ignite/blob/877a1fcd/modules/control-center-web/src/main/js/serve/routes/profile.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/profile.js b/modules/control-center-web/src/main/js/serve/routes/profile.js
index 6b166fd..da6b599 100644
--- a/modules/control-center-web/src/main/js/serve/routes/profile.js
+++ b/modules/control-center-web/src/main/js/serve/routes/profile.js
@@ -61,10 +61,10 @@ module.exports.factory = function(_, express, mongo) {
                         mongo.Account.findOne({email: params.email}, (err, _user) => {
                             // TODO send error to admin
                             if (err)
-                                reject(new Error('Failed to check e-mail!'));
+                                reject(new Error('Failed to check email!'));
 
                             if (_user && _user._id !== user._id)
-                                reject(new Error('User with this e-mail already registered!'));
+                                reject(new Error('User with this email already registered!'));
 
                             resolve(user);
                         });

http://git-wip-us.apache.org/repos/asf/ignite/blob/877a1fcd/modules/control-center-web/src/main/js/serve/routes/public.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/public.js b/modules/control-center-web/src/main/js/serve/routes/public.js
index 4195a41..02986a8 100644
--- a/modules/control-center-web/src/main/js/serve/routes/public.js
+++ b/modules/control-center-web/src/main/js/serve/routes/public.js
@@ -105,7 +105,7 @@ module.exports.factory = function(express, passport, nodemailer, settings, mail,
                     account.save()
                         .then(() => mail.send(account, `Thanks for signing up for ${settings.smtp.username}.`,
                             `Hello ${account.username}!<br><br>` +
-                            `You are receiving this e-mail because you have signed up to use <a href="http://${req.headers.host}">${settings.smtp.username}</a>.<br><br>` +
+                            `You are receiving this email because you have signed up to use <a href="http://${req.headers.host}">${settings.smtp.username}</a>.<br><br>` +
                             'If you have not done the sign up and do not know what this email is about, please ignore it.<br>' +
                             'You may reset the password by clicking on the following link, or paste this into your browser:<br><br>' +
                             `http://${req.headers.host}/password/reset?token=${account.resetPasswordToken}`));
@@ -163,9 +163,9 @@ module.exports.factory = function(express, passport, nodemailer, settings, mail,
                         'Please click on the following link, or paste this into your browser to complete the process:<br><br>' +
                         'http://' + req.headers.host + '/password/reset?token=' + user.resetPasswordToken + '<br><br>' +
                         'If you did not request this, please ignore this email and your password will remain unchanged.',
-                        'Failed to send e-mail with reset link!')
+                        'Failed to send email with reset link!')
                 )
-                .then(() => res.status(200).send('An e-mail has been sent with further instructions.'))
+                .then(() => res.status(200).send('An email has been sent with further instructions.'))
                 .catch((errMsg) => {
                     // TODO IGNITE-843 Send email to admin
                     return res.status(401).send(errMsg);
@@ -180,7 +180,7 @@ module.exports.factory = function(express, passport, nodemailer, settings, mail,
                 .then((user) => {
                     return new Promise((resolve, reject) => {
                         if (!user)
-                            return reject('Failed to find account with this token! Please check link from e-mail.');
+                            return reject('Failed to find account with this token! Please check link from email.');
 
                         user.setPassword(req.body.password, (err, _user) => {
                             if (err)
@@ -196,7 +196,7 @@ module.exports.factory = function(express, passport, nodemailer, settings, mail,
                     return mail.send(user, 'Your password has been changed',
                         `Hello ${user.username}!<br><br>` +
                         `This is a confirmation that the password for your account on <a href="http://${req.headers.host}">${settings.smtp.username}</a> has just been changed.<br><br>`,
-                        'Password was changed, but failed to send confirmation e-mail!');
+                        'Password was changed, but failed to send confirmation email!');
                 })
                 .then((user) => res.status(200).send(user.email))
                 .catch((errMsg) => {


[20/50] ignite git commit: IGNITE-843 Rework cluster remove.

Posted by ak...@apache.org.
IGNITE-843 Rework cluster remove.


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

Branch: refs/heads/ignite-843-rc3
Commit: 6fc1865e5d11d171fffc01adefbb10712c756f5f
Parents: 5110d98
Author: AKuznetsov <ak...@gridgain.com>
Authored: Mon Feb 15 17:55:10 2016 +0700
Committer: AKuznetsov <ak...@gridgain.com>
Committed: Mon Feb 15 17:55:10 2016 +0700

----------------------------------------------------------------------
 .../src/main/js/serve/routes/clusters.js              |  8 ++++----
 .../src/main/js/serve/routes/igfs.js                  | 14 ++++++++++----
 2 files changed, 14 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/6fc1865e/modules/control-center-web/src/main/js/serve/routes/clusters.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/clusters.js b/modules/control-center-web/src/main/js/serve/routes/clusters.js
index acfb2aa..2674975 100644
--- a/modules/control-center-web/src/main/js/serve/routes/clusters.js
+++ b/modules/control-center-web/src/main/js/serve/routes/clusters.js
@@ -142,14 +142,14 @@ module.exports.factory = function(_, express, mongo) {
 
             let spacesIds = [];
 
-            mongo.Cluster.remove(clusterId)
-                .then(() => mongo.Space.find({$or: [{owner: userId}, {usedBy: {$elemMatch: {account: userId}}}]}))
+            mongo.Space.find({$or: [{owner: userId}, {usedBy: {$elemMatch: {account: userId}}}]})
                 .then((spaces) => {
                     spacesIds = spaces.map((value) => value._id);
 
-                    return mongo.Cache.update(mongo.Cache.update({space: {$in: spacesIds}}, {$pull: {clusters: clusterId}}, {multi: true}));
+                    return mongo.Cache.update({space: {$in: spacesIds}}, {$pull: {clusters: clusterId}}, {multi: true});
                 })
-                .then(() => mongo.Cache.update(mongo.Igfs.update({space: {$in: spacesIds}}, {$pull: {clusters: clusterId}}, {multi: true})))
+                .then(() => mongo.Igfs.update({space: {$in: spacesIds}}, {$pull: {clusters: clusterId}}, {multi: true}))
+                .then(() => mongo.Cluster.remove(clusterId))
                 .then(() => res.sendStatus(200))
                 .catch((err) => {
                     // TODO IGNITE-843 Send error to admin

http://git-wip-us.apache.org/repos/asf/ignite/blob/6fc1865e/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 78c49b6..2a0aed4 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
@@ -107,10 +107,16 @@ module.exports.factory = function(_, express, mongo) {
          * Remove IGFS by ._id.
          */
         router.post('/remove', (req, res) => {
-            mongo.Igfs.remove(req.body, (err) => {
-                if (mongo.processed(err, res))
-                    res.sendStatus(200);
-            });
+            const igfsId = req.body;
+
+            mongo.Space.find({$or: [{owner: userId}, {usedBy: {$elemMatch: {account: userId}}}]})
+                .then((spaces) => mongo.Cluster.update({space: {$in: spacesIds}}, {$pull: {igfss: igfsId}}, {multi: true}))
+                .then(mongo.Igfs.remove(req.body))
+                .then(() => res.sendStatus(200))
+                .catch((err) => {
+                    // TODO IGNITE-843 Send error to admin
+                    res.status(500).send(err.message);
+                });
         });
 
         /**


[05/50] ignite git commit: IGNITE-843 Minor ES6 style fixes.

Posted by ak...@apache.org.
IGNITE-843 Minor ES6 style fixes.


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

Branch: refs/heads/ignite-843-rc3
Commit: 471ac276e88b071e077418ad275c9f2f1ac1f67c
Parents: b0d4bee
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Mon Feb 15 10:50:04 2016 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Mon Feb 15 10:50:04 2016 +0700

----------------------------------------------------------------------
 .../src/main/js/serve/routes/notebooks.js       | 86 ++++++++++----------
 1 file changed, 43 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/471ac276/modules/control-center-web/src/main/js/serve/routes/notebooks.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/notebooks.js b/modules/control-center-web/src/main/js/serve/routes/notebooks.js
index 48e9a5c..a595303 100644
--- a/modules/control-center-web/src/main/js/serve/routes/notebooks.js
+++ b/modules/control-center-web/src/main/js/serve/routes/notebooks.js
@@ -32,20 +32,20 @@ module.exports.factory = function(express, mongo) {
          * @param req Request.
          * @param res Response.
          */
-        router.post('/list', function(req, res) {
+        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}}}]}, (err, spaces) => {
-                if (err)
-                    return res.status(500).send(err.message);
+            mongo.Space.find({$or: [{owner: user_id}, {usedBy: {$elemMatch: {account: user_id}}}]}, (errSpace, spaces) => {
+                if (errSpace)
+                    return res.status(500).send(errSpace.message);
 
                 const space_ids = spaces.map((value) => value._id);
 
                 // Get all metadata for spaces.
-                mongo.Notebook.find({space: {$in: space_ids}}).select('_id name').sort('name').exec((err, notebooks) => {
-                    if (err)
-                        return res.status(500).send(err.message);
+                mongo.Notebook.find({space: {$in: space_ids}}).select('_id name').sort('name').exec((errNotebook, notebooks) => {
+                    if (errNotebook)
+                        return res.status(500).send(errNotebook.message);
 
                     res.json(notebooks);
                 });
@@ -58,22 +58,20 @@ module.exports.factory = function(express, mongo) {
          * @param req Request.
          * @param res Response.
          */
-        router.post('/get', function(req, res) {
-            var user_id = req.currentUserId();
+        router.post('/get', (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 (err)
-                    return res.status(500).send(err.message);
+            mongo.Space.find({$or: [{owner: user_id}, {usedBy: {$elemMatch: {account: user_id}}}]}, (errSpace, spaces) => {
+                if (errSpace)
+                    return res.status(500).send(errSpace.message);
 
-                var space_ids = spaces.map(function(value) {
-                    return value._id;
-                });
+                const space_ids = spaces.map((value) => value._id);
 
                 // Get all metadata for spaces.
-                mongo.Notebook.findOne({space: {$in: space_ids}, _id: req.body.noteId}).exec(function(err, notebook) {
-                    if (err)
-                        return res.status(500).send(err.message);
+                mongo.Notebook.findOne({space: {$in: space_ids}, _id: req.body.noteId}).exec((errNotebook, notebook) => {
+                    if (errNotebook)
+                        return res.status(500).send(errNotebook.message);
 
                     res.json(notebook);
                 });
@@ -86,32 +84,34 @@ module.exports.factory = function(express, mongo) {
          * @param req Request.
          * @param res Response.
          */
-        router.post('/save', function(req, res) {
-            var note = req.body;
-            var noteId = note._id;
+        router.post('/save', (req, res) => {
+            const note = req.body;
+            const noteId = note._id;
 
-            if (noteId)
-                mongo.Notebook.update({_id: noteId}, note, {upsert: true}, function(err) {
+            if (noteId) {
+                mongo.Notebook.update({_id: noteId}, note, {upsert: true}, (err) => {
                     if (err)
                         return res.status(500).send(err.message);
 
                     res.send(noteId);
                 });
-            else
-                mongo.Notebook.findOne({space: note.space, name: note.name}, function(err, note) {
-                    if (err)
-                        return res.status(500).send(err.message);
+            }
+            else {
+                mongo.Notebook.findOne({space: note.space, name: note.name}, (errNotebookFind, notebookFoud) => {
+                    if (errNotebookFind)
+                        return res.status(500).send(errNotebookFind.message);
 
-                    if (note)
-                        return res.status(500).send('Notebook with name: "' + note.name + '" already exist.');
+                    if (notebookFoud)
+                        return res.status(500).send('Notebook with name: "' + notebookFoud.name + '" already exist.');
 
-                    (new mongo.Notebook(req.body)).save(function(err, note) {
-                        if (err)
-                            return res.status(500).send(err.message);
+                    (new mongo.Notebook(req.body)).save((errNotebook, noteNew) => {
+                        if (errNotebook)
+                            return res.status(500).send(errNotebook.message);
 
-                        res.send(note._id);
+                        res.send(noteNew._id);
                     });
                 });
+            }
         });
 
         /**
@@ -120,8 +120,8 @@ module.exports.factory = function(express, mongo) {
          * @param req Request.
          * @param res Response.
          */
-        router.post('/remove', function(req, res) {
-            mongo.Notebook.remove(req.body, function(err) {
+        router.post('/remove', (req, res) => {
+            mongo.Notebook.remove(req.body, (err) => {
                 if (err)
                     return res.status(500).send(err.message);
 
@@ -135,17 +135,17 @@ module.exports.factory = function(express, mongo) {
          * @param req Request.
          * @param res Response.
          */
-        router.post('/new', function(req, res) {
-            var user_id = req.currentUserId();
+        router.post('/new', (req, res) => {
+            const user_id = req.currentUserId();
 
             // Get owned space and all accessed space.
-            mongo.Space.findOne({owner: user_id}, function(err, space) {
-                if (err)
-                    return res.status(500).send(err.message);
+            mongo.Space.findOne({owner: user_id}, (errSpace, space) => {
+                if (errSpace)
+                    return res.status(500).send(errSpace.message);
 
-                (new mongo.Notebook({space: space.id, name: req.body.name})).save(function(err, note) {
-                    if (err)
-                        return res.status(500).send(err.message);
+                (new mongo.Notebook({space: space.id, name: req.body.name})).save((errNotebook, note) => {
+                    if (errNotebook)
+                        return res.status(500).send(errNotebook.message);
 
                     return res.send(note._id);
                 });


[16/50] ignite git commit: IGNITE-843 Fixed feedback

Posted by ak...@apache.org.
IGNITE-843 Fixed feedback


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

Branch: refs/heads/ignite-843-rc3
Commit: 60330c8f8647e25b72db2ddc950800e543843e85
Parents: 053ba44
Author: Andrey <an...@gridgain.com>
Authored: Mon Feb 15 17:43:40 2016 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Mon Feb 15 17:43:40 2016 +0700

----------------------------------------------------------------------
 .../form-field-java-class.jade                      | 10 +++++-----
 .../js/app/modules/form/field/input/number.jade     |  2 +-
 .../states/configuration/clusters/deployment.jade   | 16 ++++++++--------
 3 files changed, 14 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/60330c8f/modules/control-center-web/src/main/js/app/directives/form-field-java-class/form-field-java-class.jade
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/app/directives/form-field-java-class/form-field-java-class.jade b/modules/control-center-web/src/main/js/app/directives/form-field-java-class/form-field-java-class.jade
index ca8e6bb..d8e5162 100644
--- a/modules/control-center-web/src/main/js/app/directives/form-field-java-class/form-field-java-class.jade
+++ b/modules/control-center-web/src/main/js/app/directives/form-field-java-class/form-field-java-class.jade
@@ -46,8 +46,8 @@ div
     )
         span(ng-transclude)
 
-        +feedback('javaPackageSpecified', 'does not have package specified!')
-        +feedback('javaBuiltInClass', 'should not be the Java built-in class!')
-        +feedback('javaKeywords', 'could not contains reserved Java keyword!')
-        +feedback('javaIdentifier', 'is invalid Java identifier!')
-        +feedback('required', 'could not be empty!')
+        +feedback('javaPackageSpecified', 'does not have package specified')
+        +feedback('javaBuiltInClass', 'should not be the Java built-in class')
+        +feedback('javaKeywords', 'could not contains reserved Java keyword')
+        +feedback('javaIdentifier', 'is invalid Java identifier')
+        +feedback('required', 'could not be empty')

http://git-wip-us.apache.org/repos/asf/ignite/blob/60330c8f/modules/control-center-web/src/main/js/app/modules/form/field/input/number.jade
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/app/modules/form/field/input/number.jade b/modules/control-center-web/src/main/js/app/modules/form/field/input/number.jade
index 01d2b48..6b31ebd 100644
--- a/modules/control-center-web/src/main/js/app/modules/form/field/input/number.jade
+++ b/modules/control-center-web/src/main/js/app/modules/form/field/input/number.jade
@@ -39,6 +39,6 @@ mixin feedback(error, message)
 
     +feedback('min', 'Value is less than allowable minimum: {{ min || 0 }}')
     +feedback('max', 'Value is more than allowable maximum: {{ max }}')
-    +feedback('number', 'Invalid value. Only numbers allowed')
+    +feedback('number', 'Only numbers allowed')
 
     span(ng-transclude='')

http://git-wip-us.apache.org/repos/asf/ignite/blob/60330c8f/modules/control-center-web/src/main/js/app/modules/states/configuration/clusters/deployment.jade
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/app/modules/states/configuration/clusters/deployment.jade b/modules/control-center-web/src/main/js/app/modules/states/configuration/clusters/deployment.jade
index 2f8ce0f..adf7fb7 100644
--- a/modules/control-center-web/src/main/js/app/modules/states/configuration/clusters/deployment.jade
+++ b/modules/control-center-web/src/main/js/app/modules/states/configuration/clusters/deployment.jade
@@ -144,10 +144,10 @@ form.panel.panel-default(name='#{form}' novalidate)
                                             data-title='Click icon or press [Enter] to save item' 
                                         )
 
-                                        +feedback(field, 'required', 'Package name could not be empty!')
-                                        +feedback(field, 'javaPackageName', 'Package name is invalid!')
-                                        +feedback(field, 'javaKeywords', 'Package name could not contains reserved java keyword: ""!')
-                                        +feedback(field, 'igniteUnique', 'Such package already exists!')
+                                        +feedback(field, 'required', 'Package name could not be empty')
+                                        +feedback(field, 'javaPackageName', 'Package name is invalid')
+                                        +feedback(field, 'javaKeywords', 'Package name could not contains reserved java keyword')
+                                        +feedback(field, 'igniteUnique', 'Such package already exists')
 
                         - var field = 'new'
                         - var valid = form + '.' + field + '.$valid'
@@ -175,10 +175,10 @@ form.panel.panel-default(name='#{form}' novalidate)
                                         data-title='Click icon or press [Enter] to save item' 
                                     )
 
-                                    +feedback(field, 'required', 'Package name could not be empty!')
-                                    +feedback(field, 'javaPackageName', 'Package name is invalid!')
-                                    +feedback(field, 'javaKeywords', 'Package name could not contains reserved java keyword: ""!')
-                                    +feedback(field, 'igniteUnique', 'Such package already exists!')
+                                    +feedback(field, 'required', 'Package name could not be empty')
+                                    +feedback(field, 'javaPackageName', 'Package name is invalid')
+                                    +feedback(field, 'javaKeywords', 'Package name could not contains reserved java keyword')
+                                    +feedback(field, 'igniteUnique', 'Such package already exists')
             
                         .group-content-empty(ng-if='!(#{exclude}.length) && !group.add.length')
                             | Not defined


[30/50] ignite git commit: IGNITE-843 Refactor serve to es6.

Posted by ak...@apache.org.
IGNITE-843 Refactor serve to es6.


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

Branch: refs/heads/ignite-843-rc3
Commit: 42873202fea7cf848c5c9f017430eab7783cf961
Parents: 63bd2c0
Author: Andrey <an...@gridgain.com>
Authored: Tue Feb 16 11:42:26 2016 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Tue Feb 16 11:42:26 2016 +0700

----------------------------------------------------------------------
 .../src/main/js/serve/mail.js                   | 71 +++++++++++++++++
 .../src/main/js/serve/routes/admin.js           | 83 ++++++--------------
 .../src/main/js/serve/routes/public.js          | 69 ++++------------
 .../src/main/js/serve/settings.js               |  1 +
 4 files changed, 114 insertions(+), 110 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/42873202/modules/control-center-web/src/main/js/serve/mail.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/mail.js b/modules/control-center-web/src/main/js/serve/mail.js
new file mode 100644
index 0000000..817c5d1
--- /dev/null
+++ b/modules/control-center-web/src/main/js/serve/mail.js
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+'use strict';
+
+// Fire me up!
+
+module.exports = {
+    implements: 'mail',
+    inject: ['require(nodemailer)', 'settings']
+};
+
+module.exports.factory = function(nodemailer, settings) {
+    return {
+        /**
+         * Send mail to user.
+         * @param {Account} user
+         * @param {String} subject
+         * @param {String} html
+         * @param {String} sendErr
+         *
+         * @return {Promise}
+         */
+        send: (user, subject, html, sendErr) => {
+            const transporter = {
+                service: settings.smtp.service,
+                auth: {
+                    user: settings.smtp.email,
+                    pass: settings.smtp.password
+                }
+            };
+
+            if (transporter.service === '' || transporter.auth.user === '' || transporter.auth.pass === '')
+                return Promise.reject('Can\'t send e-mail because not configured SMTP server. Please ask webmaster to setup SMTP server!');
+
+            const mailer = nodemailer.createTransport(transporter);
+
+            const sign = settings.smtp.sign ? `<br><br>--------------<br>${settings.smtp.sign}<br>` : '';
+
+            const mail = {
+                from: settings.smtp.address(settings.smtp.username, settings.smtp.email),
+                to: settings.smtp.address(user.username, user.email),
+                subject,
+                html: html + sign
+            };
+
+            return new Promise((resolve, reject) => {
+                mailer.sendMail(mail, (err) => {
+                    if (err)
+                        return reject(sendErr ? new Error(sendErr) : err);
+
+                    resolve(user);
+                });
+            });
+        }
+    };
+};

http://git-wip-us.apache.org/repos/asf/ignite/blob/42873202/modules/control-center-web/src/main/js/serve/routes/admin.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/admin.js b/modules/control-center-web/src/main/js/serve/routes/admin.js
index 50488b1..ab2760a 100644
--- a/modules/control-center-web/src/main/js/serve/routes/admin.js
+++ b/modules/control-center-web/src/main/js/serve/routes/admin.js
@@ -21,10 +21,10 @@
 
 module.exports = {
     implements: 'admin-routes',
-    inject: ['require(lodash)', 'require(express)', 'require(nodemailer)', 'settings', 'mongo']
+    inject: ['require(lodash)', 'require(express)', 'require(nodemailer)', 'settings', 'mail', 'mongo']
 };
 
-module.exports.factory = function(_, express, nodemailer, settings, mongo) {
+module.exports.factory = function(_, express, nodemailer, settings, mail, mongo) {
     return new Promise((factoryResolve) => {
         const router = new express.Router();
 
@@ -40,65 +40,34 @@ module.exports.factory = function(_, express, nodemailer, settings, mongo) {
         // Remove user.
         router.post('/remove', (req, res) => {
             const userId = req.body.userId;
-            let user = {};
 
             mongo.Account.findByIdAndRemove(userId).exec()
-                .then((removedUser) => {
-                    user = removedUser;
+                .then((user) => {
+                    res.sendStatus(200);
 
-                    return mongo.spaces(userId);
-                })
-                .then((spaces) => {
-                    const promises = [];
-
-                    _.forEach(spaces, (space) => {
-                        promises.push(mongo.Cluster.remove({space: space._id}).exec());
-                        promises.push(mongo.Cache.remove({space: space._id}).exec());
-                        promises.push(mongo.DomainModel.remove({space: space._id}).exec());
-                        promises.push(mongo.Notebook.remove({space: space._id}).exec());
-                        promises.push(mongo.Space.remove({owner: space._id}).exec());
-                    });
-
-                    return Promise.all(promises);
+                    mongo.spaces(userId)
+                        .then((spaces) => {
+                            const spacesIds = mongo.spacesIds(spaces);
+
+                            return Promise.all([
+                                mongo.Cluster.remove({space: {$in: spacesIds}}).exec(),
+                                mongo.Cache.remove({space: {$in: spacesIds}}).exec(),
+                                mongo.DomainModel.remove({space: {$in: spacesIds}}).exec(),
+                                mongo.Notebook.remove({space: {$in: spacesIds}}).exec(),
+                                mongo.Space.remove({owner: {$in: spacesIds}}).exec()
+                            ]);
+                        })
+                        .catch((err) => {
+                            console.error(`Failed to cleanup spaces [user=${user.username}, err=${err}`);
+                        });
+
+                    return Promise.resolve(user)
                 })
-                .then(() => {
-                    return new Promise((resolveMail, rejectMail) => {
-                        const transporter = {
-                            service: settings.smtp.service,
-                            auth: {
-                                user: settings.smtp.email,
-                                pass: settings.smtp.password
-                            }
-                        };
-
-                        if (transporter.service !== '' || transporter.auth.user !== '' || transporter.auth.pass !== '') {
-                            const mailer = nodemailer.createTransport(transporter);
-
-                            const mailOptions = {
-                                from: settings.smtp.address(settings.smtp.username, settings.smtp.email),
-                                to: settings.smtp.address(user.username, user.email),
-                                subject: 'Your account was deleted',
-                                text: 'You are receiving this e-mail because admin remove your account.\n\n' +
-                                '--------------\n' +
-                                settings.smtp.username + ' http://' + req.headers.host + '\n'
-                            };
-
-                            mailer.sendMail(mailOptions, (errMailer) => {
-                                if (errMailer) {
-                                    rejectMail({
-                                        code: 503,
-                                        message: 'Account was removed, but failed to send e-mail notification to user!<br />' + errMailer
-                                    });
-                                }
-                                else
-                                    resolveMail();
-                            });
-                        }
-                        else
-                            rejectMail({code: 503, message: 'Account was removed, but failed to send e-mail notification to user, because mailer is not configured!'});
-                    });
-                })
-                .then(() => res.sendStatus(200))
+                .then((user) => mail.send(user, 'Your account was deleted',
+                    `Hello ${user.username}!<br><br>` +
+                    `You are receiving this e-mail because "${req.user.username}" remove your account.`,
+                    'Account was removed, but failed to send e-mail notification to user!')
+                )
                 .catch((err) => mongo.handleError(res, err));
         });
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/42873202/modules/control-center-web/src/main/js/serve/routes/public.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/public.js b/modules/control-center-web/src/main/js/serve/routes/public.js
index b83208d..8eb1b6e 100644
--- a/modules/control-center-web/src/main/js/serve/routes/public.js
+++ b/modules/control-center-web/src/main/js/serve/routes/public.js
@@ -21,10 +21,10 @@
 
 module.exports = {
     implements: 'public-routes',
-    inject: ['require(express)', 'require(passport)', 'require(nodemailer)', 'settings', 'mongo']
+    inject: ['require(express)', 'require(passport)', 'require(nodemailer)', 'settings', 'mail', 'mongo']
 };
 
-module.exports.factory = function(express, passport, nodemailer, settings, mongo) {
+module.exports.factory = function(express, passport, nodemailer, settings, mail, mongo) {
     return new Promise((factoryResolve) => {
         const router = new express.Router();
 
@@ -40,42 +40,6 @@ module.exports.factory = function(express, passport, nodemailer, settings, mongo
             return res;
         };
 
-        /**
-         * Send mail to user.
-         * @private
-         * @return {Promise}
-         */
-        const _sendMail = (user, subject, text, sendErrMsg) => {
-            const transporter = {
-                service: settings.smtp.service,
-                auth: {
-                    user: settings.smtp.email,
-                    pass: settings.smtp.password
-                }
-            };
-
-            if (transporter.service === '' || transporter.auth.user === '' || transporter.auth.pass === '')
-                return Promise.reject('Can\'t send e-mail because not configured SMTP server. Please ask webmaster to setup SMTP server!');
-
-            const mailer = nodemailer.createTransport(transporter);
-
-            const mail = {
-                from: settings.smtp.address(settings.smtp.username, settings.smtp.email),
-                to: settings.smtp.address(user.username, user.email),
-                subject,
-                text: text + (settings.smtp.username ? `\n\n--------------\n${settings.smtp.username}\n` : '')
-            };
-
-            return new Promise((resolve, reject) => {
-                mailer.sendMail(mail, (err) => {
-                    if (err)
-                        return reject(sendErrMsg || err.message);
-
-                    resolve(user);
-                });
-            });
-        };
-
         // GET user.
         router.post('/user', (req, res) => {
             const becomeUsed = req.session.viewedUser && req.user.admin;
@@ -139,13 +103,12 @@ module.exports.factory = function(express, passport, nodemailer, settings, mongo
                     account.resetPasswordToken = _randomString();
 
                     account.save()
-                        .then(() =>
-                            _sendMail(account, `Thanks for signing up for ${settings.smtp.username}.`,
-                                `Hello ${account.username}!\n\n` +
-                                `You are receiving this e-mail because you (or someone else) signing up on the ${settings.smtp.username}.\n\n` +
-                                'If you did not request this, please ignore this email.\n' +
-                                'You may reset password by clicking on the following link, or paste this into your browser:\n\n' +
-                                'http://' + req.headers.host + '/password/reset?token=' + account.resetPasswordToken));
+                        .then(() => mail.send(account, `Thanks for signing up for ${settings.smtp.username}.`,
+                            `Hello ${account.username}!<br><br>` +
+                            `You are receiving this e-mail because you have signed up to use <a href="http://${req.headers.host}">${settings.smtp.username}</a>.<br><br>` +
+                            'If you have not done the sign up and do not know what this email is about, please ignore it.<br>' +
+                            'You may reset the password by clicking on the following link, or paste this into your browser:<br><br>' +
+                            `http://${req.headers.host}/password/reset?token=${account.resetPasswordToken}`));
                 })
                 .catch((err) => {
                     res.status(401).send(err.message);
@@ -194,11 +157,11 @@ module.exports.factory = function(express, passport, nodemailer, settings, mongo
 
                     return user.save();
                 })
-                .then((user) =>
-                    _sendMail(user, 'Password Reset',
-                        'You are receiving this because you (or someone else) have requested the reset of the password for your account.\n\n' +
-                        'Please click on the following link, or paste this into your browser to complete the process:\n\n' +
-                        'http://' + req.headers.host + '/password/reset?token=' + user.resetPasswordToken + '\n\n' +
+                .then((user) => mail.send(user, 'Password Reset',
+                        `Hello ${user.username}!<br><br>` +
+                        'You are receiving this because you (or someone else) have requested the reset of the password for your account.<br><br>' +
+                        'Please click on the following link, or paste this into your browser to complete the process:<br><br>' +
+                        'http://' + req.headers.host + '/password/reset?token=' + user.resetPasswordToken + '<br><br>' +
                         'If you did not request this, please ignore this email and your password will remain unchanged.',
                         'Failed to send e-mail with reset link!')
                 )
@@ -230,9 +193,9 @@ module.exports.factory = function(express, passport, nodemailer, settings, mongo
                     });
                 })
                 .then((user) => {
-                    return _sendMail(user, 'Your password has been changed',
-                        'Hello,\n\n' +
-                        'This is a confirmation that the password for your account ' + user.email + ' has just been changed.\n\n' +
+                    return mail.send(user, 'Your password has been changed',
+                        `Hello ${user.username}!<br><br>` +
+                        'This is a confirmation that the password for your account ' + user.email + ' has just been changed.<br><br>' +
                         'Now you can login: http://' + req.headers.host,
                         'Password was changed, but failed to send confirmation e-mail!');
                 })

http://git-wip-us.apache.org/repos/asf/ignite/blob/42873202/modules/control-center-web/src/main/js/serve/settings.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/settings.js b/modules/control-center-web/src/main/js/serve/settings.js
index f3d19d9..c5f8b84 100644
--- a/modules/control-center-web/src/main/js/serve/settings.js
+++ b/modules/control-center-web/src/main/js/serve/settings.js
@@ -68,6 +68,7 @@ module.exports.factory = function(nconf, fs) {
         smtp: {
             service: nconf.get('smtp:service'),
             username: nconf.get('smtp:username'),
+            sign: nconf.get('smtp:sign'),
             email: nconf.get('smtp:email'),
             password: nconf.get('smtp:password'),
             address: (username, email) => username ? '"' + username + '" <' + email + '>' : email


[14/50] ignite git commit: IGNITE-843 Fixed save button for cluster.

Posted by ak...@apache.org.
IGNITE-843 Fixed save button for cluster.


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

Branch: refs/heads/ignite-843-rc3
Commit: 77fdb37f8d18010046269f7968c8090a449d13e7
Parents: 53b9b52
Author: Dmitriyff <dm...@gmail.com>
Authored: Mon Feb 15 17:05:07 2016 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Mon Feb 15 17:05:07 2016 +0700

----------------------------------------------------------------------
 .../src/main/js/app/services/cleanup/cleanup.service.js           | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/77fdb37f/modules/control-center-web/src/main/js/app/services/cleanup/cleanup.service.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/app/services/cleanup/cleanup.service.js b/modules/control-center-web/src/main/js/app/services/cleanup/cleanup.service.js
index e3a1716..c50bfe0 100644
--- a/modules/control-center-web/src/main/js/app/services/cleanup/cleanup.service.js
+++ b/modules/control-center-web/src/main/js/app/services/cleanup/cleanup.service.js
@@ -23,6 +23,7 @@ const isNumber = angular.isNumber;
 const isObject = angular.isObject;
 const isString = angular.isString;
 const isUndefined = angular.isUndefined;
+const isBoolean = (val) => typeof val === 'boolean';
 
 export default ['$cleanup', () => {
     const cleanup = (original, dist) => {
@@ -42,7 +43,7 @@ export default ['$cleanup', () => {
                     }
                 }
             }
-        } else if ((isString(original) && original.length) || isNumber(original))
+        } else if ((isString(original) && original.length) || isNumber(original) || isBoolean(original))
             dist = original;
         else if (isArray(original) && original.length) {
             dist = [];


[10/50] ignite git commit: IGNITE-843 Minor ES6 style fixes.

Posted by ak...@apache.org.
IGNITE-843 Minor ES6 style fixes.


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

Branch: refs/heads/ignite-843-rc3
Commit: 82d7a3873245e5dad2ea731ea06b85fc7e5dcf21
Parents: 055d2a9
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Mon Feb 15 15:45:21 2016 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Mon Feb 15 15:45:21 2016 +0700

----------------------------------------------------------------------
 modules/control-center-web/src/main/js/serve/routes/igfs.js | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/82d7a387/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 eb9b877..b10e5ac 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
@@ -48,9 +48,9 @@ module.exports.factory = function(_, express, mongo) {
                 .then(clusters => {
                     result.clusters = clusters;
 
-                    return  mongo.Igfs.find({space: {$in: result.spacesIds}}).sort('name').exec();
+                    return mongo.Igfs.find({space: {$in: result.spacesIds}}).sort('name').exec();
                 })
-                .then(igfss => {
+                .then((igfss) => {
                     _.forEach(igfss, (igfs) => {
                         // Remove deleted clusters.
                         igfs.clusters = _.filter(igfs.clusters, (clusterId) => {


[07/50] ignite git commit: IGNITE-843 Refactor serve to es6.

Posted by ak...@apache.org.
IGNITE-843 Refactor serve to es6.


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

Branch: refs/heads/ignite-843-rc3
Commit: 8007e760977b4aa062e88a84d93c9d5510788119
Parents: 4f90db1
Author: Andrey <an...@gridgain.com>
Authored: Mon Feb 15 15:13:17 2016 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Mon Feb 15 15:13:17 2016 +0700

----------------------------------------------------------------------
 modules/control-center-web/src/main/js/serve/routes/admin.js     | 2 +-
 modules/control-center-web/src/main/js/serve/routes/agent.js     | 2 +-
 modules/control-center-web/src/main/js/serve/routes/caches.js    | 2 +-
 modules/control-center-web/src/main/js/serve/routes/clusters.js  | 2 +-
 modules/control-center-web/src/main/js/serve/routes/domains.js   | 2 +-
 modules/control-center-web/src/main/js/serve/routes/igfs.js      | 2 +-
 modules/control-center-web/src/main/js/serve/routes/notebooks.js | 2 +-
 7 files changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/8007e760/modules/control-center-web/src/main/js/serve/routes/admin.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/admin.js b/modules/control-center-web/src/main/js/serve/routes/admin.js
index 9bef81498..2f26f7a 100644
--- a/modules/control-center-web/src/main/js/serve/routes/admin.js
+++ b/modules/control-center-web/src/main/js/serve/routes/admin.js
@@ -26,7 +26,7 @@ module.exports = {
 
 module.exports.factory = function(_, express, nodemailer, settings, mongo) {
     return new Promise((resolve) => {
-        const router = express.Router();
+        const router = new express.Router();
 
         /**
          * Get list of user accounts.

http://git-wip-us.apache.org/repos/asf/ignite/blob/8007e760/modules/control-center-web/src/main/js/serve/routes/agent.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/agent.js b/modules/control-center-web/src/main/js/serve/routes/agent.js
index 68a86d1..40e0c82 100644
--- a/modules/control-center-web/src/main/js/serve/routes/agent.js
+++ b/modules/control-center-web/src/main/js/serve/routes/agent.js
@@ -36,7 +36,7 @@ module.exports = {
  */
 module.exports.factory = function(_, express, apacheIgnite, fs, JSZip, settings, agentMgr) {
     return new Promise((resolveFactory) => {
-        const router = express.Router();
+        const router = new express.Router();
 
         const SqlFieldsQuery = apacheIgnite.SqlFieldsQuery;
         const ScanQuery = apacheIgnite.ScanQuery;

http://git-wip-us.apache.org/repos/asf/ignite/blob/8007e760/modules/control-center-web/src/main/js/serve/routes/caches.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/caches.js b/modules/control-center-web/src/main/js/serve/routes/caches.js
index 074758c..1f5a01c 100644
--- a/modules/control-center-web/src/main/js/serve/routes/caches.js
+++ b/modules/control-center-web/src/main/js/serve/routes/caches.js
@@ -26,7 +26,7 @@ module.exports = {
 
 module.exports.factory = function(_, express, mongo) {
     return new Promise((resolve) => {
-        const router = express.Router();
+        const router = new express.Router();
 
         /**
          * Get spaces and caches accessed for user account.

http://git-wip-us.apache.org/repos/asf/ignite/blob/8007e760/modules/control-center-web/src/main/js/serve/routes/clusters.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/clusters.js b/modules/control-center-web/src/main/js/serve/routes/clusters.js
index 3115328..98db693 100644
--- a/modules/control-center-web/src/main/js/serve/routes/clusters.js
+++ b/modules/control-center-web/src/main/js/serve/routes/clusters.js
@@ -26,7 +26,7 @@ module.exports = {
 
 module.exports.factory = function(_, express, mongo) {
     return new Promise((resolve) => {
-        const router = express.Router();
+        const router = new express.Router();
 
         /**
          * Get spaces and clusters accessed for user account.

http://git-wip-us.apache.org/repos/asf/ignite/blob/8007e760/modules/control-center-web/src/main/js/serve/routes/domains.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/domains.js b/modules/control-center-web/src/main/js/serve/routes/domains.js
index 1e87b0f..368258e 100644
--- a/modules/control-center-web/src/main/js/serve/routes/domains.js
+++ b/modules/control-center-web/src/main/js/serve/routes/domains.js
@@ -26,7 +26,7 @@ module.exports = {
 
 module.exports.factory = function(_, express, async, mongo) {
     return new Promise((resolve) => {
-        const router = express.Router();
+        const router = new express.Router();
 
         /**
          * Get spaces and domain models accessed for user account.

http://git-wip-us.apache.org/repos/asf/ignite/blob/8007e760/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 76dde1f..1a864d7 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
@@ -26,7 +26,7 @@ module.exports = {
 
 module.exports.factory = function(_, express, mongo) {
     return new Promise((resolve) => {
-        const router = express.Router();
+        const router = new express.Router();
 
         /**
          * Get spaces and IGFSs accessed for user account.

http://git-wip-us.apache.org/repos/asf/ignite/blob/8007e760/modules/control-center-web/src/main/js/serve/routes/notebooks.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/notebooks.js b/modules/control-center-web/src/main/js/serve/routes/notebooks.js
index a12dacf..e65f77d 100644
--- a/modules/control-center-web/src/main/js/serve/routes/notebooks.js
+++ b/modules/control-center-web/src/main/js/serve/routes/notebooks.js
@@ -26,7 +26,7 @@ module.exports = {
 
 module.exports.factory = function(express, mongo) {
     return new Promise((resolve) => {
-        const router = express.Router();
+        const router = new express.Router();
 
         /**
          * Get notebooks names accessed for user account.


[23/50] ignite git commit: IGNITE-843 Fixed remove.

Posted by ak...@apache.org.
IGNITE-843 Fixed remove.


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

Branch: refs/heads/ignite-843-rc3
Commit: e5bfc4c7f800e6228270561546212dd14ab1f81c
Parents: ae86c52
Author: Andrey <an...@gridgain.com>
Authored: Mon Feb 15 18:08:27 2016 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Mon Feb 15 18:08:27 2016 +0700

----------------------------------------------------------------------
 .../src/main/js/serve/routes/clusters.js                | 12 ++----------
 .../control-center-web/src/main/js/serve/routes/igfs.js |  3 +--
 2 files changed, 3 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/e5bfc4c7/modules/control-center-web/src/main/js/serve/routes/clusters.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/clusters.js b/modules/control-center-web/src/main/js/serve/routes/clusters.js
index 2674975..256de5d 100644
--- a/modules/control-center-web/src/main/js/serve/routes/clusters.js
+++ b/modules/control-center-web/src/main/js/serve/routes/clusters.js
@@ -137,18 +137,10 @@ module.exports.factory = function(_, express, mongo) {
          * Remove cluster by ._id.
          */
         router.post('/remove', (req, res) => {
-            const userId = req.currentUserId();
             const clusterId = req.body;
 
-            let spacesIds = [];
-
-            mongo.Space.find({$or: [{owner: userId}, {usedBy: {$elemMatch: {account: userId}}}]})
-                .then((spaces) => {
-                    spacesIds = spaces.map((value) => value._id);
-
-                    return mongo.Cache.update({space: {$in: spacesIds}}, {$pull: {clusters: clusterId}}, {multi: true});
-                })
-                .then(() => mongo.Igfs.update({space: {$in: spacesIds}}, {$pull: {clusters: clusterId}}, {multi: true}))
+            mongo.Cache.update({clusters: {$in: [clusterId]}}, {$pull: {clusters: clusterId}}, {multi: true}).exec()
+                .then(() => mongo.Igfs.update({clusters: {$in: [clusterId]}}, {$pull: {clusters: clusterId}}, {multi: true}).exec())
                 .then(() => mongo.Cluster.remove(clusterId))
                 .then(() => res.sendStatus(200))
                 .catch((err) => {

http://git-wip-us.apache.org/repos/asf/ignite/blob/e5bfc4c7/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 c9ce238..7508f9a 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
@@ -109,8 +109,7 @@ module.exports.factory = function(_, express, mongo) {
         router.post('/remove', (req, res) => {
             const igfsId = req.body;
 
-            mongo.Space.find({$or: [{owner: userId}, {usedBy: {$elemMatch: {account: userId}}}]})
-                .then((spaces) => mongo.Cluster.update({space: {$in: spacesIds}}, {$pull: {igfss: igfsId}}, {multi: true}))
+            mongo.Cluster.update({igfss: {$in: [igfsId]}}, {$pull: {igfss: igfsId}}, {multi: true}).exec()
                 .then(mongo.Igfs.remove(igfsId))
                 .then(() => res.sendStatus(200))
                 .catch((err) => {


[09/50] ignite git commit: IGNITE-843 Rework IGFS server side to Promises.

Posted by ak...@apache.org.
IGNITE-843 Rework IGFS server side to Promises.


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

Branch: refs/heads/ignite-843-rc3
Commit: 055d2a9abaf4375dc3b6a6b0f3e3f4a463da89b1
Parents: 540acaa
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Mon Feb 15 15:42:28 2016 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Mon Feb 15 15:42:28 2016 +0700

----------------------------------------------------------------------
 .../src/main/js/serve/routes/igfs.js            | 56 ++++++++++----------
 1 file changed, 29 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/055d2a9a/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 1a864d7..eb9b877 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
@@ -35,37 +35,39 @@ module.exports.factory = function(_, express, mongo) {
          * @param res Response.
          */
         router.post('/list', (req, res) => {
-            const user_id = req.currentUserId();
+            const result = {};
 
             // Get owned space and all accessed space.
-            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.Space.find({$or: [{owner: req.currentUserId()}, {usedBy: {$elemMatch: {account: req.currentUserId()}}}]}).exec()
+                .then((spaces) => {
+                    result.spaces = spaces;
+                    result.spacesIds = spaces.map((value) => value._id);
+
+                    return mongo.Cluster.find({space: {$in: result.spacesIds}}, '_id name').sort('name').exec();
+                })
+                .then(clusters => {
+                    result.clusters = clusters;
+
+                    return  mongo.Igfs.find({space: {$in: result.spacesIds}}).sort('name').exec();
+                })
+                .then(igfss => {
+                    _.forEach(igfss, (igfs) => {
+                        // Remove deleted clusters.
+                        igfs.clusters = _.filter(igfs.clusters, (clusterId) => {
+                            return _.findIndex(result.clusters, (cluster) => cluster._id.equals(clusterId)) >= 0;
+                        });
+                    });
 
-                    // Get all clusters for spaces.
-                    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((errIgfs, igfss) => {
-                                if (mongo.processed(errIgfs, res)) {
-                                    _.forEach(igfss, (igfs) => {
-                                        // Remove deleted clusters.
-                                        igfs.clusters = _.filter(igfs.clusters, (clusterId) => {
-                                            return _.findIndex(clusters, (cluster) => cluster._id.equals(clusterId)) >= 0;
-                                        });
-                                    });
-
-                                    res.json({
-                                        spaces,
-                                        clusters: clusters.map((cluster) => ({value: cluster._id, label: cluster.name})),
-                                        igfss
-                                    });
-                                }
-                            });
-                        }
+                    res.json({
+                        spaces: result.spaces,
+                        clusters: result.clusters.map((cluster) => ({value: cluster._id, label: cluster.name})),
+                        igfss
                     });
-                }
-            });
+                })
+                .catch((err) => {
+                    // TODO IGNITE-843 Send error to admin
+                    res.status(500).send(err.message);
+                });
         });
 
         /**


[18/50] ignite git commit: IGNITE-843 Pass IGFS id on cluster add.

Posted by ak...@apache.org.
IGNITE-843 Pass IGFS id on cluster add.


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

Branch: refs/heads/ignite-843-rc3
Commit: 02d4c1ec4fa4a690911f00ab6ae174373ecf5529
Parents: 60330c8
Author: Vasiliy Sisko <vs...@gridgain.com>
Authored: Mon Feb 15 17:45:00 2016 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Mon Feb 15 17:45:00 2016 +0700

----------------------------------------------------------------------
 .../main/js/app/modules/states/configuration/clusters/igfs.jade    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/02d4c1ec/modules/control-center-web/src/main/js/app/modules/states/configuration/clusters/igfs.jade
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/app/modules/states/configuration/clusters/igfs.jade b/modules/control-center-web/src/main/js/app/modules/states/configuration/clusters/igfs.jade
index b831177..e0db188 100644
--- a/modules/control-center-web/src/main/js/app/modules/states/configuration/clusters/igfs.jade
+++ b/modules/control-center-web/src/main/js/app/modules/states/configuration/clusters/igfs.jade
@@ -29,7 +29,7 @@ form.panel.panel-default(name='igfs' novalidate)
                 .settings-row
                     ignite-form-field
                         ignite-form-field-label
-                            | IGFS: #[a(ui-sref='base.configuration.igfs') (add)]
+                            | IGFS: #[a(ui-sref='base.configuration.igfs({id: #{model}._id})') (add)]
                         ignite-form-field-tooltip
                             | Select IGFS to start in cluster or add a new IGFS
                         ignite-form-field-dropdown(