incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cr...@apache.org
Subject [2/4] Standardized the tabs and spaces usage (2 spaces per tab)
Date Tue, 08 Jul 2014 20:57:02 GMT
http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/79786aca/blur-console/src/main/webapp/js/blurconsole.model.js
----------------------------------------------------------------------
diff --git a/blur-console/src/main/webapp/js/blurconsole.model.js b/blur-console/src/main/webapp/js/blurconsole.model.js
index 61a15c2..2c2c52e 100644
--- a/blur-console/src/main/webapp/js/blurconsole.model.js
+++ b/blur-console/src/main/webapp/js/blurconsole.model.js
@@ -19,555 +19,555 @@ under the License.
 */
 /*global blurconsole:false */
 blurconsole.model = (function() {
-	'use strict';
-
-	//----------------------- Configuration and State ------------------
-	var
-		configMap = {
-			poller : null
-		},
-		stateMap = {
-			currentTables: null,
-			currentClusters: [],
-			nodeMap : null,
-			queryPerformance : [],
-			queries : {},
-			errors: [],
-			schema: {}
-		};
-
-	//----------------------- Models ----------------------------------
-	var tables = (function() {
-		//-------------- Public API -----------------
-		function getClusters() {
-			if (stateMap.currentClusters === null) {
-				return [];
-			}
-
-			return blurconsole.utils.unique(stateMap.currentClusters, true);
-		}
-
-		function getEnabledTables(cluster) {
-			var data = [];
-
-			$.each(stateMap.currentTables, function(idx, table) {
-				if (table.cluster === cluster && table.enabled) {
-					data.push({name:table.name, rowCount:table.rows, recordCount:table.records});
-				}
-			});
-
-			return data;
-		}
-
-		function getDisabledTables(cluster) {
-			var data = [];
-
-			$.each(stateMap.currentTables, function(idx, table) {
-				if (table.cluster === cluster && !table.enabled) {
-					data.push({name:table.name, rowCount:table.rows, recordCount:table.records});
-				}
-			});
-
-			return data;
-		}
-
-		function getAllEnabledTables() {
-			var tableMap = {};
-
-			$.each(getClusters(), function(c, cluster){
-				tableMap[cluster] = getEnabledTables(cluster);
-			});
-
-			return tableMap;
-		}
-
-		function isDataLoaded() {
-			return stateMap.currentTables !== null;
-		}
-
-		function disableTable(tableName) {
-			configMap.poller.disableTable(tableName);
-		}
-
-		function enableTable(tableName) {
-			configMap.poller.enableTable(tableName);
-		}
-
-		function deleteTable(tableName, includeFiles) {
-			configMap.poller.deleteTable(tableName, includeFiles);
-		}
-
-		function getSchema(tableName, callback) {
-			if(stateMap.schema && stateMap.schema.tableName === tableName && new Date() - stateMap.schema.date < 60000) {
-				setTimeout(function(){
-					callback(stateMap.schema.data);
-				}, 0);
-			} else {
-				configMap.poller.getSchema(tableName, function(schema) {
-					stateMap.schema.tableName = tableName;
-					stateMap.schema.data = schema;
-					stateMap.schema.date = new Date();
-					callback(schema);
-				});
-			}
-		}
-
-		function getFamilies(tableName) {
-			var table;
-
-			$.each(stateMap.currentTables, function(idx, t) {
-				if (t.name === tableName) {
-					table = t;
-					return false;
-				}
-			});
-			if(table) {
-				return table.families;
-			} else {
-				return [];
-			}
-		}
-
-		function findTerms(table, family, column, startsWith, callback) {
-			configMap.poller.findTerms(table, family, column, startsWith, callback);
-		}
-
-		return {
-			getClusters : getClusters,
-			getEnabledTables : getEnabledTables,
-			getDisabledTables : getDisabledTables,
-			isDataLoaded : isDataLoaded,
-			disableTable : disableTable,
-			enableTable : enableTable,
-			deleteTable : deleteTable,
-			getSchema : getSchema,
-			findTerms : findTerms,
-			getAllEnabledTables : getAllEnabledTables,
-			getFamilies : getFamilies
-		};
-	}());
-
-	var nodes = (function() {
-		//------------- Private Methods -----------------
-		function _getClusterData(clusterName) {
-			var clusterData = $.grep(stateMap.nodeMap.clusters, function(cluster) {
-				return cluster.name === clusterName;
-			});
-			return clusterData.length > 0 ? clusterData[0] : null;
-		}
-
-		//------------- Public API ----------------------
-		function getOnlineZookeeperNodes() {
-			return stateMap.nodeMap.zookeepers.online;
-		}
-
-		function getOfflineZookeeperNodes() {
-			return stateMap.nodeMap.zookeepers.offline;
-		}
-
-		function getOnlineControllerNodes() {
-			return stateMap.nodeMap.controllers.online;
-		}
-
-		function getOfflineControllerNodes() {
-			return stateMap.nodeMap.controllers.offline;
-		}
-
-		function getOfflineShardNodes(clusterName) {
-			var clusterData = _getClusterData(clusterName);
-			return clusterData ? clusterData.offline : [];
-		}
-
-		function getOnlineShardNodes(clusterName) {
-			var clusterData = _getClusterData(clusterName);
-			return clusterData ? clusterData.online : [];
-		}
-
-		function isDataLoaded() {
-			return stateMap.nodeMap !== null;
-		}
-
-		return {
-			getOnlineZookeeperNodes : getOnlineZookeeperNodes,
-			getOfflineZookeeperNodes : getOfflineZookeeperNodes,
-			getOfflineControllerNodes : getOfflineControllerNodes,
-			getOnlineControllerNodes : getOnlineControllerNodes,
-			getOfflineShardNodes : getOfflineShardNodes,
-			getOnlineShardNodes : getOnlineShardNodes,
-			isDataLoaded : isDataLoaded
-		};
-	}());
-
-	var metrics = (function() {
-		//------------- Private Methods ------------------
-		function _buildPieChartData(onlineCount, offlineCount) {
-			var onlineChart = {
-				'label':'Online',
-				'color':'#66CDCC',
-				'data':[[0,onlineCount]]
-			};
-
-			var offlineChart = {
-				'label':'Offline',
-				'color':'#FF1919',
-				'data':[[0,offlineCount]]
-			};
-
-			return [onlineChart, offlineChart];
-		}
-
-		//------------- Public API -----------------------
-		function getZookeeperChartData() {
-			return _buildPieChartData(stateMap.nodeMap.zookeepers.online.length, stateMap.nodeMap.zookeepers.offline.length);
-		}
-
-		function getControllerChartData() {
-			return _buildPieChartData(stateMap.nodeMap.controllers.online.length, stateMap.nodeMap.controllers.offline.length);
-		}
-
-		function getClusters() {
-			return $.map(stateMap.nodeMap.clusters, function(cluster) {
-				return cluster.name;
-			});
-		}
-
-		function getShardChartData(clusterName) {
-			var clusterData = $.grep(stateMap.nodeMap.clusters, function(cluster) {
-				return cluster.name === clusterName;
-			});
-
-			if (clusterData.length > 0) {
-				return _buildPieChartData(clusterData[0].online.length, clusterData[0].offline.length);
-			}
-			return null;
-		}
-
-		function getTableChartData() {
-			var enabledData = blurconsole.utils.reduce(stateMap.currentTables, [], function(accumulator, table){
-				var currentCluster = $.grep(accumulator, function(item){
-					return item[0] === table.cluster;
-				});
-
-				if (currentCluster.length === 0) {
-					currentCluster = [table.cluster, 0];
-					accumulator.push(currentCluster);
-				} else {
-					currentCluster = currentCluster[0];
-				}
-
-				if (table.enabled) {
-					currentCluster[1] = currentCluster[1]+1;
-				}
-				return accumulator;
-			});
-
-			var disabledData = blurconsole.utils.reduce(stateMap.currentTables, [], function(accumulator, table){
-				var currentCluster = $.grep(accumulator, function(item){
-					return item[0] === table.cluster;
-				});
-
-				if (currentCluster.length === 0) {
-					currentCluster = [table.cluster, 0];
-					accumulator.push(currentCluster);
-				} else {
-					currentCluster = currentCluster[0];
-				}
-
-				if (!table.enabled) {
-					currentCluster[1] = currentCluster[1]+1;
-				}
-				return accumulator;
-			});
-
-			return [
-				{
-					'data' : enabledData,
-					'label' : 'Enabled',
-					'color' : '#66CDCC',
-					'stack' : true
-				},
-				{
-					'data' : disabledData,
-					'label' : 'Disabled',
-					'color' : '#333333',
-					'stack' : true
-				}
-			];
-		}
-
-		function getQueryLoadChartData() {
-			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(queryData, function(idx, increment) {
-				queryArray.push([idx, increment]);
-				meanArray.push([idx, mean]);
-			});
-
-			return [{label: 'Queries', data: queryArray}, {label:'Average', data:meanArray}];
-		}
-
-		function getSlowQueryWarnings() {
-			return stateMap.queries.slowQueries;
-		}
-
-		return {
-			getZookeeperChartData : getZookeeperChartData,
-			getControllerChartData : getControllerChartData,
-			getClusters : getClusters,
-			getShardChartData : getShardChartData,
-			getTableChartData : getTableChartData,
-			getQueryLoadChartData : getQueryLoadChartData,
-			getSlowQueryWarnings : getSlowQueryWarnings
-		};
-	}());
-
-	var queries = (function() {
-		var states = ['running', 'interrupted', 'complete', 'backpressureinterrupted'];
-
-		//-------------- Private Methods -------------------
-		function _matchesFilter(queryData, filterText) {
-			var queryStr = queryData.user + '~~~' + queryData.query + '~~~' + states[queryData.state];
-
-			if (filterText === null || filterText === '') {
-				return true;
-			}
-
-			return queryStr.toLowerCase().indexOf(filterText.toLowerCase()) !== -1;
-		}
-
-		//-------------- Public API -----------------------
-		function queriesForTable(table, sort, filter) {
-			var queries = [], qSort, sortField, sortDir;
-
-			qSort = (sort || 'startTime~desc').split('~');
-			sortField = qSort[0];
-			sortDir = qSort.length > 1 ? qSort[1] : 'asc';
-
-			$.each(stateMap.queries.queries, function(i, query){
-				if (query.table === table && _matchesFilter(query, filter)) {
-					queries.push(query);
-				}
-			});
-
-			queries.sort(function(a, b){
-				if (sortDir === 'asc') {
-					return a[sortField] > b[sortField];
-				} else {
-					return b[sortField] > b[sortField];
-				}
-			});
-
-			return queries;
-		}
-
-		function cancelQuery(table, uuid) {
-			configMap.poller.cancelQuery(uuid);
-		}
-
-		function tableHasActivity(table) {
-			var hasActivity = false;
-			$.each(stateMap.queries.queries, function(i, query){
-				if (query.table === table) {
-					hasActivity = true;
-					return false;
-				}
-			});
-			return hasActivity;
-		}
-
-		return {
-			queriesForTable : queriesForTable,
-			cancelQuery : cancelQuery,
-			tableHasActivity : tableHasActivity
-		};
-	}());
-
-	var search = (function() {
-		var results = {}, totalRecords = 0, currentQuery, currentTable, currentArgs = {start: 0, fetch: 10, rowRecordOption: 'rowrow', families: null};
-
-		//-------------- Private Methods -------------------------
-		function _sendSearch() {
-			configMap.poller.sendSearch(currentQuery, currentTable, currentArgs, _processResults);
-		}
-
-		function _processResults(data) {
-			var dataFamilies = data.families;
-			var dataResults = data.results;
-			totalRecords = data.total;
-
-			if (typeof dataResults !== 'undefined' && dataResults !== null) {
-				$.each(dataResults, function(family, resultList){
-					var dataList = results[family] || [];
-					results[family] = dataList.concat(resultList);
-				});
-			}
-			$.gevent.publish('results-updated', [dataFamilies]);
-		}
-
-		//-------------- Public API ------------------------------
-		function runSearch( query, table, searchArgs ) {
-			var parsedFamilies = blurconsole.utils.findFamilies(query);
-
-			currentQuery = query;
-			currentTable = table;
-			currentArgs = $.extend(currentArgs, searchArgs);
-			currentArgs.families = parsedFamilies;
-			results = {};
-
-			if (query.indexOf('rowid:') === -1 && query.indexOf('recordid:') === -1) {
-				_sendSearch();
-			}
-		}
-
-		function getResults() {
-			return results;
-		}
-
-		function getTotal() {
-			return totalRecords;
-		}
-
-		function loadMoreResults(family) {
-			var alreadyLoadedResults = results[family];
-
-			if (typeof alreadyLoadedResults === 'undefined' || alreadyLoadedResults === null) {
-				currentArgs.start = 0;
-			} else if ($.isArray(alreadyLoadedResults)) {
-				currentArgs.start = alreadyLoadedResults.length;
-			} else {
-				currentArgs.start = blurconsole.utils.keys(alreadyLoadedResults).length;
-			}
-
-			// currentArgs.start = alreadyLoadedResults ? alreadyLoadedResults.length : 0;
-			currentArgs.fetch = 10;
-			currentArgs.families = [family];
-			_sendSearch();
-		}
-
-		return {
-			runSearch: runSearch,
-			getResults: getResults,
-			loadMoreResults: loadMoreResults,
-			getTotal: getTotal
-		};
-	}());
-
-	var logs = (function() {
-		//------------- Public API -------------------
-		function logError(error, module) {
-			stateMap.errors.push({error: error, module: module, timestamp: new Date()});
-			$.gevent.publish('logging-updated');
-		}
-
-		function clearErrors() {
-			delete stateMap.errors;
-			stateMap.errors = [];
-			$.gevent.publish('logging-updated');
-		}
-
-		function getLogs() {
-			return stateMap.errors;
-		}
-
-		return {
-			logError: logError,
-			clearErrors: clearErrors,
-			getLogs: getLogs
-		};
-	}());
-
-	//----------------------- Private Methods -------------------------
-	function _nodePoller() {
-		configMap.poller.getNodeList(_updateNodes);
-	}
-
-	function _tablePoller() {
-		configMap.poller.getTableList(_updateTables);
-	}
-
-	function _queryPerformancePoller() {
-		configMap.poller.getQueryPerformance(_updateQueryPerformance);
-	}
-
-	function _queryPoller() {
-		configMap.poller.getQueries(_updateQueries);
-	}
-
-	//----------------------- Event Handlers --------------------------
-	function _updateNodes(nodes) {
-		if (nodes !== 'error' && !blurconsole.utils.equals(nodes, stateMap.nodeMap)) {
-			stateMap.nodeMap = nodes;
-			$.gevent.publish('node-status-updated');
-		}
-		setTimeout(_nodePoller, 5000);
-	}
-
-	function _updateTables(data) {
-		if (data !== 'error') {
-			var tables = data.tables, clusters = data.clusters;
-			if (!blurconsole.utils.equals(tables, stateMap.currentTables) || !blurconsole.utils.equals(clusters, stateMap.currentClusters)) {
-				stateMap.currentTables = tables;
-				stateMap.currentClusters = clusters;
-				$.gevent.publish('tables-updated');
-			}
-		}
-		setTimeout(_tablePoller, 5000);
-	}
-
-	function _updateQueryPerformance(performanceMetric) {
-		if (performanceMetric !== 'error') {
-			if (stateMap.queryPerformance.length === 100) {
-				stateMap.queryPerformance.shift();
-			}
-
-			stateMap.queryPerformance.push(performanceMetric);
-			$.gevent.publish('query-perf-updated');
-		}
-		setTimeout(_queryPerformancePoller, 5000);
-	}
-
-	function _updateQueries(queries) {
-		if (queries !== 'error' && !blurconsole.utils.equals(queries, stateMap.queries)) {
-			stateMap.queries = queries;
-			$.gevent.publish('queries-updated');
-		}
-		setTimeout(_queryPoller, 5000);
-	}
-
-	//----------------------- Public API ------------------------------
-	function initModule() {
-		if(window.location.href.indexOf('fakeIt=') > -1) {
-			blurconsole.fake.initModule();
-			configMap.poller = blurconsole.fake;
-		} else {
-			configMap.poller = blurconsole.data;
-		}
-		setTimeout(function() {
-			_nodePoller();
-			_tablePoller();
-			_queryPerformancePoller();
-			_queryPoller();
-		}, 1000);
-	}
-
-	return {
-		initModule : initModule,
-		tables : tables,
-		metrics: metrics,
-		nodes : nodes,
-		queries : queries,
-		search : search,
-		logs: logs
-	};
+  'use strict';
+
+  //----------------------- Configuration and State ------------------
+  var
+    configMap = {
+      poller : null
+    },
+    stateMap = {
+      currentTables: null,
+      currentClusters: [],
+      nodeMap : null,
+      queryPerformance : [],
+      queries : {},
+      errors: [],
+      schema: {}
+    };
+
+  //----------------------- Models ----------------------------------
+  var tables = (function() {
+    //-------------- Public API -----------------
+    function getClusters() {
+      if (stateMap.currentClusters === null) {
+        return [];
+      }
+
+      return blurconsole.utils.unique(stateMap.currentClusters, true);
+    }
+
+    function getEnabledTables(cluster) {
+      var data = [];
+
+      $.each(stateMap.currentTables, function(idx, table) {
+        if (table.cluster === cluster && table.enabled) {
+          data.push({name:table.name, rowCount:table.rows, recordCount:table.records});
+        }
+      });
+
+      return data;
+    }
+
+    function getDisabledTables(cluster) {
+      var data = [];
+
+      $.each(stateMap.currentTables, function(idx, table) {
+        if (table.cluster === cluster && !table.enabled) {
+          data.push({name:table.name, rowCount:table.rows, recordCount:table.records});
+        }
+      });
+
+      return data;
+    }
+
+    function getAllEnabledTables() {
+      var tableMap = {};
+
+      $.each(getClusters(), function(c, cluster){
+        tableMap[cluster] = getEnabledTables(cluster);
+      });
+
+      return tableMap;
+    }
+
+    function isDataLoaded() {
+      return stateMap.currentTables !== null;
+    }
+
+    function disableTable(tableName) {
+      configMap.poller.disableTable(tableName);
+    }
+
+    function enableTable(tableName) {
+      configMap.poller.enableTable(tableName);
+    }
+
+    function deleteTable(tableName, includeFiles) {
+      configMap.poller.deleteTable(tableName, includeFiles);
+    }
+
+    function getSchema(tableName, callback) {
+      if(stateMap.schema && stateMap.schema.tableName === tableName && new Date() - stateMap.schema.date < 60000) {
+        setTimeout(function(){
+          callback(stateMap.schema.data);
+        }, 0);
+      } else {
+        configMap.poller.getSchema(tableName, function(schema) {
+          stateMap.schema.tableName = tableName;
+          stateMap.schema.data = schema;
+          stateMap.schema.date = new Date();
+          callback(schema);
+        });
+      }
+    }
+
+    function getFamilies(tableName) {
+      var table;
+
+      $.each(stateMap.currentTables, function(idx, t) {
+        if (t.name === tableName) {
+          table = t;
+          return false;
+        }
+      });
+      if(table) {
+        return table.families;
+      } else {
+        return [];
+      }
+    }
+
+    function findTerms(table, family, column, startsWith, callback) {
+      configMap.poller.findTerms(table, family, column, startsWith, callback);
+    }
+
+    return {
+      getClusters : getClusters,
+      getEnabledTables : getEnabledTables,
+      getDisabledTables : getDisabledTables,
+      isDataLoaded : isDataLoaded,
+      disableTable : disableTable,
+      enableTable : enableTable,
+      deleteTable : deleteTable,
+      getSchema : getSchema,
+      findTerms : findTerms,
+      getAllEnabledTables : getAllEnabledTables,
+      getFamilies : getFamilies
+    };
+  }());
+
+  var nodes = (function() {
+    //------------- Private Methods -----------------
+    function _getClusterData(clusterName) {
+      var clusterData = $.grep(stateMap.nodeMap.clusters, function(cluster) {
+        return cluster.name === clusterName;
+      });
+      return clusterData.length > 0 ? clusterData[0] : null;
+    }
+
+    //------------- Public API ----------------------
+    function getOnlineZookeeperNodes() {
+      return stateMap.nodeMap.zookeepers.online;
+    }
+
+    function getOfflineZookeeperNodes() {
+      return stateMap.nodeMap.zookeepers.offline;
+    }
+
+    function getOnlineControllerNodes() {
+      return stateMap.nodeMap.controllers.online;
+    }
+
+    function getOfflineControllerNodes() {
+      return stateMap.nodeMap.controllers.offline;
+    }
+
+    function getOfflineShardNodes(clusterName) {
+      var clusterData = _getClusterData(clusterName);
+      return clusterData ? clusterData.offline : [];
+    }
+
+    function getOnlineShardNodes(clusterName) {
+      var clusterData = _getClusterData(clusterName);
+      return clusterData ? clusterData.online : [];
+    }
+
+    function isDataLoaded() {
+      return stateMap.nodeMap !== null;
+    }
+
+    return {
+      getOnlineZookeeperNodes : getOnlineZookeeperNodes,
+      getOfflineZookeeperNodes : getOfflineZookeeperNodes,
+      getOfflineControllerNodes : getOfflineControllerNodes,
+      getOnlineControllerNodes : getOnlineControllerNodes,
+      getOfflineShardNodes : getOfflineShardNodes,
+      getOnlineShardNodes : getOnlineShardNodes,
+      isDataLoaded : isDataLoaded
+    };
+  }());
+
+  var metrics = (function() {
+    //------------- Private Methods ------------------
+    function _buildPieChartData(onlineCount, offlineCount) {
+      var onlineChart = {
+        'label':'Online',
+        'color':'#66CDCC',
+        'data':[[0,onlineCount]]
+      };
+
+      var offlineChart = {
+        'label':'Offline',
+        'color':'#FF1919',
+        'data':[[0,offlineCount]]
+      };
+
+      return [onlineChart, offlineChart];
+    }
+
+    //------------- Public API -----------------------
+    function getZookeeperChartData() {
+      return _buildPieChartData(stateMap.nodeMap.zookeepers.online.length, stateMap.nodeMap.zookeepers.offline.length);
+    }
+
+    function getControllerChartData() {
+      return _buildPieChartData(stateMap.nodeMap.controllers.online.length, stateMap.nodeMap.controllers.offline.length);
+    }
+
+    function getClusters() {
+      return $.map(stateMap.nodeMap.clusters, function(cluster) {
+        return cluster.name;
+      });
+    }
+
+    function getShardChartData(clusterName) {
+      var clusterData = $.grep(stateMap.nodeMap.clusters, function(cluster) {
+        return cluster.name === clusterName;
+      });
+
+      if (clusterData.length > 0) {
+        return _buildPieChartData(clusterData[0].online.length, clusterData[0].offline.length);
+      }
+      return null;
+    }
+
+    function getTableChartData() {
+      var enabledData = blurconsole.utils.reduce(stateMap.currentTables, [], function(accumulator, table){
+        var currentCluster = $.grep(accumulator, function(item){
+          return item[0] === table.cluster;
+        });
+
+        if (currentCluster.length === 0) {
+          currentCluster = [table.cluster, 0];
+          accumulator.push(currentCluster);
+        } else {
+          currentCluster = currentCluster[0];
+        }
+
+        if (table.enabled) {
+          currentCluster[1] = currentCluster[1]+1;
+        }
+        return accumulator;
+      });
+
+      var disabledData = blurconsole.utils.reduce(stateMap.currentTables, [], function(accumulator, table){
+        var currentCluster = $.grep(accumulator, function(item){
+          return item[0] === table.cluster;
+        });
+
+        if (currentCluster.length === 0) {
+          currentCluster = [table.cluster, 0];
+          accumulator.push(currentCluster);
+        } else {
+          currentCluster = currentCluster[0];
+        }
+
+        if (!table.enabled) {
+          currentCluster[1] = currentCluster[1]+1;
+        }
+        return accumulator;
+      });
+
+      return [
+        {
+          'data' : enabledData,
+          'label' : 'Enabled',
+          'color' : '#66CDCC',
+          'stack' : true
+        },
+        {
+          'data' : disabledData,
+          'label' : 'Disabled',
+          'color' : '#333333',
+          'stack' : true
+        }
+      ];
+    }
+
+    function getQueryLoadChartData() {
+      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(queryData, function(idx, increment) {
+        queryArray.push([idx, increment]);
+        meanArray.push([idx, mean]);
+      });
+
+      return [{label: 'Queries', data: queryArray}, {label:'Average', data:meanArray}];
+    }
+
+    function getSlowQueryWarnings() {
+      return stateMap.queries.slowQueries;
+    }
+
+    return {
+      getZookeeperChartData : getZookeeperChartData,
+      getControllerChartData : getControllerChartData,
+      getClusters : getClusters,
+      getShardChartData : getShardChartData,
+      getTableChartData : getTableChartData,
+      getQueryLoadChartData : getQueryLoadChartData,
+      getSlowQueryWarnings : getSlowQueryWarnings
+    };
+  }());
+
+  var queries = (function() {
+    var states = ['running', 'interrupted', 'complete', 'backpressureinterrupted'];
+
+    //-------------- Private Methods -------------------
+    function _matchesFilter(queryData, filterText) {
+      var queryStr = queryData.user + '~~~' + queryData.query + '~~~' + states[queryData.state];
+
+      if (filterText === null || filterText === '') {
+        return true;
+      }
+
+      return queryStr.toLowerCase().indexOf(filterText.toLowerCase()) !== -1;
+    }
+
+    //-------------- Public API -----------------------
+    function queriesForTable(table, sort, filter) {
+      var queries = [], qSort, sortField, sortDir;
+
+      qSort = (sort || 'startTime~desc').split('~');
+      sortField = qSort[0];
+      sortDir = qSort.length > 1 ? qSort[1] : 'asc';
+
+      $.each(stateMap.queries.queries, function(i, query){
+        if (query.table === table && _matchesFilter(query, filter)) {
+          queries.push(query);
+        }
+      });
+
+      queries.sort(function(a, b){
+        if (sortDir === 'asc') {
+          return a[sortField] > b[sortField];
+        } else {
+          return b[sortField] > b[sortField];
+        }
+      });
+
+      return queries;
+    }
+
+    function cancelQuery(table, uuid) {
+      configMap.poller.cancelQuery(uuid);
+    }
+
+    function tableHasActivity(table) {
+      var hasActivity = false;
+      $.each(stateMap.queries.queries, function(i, query){
+        if (query.table === table) {
+          hasActivity = true;
+          return false;
+        }
+      });
+      return hasActivity;
+    }
+
+    return {
+      queriesForTable : queriesForTable,
+      cancelQuery : cancelQuery,
+      tableHasActivity : tableHasActivity
+    };
+  }());
+
+  var search = (function() {
+    var results = {}, totalRecords = 0, currentQuery, currentTable, currentArgs = {start: 0, fetch: 10, rowRecordOption: 'rowrow', families: null};
+
+    //-------------- Private Methods -------------------------
+    function _sendSearch() {
+      configMap.poller.sendSearch(currentQuery, currentTable, currentArgs, _processResults);
+    }
+
+    function _processResults(data) {
+      var dataFamilies = data.families;
+      var dataResults = data.results;
+      totalRecords = data.total;
+
+      if (typeof dataResults !== 'undefined' && dataResults !== null) {
+        $.each(dataResults, function(family, resultList){
+          var dataList = results[family] || [];
+          results[family] = dataList.concat(resultList);
+        });
+      }
+      $.gevent.publish('results-updated', [dataFamilies]);
+    }
+
+    //-------------- Public API ------------------------------
+    function runSearch( query, table, searchArgs ) {
+      var parsedFamilies = blurconsole.utils.findFamilies(query);
+
+      currentQuery = query;
+      currentTable = table;
+      currentArgs = $.extend(currentArgs, searchArgs);
+      currentArgs.families = parsedFamilies;
+      results = {};
+
+      if (query.indexOf('rowid:') === -1 && query.indexOf('recordid:') === -1) {
+        _sendSearch();
+      }
+    }
+
+    function getResults() {
+      return results;
+    }
+
+    function getTotal() {
+      return totalRecords;
+    }
+
+    function loadMoreResults(family) {
+      var alreadyLoadedResults = results[family];
+
+      if (typeof alreadyLoadedResults === 'undefined' || alreadyLoadedResults === null) {
+        currentArgs.start = 0;
+      } else if ($.isArray(alreadyLoadedResults)) {
+        currentArgs.start = alreadyLoadedResults.length;
+      } else {
+        currentArgs.start = blurconsole.utils.keys(alreadyLoadedResults).length;
+      }
+
+      // currentArgs.start = alreadyLoadedResults ? alreadyLoadedResults.length : 0;
+      currentArgs.fetch = 10;
+      currentArgs.families = [family];
+      _sendSearch();
+    }
+
+    return {
+      runSearch: runSearch,
+      getResults: getResults,
+      loadMoreResults: loadMoreResults,
+      getTotal: getTotal
+    };
+  }());
+
+  var logs = (function() {
+    //------------- Public API -------------------
+    function logError(error, module) {
+      stateMap.errors.push({error: error, module: module, timestamp: new Date()});
+      $.gevent.publish('logging-updated');
+    }
+
+    function clearErrors() {
+      delete stateMap.errors;
+      stateMap.errors = [];
+      $.gevent.publish('logging-updated');
+    }
+
+    function getLogs() {
+      return stateMap.errors;
+    }
+
+    return {
+      logError: logError,
+      clearErrors: clearErrors,
+      getLogs: getLogs
+    };
+  }());
+
+  //----------------------- Private Methods -------------------------
+  function _nodePoller() {
+    configMap.poller.getNodeList(_updateNodes);
+  }
+
+  function _tablePoller() {
+    configMap.poller.getTableList(_updateTables);
+  }
+
+  function _queryPerformancePoller() {
+    configMap.poller.getQueryPerformance(_updateQueryPerformance);
+  }
+
+  function _queryPoller() {
+    configMap.poller.getQueries(_updateQueries);
+  }
+
+  //----------------------- Event Handlers --------------------------
+  function _updateNodes(nodes) {
+    if (nodes !== 'error' && !blurconsole.utils.equals(nodes, stateMap.nodeMap)) {
+      stateMap.nodeMap = nodes;
+      $.gevent.publish('node-status-updated');
+    }
+    setTimeout(_nodePoller, 5000);
+  }
+
+  function _updateTables(data) {
+    if (data !== 'error') {
+      var tables = data.tables, clusters = data.clusters;
+      if (!blurconsole.utils.equals(tables, stateMap.currentTables) || !blurconsole.utils.equals(clusters, stateMap.currentClusters)) {
+        stateMap.currentTables = tables;
+        stateMap.currentClusters = clusters;
+        $.gevent.publish('tables-updated');
+      }
+    }
+    setTimeout(_tablePoller, 5000);
+  }
+
+  function _updateQueryPerformance(performanceMetric) {
+    if (performanceMetric !== 'error') {
+      if (stateMap.queryPerformance.length === 100) {
+        stateMap.queryPerformance.shift();
+      }
+
+      stateMap.queryPerformance.push(performanceMetric);
+      $.gevent.publish('query-perf-updated');
+    }
+    setTimeout(_queryPerformancePoller, 5000);
+  }
+
+  function _updateQueries(queries) {
+    if (queries !== 'error' && !blurconsole.utils.equals(queries, stateMap.queries)) {
+      stateMap.queries = queries;
+      $.gevent.publish('queries-updated');
+    }
+    setTimeout(_queryPoller, 5000);
+  }
+
+  //----------------------- Public API ------------------------------
+  function initModule() {
+    if(window.location.href.indexOf('fakeIt=') > -1) {
+      blurconsole.fake.initModule();
+      configMap.poller = blurconsole.fake;
+    } else {
+      configMap.poller = blurconsole.data;
+    }
+    setTimeout(function() {
+      _nodePoller();
+      _tablePoller();
+      _queryPerformancePoller();
+      _queryPoller();
+    }, 1000);
+  }
+
+  return {
+    initModule : initModule,
+    tables : tables,
+    metrics: metrics,
+    nodes : nodes,
+    queries : queries,
+    search : search,
+    logs: logs
+  };
 }());
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/79786aca/blur-console/src/main/webapp/js/blurconsole.schema.js
----------------------------------------------------------------------
diff --git a/blur-console/src/main/webapp/js/blurconsole.schema.js b/blur-console/src/main/webapp/js/blurconsole.schema.js
index ebb36dd..27bc745 100644
--- a/blur-console/src/main/webapp/js/blurconsole.schema.js
+++ b/blur-console/src/main/webapp/js/blurconsole.schema.js
@@ -20,171 +20,171 @@ under the License.
 /*jshint laxbreak: true */
 /*global blurconsole:false */
 blurconsole.schema = (function () {
-	'use strict';
+  'use strict';
     
     //----------------------------- Configuration and State -------------------------
-	var
-		configMap = {
-			mainHtml: String()
-				+ '<div class="container-fluid">'
-					+ '<div class="row">'
-						+ '<div class="col-md-6">'
-							+ '<div class="panel-group schemaList">'
-							+ '</div>'
-						+ '</div>'
-						+ '<div class="col-md-6">'
-							+ '<div class="row">'
-								+ '<div class="col-md-12 schemaColumnInfo">'
-									+ '<div class="schemaColumnDef in">'
-										+ '<strong>Choose a column on the left to see def</strong>'
-									+ '</div>'
-								+ '</div>'
-							+ '</div>'
-							+ '<div class="row">'
-								+ '<div class="col-md-12 schemaColumnTerms">'
-									+ '<div class="input-group">'
-										+ '<input class="form-control termSearch" placeholder="Starts With" type="text">'
-										+ '<span class="input-group-btn">'
-											+ '<button class="btn btn-default" type="button">Go!</button>'
-										+ '</span>'
-									+ '</div>'
-									+ '<ul class="list-group termList"></ul>'
-								+ '</div>'
-							+ '</div>'
-						+ '</div>'
-					+ '</div>'
-				+ '</div>'
-		},
-		stateMap = {},
-		jqueryMap = {};
-
-	//------------------------------ Private Methods -----------------------------------------------------
-	function _findTerms() {
-		blurconsole.model.tables.findTerms(stateMap.table, stateMap.termFamily, stateMap.termColumn, jqueryMap.termSearch.val(), _loadTerms);
-	}
-
-	//------------------------------ Event Handling and DOM Methods --------------------------------------
-	function _showSchema(event, table) {
-		stateMap.table = table;
-		stateMap.modalId = stateMap.table + '_modal';
-		blurconsole.model.tables.getSchema(stateMap.table, _popupSchemaView);
-	}
-
-	function _popupSchemaView(schema) {
-		stateMap.schema = schema;
-		jqueryMap.contentHolder = $(configMap.mainHtml);
-		jqueryMap.contentHolder.find('.schemaList').html(_buildTreeSection());
-		jqueryMap.contentHolder.find('.schemaColumnInfo').append(_buildInfoSection());
-
-		jqueryMap.modal = $(blurconsole.browserUtils.modal(stateMap.modalId, 'Schema Definition for ' + stateMap.table, jqueryMap.contentHolder, null, 'large'));
-		jqueryMap.modal.modal()
-		.on('shown.bs.modal', function(e){
-			jqueryMap.columnTermsSection = $('.schemaColumnTerms', jqueryMap.modal);
-			jqueryMap.termSearch = $('.termSearch', jqueryMap.modal);
-			jqueryMap.termList = $('.termList', jqueryMap.modal);
-			jqueryMap.termSearchButton = $('.schemaColumnTerms button', jqueryMap.modal);
-			$('.collapse', e.currentTarget).collapse({ toggle: false });
-		})
-		.on('hidden.bs.modal', function(e) {
-			$(e.currentTarget).remove();
-			jqueryMap.contentHolder.remove();
-			jqueryMap = {};
-			stateMap = {};
-		})
-		.on('click', 'li.schemaColumn', function() {
-			var defId = $(this).find('a').attr('href');
-			$('div.schemaColumnDef').removeClass('in');
-			$(defId).addClass('in');
-			jqueryMap.columnTermsSection.hide();
-			return false;
-		})
-		.on('click', 'a.termsTrigger', _viewTerms)
-		.on('click', '.schemaColumnTerms button', _findTerms)
-		.on('click', '.searchTrigger', _switchToSearch);
-	}
-
-	function _buildTreeSection() {
-		var tree = '';
-		$.each(stateMap.schema, function(family, cols){
-			var famId = blurconsole.browserUtils.cleanId(family);
-			tree += '<div class="panel panel-default"><div class="panel-heading">';
-			tree += '<h4 class="panel-title" data-toggle="collapse" data-parent=".schemaList" data-target="#' + famId + '">' + family + '</h4></div>';
-			tree += '<div id="' + famId + '" class="panel-collapse collapse"><div class="panel-body"><ul class="list-group">';
-			$.each(cols, function(col, def) {
-				var colId = blurconsole.browserUtils.cleanId(col);
-				tree += '<li class="list-group-item schemaColumn"><a href="#' + famId + '_' + colId + '">' + col + '';
-				tree += '</a><div class="pull-right">';
-				if (def.type !== 'stored') {
-					tree += ' <span class="badge">searchable</span>';
-				}
-				tree += '<i class="glyphicon glyphicon-chevron-right"></i></div></li>';
-			});
-			tree += '</ul></div></div></div>';
-		});
-		return tree;
-	}
-
-	function _buildInfoSection() {
-		var info = '';
-		$.each(stateMap.schema, function(family, cols){
-			var famId = blurconsole.browserUtils.cleanId(family);
-			$.each(cols, function(col, def){
-				var colId = blurconsole.browserUtils.cleanId(col);
-				info += '<div class="schemaColumnDef" id="' + famId + '_' + colId + '"><ul class="list-group">';
-				info += '<li class="list-group-item"><strong>Field Name:</strong> ' + col + '</li>';
-				info += '<li class="list-group-item"><strong>Fieldless Searching:</strong> ' + blurconsole.browserUtils.booleanImg(def.fieldLess) + '</li>';
-				info += '<li class="list-group-item"><strong>Field Type:</strong> ' + def.type + '</li>';
-				if (def.extra) {
-					$.each(def.extra, function(key, value) {
-						info += '<li class="list-group-item"><strong>' + key + ':</strong> ' + value + '</li>';
-					});
-				}
-				if (def.type !== 'stored') {
-					info += '<li class="list-group-item"><a href="#" class="termsTrigger" data-fam="' + family + '" data-col="' + col + '">View Terms</a></li>';
-				}
-				info += '</ul></div>';
-			});
-		});
-		return info;
-	}
-
-	function _viewTerms(evt) {
-		jqueryMap.termList.html('<div class="center-block"><img src="img/ajax-loader.gif"></div>');
-		jqueryMap.termSearch.val('');
-		jqueryMap.columnTermsSection.show();
-		var $this = $(evt.currentTarget);
-
-		stateMap.termFamily = $this.data('fam');
-		stateMap.termColumn = $this.data('col');
-
-		jqueryMap.termSearchButton.trigger('click');
-	}
-
-	function _loadTerms(terms) {
-		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 + '" data-table="' + stateMap.table + '"><i class="glyphicon glyphicon-search"></i></span></li>');
-		});
-	}
-
-	function _switchToSearch(evt){
-		blurconsole.shell.changeAnchorPart({
-			tab: 'search',
-			_tab: {
-				query: encodeURIComponent(stateMap.termFamily + '.' + stateMap.termColumn + ':' + $(evt.currentTarget).data('value')),
-				table: $(evt.currentTarget).data('table'),
-				rr: 'rowrow'
-			}
-		});
-		jqueryMap.modal.modal('hide');
-	}
+  var
+    configMap = {
+      mainHtml: String()
+        + '<div class="container-fluid">'
+          + '<div class="row">'
+            + '<div class="col-md-6">'
+              + '<div class="panel-group schemaList">'
+              + '</div>'
+            + '</div>'
+            + '<div class="col-md-6">'
+              + '<div class="row">'
+                + '<div class="col-md-12 schemaColumnInfo">'
+                  + '<div class="schemaColumnDef in">'
+                    + '<strong>Choose a column on the left to see def</strong>'
+                  + '</div>'
+                + '</div>'
+              + '</div>'
+              + '<div class="row">'
+                + '<div class="col-md-12 schemaColumnTerms">'
+                  + '<div class="input-group">'
+                    + '<input class="form-control termSearch" placeholder="Starts With" type="text">'
+                    + '<span class="input-group-btn">'
+                      + '<button class="btn btn-default" type="button">Go!</button>'
+                    + '</span>'
+                  + '</div>'
+                  + '<ul class="list-group termList"></ul>'
+                + '</div>'
+              + '</div>'
+            + '</div>'
+          + '</div>'
+        + '</div>'
+    },
+    stateMap = {},
+    jqueryMap = {};
+
+  //------------------------------ Private Methods -----------------------------------------------------
+  function _findTerms() {
+    blurconsole.model.tables.findTerms(stateMap.table, stateMap.termFamily, stateMap.termColumn, jqueryMap.termSearch.val(), _loadTerms);
+  }
+
+  //------------------------------ Event Handling and DOM Methods --------------------------------------
+  function _showSchema(event, table) {
+    stateMap.table = table;
+    stateMap.modalId = stateMap.table + '_modal';
+    blurconsole.model.tables.getSchema(stateMap.table, _popupSchemaView);
+  }
+
+  function _popupSchemaView(schema) {
+    stateMap.schema = schema;
+    jqueryMap.contentHolder = $(configMap.mainHtml);
+    jqueryMap.contentHolder.find('.schemaList').html(_buildTreeSection());
+    jqueryMap.contentHolder.find('.schemaColumnInfo').append(_buildInfoSection());
+
+    jqueryMap.modal = $(blurconsole.browserUtils.modal(stateMap.modalId, 'Schema Definition for ' + stateMap.table, jqueryMap.contentHolder, null, 'large'));
+    jqueryMap.modal.modal()
+    .on('shown.bs.modal', function(e){
+      jqueryMap.columnTermsSection = $('.schemaColumnTerms', jqueryMap.modal);
+      jqueryMap.termSearch = $('.termSearch', jqueryMap.modal);
+      jqueryMap.termList = $('.termList', jqueryMap.modal);
+      jqueryMap.termSearchButton = $('.schemaColumnTerms button', jqueryMap.modal);
+      $('.collapse', e.currentTarget).collapse({ toggle: false });
+    })
+    .on('hidden.bs.modal', function(e) {
+      $(e.currentTarget).remove();
+      jqueryMap.contentHolder.remove();
+      jqueryMap = {};
+      stateMap = {};
+    })
+    .on('click', 'li.schemaColumn', function() {
+      var defId = $(this).find('a').attr('href');
+      $('div.schemaColumnDef').removeClass('in');
+      $(defId).addClass('in');
+      jqueryMap.columnTermsSection.hide();
+      return false;
+    })
+    .on('click', 'a.termsTrigger', _viewTerms)
+    .on('click', '.schemaColumnTerms button', _findTerms)
+    .on('click', '.searchTrigger', _switchToSearch);
+  }
+
+  function _buildTreeSection() {
+    var tree = '';
+    $.each(stateMap.schema, function(family, cols){
+      var famId = blurconsole.browserUtils.cleanId(family);
+      tree += '<div class="panel panel-default"><div class="panel-heading">';
+      tree += '<h4 class="panel-title" data-toggle="collapse" data-parent=".schemaList" data-target="#' + famId + '">' + family + '</h4></div>';
+      tree += '<div id="' + famId + '" class="panel-collapse collapse"><div class="panel-body"><ul class="list-group">';
+      $.each(cols, function(col, def) {
+        var colId = blurconsole.browserUtils.cleanId(col);
+        tree += '<li class="list-group-item schemaColumn"><a href="#' + famId + '_' + colId + '">' + col + '';
+        tree += '</a><div class="pull-right">';
+        if (def.type !== 'stored') {
+          tree += ' <span class="badge">searchable</span>';
+        }
+        tree += '<i class="glyphicon glyphicon-chevron-right"></i></div></li>';
+      });
+      tree += '</ul></div></div></div>';
+    });
+    return tree;
+  }
+
+  function _buildInfoSection() {
+    var info = '';
+    $.each(stateMap.schema, function(family, cols){
+      var famId = blurconsole.browserUtils.cleanId(family);
+      $.each(cols, function(col, def){
+        var colId = blurconsole.browserUtils.cleanId(col);
+        info += '<div class="schemaColumnDef" id="' + famId + '_' + colId + '"><ul class="list-group">';
+        info += '<li class="list-group-item"><strong>Field Name:</strong> ' + col + '</li>';
+        info += '<li class="list-group-item"><strong>Fieldless Searching:</strong> ' + blurconsole.browserUtils.booleanImg(def.fieldLess) + '</li>';
+        info += '<li class="list-group-item"><strong>Field Type:</strong> ' + def.type + '</li>';
+        if (def.extra) {
+          $.each(def.extra, function(key, value) {
+            info += '<li class="list-group-item"><strong>' + key + ':</strong> ' + value + '</li>';
+          });
+        }
+        if (def.type !== 'stored') {
+          info += '<li class="list-group-item"><a href="#" class="termsTrigger" data-fam="' + family + '" data-col="' + col + '">View Terms</a></li>';
+        }
+        info += '</ul></div>';
+      });
+    });
+    return info;
+  }
+
+  function _viewTerms(evt) {
+    jqueryMap.termList.html('<div class="center-block"><img src="img/ajax-loader.gif"></div>');
+    jqueryMap.termSearch.val('');
+    jqueryMap.columnTermsSection.show();
+    var $this = $(evt.currentTarget);
+
+    stateMap.termFamily = $this.data('fam');
+    stateMap.termColumn = $this.data('col');
+
+    jqueryMap.termSearchButton.trigger('click');
+  }
+
+  function _loadTerms(terms) {
+    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 + '" data-table="' + stateMap.table + '"><i class="glyphicon glyphicon-search"></i></span></li>');
+    });
+  }
+
+  function _switchToSearch(evt){
+    blurconsole.shell.changeAnchorPart({
+      tab: 'search',
+      _tab: {
+        query: encodeURIComponent(stateMap.termFamily + '.' + stateMap.termColumn + ':' + $(evt.currentTarget).data('value')),
+        table: $(evt.currentTarget).data('table'),
+        rr: 'rowrow'
+      }
+    });
+    jqueryMap.modal.modal('hide');
+  }
 
     //----------------------------- Public API ----------------------------
-	function initModule() {
-		$.gevent.subscribe($(document), 'schema-show', _showSchema);
-	}
+  function initModule() {
+    $.gevent.subscribe($(document), 'schema-show', _showSchema);
+  }
 
-	return {
-		initModule : initModule
-	};
+  return {
+    initModule : initModule
+  };
 }());
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/79786aca/blur-console/src/main/webapp/js/blurconsole.search.js
----------------------------------------------------------------------
diff --git a/blur-console/src/main/webapp/js/blurconsole.search.js b/blur-console/src/main/webapp/js/blurconsole.search.js
index a35da9e..7274549 100644
--- a/blur-console/src/main/webapp/js/blurconsole.search.js
+++ b/blur-console/src/main/webapp/js/blurconsole.search.js
@@ -18,457 +18,457 @@ under the License.
 */
 /*global blurconsole:false, confirm:false */
 blurconsole.search = (function () {
-	'use strict';
+  'use strict';
     
     //----------------------------- Configuration and State --------------------------------
-	var configMap = {
-		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,
-		$currentTable : null,
-		$currentQuery : null,
-		$schemaForCurrentTable : null,
-		$start : 0,
-		$fetch : 10,
-		$filter : null,
-		$rowRecordOption : 'rowrow'
-	},
-	jqueryMap = {};
+  var configMap = {
+    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,
+    $currentTable : null,
+    $currentQuery : null,
+    $schemaForCurrentTable : null,
+    $start : 0,
+    $fetch : 10,
+    $filter : null,
+    $rowRecordOption : 'rowrow'
+  },
+  jqueryMap = {};
     
     //----------------- Private Methods ----------------------------------
-	function _setJqueryMap() {
-		var $container = stateMap.$container;
-		jqueryMap = {
-			$container : $container,
-			$queryField : $('#queryField'),
-			$tableField : $('#tableChooser'),
-			$tableSelectorStatusOption : $('#statusOption'),
-			$tableWarning : $('#tableGoneWarning'),
-			$resultsHolder : $('#results'),
-			$optionsDisplay : $('#searchOptionsDisplay'),
-			$countHolder : $('#resultCount'),
-			$facetTrigger : $('#facetTrigger'),
-			$optionsTrigger: $('#searchOptionsTrigger'),
-			$searchTrigger : $('#searchTrigger')
-		};
-	}
-
-	function _parseQueryForTypeahead(query) {
-		var ret = {
-			family: null,
-			column: null,
-			term: null,
-			mode: null
-		};
-		query = query.toLowerCase();
-		var dotIndex = query.lastIndexOf('.');
-		var colonIndex = query.lastIndexOf(':');
-		var lParenIndex = query.lastIndexOf('(');
-		var rParenIndex = query.lastIndexOf(')');
-		var inParen = lParenIndex > -1 && lParenIndex > rParenIndex;
-		var spaceIndex = query.lastIndexOf(' ');
-		var lastIndex = Math.max(0,dotIndex,colonIndex,lParenIndex,rParenIndex,spaceIndex);
-		if(dotIndex === lastIndex) { // column mode
-			ret.family = query.substring(spaceIndex+1, dotIndex);
-			ret.column = query.substring(dotIndex+1);
-			ret.mode = 'column';
-		} else if(colonIndex === lastIndex || (inParen && lParenIndex === colonIndex+1)) { // term mode
-			var familyStart = query.lastIndexOf(' ', dotIndex);
-			if(familyStart === -1) {
-				familyStart = 0;
-			}
-			ret.family = query.substring(familyStart, dotIndex);
-			ret.column = query.substring(dotIndex+1, colonIndex);
-			ret.term = query.substring(lastIndex+1);
-			ret.mode = 'term';
-		} else if(query.length === 1 || query.length -1 !== lastIndex) { // family mode
-			ret.family = query.substring(spaceIndex+1);
-			ret.mode = 'family';
-		}
-		if(ret.family) {
-			ret.family = ret.family.replace(/[\.\:\(\)\+\- ]/g,'');
-		}
-		if(ret.term) {
-			ret.term = ret.term.replace(/[\+\-]/g,'');
-		}
-		return ret;
-	}
-
-	var _queryTypeaheadDataset = {
-		name:'query-dataset',
-		source: function _queryTypeaheadSource(query, cb) {
-			function buildSuggestionObject(query, hint, value) {
-				return {value:query.substring(0,query.lastIndexOf(hint)) + value, display:value};
-			}
-			var table = stateMap.$currentTable;
-			if(table && table !== '' && blurconsole.model.tables.isDataLoaded()) {
-				query = query.toLowerCase();
-				var parsedQuery = _parseQueryForTypeahead(query);
-				console.log(parsedQuery.mode);
-				switch(parsedQuery.mode) {
-				case 'family':
-					var families = blurconsole.model.tables.getFamilies(table);
-					families = $.map(families, function(fam) {
-						if(fam.indexOf(parsedQuery.family) === 0) {
-							return buildSuggestionObject(query, parsedQuery.family, fam);
-						}
-					});
-					cb(families);
-					break;
-				case 'column':
-					blurconsole.model.tables.getSchema(table, function(schema) {
-						var columnMap = schema[parsedQuery.family];
-						if(columnMap) {
-							var columns = $.map(columnMap, function(data, col) {
-								if(col.indexOf(parsedQuery.column) === 0) {
-									return buildSuggestionObject(query, parsedQuery.column, col);
-								}
-							});
-							cb(columns);
-						}
-					});
-					break;
-				case 'term':
-					if(parsedQuery.term.length > 0) {
-						blurconsole.model.tables.findTerms(table, parsedQuery.family, parsedQuery.column, parsedQuery.term, function(terms){
-							terms = $.map(terms, function(suggestedTerm){
-								return buildSuggestionObject(query, parsedQuery.term, suggestedTerm);
-							});
-							cb(terms);
-						});
-					} else {
-						cb(null);
-					}
-					break;
-				default:
-					cb(null);
-				}
-			}
-		},
-		templates: {
-			suggestion: function(suggestion) {
-				return '<p>' + suggestion.display + '</p>';
-			}
-		}
-	};
-
-	function _registerPageEvents() {
-		jqueryMap.$searchTrigger.on('click', _sendSearch);
-		jqueryMap.$queryField.typeahead({}, _queryTypeaheadDataset);
-		jqueryMap.$queryField.on('keyup', function(evt) {
-			if (evt.keyCode === 13) {
-				_sendSearch();
-			}
-		});
-		jqueryMap.$resultsHolder.on('shown.bs.collapse', '.panel-collapse:not(.loaded)', _getMoreData);
-		jqueryMap.$resultsHolder.on('click', '.nextPage', _getMoreData);
-		jqueryMap.$optionsTrigger.popover({
-			html: true,
-			placement: 'bottom',
-			title: 'Extra Search Options',
-			container: 'body',
-			content: configMap.optionsHtml
-		});
-		jqueryMap.$optionsTrigger.on('shown.bs.popover', _updateOptionPopover);
-		$(document).on('change', '.popover select', _persistOptions);
-		jqueryMap.$facetTrigger.on('click', _popupFacetDialog);
-		jqueryMap.$tableField.on('change', function(evt) {
-			stateMap.$currentTable = $(evt.currentTarget).val();
-		});
-	}
-
-	function _unregisterPageEvents() {
-		if (jqueryMap.$searchTrigger) {
-			jqueryMap.$searchTrigger.off('click');
-			jqueryMap.$queryField.typeahead('destroy');
-			jqueryMap.$queryField.off('keyup');
-			jqueryMap.$resultsHolder.off('shown.bs.collapse');
-			jqueryMap.$resultsHolder.off('click');
-			jqueryMap.$optionsTrigger.popover('destroy');
-			jqueryMap.$optionsTrigger.off('shown.bs.popover');
-			$(document).off('change');
-			jqueryMap.$tableField.off('change');
-			//jqueryMap.$facetTrigger.off('click');
-		}
-	}
+  function _setJqueryMap() {
+    var $container = stateMap.$container;
+    jqueryMap = {
+      $container : $container,
+      $queryField : $('#queryField'),
+      $tableField : $('#tableChooser'),
+      $tableSelectorStatusOption : $('#statusOption'),
+      $tableWarning : $('#tableGoneWarning'),
+      $resultsHolder : $('#results'),
+      $optionsDisplay : $('#searchOptionsDisplay'),
+      $countHolder : $('#resultCount'),
+      $facetTrigger : $('#facetTrigger'),
+      $optionsTrigger: $('#searchOptionsTrigger'),
+      $searchTrigger : $('#searchTrigger')
+    };
+  }
+
+  function _parseQueryForTypeahead(query) {
+    var ret = {
+      family: null,
+      column: null,
+      term: null,
+      mode: null
+    };
+    query = query.toLowerCase();
+    var dotIndex = query.lastIndexOf('.');
+    var colonIndex = query.lastIndexOf(':');
+    var lParenIndex = query.lastIndexOf('(');
+    var rParenIndex = query.lastIndexOf(')');
+    var inParen = lParenIndex > -1 && lParenIndex > rParenIndex;
+    var spaceIndex = query.lastIndexOf(' ');
+    var lastIndex = Math.max(0,dotIndex,colonIndex,lParenIndex,rParenIndex,spaceIndex);
+    if(dotIndex === lastIndex) { // column mode
+      ret.family = query.substring(spaceIndex+1, dotIndex);
+      ret.column = query.substring(dotIndex+1);
+      ret.mode = 'column';
+    } else if(colonIndex === lastIndex || (inParen && lParenIndex === colonIndex+1)) { // term mode
+      var familyStart = query.lastIndexOf(' ', dotIndex);
+      if(familyStart === -1) {
+        familyStart = 0;
+      }
+      ret.family = query.substring(familyStart, dotIndex);
+      ret.column = query.substring(dotIndex+1, colonIndex);
+      ret.term = query.substring(lastIndex+1);
+      ret.mode = 'term';
+    } else if(query.length === 1 || query.length -1 !== lastIndex) { // family mode
+      ret.family = query.substring(spaceIndex+1);
+      ret.mode = 'family';
+    }
+    if(ret.family) {
+      ret.family = ret.family.replace(/[\.\:\(\)\+\- ]/g,'');
+    }
+    if(ret.term) {
+      ret.term = ret.term.replace(/[\+\-]/g,'');
+    }
+    return ret;
+  }
+
+  var _queryTypeaheadDataset = {
+    name:'query-dataset',
+    source: function _queryTypeaheadSource(query, cb) {
+      function buildSuggestionObject(query, hint, value) {
+        return {value:query.substring(0,query.lastIndexOf(hint)) + value, display:value};
+      }
+      var table = stateMap.$currentTable;
+      if(table && table !== '' && blurconsole.model.tables.isDataLoaded()) {
+        query = query.toLowerCase();
+        var parsedQuery = _parseQueryForTypeahead(query);
+        console.log(parsedQuery.mode);
+        switch(parsedQuery.mode) {
+        case 'family':
+          var families = blurconsole.model.tables.getFamilies(table);
+          families = $.map(families, function(fam) {
+            if(fam.indexOf(parsedQuery.family) === 0) {
+              return buildSuggestionObject(query, parsedQuery.family, fam);
+            }
+          });
+          cb(families);
+          break;
+        case 'column':
+          blurconsole.model.tables.getSchema(table, function(schema) {
+            var columnMap = schema[parsedQuery.family];
+            if(columnMap) {
+              var columns = $.map(columnMap, function(data, col) {
+                if(col.indexOf(parsedQuery.column) === 0) {
+                  return buildSuggestionObject(query, parsedQuery.column, col);
+                }
+              });
+              cb(columns);
+            }
+          });
+          break;
+        case 'term':
+          if(parsedQuery.term.length > 0) {
+            blurconsole.model.tables.findTerms(table, parsedQuery.family, parsedQuery.column, parsedQuery.term, function(terms){
+              terms = $.map(terms, function(suggestedTerm){
+                return buildSuggestionObject(query, parsedQuery.term, suggestedTerm);
+              });
+              cb(terms);
+            });
+          } else {
+            cb(null);
+          }
+          break;
+        default:
+          cb(null);
+        }
+      }
+    },
+    templates: {
+      suggestion: function(suggestion) {
+        return '<p>' + suggestion.display + '</p>';
+      }
+    }
+  };
+
+  function _registerPageEvents() {
+    jqueryMap.$searchTrigger.on('click', _sendSearch);
+    jqueryMap.$queryField.typeahead({}, _queryTypeaheadDataset);
+    jqueryMap.$queryField.on('keyup', function(evt) {
+      if (evt.keyCode === 13) {
+        _sendSearch();
+      }
+    });
+    jqueryMap.$resultsHolder.on('shown.bs.collapse', '.panel-collapse:not(.loaded)', _getMoreData);
+    jqueryMap.$resultsHolder.on('click', '.nextPage', _getMoreData);
+    jqueryMap.$optionsTrigger.popover({
+      html: true,
+      placement: 'bottom',
+      title: 'Extra Search Options',
+      container: 'body',
+      content: configMap.optionsHtml
+    });
+    jqueryMap.$optionsTrigger.on('shown.bs.popover', _updateOptionPopover);
+    $(document).on('change', '.popover select', _persistOptions);
+    jqueryMap.$facetTrigger.on('click', _popupFacetDialog);
+    jqueryMap.$tableField.on('change', function(evt) {
+      stateMap.$currentTable = $(evt.currentTarget).val();
+    });
+  }
+
+  function _unregisterPageEvents() {
+    if (jqueryMap.$searchTrigger) {
+      jqueryMap.$searchTrigger.off('click');
+      jqueryMap.$queryField.typeahead('destroy');
+      jqueryMap.$queryField.off('keyup');
+      jqueryMap.$resultsHolder.off('shown.bs.collapse');
+      jqueryMap.$resultsHolder.off('click');
+      jqueryMap.$optionsTrigger.popover('destroy');
+      jqueryMap.$optionsTrigger.off('shown.bs.popover');
+      $(document).off('change');
+      jqueryMap.$tableField.off('change');
+      //jqueryMap.$facetTrigger.off('click');
+    }
+  }
 
     function _getColList(row) {
-		var cols = blurconsole.utils.reject(blurconsole.utils.keys(row), function(i) {
-			return i === 'recordid';
-		});
+    var cols = blurconsole.utils.reject(blurconsole.utils.keys(row), function(i) {
+      return i === 'recordid';
+    });
 
-		if (cols.length === 0) {
-			return [];
-		}
+    if (cols.length === 0) {
+      return [];
+    }
 
-		cols.sort();
+    cols.sort();
 
-		cols = ['recordid'].concat(cols);
-		return cols;
-	}
+    cols = ['recordid'].concat(cols);
+    return cols;
+  }
 
     //------------------------------ Event Handlers and DOM Methods ---------------------
-	function _updateOptionDisplay() {
-		var displayText = '';
-		displayText += configMap.superQueryMap[stateMap.$rowRecordOption];
-		jqueryMap.$optionsDisplay.html(displayText);
-	}
-
-	function _updateOptionPopover() {
-		if ($('#superQuery').length > 0) {
-			$('#superQuery').val(stateMap.$rowRecordOption);
-		}
-	}
-
-	function _persistOptions() {
-		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');
-	}
-
-	function _sendSearch() {
-		stateMap.$currentTable = jqueryMap.$tableField.val();
-		stateMap.$currentQuery = jqueryMap.$queryField.val();
-
-		blurconsole.shell.changeAnchorPart({
-			tab: 'search',
-			_tab: {
-				query: encodeURIComponent(stateMap.$currentQuery),
-				table: stateMap.$currentTable,
-				rr: stateMap.$rowRecordOption
-			}
-		});
-		_drawResultHolders();
-		jqueryMap.$countHolder.html('');
-		blurconsole.model.search.runSearch(stateMap.$currentQuery, stateMap.$currentTable, {start: 0, fetch: 10, rowRecordOption: stateMap.$rowRecordOption});
-	}
-
-	function _getMoreData(evt) {
-		var family = $(evt.currentTarget).attr('href') ? $(evt.currentTarget).attr('href').substring(1) : $(evt.currentTarget).attr('id');
-		blurconsole.model.search.loadMoreResults(family);
-		return false;
-	}
-
-	function _reviewTables() {
-		var tableFound = false;
-
-		if (stateMap.$currentTable) {
-			var 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 if (stateMap.$currentTable) {
-			jqueryMap.$tableWarning.show();
-		} else {
-			_loadTableList();
-		}
-	}
-
-	function _drawResultHolders() {
-		var familyMarkup = '', parsedFamilies = blurconsole.utils.findFamilies(stateMap.$currentQuery);
-
-		jqueryMap.$resultsHolder.html('');
-
-		// Redraw families
-		var allFamilies = blurconsole.model.tables.getFamilies(stateMap.$currentTable);
-		var extraFamilies = blurconsole.utils.reject(allFamilies, function(fam){ return parsedFamilies.indexOf(fam) >= 0; });
-
-		parsedFamilies.sort();
-		extraFamilies.sort();
-
-		var 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" data-toggle="collapse" data-parent="#results" data-target="#' + famId + '">' + fam + '</h4></div>';
-			familyMarkup += '<div id="' + famId + '" class="panel-collapse collapse' + (parsedFamilies.indexOf(fam) >= 0 ? ' in' : '') + '">';
-			familyMarkup += '<div class="panel-body"><img src="img/ajax-loader.gif"></div></div></div>';
-		});
-
-		jqueryMap.$resultsHolder.html(familyMarkup);
-	}
-
-	function _drawResults(evt, families) {
-		var results = blurconsole.model.search.getResults();
-		jqueryMap.$countHolder.html('<small>Found ' + blurconsole.model.search.getTotal() + ' total results</small>');
-		//jqueryMap.$facetTrigger.show();
-
-		if (typeof families !== 'undefined' && families !== null) {
-			$.each(families, function(i, fam) {
-				var famResults = results[fam],
-					famId = '#' + blurconsole.browserUtils.cleanId(fam),
-					famHolder = $(famId + ' .panel-body');
-
-				if (typeof famResults === 'undefined' || famResults.length === 0) {
-					famHolder.html('<div class="alert alert-info">No Data Found</div>');
-				} else {
-					var table;
-					var cols;
-					if (blurconsole.utils.keys(famResults[0]).indexOf('rowid') === -1 ) {
-						// Record results
-						table = '<table class="table table-condensed table-hover table-bordered"><thead><tr>';
-						cols = _getColList(famResults[0]);
-
-						$.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>';
-					} else {
-						// Row results
-						$.each(famResults, function(i, row){
-							if (row.records.length > 0) {
-								var tmpCols = _getColList(row.records[0]);
-								if (tmpCols.length > 0) {
-									cols = tmpCols;
-									return false;
-								}
-							}
-						});
-
-						cols = cols || [];
-						table = '';
-
-						$.each(famResults, function(r, row) {
-							table += '<table class="table table-condensed table-hover table-bordered"><thead>';
-							table += '<tr class="row-separator"><th colspan="' + (cols.length === 0 ? 1 : cols.length) + '">' + (r+1) + '. <strong>rowid:</strong> ' + row.rowid + ' (<em>' + (row.records === null ? 0 : row.records.length) + ' records</em>)</th></tr>';
-							table += '<tr>';
-							$.each(cols, function(i, col) {
-								table += '<th>' + col + '</th>';
-							});
-							table += '</tr></thead><tbody>';
-
-							if (row.records === null || row.records.length === 0) {
-								table += '<tr><td colspan="' + (cols.length === 0 ? 1 : cols.length) + '"><em>No Data Found</em></td></tr>';
-							} else {
-								$.each(row.records, function(i, rec) {
-									table += '<tr>';
-									$.each(cols, function(c, col) {
-										table += '<td>' + (rec[col] || '') + '</td>';
-									});
-									table += '</tr>';
-								});
-							}
-							table += '</tbody></table>';
-						});
-					}
-
-					if (famResults.length < blurconsole.model.search.getTotal()) {
-						table += '<div class="pull-left"><a href="' + famId + '" class="btn btn-primary nextPage">Load More...</a></div>';
-					}
-
-					famHolder.html(table);
-				}
-				if (!$(famId).hasClass('loaded')) {
-					$(famId).addClass('loaded');
-				}
-			});
-		}
-	}
-
-	function _loadTableList() {
-		var tableMap = blurconsole.model.tables.getAllEnabledTables();
-
-		jqueryMap.$tableField.find('optgroup').remove();
-
-		$.each(tableMap, function(cluster, tables) {
-			var optGroupString;
-
-			if (tables.length > 0) {
-				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);
-			}
-		});
-
-		if (jqueryMap.$tableSelectorStatusOption && blurconsole.utils.keys(tableMap).length > 0) {
-			jqueryMap.$tableSelectorStatusOption.remove();
-			jqueryMap.$tableSelectorStatusOption = null;
-		}
-	}
-
-	function _popupFacetDialog() {
-		jqueryMap.facetModal = $(blurconsole.browserUtils.modal('facetDialog', 'Facets for Current Search', 'TBD', null, 'large'));
-		jqueryMap.facetModal.modal();
-	}
+  function _updateOptionDisplay() {
+    var displayText = '';
+    displayText += configMap.superQueryMap[stateMap.$rowRecordOption];
+    jqueryMap.$optionsDisplay.html(displayText);
+  }
+
+  function _updateOptionPopover() {
+    if ($('#superQuery').length > 0) {
+      $('#superQuery').val(stateMap.$rowRecordOption);
+    }
+  }
+
+  function _persistOptions() {
+    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');
+  }
+
+  function _sendSearch() {
+    stateMap.$currentTable = jqueryMap.$tableField.val();
+    stateMap.$currentQuery = jqueryMap.$queryField.val();
+
+    blurconsole.shell.changeAnchorPart({
+      tab: 'search',
+      _tab: {
+        query: encodeURIComponent(stateMap.$currentQuery),
+        table: stateMap.$currentTable,
+        rr: stateMap.$rowRecordOption
+      }
+    });
+    _drawResultHolders();
+    jqueryMap.$countHolder.html('');
+    blurconsole.model.search.runSearch(stateMap.$currentQuery, stateMap.$currentTable, {start: 0, fetch: 10, rowRecordOption: stateMap.$rowRecordOption});
+  }
+
+  function _getMoreData(evt) {
+    var family = $(evt.currentTarget).attr('href') ? $(evt.currentTarget).attr('href').substring(1) : $(evt.currentTarget).attr('id');
+    blurconsole.model.search.loadMoreResults(family);
+    return false;
+  }
+
+  function _reviewTables() {
+    var tableFound = false;
+
+    if (stateMap.$currentTable) {
+      var 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 if (stateMap.$currentTable) {
+      jqueryMap.$tableWarning.show();
+    } else {
+      _loadTableList();
+    }
+  }
+
+  function _drawResultHolders() {
+    var familyMarkup = '', parsedFamilies = blurconsole.utils.findFamilies(stateMap.$currentQuery);
+
+    jqueryMap.$resultsHolder.html('');
+
+    // Redraw families
+    var allFamilies = blurconsole.model.tables.getFamilies(stateMap.$currentTable);
+    var extraFamilies = blurconsole.utils.reject(allFamilies, function(fam){ return parsedFamilies.indexOf(fam) >= 0; });
+
+    parsedFamilies.sort();
+    extraFamilies.sort();
+
+    var 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" data-toggle="collapse" data-parent="#results" data-target="#' + famId + '">' + fam + '</h4></div>';
+      familyMarkup += '<div id="' + famId + '" class="panel-collapse collapse' + (parsedFamilies.indexOf(fam) >= 0 ? ' in' : '') + '">';
+      familyMarkup += '<div class="panel-body"><img src="img/ajax-loader.gif"></div></div></div>';
+    });
+
+    jqueryMap.$resultsHolder.html(familyMarkup);
+  }
+
+  function _drawResults(evt, families) {
+    var results = blurconsole.model.search.getResults();
+    jqueryMap.$countHolder.html('<small>Found ' + blurconsole.model.search.getTotal() + ' total results</small>');
+    //jqueryMap.$facetTrigger.show();
+
+    if (typeof families !== 'undefined' && families !== null) {
+      $.each(families, function(i, fam) {
+        var famResults = results[fam],
+          famId = '#' + blurconsole.browserUtils.cleanId(fam),
+          famHolder = $(famId + ' .panel-body');
+
+        if (typeof famResults === 'undefined' || famResults.length === 0) {
+          famHolder.html('<div class="alert alert-info">No Data Found</div>');
+        } else {
+          var table;
+          var cols;
+          if (blurconsole.utils.keys(famResults[0]).indexOf('rowid') === -1 ) {
+            // Record results
+            table = '<table class="table table-condensed table-hover table-bordered"><thead><tr>';
+            cols = _getColList(famResults[0]);
+
+            $.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>';
+          } else {
+            // Row results
+            $.each(famResults, function(i, row){
+              if (row.records.length > 0) {
+                var tmpCols = _getColList(row.records[0]);
+                if (tmpCols.length > 0) {
+                  cols = tmpCols;
+                  return false;
+                }
+              }
+            });
+
+            cols = cols || [];
+            table = '';
+
+            $.each(famResults, function(r, row) {
+              table += '<table class="table table-condensed table-hover table-bordered"><thead>';
+              table += '<tr class="row-separator"><th colspan="' + (cols.length === 0 ? 1 : cols.length) + '">' + (r+1) + '. <strong>rowid:</strong> ' + row.rowid + ' (<em>' + (row.records === null ? 0 : row.records.length) + ' records</em>)</th></tr>';
+              table += '<tr>';
+              $.each(cols, function(i, col) {
+                table += '<th>' + col + '</th>';
+              });
+              table += '</tr></thead><tbody>';
+
+              if (row.records === null || row.records.length === 0) {
+                table += '<tr><td colspan="' + (cols.length === 0 ? 1 : cols.length) + '"><em>No Data Found</em></td></tr>';
+              } else {
+                $.each(row.records, function(i, rec) {
+                  table += '<tr>';
+                  $.each(cols, function(c, col) {
+                    table += '<td>' + (rec[col] || '') + '</td>';
+                  });
+                  table += '</tr>';
+                });
+              }
+              table += '</tbody></table>';
+            });
+          }
+
+          if (famResults.length < blurconsole.model.search.getTotal()) {
+            table += '<div class="pull-left"><a href="' + famId + '" class="btn btn-primary nextPage">Load More...</a></div>';
+          }
+
+          famHolder.html(table);
+        }
+        if (!$(famId).hasClass('loaded')) {
+          $(famId).addClass('loaded');
+        }
+      });
+    }
+  }
+
+  function _loadTableList() {
+    var tableMap = blurconsole.model.tables.getAllEnabledTables();
+
+    jqueryMap.$tableField.find('optgroup').remove();
+
+    $.each(tableMap, function(cluster, tables) {
+      var optGroupString;
+
+      if (tables.length > 0) {
+        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);
+      }
+    });
+
+    if (jqueryMap.$tableSelectorStatusOption && blurconsole.utils.keys(tableMap).length > 0) {
+      jqueryMap.$tableSelectorStatusOption.remove();
+      jqueryMap.$tableSelectorStatusOption = null;
+    }
+  }
+
+  function _popupFacetDialog() {
+    jqueryMap.facetModal = $(blurconsole.browserUtils.modal('facetDialog', 'Facets for Current Search', 'TBD', null, 'large'));
+    jqueryMap.facetModal.modal();
+  }
 
     //--------------------------------- Public API ------------------------------------------
-	function initModule($container) {
-		$container.load(configMap.view, 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();
-
-			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;
-	}
-
-	function unloadModule() {
-		$.gevent.unsubscribe(jqueryMap.$container, 'tables-updated');
-		_unregisterPageEvents();
-	}
-
-	return {
-		initModule : initModule,
-		unloadModule : unloadModule
-	};
+  function initModule($container) {
+    $container.load(configMap.view, 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();
+
+      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;
+  }
+
+  function unloadModule() {
+    $.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/79786aca/blur-console/src/main/webapp/js/blurconsole.shell.js
----------------------------------------------------------------------
diff --git a/blur-console/src/main/webapp/js/blurconsole.shell.js b/blur-console/src/main/webapp/js/blurconsole.shell.js
index 23ce5f4..6c80b7c 100644
--- a/blur-console/src/main/webapp/js/blurconsole.shell.js
+++ b/blur-console/src/main/webapp/js/blurconsole.shell.js
@@ -24,167 +24,167 @@ under the License.
  */
 /* global blurconsole:false, $:false */
 blurconsole.shell = (function () {
-	'use strict';
+  'use strict';
     
     //---------------------------- Configuration and State ----------------------------
-	var configMap = {
-		anchorSchemaMap : {
-			tab : { dashboard : true, tables : true, queries : true, search : true },
-			_tab : { query: true, table: true, rr: true }
-		},
-		defaultTab : 'dashboard',
-		allTabs : ['dashboard', 'tables', 'queries', 'search']
-	},
-	stateMap = {
-		$container : null,
-		currentTab : null,
-		anchorMap  : {}
-	},
-	jqueryMap = {};
+  var configMap = {
+    anchorSchemaMap : {
+      tab : { dashboard : true, tables : true, queries : true, search : true },
+      _tab : { query: true, table: true, rr: true }
+    },
+    defaultTab : 'dashboard',
+    allTabs : ['dashboard', 'tables', 'queries', 'search']
+  },
+  stateMap = {
+    $container : null,
+    currentTab : null,
+    anchorMap  : {}
+  },
+  jqueryMap = {};
     
     //---------------------------- Private Methods -------------------------
     function _setJqueryMap() {
-		var $container = stateMap.$container;
-		jqueryMap = {
-			$container   : $container,
-			$sideNavTabs : $('.side-nav a')
-		};
-	}
+    var $container = stateMap.$container;
+    jqueryMap = {
+      $container   : $container,
+      $sideNavTabs : $('.side-nav a')
+    };
+  }
     
     function _copyAnchorMap() {
-		return $.extend( true, {}, stateMap.anchorMap );
-	}
+    return $.extend( true, {}, stateMap.anchorMap );
+  }
     
     function _switchView( tab ) {
-		if (stateMap.currentTab !== tab) {
-			for ( var 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 );
-			}
-		}
-
-		return true;
-	}
+    if (stateMap.currentTab !== tab) {
+      for ( var 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 );
+      }
+    }
+
+    return true;
+  }
     
     //---------------------------- Event Handlers and DOM Methods ----------
     function _onHashChange() {
-		var anchorMapPrevious = _copyAnchorMap(), anchorMapProposed;
+    var anchorMapPrevious = _copyAnchorMap(), anchorMapProposed;
 
-		try {
+    try {
             anchorMapProposed = $.uriAnchor.makeAnchorMap();
         } catch ( error ) {
-			$.uriAnchor.setAnchor( anchorMapPrevious, null, true );
-			return false;
-		}
-
-		stateMap.anchorMap = anchorMapProposed;
-
-		var _sTabPrevious = anchorMapPrevious._s_tab; // jshint ignore:line
-		var _sTabProposed = anchorMapProposed._s_tab; // jshint ignore:line
-
-		if ( ! anchorMapPrevious || _sTabPrevious !== _sTabProposed ){
-			var sTabProposed = anchorMapProposed.tab;
-			switch ( sTabProposed ) {
-				case 'dashboard':
-				case 'tables':
-				case 'queries':
-				case 'search':
-					_switchView( sTabProposed );
-					break;
-				default:
-					$.uriAnchor.setAnchor( anchorMapPrevious, null, true );
-			}
-		}
-
-		return false;
-	}
+      $.uriAnchor.setAnchor( anchorMapPrevious, null, true );
+      return false;
+    }
+
+    stateMap.anchorMap = anchorMapProposed;
+
+    var _sTabPrevious = anchorMapPrevious._s_tab; // jshint ignore:line
+    var _sTabProposed = anchorMapProposed._s_tab; // jshint ignore:line
+
+    if ( ! anchorMapPrevious || _sTabPrevious !== _sTabProposed ){
+      var sTabProposed = anchorMapProposed.tab;
+      switch ( sTabProposed ) {
+        case 'dashboard':
+        case 'tables':
+        case 'queries':
+        case 'search':
+          _switchView( sTabProposed );
+          break;
+        default:
+          $.uriAnchor.setAnchor( anchorMapPrevious, null, true );
+      }
+    }
+
+    return false;
+  }
     
     function _onClickTab(evt) {
-		var target = $(evt.currentTarget);
-		changeAnchorPart({
-			tab : target.attr('href').split('=')[1]
-		});
-		return false;
-	}
+    var target = $(evt.currentTarget);
+    changeAnchorPart({
+      tab : target.attr('href').split('=')[1]
+    });
+    return false;
+  }
     
     //---------------------------- Public API ------------------------------
-	function changeAnchorPart( argMap ) {
-		var anchorMapRevise = _copyAnchorMap(), boolReturn = true;
-
-		KEYVAL:
-		for ( var keyName in argMap ) {
-			if ( argMap.hasOwnProperty( keyName ) ) {
-				if ( keyName.indexOf( '_' ) === 0 ) { continue KEYVAL; }
-				anchorMapRevise[keyName] = argMap[keyName];
-				var keyNameDep = '_' + keyName;
-				if ( argMap[keyNameDep] ) {
-					anchorMapRevise[keyNameDep] = argMap[keyNameDep];
-				} else {
-					delete anchorMapRevise[keyNameDep];
-					delete anchorMapRevise['_s' + keyNameDep];
-				}
-			}
-		}
-
-		try {
-			$.uriAnchor.setAnchor( anchorMapRevise );
-		} catch ( error ) {
-			$.uriAnchor.setAnchor( stateMap.anchorMap, null, true );
-			boolReturn = false;
-		}
-
-		return boolReturn;
-	}
-
-	function initModule( $container ) {
-		stateMap.$container = $container;
-		_setJqueryMap();
-
-		blurconsole.schema.initModule();
-		blurconsole.logging.initModule();
-
-		$('#view_logging_trigger').on('click', function() {
-			$.gevent.publish('show-logging');
-		});
-
-		$('.side-nav li').tooltip();
-
-		jqueryMap.$sideNavTabs.click( _onClickTab );
-
-		$.uriAnchor.configModule({
-			schema_map : configMap.anchorSchemaMap // jshint ignore:line
-		});
-
-		$(window).bind('hashchange', _onHashChange).trigger('hashchange');
-
-		var startupMap = $.uriAnchor.makeAnchorMap();
-
-		if ( !startupMap.tab ) {
-			changeAnchorPart({
-				tab: configMap.defaultTab
-			});
-		}
-
-		$.gevent.subscribe($(document), 'logging-updated', function() {
-			var errors = blurconsole.model.logs.getLogs();
-			if (errors.length === 0) {
-				$('#view_logging_trigger .badge').html('');
-			} else {
-				$('#view_logging_trigger .badge').html(errors.length);
-			}
-		});
-	}
-
-	return {
-		initModule: initModule,
-		changeAnchorPart : changeAnchorPart
-	};
+  function changeAnchorPart( argMap ) {
+    var anchorMapRevise = _copyAnchorMap(), boolReturn = true;
+
+    KEYVAL:
+    for ( var keyName in argMap ) {
+      if ( argMap.hasOwnProperty( keyName ) ) {
+        if ( keyName.indexOf( '_' ) === 0 ) { continue KEYVAL; }
+        anchorMapRevise[keyName] = argMap[keyName];
+        var keyNameDep = '_' + keyName;
+        if ( argMap[keyNameDep] ) {
+          anchorMapRevise[keyNameDep] = argMap[keyNameDep];
+        } else {
+          delete anchorMapRevise[keyNameDep];
+          delete anchorMapRevise['_s' + keyNameDep];
+        }
+      }
+    }
+
+    try {
+      $.uriAnchor.setAnchor( anchorMapRevise );
+    } catch ( error ) {
+      $.uriAnchor.setAnchor( stateMap.anchorMap, null, true );
+      boolReturn = false;
+    }
+
+    return boolReturn;
+  }
+
+  function initModule( $container ) {
+    stateMap.$container = $container;
+    _setJqueryMap();
+
+    blurconsole.schema.initModule();
+    blurconsole.logging.initModule();
+
+    $('#view_logging_trigger').on('click', function() {
+      $.gevent.publish('show-logging');
+    });
+
+    $('.side-nav li').tooltip();
+
+    jqueryMap.$sideNavTabs.click( _onClickTab );
+
+    $.uriAnchor.configModule({
+      schema_map : configMap.anchorSchemaMap // jshint ignore:line
+    });
+
+    $(window).bind('hashchange', _onHashChange).trigger('hashchange');
+
+    var startupMap = $.uriAnchor.makeAnchorMap();
+
+    if ( !startupMap.tab ) {
+      changeAnchorPart({
+        tab: configMap.defaultTab
+      });
+    }
+
+    $.gevent.subscribe($(document), 'logging-updated', function() {
+      var errors = blurconsole.model.logs.getLogs();
+      if (errors.length === 0) {
+        $('#view_logging_trigger .badge').html('');
+      } else {
+        $('#view_logging_trigger .badge').html(errors.length);
+      }
+    });
+  }
+
+  return {
+    initModule: initModule,
+    changeAnchorPart : changeAnchorPart
+  };
 }());
\ No newline at end of file


Mime
View raw message