incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cr...@apache.org
Subject git commit: Finished UI for search tab
Date Thu, 15 May 2014 13:56:10 GMT
Repository: incubator-blur
Updated Branches:
  refs/heads/console-v2 5066673dd -> 1ffef615f


Finished UI for search tab


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

Branch: refs/heads/console-v2
Commit: 1ffef615f205f6d6d5de8655f0d5a7c41e0ff13e
Parents: 5066673
Author: Chris Rohr <crohr@nearinfinity.com>
Authored: Thu May 15 09:56:03 2014 -0400
Committer: Chris Rohr <crohr@nearinfinity.com>
Committed: Thu May 15 09:56:03 2014 -0400

----------------------------------------------------------------------
 contrib/blur-console/ui/.jshintrc               |   2 +-
 contrib/blur-console/ui/Gruntfile.js            |  16 +-
 contrib/blur-console/ui/app/index.html          |   1 +
 .../ui/app/scripts/blurconsole.fake.js          |  37 +++-
 .../ui/app/scripts/blurconsole.model.js         |  61 +++---
 .../ui/app/scripts/blurconsole.search.js        | 189 ++++++++++++++++---
 .../ui/app/scripts/blurconsole.shell.js         |  24 +--
 .../ui/app/scripts/blurconsole.utils.js         |  20 +-
 contrib/blur-console/ui/app/styles/_colors.scss |   4 +
 .../blur-console/ui/app/styles/blurconsole.scss |  15 +-
 .../ui/app/styles/blurconsole.search.scss       |  11 ++
 .../blur-console/ui/app/views/search.tpl.html   |  32 ++--
 contrib/blur-console/ui/package.json            |  12 +-
 contrib/blur-console/ui/test/bower.json         |   3 +-
 contrib/blur-console/ui/test/index.html         |  28 ++-
 contrib/blur-console/ui/test/spec/utils.js      |   5 +-
 16 files changed, 357 insertions(+), 103 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/1ffef615/contrib/blur-console/ui/.jshintrc
----------------------------------------------------------------------
diff --git a/contrib/blur-console/ui/.jshintrc b/contrib/blur-console/ui/.jshintrc
index 287bc43..abc9b0a 100644
--- a/contrib/blur-console/ui/.jshintrc
+++ b/contrib/blur-console/ui/.jshintrc
@@ -3,7 +3,7 @@
     "browser": true,
     "esnext": true,
     "bitwise": true,
-    "camelcase": true,
+    "camelcase": false,
     "curly": true,
     "eqeqeq": true,
     "immed": true,

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/1ffef615/contrib/blur-console/ui/Gruntfile.js
----------------------------------------------------------------------
diff --git a/contrib/blur-console/ui/Gruntfile.js b/contrib/blur-console/ui/Gruntfile.js
index 8a7460e..65677b2 100644
--- a/contrib/blur-console/ui/Gruntfile.js
+++ b/contrib/blur-console/ui/Gruntfile.js
@@ -152,8 +152,17 @@ module.exports = function (grunt) {
             }
         },
 
-
-
+        // Code coverage options
+        blanket_mocha: {
+            test: {
+                src: ['test/index.html'],
+                options : {
+                    threshold : 60,
+                    log : true,
+                    logErrors: true
+                }
+            }
+        },
 
         // Compiles Sass to CSS and generates necessary files if requested
         compass: {
@@ -397,7 +406,8 @@ module.exports = function (grunt) {
 
         grunt.task.run([
             'connect:test',
-            'mocha'
+            'mocha',
+            'blanket_mocha'
         ]);
     });
 

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/1ffef615/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 8757df1..0a79460 100644
--- a/contrib/blur-console/ui/app/index.html
+++ b/contrib/blur-console/ui/app/index.html
@@ -40,6 +40,7 @@ under the License.
         <link rel="stylesheet" href="styles/blurconsole.dashboard.css">
         <link rel="stylesheet" href="styles/blurconsole.schema.css">
         <link rel="stylesheet" href="styles/blurconsole.queries.css">
+        <link rel="stylesheet" href="styles/blurconsole.search.css">
         <!-- endbuild -->
         <script src="bower_components/modernizr/modernizr.js"></script>
 

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/1ffef615/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 234bd04..aa85975 100644
--- a/contrib/blur-console/ui/app/scripts/blurconsole.fake.js
+++ b/contrib/blur-console/ui/app/scripts/blurconsole.fake.js
@@ -33,7 +33,7 @@ blurconsole.fake = (function() {
 			records = randomNumber(10000)+1000;
 			enabled = randomBoolean();
 
-			data.push({cluster:cluster, name:'testtable'+i, enabled:enabled, rows:rows, records:records});
+			data.push({cluster:cluster, name:'testtable'+i, enabled:enabled, rows:rows, records:records,
families: blurconsole.utils.keys(getSchema('testtable'+i))});
 
 		}
 		return data;
@@ -152,12 +152,33 @@ blurconsole.fake = (function() {
 
 		callback(terms);
 	};
-  
-  sendSearch = function(query, table, args, callback) {
-    console.log('sending fake search [' + query + '] on table [' + table + ']');
-    
-    
-  };
+
+	sendSearch = function(query, table, args, callback) {
+		console.log('sending fake search [' + query + '] on table [' + table + ']');
+
+		var fams = args.families, results = {}, total = randomNumber(1000);
+
+		$.each(fams, function(i, fam){
+			var cols = randomNumber(30, true), toFetch = args.fetch;
+			if (total - args.start < toFetch) {
+				toFetch = total - args.start;
+			}
+			results[fam] = [];
+			for (var r = 0; r < randomNumber(toFetch); r++) {
+				var row = {};
+				for (var c=0; c < cols; c++) {
+					row['col'+c] = randomString();
+				}
+				results[fam].push(row);
+			}
+		});
+
+		callback({
+			families: args.families,
+			results: results,
+			total: total
+		});
+	};
 
 	randomNumber = function(max, includeZero) {
 		var random = Math.random()*max;
@@ -195,6 +216,6 @@ blurconsole.fake = (function() {
 		deleteTable : deleteTable,
 		getSchema : getSchema,
 		findTerms : findTerms,
-    sendSearch : sendSearch
+		sendSearch : sendSearch
 	};
 }());
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/1ffef615/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 f696506..c79900e 100644
--- a/contrib/blur-console/ui/app/scripts/blurconsole.model.js
+++ b/contrib/blur-console/ui/app/scripts/blurconsole.model.js
@@ -34,7 +34,7 @@ blurconsole.model = (function() {
 		tables, metrics, nodes, queries, search, initModule, nodePoller, tablePoller, queryPerformancePoller,
queryPoller;
 
 	tables = (function() {
-		var getClusters, getEnabledTables, getDisabledTables, isDataLoaded, disableTable, enableTable,
deleteTable, getSchema, findTerms, getAllEnabledTables;
+		var getClusters, getEnabledTables, getDisabledTables, isDataLoaded, disableTable, enableTable,
deleteTable, getSchema, findTerms, getAllEnabledTables, getFamilies;
 
 		getClusters = function() {
 			if (stateMap.tableNameMap === null) {
@@ -100,6 +100,19 @@ blurconsole.model = (function() {
 			return configMap.poller.getSchema(tableName);
 		};
 
+		getFamilies = function(tableName) {
+			var table;
+
+			$.each(stateMap.tableNameMap, function(idx, t) {
+				if (t.name === tableName) {
+					table = t;
+					return false;
+				}
+			});
+
+			return table.families;
+		};
+
 		findTerms = function(table, family, column, startsWith) {
 			configMap.poller.findTerms(table, family, column, startsWith, function(terms) {
 				$.gevent.publish('terms-updated', terms);
@@ -116,7 +129,8 @@ blurconsole.model = (function() {
 			deleteTable : deleteTable,
 			getSchema : getSchema,
 			findTerms : findTerms,
-			getAllEnabledTables : getAllEnabledTables
+			getAllEnabledTables : getAllEnabledTables,
+			getFamilies : getFamilies
 		};
 	}());
 
@@ -350,14 +364,20 @@ blurconsole.model = (function() {
 	}());
 
 	search = (function() {
-		var results = {}, families = {}, currentQuery, currentTable, currentArgs = {start: 0, fetch:
10, rowRecordOption: 'rowrow', families: null},
-			runSearch, getResults, getFamilies, loadMoreResults,
+		var results = {}, totalRecords = 0, currentQuery, currentTable, currentArgs = {start: 0,
fetch: 10, rowRecordOption: 'rowrow', families: null},
+			runSearch, getResults, getFamilies, loadMoreResults, getTotal,
 			sendSearch, processResults;
 
 		runSearch = function( query, table, searchArgs ) {
+			var parsedFamilies = blurconsole.utils.findFamilies(query);
+
 			currentQuery = query;
 			currentTable = table;
 			currentArgs = $.extend(currentArgs, searchArgs);
+			if (parsedFamilies.length > 0) {
+				currentArgs.families = parsedFamilies;
+			}
+			results = {};
 			sendSearch();
 		};
 
@@ -365,13 +385,15 @@ blurconsole.model = (function() {
 			return results;
 		};
 
-		getFamilies = function() {
-			return families;
+		getTotal = function() {
+			return totalRecords;
 		};
 
-		loadMoreResults = function(family, start, fetch) {
-			currentArgs.start = start;
-			currentArgs.fetch = fetch;
+		loadMoreResults = function(family) {
+			var alreadyLoadedResults = results[family];
+
+			currentArgs.start = alreadyLoadedResults ? alreadyLoadedResults.length : 0;
+			currentArgs.fetch = 10;
 			currentArgs.families = [family];
 			sendSearch();
 		};
@@ -381,33 +403,27 @@ blurconsole.model = (function() {
 		};
 
 		processResults = function(data) {
-			var dataFamilies, dataResults, tmpFamilies = {};
+			var dataFamilies, dataResults;
 
 			dataFamilies = data.families;
 			dataResults = data.results;
+			totalRecords = data.total;
 
-			if (dataFamilies !== null) {
-				$.each(dataFamilies, function(f, family){
-					tmpFamilies[family] = false;
-				});
-			}
-
-			if (dataResults !== null) {
+			if (typeof dataResults !== 'undefined' && dataResults !== null) {
 				$.each(dataResults, function(family, resultList){
-					tmpFamilies[family] = true;
 					var tmpList = results[family] || [];
 					results[family] = tmpList.concat(resultList);
 				});
 			}
-			families = tmpFamilies;
-			$.gevent.publish('results-updated');
+			$.gevent.publish('results-updated', [dataFamilies]);
 		};
 
 		return {
 			runSearch: runSearch,
 			getResults: getResults,
 			getFamilies: getFamilies,
-			loadMoreResults: loadMoreResults
+			loadMoreResults: loadMoreResults,
+			getTotal: getTotal
 		};
 	}());
 
@@ -462,6 +478,7 @@ blurconsole.model = (function() {
 		tables : tables,
 		metrics: metrics,
 		nodes : nodes,
-		queries : queries
+		queries : queries,
+		search : search
 	};
 }());
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/1ffef615/contrib/blur-console/ui/app/scripts/blurconsole.search.js
----------------------------------------------------------------------
diff --git a/contrib/blur-console/ui/app/scripts/blurconsole.search.js b/contrib/blur-console/ui/app/scripts/blurconsole.search.js
index 3521fcd..b94e7cf 100644
--- a/contrib/blur-console/ui/app/scripts/blurconsole.search.js
+++ b/contrib/blur-console/ui/app/scripts/blurconsole.search.js
@@ -16,11 +16,23 @@ KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
 */
-/*global blurconsole:false */
+/*global blurconsole:false, confirm:false */
 blurconsole.search = (function () {
 	'use strict';
 	var configMap = {
-		view : 'views/search.tpl.html'
+		view : 'views/search.tpl.html',
+		superQueryMap: {
+			'rowrow' : 'Search Row / Retrieve Row',
+			'recordrow' : 'Search Record / Retrieve Row',
+			'recordrecord' : 'Search Record / Retrieve Record'
+		},
+		optionsHtml:
+			'<label for="superQuery">Search & Retrieve</label>' +
+			'<select id="superQuery">' +
+				'<option value="rowrow">Search Row / Retrieve Row</option>' +
+				'<option value="recordrow">Search Record / Retrieve Row</option>' +
+				'<option value="recordrecord">Search Record / Retrieve Record</option>' +
+			'</select>'
 	},
 	stateMap = {
 		$container : null,
@@ -33,7 +45,9 @@ blurconsole.search = (function () {
 		$rowRecordOption : 'rowrow'
 	},
 	jqueryMap = {},
-	setJqueryMap, initModule, unloadModule, drawResults, registerPageEvents, unregisterPageEvents,
sendSearch, showOptions, reviewTables, loadTableList;
+	setJqueryMap, initModule, unloadModule, drawResultHolders, drawResults, registerPageEvents,
unregisterPageEvents,
+	sendSearch, showOptions, reviewTables, loadTableList, getMoreData, fixPanelWidths, updateOptionPopover,
updateOptionDisplay,
+	persistOptions;
 
 	setJqueryMap = function() {
 		var $container = stateMap.$container;
@@ -42,34 +56,91 @@ blurconsole.search = (function () {
 			$queryField : $('#queryField'),
 			$tableField : $('#tableChooser'),
 			$tableSelectorStatusOption : $('#statusOption'),
-			$tableWarning : $('#tableGoneWarning')
+			$tableWarning : $('#tableGoneWarning'),
+			$resultsHolder : $('#results'),
+			$optionsDisplay : $('#searchOptionsDisplay'),
+			$countHolder : $('#resultCount')
 		};
 	};
 
 	registerPageEvents = function() {
 		$('#searchTrigger').on('click', sendSearch);
-		$('#searchOptionsTrigger').on('click', showOptions);
+		$('#results').on('shown.bs.collapse', '.panel-collapse:not(.loaded)', getMoreData);
+		$('#results').on('click', '.nextPage', getMoreData);
+		$('#searchOptionsTrigger').popover({
+			html: true,
+			placement: 'bottom',
+			title: 'Extra Search Options',
+			container: 'body',
+			content: configMap.optionsHtml
+		});
+		$('#searchOptionsTrigger').on('shown.bs.popover', updateOptionPopover);
+		$(document).on('change', '.popover select', persistOptions);
 	};
 
 	unregisterPageEvents = function() {
 		$('#searchTrigger').off('click');
-		$('#searchOptionsTrigger').off('click');
+		$('#results').off('shown.bs.collapse');
+		$('#results').off('click');
+		$('#searchOptionsTrigger').popover('destroy');
+		$('#searchOptionsTrigger').off('shown.bs.popover');
+		$(document).off('change');
+	};
+
+	updateOptionDisplay = function() {
+		var displayText = '';
+
+		displayText += configMap.superQueryMap[stateMap.$rowRecordOption];
+
+		jqueryMap.$optionsDisplay.html(displayText);
+	};
+
+	updateOptionPopover = function() {
+		if ($('#superQuery').length > 0) {
+			$('#superQuery').val(stateMap.$rowRecordOption);
+		}
+	};
+
+	persistOptions = function() {
+		var resendSearch = false;
+		if (jqueryMap.$resultsHolder.children().length > 0) {
+			if (confirm('You have existing results on the screen, changing the search options will
erase your results.  Continue?')) {
+				resendSearch = true;
+			} else {
+				$('#superQuery').val(stateMap.$rowRecordOption);
+				return false;
+			}
+		}
+		stateMap.$rowRecordOption = $('#superQuery').val();
+		if (resendSearch) {
+			sendSearch();
+		}
+		updateOptionDisplay();
+		$('#searchOptionsTrigger').popover('hide');
 	};
 
 	sendSearch = function() {
-		// Save options
-		stateMap.currentTable = jqueryMap.$tableField.val();
-		stateMap.currentQuery = jqueryMap.$queryField.val();
+		stateMap.$currentTable = jqueryMap.$tableField.val();
+		stateMap.$currentQuery = jqueryMap.$queryField.val();
 
 		blurconsole.shell.changeAnchorPart({
 			tab: 'search',
 			_tab: {
-				query: encodeURIComponent(stateMap.currentQuery),
-				table: stateMap.currentTable
+				query: encodeURIComponent(stateMap.$currentQuery),
+				table: stateMap.$currentTable,
+				rr: stateMap.$rowRecordOption
 			}
 		});
 
-		blurconsole.model.search.runSearch(stateMap.currentQuery, stateMap.currentTable, {start:
0, fetch: 10});
+		drawResultHolders();
+
+		blurconsole.model.search.runSearch(stateMap.$currentQuery, stateMap.$currentTable, {start:
0, fetch: 10});
+	};
+
+	getMoreData = function() {
+		var family = $(this).attr('href') ? $(this).attr('href').substring(1) : $(this).attr('id');
+		blurconsole.model.search.loadMoreResults(family);
+		return false;
 	};
 
 	showOptions = function() {
@@ -79,11 +150,11 @@ blurconsole.search = (function () {
 	reviewTables = function() {
 		var tableFound = false, tableMap;
 
-		if (stateMap.currentTable) {
+		if (stateMap.$currentTable) {
 			tableMap = blurconsole.model.tables.getAllEnabledTables();
 			$.each(tableMap, function(cluster, tables){
 				var tableList = $.map(tables, function(t){ return t.name; });
-				if (tableList.indexOf(stateMap.currentTable) > -1) {
+				if (tableList.indexOf(stateMap.$currentTable) > -1) {
 					tableFound = true;
 				}
 			});
@@ -92,13 +163,83 @@ blurconsole.search = (function () {
 		if (tableFound) {
 			jqueryMap.$tableWarning.hide();
 			loadTableList();
-		} else {
+		} else if (stateMap.$currentTable) {
 			jqueryMap.$tableWarning.show();
+		} else {
+			loadTableList();
 		}
 	};
 
-	drawResults = function() {
+	drawResultHolders = function() {
+		var familyMarkup = '', allFamilies, extraFamilies = [], parsedFamilies = blurconsole.utils.findFamilies(stateMap.$currentQuery),
sortedFamilies;
+
+		jqueryMap.$resultsHolder.html('');
+
+		// Redraw families
+		allFamilies = blurconsole.model.tables.getFamilies(stateMap.$currentTable);
+		extraFamilies = blurconsole.utils.reject(allFamilies, function(fam){ return parsedFamilies.indexOf(fam)
>= 0; });
 
+		parsedFamilies.sort();
+		extraFamilies.sort();
+
+		sortedFamilies = parsedFamilies.concat(extraFamilies);
+
+		$.each(sortedFamilies, function(i, fam) {
+			var famId = blurconsole.browserUtils.cleanId(fam);
+			familyMarkup += '<div class="panel panel-default"><div class="panel-heading">';
+			familyMarkup += '<h4 class="panel-title"><a data-toggle="collapse" data-parent="#results"
href="#' + famId + '">' + fam + '</a></h4></div>';
+			familyMarkup += '<div id="' + famId + '" class="panel-collapse collapse' + (parsedFamilies.indexOf(fam)
>= 0 ? ' in' : '') + '">';
+			familyMarkup += '<div class="panel-body"><img src="images/ajax-loader.gif"></div></div></div>';
+		});
+
+		jqueryMap.$resultsHolder.html(familyMarkup);
+		fixPanelWidths();
+	};
+
+	fixPanelWidths = function() {
+		var allPanels = jqueryMap.$resultsHolder.find('.panel-collapse');
+		if (allPanels.length > 0) {
+			var width = $(allPanels[0]).width();
+			allPanels.width(width);
+		}
+	};
+
+	drawResults = function(evt, families) {
+		var results = blurconsole.model.search.getResults();
+		jqueryMap.$countHolder.html('<small>Found ' + blurconsole.model.search.getTotal()
+ ' total results</small>');
+
+		$.each(families, function(i, fam) {
+			var famResults = results[fam],
+				famId = '#' + blurconsole.browserUtils.cleanId(fam),
+				famHolder = $(famId + ' .panel-body'), table = '', cols;
+
+			cols = blurconsole.utils.keys(famResults[0]);
+			cols.sort();
+
+			table += '<table class="table table-condensed table-hover table-bordered"><thead><tr>';
+			$.each(cols, function(i, col) {
+				table += '<th>' + col + '</th>';
+			});
+			table += '</tr></thead><tbody>';
+			$.each(famResults, function(i, row) {
+				table += '<tr>';
+				$.each(cols, function(c, col) {
+					table += '<td>' + (row[col] || '') + '</td>';
+				});
+				table += '</tr>';
+			});
+			table += '</tbody></table>';
+
+			if (famResults.length < blurconsole.model.search.getTotal()) {
+				table += '<div class="pull-right"><a href="' + famId + '" class="btn btn-primary
nextPage">Load More...</a></div>';
+			}
+
+			famHolder.html(table);
+			if (!$(famId).hasClass('loaded')) {
+				$(famId).addClass('loaded');
+			}
+		});
+		fixPanelWidths();
 	};
 
 	loadTableList = function() {
@@ -112,7 +253,7 @@ blurconsole.search = (function () {
 
 			optGroupString = '<optgroup label="' + cluster + '">';
 			$.each(tables, function(t, table){
-				optGroupString += '<option value="' + table.name + '"' + (table.name === stateMap.currentTable
? ' selected' : '') + '>' + table.name + '</option>';
+				optGroupString += '<option value="' + table.name + '"' + (table.name === stateMap.$currentTable
? ' selected' : '') + '>' + table.name + '</option>';
 			});
 			optGroupString += '</optgroup>';
 			jqueryMap.$tableField.append(optGroupString);
@@ -126,16 +267,22 @@ blurconsole.search = (function () {
 			stateMap.$container = $container;
 			setJqueryMap();
 			$.gevent.subscribe(jqueryMap.$container, 'tables-updated', reviewTables);
+			$.gevent.subscribe(jqueryMap.$container, 'results-updated', drawResults);
 			registerPageEvents();
 			loadTableList();
 
 			var startupMap = $.uriAnchor.makeAnchorMap();
 
-			stateMap.currentQuery = startupMap._tab.query;
-			jqueryMap.$queryField.val(stateMap.currentQuery);
-			stateMap.currentTable = startupMap._tab.table;
-			jqueryMap.$tableField.val(stateMap.currentTable);
+			if (startupMap._tab) {
+				stateMap.$currentQuery = startupMap._tab.query;
+				jqueryMap.$queryField.val(stateMap.$currentQuery);
+				stateMap.$currentTable = startupMap._tab.table;
+				jqueryMap.$tableField.val(stateMap.$currentTable);
+				stateMap.$rowRecordOption = startupMap._tab.rr;
+			}
 
+			updateOptionDisplay();
+			stateMap.loaded = true;
 		});
 		return true;
 	};

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/1ffef615/contrib/blur-console/ui/app/scripts/blurconsole.shell.js
----------------------------------------------------------------------
diff --git a/contrib/blur-console/ui/app/scripts/blurconsole.shell.js b/contrib/blur-console/ui/app/scripts/blurconsole.shell.js
index de8f327..ee19283 100644
--- a/contrib/blur-console/ui/app/scripts/blurconsole.shell.js
+++ b/contrib/blur-console/ui/app/scripts/blurconsole.shell.js
@@ -20,7 +20,7 @@ under the License.
 
 /**
  * blurconsole.shell.js
- * Shell module for Blur Console 
+ * Shell module for Blur Console
  */
 /* global blurconsole:false, $:false */
 blurconsole.shell = (function () {
@@ -28,7 +28,7 @@ blurconsole.shell = (function () {
 	var configMap = {
 		anchorSchemaMap : {
 			tab : { dashboard : true, tables : true, queries : true, search : true },
-			_tab : { query: true, table: true }
+			_tab : { query: true, table: true, rr: true }
 		},
 		defaultTab : 'dashboard',
 		allTabs : ['dashboard', 'tables', 'queries', 'search']
@@ -58,17 +58,19 @@ blurconsole.shell = (function () {
 	switchView = function ( tab ) {
 		var i;
 
-		for ( i = 0; i < configMap.allTabs.length; i++ ) {
-			if (blurconsole[configMap.allTabs[i]]) {
-				blurconsole[configMap.allTabs[i]].unloadModule();
+		if (stateMap.currentTab !== tab) {
+			for ( i = 0; i < configMap.allTabs.length; i++ ) {
+				if (blurconsole[configMap.allTabs[i]]) {
+					blurconsole[configMap.allTabs[i]].unloadModule();
+				}
 			}
-		}
 
-		stateMap.currentTab = tab;
-		jqueryMap.$sideNavTabs.removeClass('active');
-		jqueryMap.$sideNavTabs.filter('a[href$="' + tab + '"]').addClass('active');
-		if (blurconsole[tab]) {
-			blurconsole[tab].initModule( jqueryMap.$container );
+			stateMap.currentTab = tab;
+			jqueryMap.$sideNavTabs.removeClass('active');
+			jqueryMap.$sideNavTabs.filter('a[href$="' + tab + '"]').addClass('active');
+			if (blurconsole[tab]) {
+				blurconsole[tab].initModule( jqueryMap.$container );
+			}
 		}
 
 		return true;

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/1ffef615/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 f2aab55..216079c 100644
--- a/contrib/blur-console/ui/app/scripts/blurconsole.utils.js
+++ b/contrib/blur-console/ui/app/scripts/blurconsole.utils.js
@@ -20,7 +20,7 @@ under the License.
 /*global blurconsole:false */
 blurconsole.utils = (function(){
 	'use strict';
-	var inject, unique, equals, findFamilies;
+	var inject, unique, equals, keys, findFamilies, reject;
 
 	inject = function(collection, initial, block) {
 		if (collection === null || collection.length === 0) {
@@ -55,6 +55,10 @@ blurconsole.utils = (function(){
 		return JSON.stringify(obj1) === JSON.stringify(obj2);
 	};
 
+	keys = function(map) {
+		return $.map(map, function(v, key){ return key; });
+	};
+
 	findFamilies = function(query) {
 		// Determine regex to find column families in lucene query
 		var matches = query.match(/[^ \(\)\+\-]+(\w+)\.\w+:/g);
@@ -65,11 +69,23 @@ blurconsole.utils = (function(){
 		return families;
 	};
 
+	reject = function(collection, block) {
+		var newArray = [];
+		$.each(collection, function(i, item){
+			if (!block(item)) {
+				newArray.push(item);
+			}
+		});
+		return newArray;
+	};
+
 	return {
 		inject: inject,
 		reduce: inject,
 		unique: unique,
 		equals: equals,
-		findFamilies: findFamilies
+		keys: keys,
+		findFamilies: findFamilies,
+		reject: reject
 	};
 }());
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/1ffef615/contrib/blur-console/ui/app/styles/_colors.scss
----------------------------------------------------------------------
diff --git a/contrib/blur-console/ui/app/styles/_colors.scss b/contrib/blur-console/ui/app/styles/_colors.scss
new file mode 100644
index 0000000..82a2b31
--- /dev/null
+++ b/contrib/blur-console/ui/app/styles/_colors.scss
@@ -0,0 +1,4 @@
+$silver: #CCC;
+$black: #000;
+$san-marino: #4c66a4;
+$white: #FFF;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/1ffef615/contrib/blur-console/ui/app/styles/blurconsole.scss
----------------------------------------------------------------------
diff --git a/contrib/blur-console/ui/app/styles/blurconsole.scss b/contrib/blur-console/ui/app/styles/blurconsole.scss
index 3f387a2..3c0729f 100644
--- a/contrib/blur-console/ui/app/styles/blurconsole.scss
+++ b/contrib/blur-console/ui/app/styles/blurconsole.scss
@@ -21,11 +21,12 @@ under the License.
 $icon-font-path: "/bower_components/twbs-bootstrap-sass/vendor/assets/fonts/bootstrap/";
 
 @import 'twbs-bootstrap-sass/vendor/assets/stylesheets/bootstrap';
+@import 'colors';
 
 .browsehappy {
     margin: 0.2em 0;
-    background: #ccc;
-    color: #000;
+    background: $silver;
+    color: $black;
     padding: 0.2em 0;
 }
 
@@ -40,9 +41,9 @@ body {
 
 /* Top Navigation */
 nav.navbar-fixed-top {
-    background-color: #4c66a4;
+    background-color: $san-marino;
     .navbar-brand {
-        color: #fff;
+        color: $white;
     }
 }
 
@@ -64,14 +65,14 @@ nav.navbar-fixed-top {
             display: block;
             a {
                 padding: 10px;
-                color: #ccc;
+                color: $silver;
                 margin-right: 0;
                 font-size: 20px;
                 position: relative;
                 display: block;
                 &.active {
-                    background-color: #fff;
-                    color: #000;
+                    background-color: $white;
+                    color: $black;
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/1ffef615/contrib/blur-console/ui/app/styles/blurconsole.search.scss
----------------------------------------------------------------------
diff --git a/contrib/blur-console/ui/app/styles/blurconsole.search.scss b/contrib/blur-console/ui/app/styles/blurconsole.search.scss
new file mode 100644
index 0000000..1e4f2b8
--- /dev/null
+++ b/contrib/blur-console/ui/app/styles/blurconsole.search.scss
@@ -0,0 +1,11 @@
+#results {
+	.panel-collapse {
+		padding: 5px;
+		overflow-x: auto;
+	}
+}
+
+#resultCount {
+	padding-left: 30px;
+	font-style: italic;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/1ffef615/contrib/blur-console/ui/app/views/search.tpl.html
----------------------------------------------------------------------
diff --git a/contrib/blur-console/ui/app/views/search.tpl.html b/contrib/blur-console/ui/app/views/search.tpl.html
index 07e684e..3a58fe4 100644
--- a/contrib/blur-console/ui/app/views/search.tpl.html
+++ b/contrib/blur-console/ui/app/views/search.tpl.html
@@ -21,22 +21,28 @@ under the License.
 <div id="tableGoneWarning" class="alert alert-warning" style="display:none"><strong>Heads
Up!</strong> The table that is currently being used for search is no longer enabled!</div>
 <div class="well">
 	<div class="container-fluid">
-		<div class="col-xs-6">
-			<div class="input-group">
-				<input type="text" class="form-control" placeholder="Query" id="queryField">
-				<span class="input-group-btn">
-        			<button class="btn btn-default" type="button" id="searchTrigger">Go!</button>
-      			</span>
+		<div class="row">
+			<div class="col-xs-6">
+				<div class="input-group">
+					<input type="text" class="form-control" placeholder="Query" id="queryField">
+					<span class="input-group-btn">
+	        			<button class="btn btn-default" type="button" id="searchTrigger">Go!</button>
+	      			</span>
+				</div>
 			</div>
+			<div class="col-xs-2">
+				<select class="form-control" id="tableChooser">
+					<option value="" id="statusOption">Loading Tables....</option>
+				</select>
+			</div>
+			<button class="btn btn-default" type="button" id="searchOptionsTrigger">
+				<i class="glyphicon glyphicon-cog"></i>
+			</button>
+			<span id="searchOptionsDisplay"></span>
 		</div>
-		<div class="col-xs-2">
-			<select class="form-control" id="tableChooser">
-				<option value="" id="statusOption">Loading Tables....</option>
-			</select>
+		<div class="row">
+			<div id="resultCount" class="col-xs-2"></div>
 		</div>
-		<button class="btn btn-default" type="button" id="searchOptionsTrigger">
-			<i class="glyphicon glyphicon-cog"></i>
-		</button>
 	</div>
 </div>
 <div id="results">

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/1ffef615/contrib/blur-console/ui/package.json
----------------------------------------------------------------------
diff --git a/contrib/blur-console/ui/package.json b/contrib/blur-console/ui/package.json
index 5ec6233..5c3c36a 100644
--- a/contrib/blur-console/ui/package.json
+++ b/contrib/blur-console/ui/package.json
@@ -1,6 +1,11 @@
 {
-  "name": "ui",
-  "version": "0.0.0",
+  "name": "blur-console",
+  "version": "2.0.0",
+  "description": "Managment and Monitoring Console for Apache Blur",
+  "repository": "https://git-wip-us.apache.org/repos/asf/incubator-blur.git",
+  "directories": {
+    "test": "test"
+  },
   "dependencies": {},
   "devDependencies": {
     "grunt": "~0.4.1",
@@ -26,7 +31,8 @@
     "grunt-concurrent": "~0.4.0",
     "load-grunt-tasks": "~0.2.0",
     "time-grunt": "~0.2.0",
-    "jshint-stylish": "~0.1.3"
+    "jshint-stylish": "~0.1.3",
+    "grunt-blanket-mocha":"~0.4.0"
   },
   "engines": {
     "node": ">=0.8.0"

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/1ffef615/contrib/blur-console/ui/test/bower.json
----------------------------------------------------------------------
diff --git a/contrib/blur-console/ui/test/bower.json b/contrib/blur-console/ui/test/bower.json
index 5453ee2..4a7bafd 100644
--- a/contrib/blur-console/ui/test/bower.json
+++ b/contrib/blur-console/ui/test/bower.json
@@ -3,7 +3,8 @@
   "private": true,
   "dependencies": {
     "chai": "~1.8.0",
-    "mocha": "~1.14.0"
+    "mocha": "~1.14.0",
+    "blanket":"~1.1.5"
   },
   "devDependencies": {}
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/1ffef615/contrib/blur-console/ui/test/index.html
----------------------------------------------------------------------
diff --git a/contrib/blur-console/ui/test/index.html b/contrib/blur-console/ui/test/index.html
index f04325e..569cdc0 100644
--- a/contrib/blur-console/ui/test/index.html
+++ b/contrib/blur-console/ui/test/index.html
@@ -24,24 +24,36 @@ under the License.
     <meta http-equiv="X-UA-Compatible" content="IE=edge">
     <title>Mocha Spec Runner</title>
     <link rel="stylesheet" href="bower_components/mocha/mocha.css">
-</head>
-<body>
-    <div id="mocha"></div>
-    <script src="bower_components/mocha/mocha.js"></script>
-    <script>mocha.setup('bdd')</script>
+
     <script src="bower_components/chai/chai.js"></script>
+    <script src="bower_components/mocha/mocha.js"></script>
+
+    <!-- include source files here... -->
+    <script src="bower_components/jquery/dist/jquery.js"></script>
+    <script src="app/scripts/blurconsole.js"></script>
+    <script src="app/scripts/blurconsole.utils.js"></script>
+
+    <script src="bower_components/blanket/dist/qunit/blanket.js" data-cover-flags="branchTracking"
data-cover-only="//scripts/"></script>
+    <script src="../node_modules/grunt-blanket-mocha/support/mocha-blanket.js"></script>
+
     <script>
         var assert = chai.assert;
         var expect = chai.expect;
         var should = chai.should();
-    </script>
 
-    <!-- include source files here... -->
-    <script src="scripts/blurconsole.utils.js"></script>
+        mocha.setup('bdd');
+
+        if (window.PHANTOMJS) {
+            blanket.options("reporter", "../node_modules/grunt-blanket-mocha/support/grunt-reporter.js");
+        }
+    </script>
 
     <!-- include spec files here... -->
     <script src="spec/test.js"></script>
     <script src="spec/utils.js"></script>
+</head>
+<body>
+    <div id="mocha"></div>
 
     <script>mocha.run()</script>
 </body>

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/1ffef615/contrib/blur-console/ui/test/spec/utils.js
----------------------------------------------------------------------
diff --git a/contrib/blur-console/ui/test/spec/utils.js b/contrib/blur-console/ui/test/spec/utils.js
index 7fa9665..927567d 100644
--- a/contrib/blur-console/ui/test/spec/utils.js
+++ b/contrib/blur-console/ui/test/spec/utils.js
@@ -17,16 +17,15 @@ KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
 */
-/* global describe, it */
+/* global describe, it, assert, blurconsole */
 
 (function () {
     'use strict';
 
-    var assert = require("assert");
     describe('Test blurconsole.utils', function () {
         describe('inject', function () {
             it('[1,2,3,4,5] should be 15 with simple summing', function () {
-              assert(blurconsole.utils.inject([1,2,3,4,5], 0, function(sum, item){ return
sum + item; }));
+                assert(blurconsole.utils.inject([1,2,3,4,5], 0, function(sum, item){ return
sum + item; }));
             });
         });
     });


Mime
View raw message