incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cr...@apache.org
Subject [1/4] git commit: Started adding in the table page
Date Wed, 26 Mar 2014 22:31:05 GMT
Repository: incubator-blur
Updated Branches:
  refs/heads/console-v2 0e2ad4304 -> ef5f913b4


Started adding in the table page


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

Branch: refs/heads/console-v2
Commit: cd3c9e8307d93e8ab102a4251cc6d381f1fc2b20
Parents: 0e2ad43
Author: Chris Rohr <crohr@nearinfinity.com>
Authored: Mon Mar 3 10:55:40 2014 -0500
Committer: Chris Rohr <crohr@nearinfinity.com>
Committed: Mon Mar 3 10:55:40 2014 -0500

----------------------------------------------------------------------
 contrib/blur-console/ui/app/index.html          |   4 +-
 .../ui/app/scripts/blurconsole.dashboard.js     |   2 +-
 .../ui/app/scripts/blurconsole.model.js         |  75 +++++++++--
 .../ui/app/scripts/blurconsole.tables.js        | 126 +++++++++++++++++++
 .../ui/app/scripts/blurconsole.utils.js         |  21 +++-
 .../blur-console/ui/app/views/tables.tpl.html   |  15 +++
 contrib/blur-console/ui/bower.json              |   7 +-
 7 files changed, 232 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/cd3c9e83/contrib/blur-console/ui/app/index.html
----------------------------------------------------------------------
diff --git a/contrib/blur-console/ui/app/index.html b/contrib/blur-console/ui/app/index.html
index 140b922..6a87c68 100644
--- a/contrib/blur-console/ui/app/index.html
+++ b/contrib/blur-console/ui/app/index.html
@@ -66,10 +66,9 @@ limitations under the License.
 
         <!-- build:js scripts/vendor.js -->
         <!-- bower:js -->
-        <script src="bower_components/jquery/jquery.js"></script>
+        <script src="bower_components/jquery/dist/jquery.js"></script>
         <script src="lib/jquery.uriAnchor.js"></script>
         <script src="lib/jquery.event.gevent.js"></script>
-        <script src="bower_components/taffydb/taffy.js"></script>
         <!-- endbower -->
         <!-- endbuild -->
 
@@ -97,6 +96,7 @@ limitations under the License.
         <script src="scripts/blurconsole.utils.js"></script>
         <script src="scripts/blurconsole.shell.js"></script>
         <script src="scripts/blurconsole.dashboard.js"></script>
+        <script src="scripts/blurconsole.tables.js"></script>
         <script src="scripts/blurconsole.data.js"></script>
         <script src="scripts/blurconsole.fake.js"></script>
         <script src="scripts/blurconsole.model.js"></script>

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/cd3c9e83/contrib/blur-console/ui/app/scripts/blurconsole.dashboard.js
----------------------------------------------------------------------
diff --git a/contrib/blur-console/ui/app/scripts/blurconsole.dashboard.js b/contrib/blur-console/ui/app/scripts/blurconsole.dashboard.js
index 78fcfe7..417ed38 100644
--- a/contrib/blur-console/ui/app/scripts/blurconsole.dashboard.js
+++ b/contrib/blur-console/ui/app/scripts/blurconsole.dashboard.js
@@ -130,7 +130,7 @@ blurconsole.dashboard = (function () {
 	};
 
 	loadQueryPerfLineChart = function() {
-		$.plot(jqueryMap.$queryLoadChartHolder, [blurconsole.model.metrics.getQueryLoadChartData()],
{
+		$.plot(jqueryMap.$queryLoadChartHolder, blurconsole.model.metrics.getQueryLoadChartData(),
{
 			series : {
 				shadowSize : 0
 			},

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/cd3c9e83/contrib/blur-console/ui/app/scripts/blurconsole.model.js
----------------------------------------------------------------------
diff --git a/contrib/blur-console/ui/app/scripts/blurconsole.model.js b/contrib/blur-console/ui/app/scripts/blurconsole.model.js
index 063bb8f..a15cd2a 100644
--- a/contrib/blur-console/ui/app/scripts/blurconsole.model.js
+++ b/contrib/blur-console/ui/app/scripts/blurconsole.model.js
@@ -28,10 +28,51 @@ blurconsole.model = (function() {
 		tables, metrics, initModule, nodePoller, tablePoller, queryPerformancePoller;
 
 	tables = (function() {
-		var getDb, getNameMap;
+		var getClusters, getEnabledTables, getDisabledTables;
 
-		getDb = function() { return stateMap.tableDb; };
-		getNameMap = function() { return stateMap.tableNameMap; };
+		getClusters = function() {
+			return blurconsole.utils.unique($.map(stateMap.tableNameMap, function(table){
+				return table.cluster;
+			}), true);
+		};
+
+		getEnabledTables = function(cluster) {
+			var data = [];
+
+			$.each(stateMap.tableNameMap, function(idx, table) {
+				if (table.cluster === cluster && table.enabled) {
+					data.push({name:table.name, rowCount:table.rows, recordCount:table.records});
+				}
+			});
+
+			return {
+				cols : {
+					name : {
+						index : 1,
+						type : 'string'
+					},
+					rowCount : {
+						index : 2,
+						type : 'number'
+					},
+					recordCount : {
+						index : 3,
+						type : 'number'
+					}
+				},
+				rows: data
+			};
+		};
+
+		getDisabledTables = function(cluster) {
+			console.log(cluster);
+		};
+
+		return {
+			getClusters : getClusters,
+			getEnabledTables : getEnabledTables,
+			getDisabledTables : getDisabledTables
+		};
 	}());
 
 	metrics = (function() {
@@ -117,13 +158,25 @@ blurconsole.model = (function() {
 		};
 
 		getQueryLoadChartData = function() {
-			var dataArray = [];
+			var total = 0,
+				queryArray = [], 
+				meanArray = [],
+				queryData, mean;
+
+			queryData = stateMap.queryPerformance;
+			
+			$.each(queryData, function(idx, increment) {
+				total += increment;
+			});
+
+			mean = queryData.length === 0 ? 0 : total/queryData.length;
 
-			$.each(stateMap.queryPerformance, function(idx, increment) {
-				dataArray.push([idx, increment]);
+			$.each(queryData, function(idx, increment) {
+				queryArray.push([idx, increment]);
+				meanArray.push([idx, mean]);
 			});
 
-			return dataArray;
+			return [queryArray, meanArray];
 		};
 
 		buildPieChartData = function(onlineCount, offlineCount) {
@@ -176,9 +229,11 @@ blurconsole.model = (function() {
 
 	initModule = function() {
 		configMap.poller = isFakeData ? blurconsole.fake : blurconsole.data;
-		nodePoller();
-		tablePoller();
-		queryPerformancePoller();
+		setTimeout(function() {
+			nodePoller();
+			tablePoller();
+			queryPerformancePoller();
+		}, 1000);
 	};
 	return {
 		initModule : initModule,

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/cd3c9e83/contrib/blur-console/ui/app/scripts/blurconsole.tables.js
----------------------------------------------------------------------
diff --git a/contrib/blur-console/ui/app/scripts/blurconsole.tables.js b/contrib/blur-console/ui/app/scripts/blurconsole.tables.js
new file mode 100644
index 0000000..fca683b
--- /dev/null
+++ b/contrib/blur-console/ui/app/scripts/blurconsole.tables.js
@@ -0,0 +1,126 @@
+/*
+
+Licensed 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.
+*/
+
+/*global blurconsole:false */
+blurconsole.tables = (function () {
+	'use strict';
+	var configMap = {
+		view : 'views/tables.tpl.html',
+		tableSettings : {
+			pageSize : 500,
+			pageSizes : null
+		}
+	},
+	stateMap = { $container : null },
+	jqueryMap = {},
+	setJqueryMap, initModule, unloadModule, updateTableList, buildTabs, waitForData;
+
+	setJqueryMap = function() {
+		var $container = stateMap.$container;
+		jqueryMap = {
+			$container : $container,
+			$tableInfoHolder : $('#tableInfoHolder'),
+			$tables : {}
+		};
+	};
+
+	unloadModule = function() {
+		$.gevent.unsubscribe(jqueryMap.$container, 'tables-updated');
+	};
+
+	initModule = function($container) {
+		$container.load(configMap.view, function() {
+			stateMap.$container = $container;
+			setJqueryMap();
+			$.gevent.subscribe(jqueryMap.$container, 'tables-updated', updateTableList);
+			waitForData();
+			jqueryMap.$tableInfoHolder.on('click', 'ul.nav a', function(e) {
+				e.preventDefault();
+				$(this).tab('show');
+			});
+		});
+		return true;
+	};
+
+	waitForData = function() {
+		if (blurconsole.model.tables.getClusters().length > 0) {
+			buildTabs();
+		} else {
+			setTimeout(waitForData, 100);
+		}
+	};
+
+	buildTabs = function() {
+		var clusters, tabMarkup, paneMarkup, needsTabs;
+
+		clusters = blurconsole.model.tables.getClusters();
+		needsTabs = clusters.length > 1;
+
+		if (needsTabs) {
+			tabMarkup = '<ul class="nav nav-tabs">';
+			tabMarkup += $.map(clusters, function(cluster, idx) {
+				return '<li class="' + (idx === 0 ? 'active' : '') + '"><a href="#' + cluster
+ '_pane" data-toggle="tab">' + cluster + '</a></li>';
+			}).join('');
+			tabMarkup += '</ul>';
+
+			jqueryMap.$tableInfoHolder.html($(tabMarkup));
+		}
+
+		paneMarkup = needsTabs ? '<div class="tab-content">' : '';
+		paneMarkup += $.map(clusters, function(cluster, idx) {
+			return '<div id="' + cluster + '_pane" class="tab-pane' + (idx === 0 ? ' active' :
'') + '"><h3>Enabled Tables</h3><div class="enabledSection"></div><h3>Disabled
Tables</h3><div class="disabledSection"></div></div>';
+		}).join('');
+		paneMarkup += needsTabs ? '</div>' : '';
+
+		if (needsTabs) {
+			jqueryMap.$tableInfoHolder.append(paneMarkup);
+		} else {
+			jqueryMap.$tableInfoHolder.html(paneMarkup);
+		}
+
+		$.each(clusters, function(idx, cluster){
+			var clusterPane = $('#' + cluster + '_pane'), enabledSection, disabledSection;
+			clusterPane.find('.enabledSection').WATable({
+
+			});
+			clusterPane.find('.disabledSection').WATable();
+		});
+	};
+
+	updateTableList = function() {
+		console.log('Updating tables');
+		var clusters = blurconsole.model.tables.getClusters();
+
+		$.each(clusters, function(idx, cluster) {
+			var clusterPane = $('#' + cluster + '_pane'), enabledSection, disabledSection;
+			enabledSection = clusterPane.find('.enabledSection');
+			disabledSection = clusterPane.find('.disabledSection');
+
+			if (enabledSection.length > 0) {
+				console.log(blurconsole.model.tables.getEnabledTables(cluster));
+				console.log(enabledSection);
+				enabledSection.data('WATable').setData(blurconsole.model.tables.getEnabledTables(cluster),
false, false);
+			}
+			if (disabledSection.length > 0) {
+				disabledSection.data('WATable').setData(blurconsole.model.tables.getDisabledTables(cluster),
false, false);
+			}
+		});
+	};
+
+	return {
+		initModule : initModule,
+		unloadModule : unloadModule
+	};
+}());
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/cd3c9e83/contrib/blur-console/ui/app/scripts/blurconsole.utils.js
----------------------------------------------------------------------
diff --git a/contrib/blur-console/ui/app/scripts/blurconsole.utils.js b/contrib/blur-console/ui/app/scripts/blurconsole.utils.js
index e427115..fd12abf 100644
--- a/contrib/blur-console/ui/app/scripts/blurconsole.utils.js
+++ b/contrib/blur-console/ui/app/scripts/blurconsole.utils.js
@@ -15,7 +15,7 @@ limitations under the License.
 /*global blurconsole:false */
 blurconsole.utils = (function(){
 	'use strict';
-	var inject;
+	var inject, unique;
 
 	inject = function(collection, initial, block) {
 		if (collection === null || collection.length === 0) {
@@ -30,8 +30,25 @@ blurconsole.utils = (function(){
 		return accumulator;
 	};
 
+	unique = function(collection, sort) {
+		var uniqueList = [];
+
+		$.each(collection, function(idx, item){
+			if (uniqueList.indexOf(item) === -1) {
+				uniqueList.push(item);
+			}
+		});
+
+		if (sort) {
+			uniqueList.sort();
+		}
+
+		return uniqueList;
+	};
+
 	return {
 		inject: inject,
-		reduce: inject
+		reduce: inject,
+		unique: unique
 	};
 }());
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/cd3c9e83/contrib/blur-console/ui/app/views/tables.tpl.html
----------------------------------------------------------------------
diff --git a/contrib/blur-console/ui/app/views/tables.tpl.html b/contrib/blur-console/ui/app/views/tables.tpl.html
new file mode 100644
index 0000000..753c72b
--- /dev/null
+++ b/contrib/blur-console/ui/app/views/tables.tpl.html
@@ -0,0 +1,15 @@
+<!--
+
+Licensed 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.
+ -->
+<div id="tableInfoHolder"><img src="images/ajax-loader.gif"></div>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/cd3c9e83/contrib/blur-console/ui/bower.json
----------------------------------------------------------------------
diff --git a/contrib/blur-console/ui/bower.json b/contrib/blur-console/ui/bower.json
index 4c0ae05..23cd132 100644
--- a/contrib/blur-console/ui/bower.json
+++ b/contrib/blur-console/ui/bower.json
@@ -2,9 +2,10 @@
   "name": "ui",
   "private": true,
   "dependencies": {
-    "sass-bootstrap": "~3.0.0",
-    "modernizr": "~2.6.2",
-    "jquery": "~1.10.2"
+    "sass-bootstrap": "3.0.2",
+    "modernizr": "2.7.1",
+    "jquery": "1.11.0",
+    "flot":"0.8.2"
   },
   "devDependencies": {}
 }


Mime
View raw message