ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anovi...@apache.org
Subject ignite git commit: IGNITE-843 Refactor serve to es6.
Date Fri, 12 Feb 2016 09:35:16 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-843-rc2 a7f04fb22 -> 8a7b7bb5a


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/8a7b7bb5
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/8a7b7bb5
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/8a7b7bb5

Branch: refs/heads/ignite-843-rc2
Commit: 8a7b7bb5a7e276d4817e007ac764fe708be01d3e
Parents: a7f04fb
Author: Andrey <anovikov@gridgain.com>
Authored: Fri Feb 12 16:35:23 2016 +0700
Committer: Andrey <anovikov@gridgain.com>
Committed: Fri Feb 12 16:35:23 2016 +0700

----------------------------------------------------------------------
 .../src/main/js/serve/routes/agent.js           | 96 ++++++++++----------
 1 file changed, 50 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/8a7b7bb5/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 5fa0328..68a86d1 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
@@ -35,7 +35,7 @@ module.exports = {
  * @returns {Promise}
  */
 module.exports.factory = function(_, express, apacheIgnite, fs, JSZip, settings, agentMgr)
{
-    return new Promise((resolve) => {
+    return new Promise((resolveFactory) => {
         const router = express.Router();
 
         const SqlFieldsQuery = apacheIgnite.SqlFieldsQuery;
@@ -212,13 +212,13 @@ module.exports.factory = function(_, express, apacheIgnite, fs, JSZip,
settings,
                 .then((caches) => {
                     let types = [];
 
-                    for (const meta of caches) {
-                        const cacheTypes = meta.types.map(function(typeName) {
-                            let fields = meta.fields[typeName];
+                    const _typeMapper = (meta, typeName) => {
+                        let fields = meta.fields[typeName];
 
-                            let columns = [];
+                        let columns = [];
 
-                            for (const fieldName in fields) {
+                        for (const fieldName in fields) {
+                            if (fields.hasOwnProperty(fieldName)) {
                                 const fieldClass = _compact(fields[fieldName]);
 
                                 columns.push({
@@ -230,53 +230,57 @@ module.exports.factory = function(_, express, apacheIgnite, fs, JSZip,
settings,
                                     typeName
                                 });
                             }
+                        }
 
-                            const indexes = [];
-
-                            for (const index of meta.indexes[typeName]) {
-                                fields = [];
-
-                                for (const field of index.fields) {
-                                    fields.push({
-                                        type: 'index-field',
-                                        name: field,
-                                        order: index.descendings.indexOf(field) < 0,
-                                        unique: index.unique,
-                                        cacheName: meta.cacheName,
-                                        typeName
-                                    });
-                                }
-
-                                if (fields.length > 0) {
-                                    indexes.push({
-                                        type: 'index',
-                                        name: index.name,
-                                        children: fields,
-                                        cacheName: meta.cacheName,
-                                        typeName
-                                    });
-                                }
-                            }
+                        const indexes = [];
 
-                            columns = _.sortBy(columns, 'name');
+                        for (const index of meta.indexes[typeName]) {
+                            fields = [];
 
-                            if (!_.isEmpty(indexes)) {
-                                columns = columns.concat({
-                                    type: 'indexes',
-                                    name: 'Indexes',
+                            for (const field of index.fields) {
+                                fields.push({
+                                    type: 'index-field',
+                                    name: field,
+                                    order: index.descendings.indexOf(field) < 0,
+                                    unique: index.unique,
                                     cacheName: meta.cacheName,
-                                    typeName,
-                                    children: indexes
+                                    typeName
                                 });
                             }
 
-                            return {
-                                type: 'type',
-                                cacheName: meta.cacheName || '',
+                            if (fields.length > 0) {
+                                indexes.push({
+                                    type: 'index',
+                                    name: index.name,
+                                    children: fields,
+                                    cacheName: meta.cacheName,
+                                    typeName
+                                });
+                            }
+                        }
+
+                        columns = _.sortBy(columns, 'name');
+
+                        if (!_.isEmpty(indexes)) {
+                            columns = columns.concat({
+                                type: 'indexes',
+                                name: 'Indexes',
+                                cacheName: meta.cacheName,
                                 typeName,
-                                children: columns
-                            };
-                        });
+                                children: indexes
+                            });
+                        }
+
+                        return {
+                            type: 'type',
+                            cacheName: meta.cacheName || '',
+                            typeName,
+                            children: columns
+                        };
+                    };
+
+                    for (const meta of caches) {
+                        const cacheTypes = meta.types.map(_typeMapper.bind(null, meta));
 
                         if (!_.isEmpty(cacheTypes))
                             types = types.concat(cacheTypes);
@@ -330,7 +334,7 @@ module.exports.factory = function(_, express, apacheIgnite, fs, JSZip,
settings,
                 .catch(_handleException(res));
         });
 
-        resolve(router);
+        resolveFactory(router);
     });
 };
 


Mime
View raw message