incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [05/50] [abbrv] git commit: Initial commit of search page - not finished yet
Date Sat, 31 May 2014 14:21:38 GMT
Initial commit of search page - not finished yet


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

Branch: refs/heads/apache-blur-0.2
Commit: f96b0b6d9179337d3f65ef22c9b3ef5d69edf493
Parents: d2f498b
Author: Chris Rohr <crohr@nearinfinity.com>
Authored: Tue Apr 15 20:33:58 2014 -0400
Committer: Chris Rohr <crohr@nearinfinity.com>
Committed: Tue Apr 15 20:33:58 2014 -0400

----------------------------------------------------------------------
 contrib/blur-console/ui/app/index.html          |   1 +
 .../ui/app/scripts/blurconsole.model.js         |  79 +++++++++-
 .../ui/app/scripts/blurconsole.schema.js        |   7 +-
 .../ui/app/scripts/blurconsole.search.js        | 152 +++++++++++++++++++
 .../ui/app/scripts/blurconsole.shell.js         |   2 +-
 .../ui/app/scripts/blurconsole.utils.js         |   9 +-
 .../ui/app/views/dashboard.tpl.html             |  14 +-
 .../blur-console/ui/app/views/queries.tpl.html  |  10 +-
 .../blur-console/ui/app/views/search.tpl.html   |  44 ++++++
 9 files changed, 298 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f96b0b6d/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 41a33a9..8757df1 100644
--- a/contrib/blur-console/ui/app/index.html
+++ b/contrib/blur-console/ui/app/index.html
@@ -106,6 +106,7 @@ under the License.
         <script src="scripts/blurconsole.dashboard.js"></script>
         <script src="scripts/blurconsole.tables.js"></script>
         <script src="scripts/blurconsole.queries.js"></script>
+        <script src="scripts/blurconsole.search.js"></script>
         <script src="scripts/blurconsole.schema.js"></script>
         <script src="scripts/blurconsole.data.js"></script>
         <script src="scripts/blurconsole.fake.js"></script>

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f96b0b6d/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 6153bd9..f696506 100644
--- a/contrib/blur-console/ui/app/scripts/blurconsole.model.js
+++ b/contrib/blur-console/ui/app/scripts/blurconsole.model.js
@@ -31,10 +31,10 @@ blurconsole.model = (function() {
 			queries : {}
 		},
 		isFakeData = true,
-		tables, metrics, nodes, queries, initModule, nodePoller, tablePoller, queryPerformancePoller,
queryPoller;
+		tables, metrics, nodes, queries, search, initModule, nodePoller, tablePoller, queryPerformancePoller,
queryPoller;
 
 	tables = (function() {
-		var getClusters, getEnabledTables, getDisabledTables, isDataLoaded, disableTable, enableTable,
deleteTable, getSchema, findTerms;
+		var getClusters, getEnabledTables, getDisabledTables, isDataLoaded, disableTable, enableTable,
deleteTable, getSchema, findTerms, getAllEnabledTables;
 
 		getClusters = function() {
 			if (stateMap.tableNameMap === null) {
@@ -70,6 +70,16 @@ blurconsole.model = (function() {
 			return data;
 		};
 
+		getAllEnabledTables = function() {
+			var tableMap = {};
+
+			$.each(getClusters(), function(c, cluster){
+				tableMap[cluster] = getEnabledTables(cluster);
+			});
+
+			return tableMap;
+		};
+
 		isDataLoaded = function() {
 			return stateMap.tableNameMap !== null;
 		};
@@ -105,7 +115,8 @@ blurconsole.model = (function() {
 			enableTable : enableTable,
 			deleteTable : deleteTable,
 			getSchema : getSchema,
-			findTerms : findTerms
+			findTerms : findTerms,
+			getAllEnabledTables : getAllEnabledTables
 		};
 	}());
 
@@ -338,6 +349,68 @@ blurconsole.model = (function() {
 		};
 	}());
 
+	search = (function() {
+		var results = {}, families = {}, currentQuery, currentTable, currentArgs = {start: 0, fetch:
10, rowRecordOption: 'rowrow', families: null},
+			runSearch, getResults, getFamilies, loadMoreResults,
+			sendSearch, processResults;
+
+		runSearch = function( query, table, searchArgs ) {
+			currentQuery = query;
+			currentTable = table;
+			currentArgs = $.extend(currentArgs, searchArgs);
+			sendSearch();
+		};
+
+		getResults = function() {
+			return results;
+		};
+
+		getFamilies = function() {
+			return families;
+		};
+
+		loadMoreResults = function(family, start, fetch) {
+			currentArgs.start = start;
+			currentArgs.fetch = fetch;
+			currentArgs.families = [family];
+			sendSearch();
+		};
+
+		sendSearch = function() {
+			configMap.poller.sendSearch(currentQuery, currentTable, currentArgs, processResults);
+		};
+
+		processResults = function(data) {
+			var dataFamilies, dataResults, tmpFamilies = {};
+
+			dataFamilies = data.families;
+			dataResults = data.results;
+
+			if (dataFamilies !== null) {
+				$.each(dataFamilies, function(f, family){
+					tmpFamilies[family] = false;
+				});
+			}
+
+			if (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');
+		};
+
+		return {
+			runSearch: runSearch,
+			getResults: getResults,
+			getFamilies: getFamilies,
+			loadMoreResults: loadMoreResults
+		};
+	}());
+
 	nodePoller = function() {
 		var tmpNodeMap = configMap.poller.getNodeList();
 		if (!blurconsole.utils.equals(tmpNodeMap, stateMap.nodeMap)) {

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f96b0b6d/contrib/blur-console/ui/app/scripts/blurconsole.schema.js
----------------------------------------------------------------------
diff --git a/contrib/blur-console/ui/app/scripts/blurconsole.schema.js b/contrib/blur-console/ui/app/scripts/blurconsole.schema.js
index 8a0dfe5..15dec2b 100644
--- a/contrib/blur-console/ui/app/scripts/blurconsole.schema.js
+++ b/contrib/blur-console/ui/app/scripts/blurconsole.schema.js
@@ -16,6 +16,7 @@ software distributed under the License is distributed on an
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
+*/
 /*jshint laxbreak: true */
 /*global blurconsole:false */
 blurconsole.schema = (function () {
@@ -155,7 +156,7 @@ blurconsole.schema = (function () {
 		var terms = Array.prototype.slice.call(arguments, 1);
 		jqueryMap.termList.html('');
 		$.each(terms, function(i, term){
-			jqueryMap.termList.append('<li class="list-group-item">' + term + ' <span class="badge
badge-success searchTrigger" title="Search for this value" data-value="' + term + '"><i
class="glyphicon glyphicon-search"></i></span></li>');
+			jqueryMap.termList.append('<li class="list-group-item">' + term + ' <span class="badge
badge-success searchTrigger" title="Search for this value" data-value="' + term + '" data-table="'
+ stateMap.table + '"><i class="glyphicon glyphicon-search"></i></span></li>');
 		});
 	};
 
@@ -163,9 +164,11 @@ blurconsole.schema = (function () {
 		blurconsole.shell.changeAnchorPart({
 			tab: 'search',
 			_tab: {
-				query: stateMap.termFamily + '.' + stateMap.termColumn + ':' + $(this).data('value')
+				query: encodeURIComponent(stateMap.termFamily + '.' + stateMap.termColumn + ':' + $(this).data('value')),
+				table: $(this).data('table')
 			}
 		});
+		jqueryMap.modal.modal('hide');
 	};
 
 	initModule = function() {

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f96b0b6d/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
new file mode 100644
index 0000000..3521fcd
--- /dev/null
+++ b/contrib/blur-console/ui/app/scripts/blurconsole.search.js
@@ -0,0 +1,152 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.search = (function () {
+	'use strict';
+	var configMap = {
+		view : 'views/search.tpl.html'
+	},
+	stateMap = {
+		$container : null,
+		$currentTable : null,
+		$currentQuery : null,
+		$schemaForCurrentTable : null,
+		$start : 0,
+		$fetch : 10,
+		$filter : null,
+		$rowRecordOption : 'rowrow'
+	},
+	jqueryMap = {},
+	setJqueryMap, initModule, unloadModule, drawResults, registerPageEvents, unregisterPageEvents,
sendSearch, showOptions, reviewTables, loadTableList;
+
+	setJqueryMap = function() {
+		var $container = stateMap.$container;
+		jqueryMap = {
+			$container : $container,
+			$queryField : $('#queryField'),
+			$tableField : $('#tableChooser'),
+			$tableSelectorStatusOption : $('#statusOption'),
+			$tableWarning : $('#tableGoneWarning')
+		};
+	};
+
+	registerPageEvents = function() {
+		$('#searchTrigger').on('click', sendSearch);
+		$('#searchOptionsTrigger').on('click', showOptions);
+	};
+
+	unregisterPageEvents = function() {
+		$('#searchTrigger').off('click');
+		$('#searchOptionsTrigger').off('click');
+	};
+
+	sendSearch = function() {
+		// Save options
+		stateMap.currentTable = jqueryMap.$tableField.val();
+		stateMap.currentQuery = jqueryMap.$queryField.val();
+
+		blurconsole.shell.changeAnchorPart({
+			tab: 'search',
+			_tab: {
+				query: encodeURIComponent(stateMap.currentQuery),
+				table: stateMap.currentTable
+			}
+		});
+
+		blurconsole.model.search.runSearch(stateMap.currentQuery, stateMap.currentTable, {start:
0, fetch: 10});
+	};
+
+	showOptions = function() {
+
+	};
+
+	reviewTables = function() {
+		var tableFound = false, tableMap;
+
+		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) {
+					tableFound = true;
+				}
+			});
+		}
+
+		if (tableFound) {
+			jqueryMap.$tableWarning.hide();
+			loadTableList();
+		} else {
+			jqueryMap.$tableWarning.show();
+		}
+	};
+
+	drawResults = function() {
+
+	};
+
+	loadTableList = function() {
+		var tableMap = blurconsole.model.tables.getAllEnabledTables();
+
+		jqueryMap.$tableSelectorStatusOption.html('Loading Tables...');
+		jqueryMap.$tableField.find('optgroup').remove();
+
+		$.each(tableMap, function(cluster, tables) {
+			var optGroupString;
+
+			optGroupString = '<optgroup label="' + cluster + '">';
+			$.each(tables, function(t, table){
+				optGroupString += '<option value="' + table.name + '"' + (table.name === stateMap.currentTable
? ' selected' : '') + '>' + table.name + '</option>';
+			});
+			optGroupString += '</optgroup>';
+			jqueryMap.$tableField.append(optGroupString);
+		});
+
+		jqueryMap.$tableSelectorStatusOption.html('Choose Table');
+	};
+
+	initModule = function($container) {
+		$container.load(configMap.view, function() {
+			stateMap.$container = $container;
+			setJqueryMap();
+			$.gevent.subscribe(jqueryMap.$container, 'tables-updated', reviewTables);
+			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);
+
+		});
+		return true;
+	};
+
+	unloadModule = function() {
+		$.gevent.unsubscribe(jqueryMap.$container, 'tables-updated');
+		unregisterPageEvents();
+	};
+
+	return {
+		initModule : initModule,
+		unloadModule : unloadModule
+	};
+}());
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f96b0b6d/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 055018e..de8f327 100644
--- a/contrib/blur-console/ui/app/scripts/blurconsole.shell.js
+++ b/contrib/blur-console/ui/app/scripts/blurconsole.shell.js
@@ -28,7 +28,7 @@ blurconsole.shell = (function () {
 	var configMap = {
 		anchorSchemaMap : {
 			tab : { dashboard : true, tables : true, queries : true, search : true },
-			_tab : { query: true }
+			_tab : { query: true, table: true }
 		},
 		defaultTab : 'dashboard',
 		allTabs : ['dashboard', 'tables', 'queries', 'search']

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f96b0b6d/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 0154e65..028fc36 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;
+	var inject, unique, equals, findFamilies;
 
 	inject = function(collection, initial, block) {
 		if (collection === null || collection.length === 0) {
@@ -55,10 +55,15 @@ blurconsole.utils = (function(){
 		return JSON.stringify(obj1) === JSON.stringify(obj2);
 	};
 
+	findFamilies = function(query) {
+		// Determine regex to find column families in lucene query
+	};
+
 	return {
 		inject: inject,
 		reduce: inject,
 		unique: unique,
-		equals: equals
+		equals: equals,
+		findFamilies: findFamilies
 	};
 }());
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f96b0b6d/contrib/blur-console/ui/app/views/dashboard.tpl.html
----------------------------------------------------------------------
diff --git a/contrib/blur-console/ui/app/views/dashboard.tpl.html b/contrib/blur-console/ui/app/views/dashboard.tpl.html
index c4f8e57..b805455 100644
--- a/contrib/blur-console/ui/app/views/dashboard.tpl.html
+++ b/contrib/blur-console/ui/app/views/dashboard.tpl.html
@@ -24,35 +24,35 @@ under the License.
 </div>
 
 <div class="row">
-	<div class="col-md-8">
+	<div class="col-sm-8">
 		<div class="row">
-			<div class="col-md-6 text-center">
+			<div class="col-sm-6 text-center">
 					<h4>Zookeepers <small><i class="glyphicon glyphicon-retweet swapper-trigger"
title="Swap Chart/Info"></i></small></h4>
 					<div id="zookeeperNodes" class="simple-chart swapper-chart"><img src="images/ajax-loader.gif"></div>
 					<div id="zookeeperInfo" class="swapper-info hidden"></div>
 			</div>
-			<div class="col-md-6 text-center">
+			<div class="col-sm-6 text-center">
 				<h4>Controllers <small><i class="glyphicon glyphicon-retweet swapper-trigger"
title="Swap Chart/Info"></i></small></h4>
 				<div id="controllerNodes" class="simple-chart swapper-chart"><img src="images/ajax-loader.gif"></div>
 				<div id="controllerInfo" class="swapper-info hidden"></div>
 			</div>
 		</div>
 		<div class="row">
-			<div class="col-md-12 text-center">
+			<div class="col-sm-12 text-center">
 				<h4>Query Load</h4>
 				<div id="queryLoad" class="wide-chart"><img src="images/ajax-loader.gif"></div>
 			</div>
 		</div>
 	</div>
-	<div class="col-md-4">
+	<div class="col-sm-4">
 		<div class="row">
-			<div class="col-md-12 text-center">
+			<div class="col-sm-12 text-center">
 				<h4>Shards</h4>
 				<div id="shardNodes"><img src="images/ajax-loader.gif"></div>
 			</div>
 		</div>
 		<div class="row">
-			<div class="col-md-12 text-center">
+			<div class="col-sm-12 text-center">
 				<h4>Tables</h4>
 				<div id="tableCounts" class="simple-chart"><img src="images/ajax-loader.gif"></div>
 			</div>

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f96b0b6d/contrib/blur-console/ui/app/views/queries.tpl.html
----------------------------------------------------------------------
diff --git a/contrib/blur-console/ui/app/views/queries.tpl.html b/contrib/blur-console/ui/app/views/queries.tpl.html
index 1667e64..cda6d89 100644
--- a/contrib/blur-console/ui/app/views/queries.tpl.html
+++ b/contrib/blur-console/ui/app/views/queries.tpl.html
@@ -18,20 +18,20 @@ specific language governing permissions and limitations
 under the License.
  -->
 <div class="row">
-	<div id="tableHolder" class="col-md-4">
+	<div id="tableHolder" class="col-sm-4">
 
 	</div>
-	<div class="col-md-8">
+	<div class="col-sm-8">
 		<div class="row">
-			<div id="filterOptions" class="col-md-12">
-				<div class="input-group col-md-4 pull-right">
+			<div id="filterOptions" class="col-sm-12">
+				<div class="input-group col-sm-4 pull-right">
 					<input class="form-control filterText" placeholder="Filter" type="text">
 					<span class="input-group-btn">
 						<button class="btn btn-default filterTrigger" type="button">Go!</button>
 					</span>
 				</div>
 			</div>
-			<div id="queryHolder" class="col-md-12">
+			<div id="queryHolder" class="col-sm-12">
 
 			</div>
 		</div>

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f96b0b6d/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
new file mode 100644
index 0000000..07e684e
--- /dev/null
+++ b/contrib/blur-console/ui/app/views/search.tpl.html
@@ -0,0 +1,44 @@
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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="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>
+		</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>
+	</div>
+</div>
+<div id="results">
+
+</div>
\ No newline at end of file


Mime
View raw message