Made the fake data randomly generate to give the illusion of change

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

Branch: refs/heads/console-v2
Commit: 0e2ad4304b3f6dc79d3512a002e6f8ecb26d6184
Parents: 03d7db0
Author: Chris Rohr <[email protected]>
Authored: Mon Feb 17 15:43:23 2014 -0500
Committer: Chris Rohr <[email protected]>
Committed: Mon Feb 17 15:43:23 2014 -0500

----------------------------------------------------------------------
 .../ui/app/scripts/blurconsole.fake.js          | 51 ++++++++++++--------
 1 file changed, 31 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/0e2ad430/contrib/blur-console/ui/app/scripts/blurconsole.fake.js
----------------------------------------------------------------------
diff --git a/contrib/blur-console/ui/app/scripts/blurconsole.fake.js 
b/contrib/blur-console/ui/app/scripts/blurconsole.fake.js
index d1148cf..289a239 100644
--- a/contrib/blur-console/ui/app/scripts/blurconsole.fake.js
+++ b/contrib/blur-console/ui/app/scripts/blurconsole.fake.js
@@ -18,30 +18,41 @@ blurconsole.fake = (function() {
        var getTableList, getNodeList, getQueryPerformance;
 
        getTableList = function() {
-               return [
-                       {cluster: 'prodA', name: 'testtable1', enabled: true, 
rows: 1000, records: 10000},
-                       {cluster: 'prodA', name: 'testtable2', enabled: true, 
rows: 1000, records: 10000},
-                       {cluster: 'prodA', name: 'testtable3', enabled: false, 
rows: 1000, records: 10000},
-                       {cluster: 'prodB', name: 'testtable4', enabled: true, 
rows: 1000, records: 10000},
-                       {cluster: 'prodB', name: 'testtable5', enabled: false, 
rows: 1000, records: 10000},
-               ];
+               var clusters = ['prodA', 'prodB'], data = [], i, cluster, rows, 
records, enabled;
+
+               for (i = 0; i < 5; i++) {
+                       cluster = clusters[Math.floor(Math.random()*2)];
+                       rows = Math.floor(Math.random()*1000+1);
+                       records = Math.floor(Math.random()*10000+1001);
+                       enabled = Math.floor(Math.random()*2) === 1;
+
+                       data.push({cluster:cluster, name:'testtable'+i, 
enabled:enabled, rows:rows, records:records});
+
+               }
+               return data;
        };
 
        getNodeList = function() {
-               return {
-                       controllers: {
-                               online: ['controller1.localhost', 
'controller2.localhost'],
-                               offline: ['controller3.localhost']
-                       },
-                       clusters: [
-                               {name: 'prodA', online: [], offline: 
['shard1.localhost']},
-                               {name: 'prodB', online: ['shard2.localhost'], 
offline: ['shard4.localhost']}
-                       ],
-                       zookeepers: {
-                               online: ['zookeeper1.localhost'],
-                               offline: []
+               var controllers = {online:[], offline:[]},
+                       clusters = [{name:'prodA', online:[], offline:[]}, 
{name:'prodB', online:[], offline:[]}],
+                       zookeepers = {online: [], offline:[]},
+                       i, state;
+
+               for(i = 0; i < 3; i++) {
+                       state = Math.floor(Math.random()*2);
+                       if (state === 0) {
+                               controllers.online.push('controller' + i + 
'.localhost');
+                               clusters[0].online.push('prodA.shard' + i + 
'.localhost');
+                               clusters[1].online.push('prodB.shard' + i + 
'.localhost');
+                               zookeepers.online.push('zookeeper' + i + 
'.localhost');
+                       } else {
+                               controllers.offline.push('controller' + i + 
'.localhost');
+                               clusters[0].offline.push('prodA.shard' + i + 
'.localhost');
+                               clusters[1].offline.push('prodB.shard' + i + 
'.localhost');
+                               zookeepers.offline.push('zookeeper' + i + 
'.localhost');
                        }
-               };
+               }
+               return {controllers: controllers, clusters: clusters, 
zookeepers: zookeepers};
        };
 
        getQueryPerformance = function() {

Reply via email to