Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-843 72c15eb02 -> 9741bfc70


# IGNITE-843 WIP on clusters table.


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

Branch: refs/heads/ignite-843
Commit: 319fc3ed16c5fa2144c0e49ef390a6974b6d0f69
Parents: a449703
Author: AKuznetsov <akuznet...@gridgain.com>
Authored: Mon May 25 17:39:13 2015 +0700
Committer: AKuznetsov <akuznet...@gridgain.com>
Committed: Mon May 25 17:39:13 2015 +0700

----------------------------------------------------------------------
 modules/webconfig/nodejs/db.js                  |  12 +-
 .../public/javascripts/controllers/clusters.js  | 204 ++++++++++---------
 modules/webconfig/nodejs/views/clusters.jade    |   3 +-
 3 files changed, 112 insertions(+), 107 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/319fc3ed/modules/webconfig/nodejs/db.js
----------------------------------------------------------------------
diff --git a/modules/webconfig/nodejs/db.js b/modules/webconfig/nodejs/db.js
index 5c711bf..b6cbf43 100644
--- a/modules/webconfig/nodejs/db.js
+++ b/modules/webconfig/nodejs/db.js
@@ -1,15 +1,15 @@
 var config = require('./configuration.js');
 
-// mongoose for mongodb
+// Mongoose for mongodb.
 var mongoose = require('mongoose'),
     Schema = mongoose.Schema,
     ObjectId = mongoose.Schema.Types.ObjectId,
     passportLocalMongoose = require('passport-local-mongoose');
 
-// connect to mongoDB database on modulus.io
+// Connect to mongoDB database on modulus.io.
 mongoose.connect(config.get('mongoDB:url'), {server: {poolSize: 4}});
 
-// define user model.
+// Define user model.
 var AccountSchema = new Schema({
     username: String
 });
@@ -18,7 +18,7 @@ AccountSchema.plugin(passportLocalMongoose, { usernameField: 
'email' });
 
 exports.Account = mongoose.model('Account', AccountSchema);
 
-// define space model.
+// Define space model.
 exports.Space =  mongoose.model('Space', new Schema({
     name: String,
     owner: { type: ObjectId, ref: 'Account' },
@@ -28,7 +28,7 @@ exports.Space =  mongoose.model('Space', new Schema({
     }]
 }));
 
-// define cluster model.
+// Define cluster model.
 exports.Cluster =  mongoose.model('Cluster', new Schema({
     space: { type: ObjectId, ref: 'Space' },
     name : String,
@@ -36,7 +36,7 @@ exports.Cluster =  mongoose.model('Cluster', new Schema({
     addresses : [String]
 }));
 
-// define cache model.
+// Define cache model.
 exports.Cache =  mongoose.model('Cache', new Schema({
     space: { type: ObjectId, ref: 'Space' },
     name: String,

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/319fc3ed/modules/webconfig/nodejs/public/javascripts/controllers/clusters.js
----------------------------------------------------------------------
diff --git 
a/modules/webconfig/nodejs/public/javascripts/controllers/clusters.js 
b/modules/webconfig/nodejs/public/javascripts/controllers/clusters.js
index 0cfbe1b..8bd3fc9 100644
--- a/modules/webconfig/nodejs/public/javascripts/controllers/clusters.js
+++ b/modules/webconfig/nodejs/public/javascripts/controllers/clusters.js
@@ -1,121 +1,125 @@
-configuratorModule.controller('clustersController', ['$scope', '$modal', 
'$http', '$filter', 'ngTableParams', function($scope, $modal, $http, $filter, 
ngTableParams) {
-    $scope.edit = { };
-
-    $scope.editRow = {};
-    $scope.editIdx = false;
-
-    $scope.discoveries = [
-        {value: 'TcpDiscoveryVmIpFinder', label: 'Static IPs'},
-        {value: 'TcpDiscoveryMulticastIpFinder', label: 'Multicast'}
-    ];
-
-    $scope.discoveryAsString = function(value) {
-        for (var i in $scope.discoveries) {
-            if ($scope.discoveries[i].value == value)
-                return $scope.discoveries[i].label;
-        }
-
-        return 'Wrong discovery';
-    };
-
-    // when landing on the page, get all settings and show them
-    $http.get('/rest/clusters')
-        .success(function(data) {
-            $scope.clusters = data;
-
-            $scope.clustersTable = new ngTableParams({
-                page: 1,                    // show first page
-                count: Number.MAX_VALUE,        // count per page
-                sorting: {
-                    name: 'asc'             // initial sorting
-                }
-            }, {
-                total: $scope.clusters.length, // length of data
-                counts: [],
-                getData: function($defer, params) {
-                    // use build-in angular filter
-                    var orderedData = params.sorting() ?
-                        $filter('orderBy')($scope.clusters, params.orderBy()) :
-                        $scope.clusters;
-
-                    $defer.resolve(orderedData.slice((params.page() - 1) * 
params.count(), params.page() * params.count()));
+configuratorModule.controller('clustersController',
+    [
+        '$scope', '$modal', '$http', '$filter', 'ngTableParams',
+        function ($scope, $modal, $http, $filter, ngTableParams) {
+            $scope.edit = {};
+            $scope.editRow = {};
+            $scope.editIdx = false;
+
+            $scope.discoveries = [
+                {value: 'TcpDiscoveryVmIpFinder', label: 'Static IPs'},
+                {value: 'TcpDiscoveryMulticastIpFinder', label: 'Multicast'}
+            ];
+
+            $scope.discoveryAsString = function (value) {
+                for (var i in $scope.discoveries) {
+                    if ($scope.discoveries[i].value == value)
+                        return $scope.discoveries[i].label;
                 }
-            });
-        })
-        .error(function(data) {
-            $scope.text = data;
-        });
-
-    // Pre-fetch an external template populated with a custom scope
-    var myOtherModal = $modal({scope: $scope, template: '/cluster/edit', show: 
false});
-
-    $scope.submit = function() {
-        if ($scope.editIdx !== false) {
-            var cluster = $scope.clusters[$scope.editIdx];
-
-            var data = {
-                _id: cluster._id,
-                name: cluster.name,
-                discovery: cluster.discovery,
-                addresses: ['127.0.0.1', '192.168.1.1']
-            };
 
-            $scope.editIdx = false;
+                return 'Wrong discovery';
+            };
 
-            $http.post('/rest/clusters/save', data)
+            // When landing on the page, get clusters and show them.
+            $http.get('/rest/clusters')
                 .success(function (data) {
-                    myOtherModal.hide();
-
                     $scope.clusters = data;
 
-                    $scope.clustersTable.reload();
+                    $scope.clustersTable = new ngTableParams({
+                        page: 1,                    // Show first page.
+                        count: Number.MAX_VALUE,    // Count per page.
+                        sorting: { name: 'asc'}     // Initial sorting.
+                    }, {
+                        total: $scope.clusters.length, // Length of data.
+                        counts: [],
+                        getData: function ($defer, params) {
+                            // Use build-in angular filter.
+                            var orderedData = params.sorting() ?
+                                $filter('orderBy')($scope.clusters, 
params.orderBy()) :
+                                $scope.clusters;
+
+                            var page = params.page();
+                            var cnt = params.count();
+                            $defer.resolve(orderedData.slice(page - 1 * cnt, 
page * cnt));
+                        }
+                    });
                 })
                 .error(function (data) {
-                    console.log('Error: ' + data);
+                    $scope.text = data;
                 });
-        }
-    };
 
-    $scope.add = function () {
-        $scope.clusters.push({});
+            // TODO: Pre-fetch an external template populated with a custom 
scope.
+            var myOtherModal = $modal({scope: $scope, template: 
'/cluster/edit', show: false});
 
-        $scope.clustersTable.reload();
+            $scope.submit = function () {
+                if ($scope.editIdx !== false) {
+                    var cluster = $scope.clusters[$scope.editIdx];
 
-        // Show when some event occurs (use $promise property to ensure the 
template has been loaded)
-        //myOtherModal.$promise.then(myOtherModal.show);
-    };
+                    var data = {
+                        _id: cluster._id,
+                        name: cluster.name,
+                        discovery: cluster.discovery,
+                        addresses: ['127.0.0.1', '192.168.1.1']
+                    };
 
-    $scope.beginEdit = function (cluster) {
-        $scope.editIdx = $scope.clusters.indexOf(cluster);
+                    $scope.editIdx = false;
 
-        $scope.editRow = angular.copy(cluster);
+                    $http.post('/rest/clusters/save', data)
+                        .success(function (data) {
+                            myOtherModal.hide();
 
-        //// Show when some event occurs (use $promise property to ensure the 
template has been loaded)
-        //myOtherModal.$promise.then(myOtherModal.show);
-    };
+                            $scope.clusters = data;
 
-    $scope.revert = function () {
-        if ($scope.editIdx !== false) {
-            $scope.clusters[$scope.editIdx] = $scope.editRow;
+                            $scope.clustersTable.reload();
+                        })
+                        .error(function (data) {
+                            console.log('Error: ' + data);
+                        });
+                }
+            };
 
-            $scope.editIdx = false;
+            // Add new cluster.
+            $scope.add = function () {
+//                $scope.clusters.push({name: 'Cluster', discovery: 
'TcpDiscoveryVmIpFinder'});
+                $scope.clusters.push({});
 
-            $scope.clustersTable.reload();
-        }
+                $scope.clustersTable.reload();
 
-        //// Show when some event occurs (use $promise property to ensure the 
template has been loaded)
-        //myOtherModal.$promise.then(myOtherModal.show);
-    };
+                // Show when some event occurs (use $promise property to 
ensure the template has been loaded)
+                //myOtherModal.$promise.then(myOtherModal.show);
+            };
 
-    $scope.delete = function (cluster) {
-        $http.post('/rest/clusters/remove', { _id: cluster._id })
-            .success(function(data) {
-                $scope.clusters = data;
+            $scope.beginEdit = function (cluster) {
+                $scope.editIdx = $scope.clusters.indexOf(cluster);
 
-                $scope.clustersTable.reload();
-            })
-            .error(function(data) {
-                console.log('Error: ' + data);
-            });
-    };
-}]);
\ No newline at end of file
+                $scope.editRow = angular.copy(cluster);
+
+                //// Show when some event occurs (use $promise property to 
ensure the template has been loaded)
+                //myOtherModal.$promise.then(myOtherModal.show);
+            };
+
+            $scope.revert = function () {
+                if ($scope.editIdx !== false) {
+                    $scope.clusters[$scope.editIdx] = $scope.editRow;
+
+                    $scope.editIdx = false;
+
+                    $scope.clustersTable.reload();
+                }
+
+                //// Show when some event occurs (use $promise property to 
ensure the template has been loaded)
+                //myOtherModal.$promise.then(myOtherModal.show);
+            };
+
+            $scope.delete = function (cluster) {
+                $http.post('/rest/clusters/remove', {_id: cluster._id})
+                    .success(function (data) {
+                        $scope.clusters = data;
+
+                        $scope.clustersTable.reload();
+                    })
+                    .error(function (data) {
+                        console.log('Error: ' + data);
+                    });
+            };
+        }]);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/319fc3ed/modules/webconfig/nodejs/views/clusters.jade
----------------------------------------------------------------------
diff --git a/modules/webconfig/nodejs/views/clusters.jade 
b/modules/webconfig/nodejs/views/clusters.jade
index 3abc8c2..40e8235 100644
--- a/modules/webconfig/nodejs/views/clusters.jade
+++ b/modules/webconfig/nodejs/views/clusters.jade
@@ -1,3 +1,4 @@
+// Page with cluster configuration.
 extends layout-sidebar
 
 append css
@@ -13,7 +14,7 @@ block content
         hr
     div.docs-body(ng-controller='clustersController')
         div.block-edit-parameters
-            div(class=['btn-group'])
+            div.btn-group
                 button(ng-click='add()' class=['btn', 'btn-default', 'fa', 
'fa-plus'] ) &nbspAdd
         table(ng-table="clustersTable" class=['table', 'table-bordered', 
'table-hover'])
             tr(ng-repeat="cluster in $data")

Reply via email to