split by field
This commit is contained in:
@@ -58,6 +58,9 @@ body{
|
|||||||
.autocomplete .active {
|
.autocomplete .active {
|
||||||
background-color: #AAA;
|
background-color: #AAA;
|
||||||
}
|
}
|
||||||
|
.autocomplete.open{
|
||||||
|
z-index:2;
|
||||||
|
}
|
||||||
|
|
||||||
/* scrollbars are nice, but with them an empty autocomplete box is shown
|
/* scrollbars are nice, but with them an empty autocomplete box is shown
|
||||||
|
|
||||||
@@ -93,19 +96,42 @@ body{
|
|||||||
margin-right:3px;
|
margin-right:3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#result-view {
|
#result {
|
||||||
grid-area: result;
|
grid-area: result;
|
||||||
background: #eee;
|
background: #eee;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
position:relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
#result-view i {
|
#result-image {
|
||||||
background: white;
|
height: 100%;
|
||||||
display:inline;
|
}
|
||||||
font-style:normal;
|
|
||||||
line-height: 1.2em;
|
#prev_image, #next_image {
|
||||||
|
position: absolute;
|
||||||
|
height: 100%;
|
||||||
|
font-size: 4em;
|
||||||
|
opacity: 0.1;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
#prev_image:hover, #next_image:hover {
|
||||||
|
background: whitesmoke;
|
||||||
|
opacity: 0.7;
|
||||||
|
}
|
||||||
|
|
||||||
|
#prev_image:hover i, #next_image:hover i {
|
||||||
|
opacity: 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#prev_image {
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
#next_image{
|
||||||
|
right: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ function startInvaders() {
|
|||||||
}
|
}
|
||||||
$('#'+invaders_parentDivId).show();
|
$('#'+invaders_parentDivId).show();
|
||||||
|
|
||||||
|
clearIntervals();
|
||||||
invaders_game_move=window.setInterval("moveRandomly('"+invaders_parentDivId+"')",100);
|
invaders_game_move=window.setInterval("moveRandomly('"+invaders_parentDivId+"')",100);
|
||||||
invaders_game_new=window.setInterval("addInvader()", 1000);
|
invaders_game_new=window.setInterval("addInvader()", 1000);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,11 @@
|
|||||||
|
|
||||||
|
var splitBy = {
|
||||||
|
field: '',
|
||||||
|
query: '',
|
||||||
|
values: [],
|
||||||
|
index: 0
|
||||||
|
};
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
|
|
||||||
$('#search-submit').click(plot);
|
$('#search-submit').click(plot);
|
||||||
@@ -7,11 +14,14 @@ $(document).ready(function(){
|
|||||||
updateSearchLimitValue();
|
updateSearchLimitValue();
|
||||||
|
|
||||||
$('#search-limit-by').change(updateSearchLimitValue);
|
$('#search-limit-by').change(updateSearchLimitValue);
|
||||||
|
disableSplitBy();
|
||||||
|
|
||||||
$('#nav_left').click(dateLeftShift);
|
$('#nav_left').click(dateLeftShift);
|
||||||
$('#nav_left_half').click(dateHalfLeftShift);
|
$('#nav_left_half').click(dateHalfLeftShift);
|
||||||
$('#nav_right_half').click(dateHalfRightShift);
|
$('#nav_right_half').click(dateHalfRightShift);
|
||||||
$('#nav_right').click(dateRightShift);
|
$('#nav_right').click(dateRightShift);
|
||||||
|
$('#prev_image').click(prev_image);
|
||||||
|
$('#next_image').click(next_image);
|
||||||
|
|
||||||
$('#zoom_in').click(zoomIn);
|
$('#zoom_in').click(zoomIn);
|
||||||
$('#zoom_out').click(zoomOut);
|
$('#zoom_out').click(zoomOut);
|
||||||
@@ -42,7 +52,7 @@ $(document).ready(function(){
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
initInvaders('result-view');
|
initInvaders('result-image');
|
||||||
//startInvaders();
|
//startInvaders();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -50,36 +60,36 @@ function zoomIn()
|
|||||||
{
|
{
|
||||||
shiftDate(0.25);
|
shiftDate(0.25);
|
||||||
zoom(0.5);
|
zoom(0.5);
|
||||||
plot();
|
plotCurrent();
|
||||||
}
|
}
|
||||||
|
|
||||||
function zoomOut()
|
function zoomOut()
|
||||||
{
|
{
|
||||||
shiftDate(-0.5);
|
shiftDate(-0.5);
|
||||||
zoom(2);
|
zoom(2);
|
||||||
plot();
|
plotCurrent();
|
||||||
}
|
}
|
||||||
|
|
||||||
function dateLeftShift()
|
function dateLeftShift()
|
||||||
{
|
{
|
||||||
shiftDate(-1);
|
shiftDate(-1);
|
||||||
plot();
|
plotCurrent();
|
||||||
}
|
}
|
||||||
function dateHalfLeftShift()
|
function dateHalfLeftShift()
|
||||||
{
|
{
|
||||||
shiftDate(-0.5);
|
shiftDate(-0.5);
|
||||||
plot();
|
plotCurrent();
|
||||||
}
|
}
|
||||||
|
|
||||||
function dateHalfRightShift()
|
function dateHalfRightShift()
|
||||||
{
|
{
|
||||||
shiftDate(0.5);
|
shiftDate(0.5);
|
||||||
plot();
|
plotCurrent();
|
||||||
}
|
}
|
||||||
function dateRightShift()
|
function dateRightShift()
|
||||||
{
|
{
|
||||||
shiftDate(1);
|
shiftDate(1);
|
||||||
plot();
|
plotCurrent();
|
||||||
}
|
}
|
||||||
|
|
||||||
function zoom(factor)
|
function zoom(factor)
|
||||||
@@ -207,6 +217,24 @@ function shiftByInterval(date, directionalFactor)
|
|||||||
return date;
|
return date;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function prev_image()
|
||||||
|
{
|
||||||
|
if (splitBy['values'].length > 0)
|
||||||
|
{
|
||||||
|
splitBy['index'] = (splitBy['index']+ splitBy['values'].length-1) % splitBy['values'].length;
|
||||||
|
plotCurrent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function next_image()
|
||||||
|
{
|
||||||
|
if (splitBy['values'].length > 0)
|
||||||
|
{
|
||||||
|
splitBy['index'] = (splitBy['index']+1) % splitBy['values'].length;
|
||||||
|
plotCurrent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function updateSearchLimitValue () {
|
function updateSearchLimitValue () {
|
||||||
var optionSelected = $('#search-limit-by').find("option:selected");
|
var optionSelected = $('#search-limit-by').find("option:selected");
|
||||||
var valueSelected = optionSelected.val();
|
var valueSelected = optionSelected.val();
|
||||||
@@ -216,7 +244,25 @@ function updateSearchLimitValue () {
|
|||||||
}else{
|
}else{
|
||||||
$('#search-limit-value').show();
|
$('#search-limit-value').show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function enableSplitBy(fieldValues) {
|
||||||
|
splitBy['field'] = $('#split-by').val();
|
||||||
|
splitBy['values'] = fieldValues;
|
||||||
|
splitBy['index'] = 0;
|
||||||
|
splitBy['query'] = $('#search-input').val();
|
||||||
|
$('#prev_image').show();
|
||||||
|
$('#next_image').show();
|
||||||
|
}
|
||||||
|
|
||||||
|
function disableSplitBy() {
|
||||||
|
splitBy['field'] = '';
|
||||||
|
splitBy['values'] = [];
|
||||||
|
splitBy['index'] = 0;
|
||||||
|
splitBy['query'] = '';
|
||||||
|
$('#prev_image').hide();
|
||||||
|
$('#next_image').hide();
|
||||||
|
}
|
||||||
|
|
||||||
function renderGroupBy()
|
function renderGroupBy()
|
||||||
{
|
{
|
||||||
@@ -227,6 +273,7 @@ function renderGroupBy()
|
|||||||
initSearchGroupBy('#search-group-by-1', response);
|
initSearchGroupBy('#search-group-by-1', response);
|
||||||
initSearchGroupBy('#search-group-by-2', response);
|
initSearchGroupBy('#search-group-by-2', response);
|
||||||
initSearchGroupBy('#search-group-by-3', response);
|
initSearchGroupBy('#search-group-by-3', response);
|
||||||
|
initFieldsDropDown('#split-by', response);
|
||||||
};
|
};
|
||||||
var error = function(e) {
|
var error = function(e) {
|
||||||
$('#result-view').text("FAILED: " + JSON.parse(e.responseText).message);
|
$('#result-view').text("FAILED: " + JSON.parse(e.responseText).message);
|
||||||
@@ -250,23 +297,85 @@ function initSearchGroupBy(selector, response)
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function initFieldsDropDown(selector, response)
|
||||||
|
{
|
||||||
|
$(selector).empty();
|
||||||
|
var option = new Option("", "");
|
||||||
|
$(selector).append($(option));
|
||||||
|
|
||||||
|
response.forEach(
|
||||||
|
(item, index) => {
|
||||||
|
var option = new Option(item, item);
|
||||||
|
$(selector).append($(option));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function showLoadingIcon()
|
function showLoadingIcon()
|
||||||
{
|
{
|
||||||
//$('#result-view').html("<div class='center'><div class='uil-cube-css' style='-webkit-transform:scale(0.41)'><div /><div></div><div></div><div></div></div></div>");
|
//$('#result-view').html("<div class='center'><div class='uil-cube-css' style='-webkit-transform:scale(0.41)'><div /><div></div><div></div><div></div></div></div>");
|
||||||
$('#result-view').html("");
|
$('#result-image').html("");
|
||||||
startInvaders();
|
startInvaders();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Called by the 'plot' button
|
||||||
|
*/
|
||||||
function plot(event){
|
function plot(event){
|
||||||
if(event){
|
if(event){
|
||||||
event.preventDefault(); // prevent submit of form which would reload the page
|
event.preventDefault(); // prevent submit of form which would reload the page
|
||||||
}
|
}
|
||||||
|
|
||||||
showLoadingIcon();
|
showLoadingIcon();
|
||||||
|
|
||||||
|
var splitByField = $('#split-by').val();
|
||||||
|
if (splitByField){
|
||||||
|
splitQueries(function (fieldValues) {
|
||||||
|
splitBy['values'] = fieldValues;
|
||||||
|
enableSplitBy(fieldValues);
|
||||||
|
plotCurrent();
|
||||||
|
});
|
||||||
|
|
||||||
|
}else{
|
||||||
|
splitBy['field'] = '';
|
||||||
|
splitBy['values'] = [];
|
||||||
|
splitBy['index'] = 0;
|
||||||
|
splitBy['query'] = '';
|
||||||
|
plotCurrent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function plotCurrent()
|
||||||
|
{
|
||||||
|
showLoadingIcon();
|
||||||
|
|
||||||
|
if (splitBy['field']) {
|
||||||
|
var query = createQuery();
|
||||||
|
sendPlotRequest(query);
|
||||||
|
}else{
|
||||||
|
var query = $('#search-input').val();
|
||||||
|
sendPlotRequest(query);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function createQuery()
|
||||||
|
{
|
||||||
|
var query = splitBy['query'];
|
||||||
|
if (query.length > 0) {
|
||||||
|
query = "("+query+") and "+splitBy['field']+ " = " +splitBy['values'][splitBy['index']];
|
||||||
|
} else {
|
||||||
|
query = splitBy['field']+ " = " +splitBy['values'][splitBy['index']];
|
||||||
|
}
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
function sendPlotRequest(query){
|
||||||
|
|
||||||
var request = {};
|
var request = {};
|
||||||
request['query'] = $('#search-input').val();
|
request['query'] = query;
|
||||||
request['height'] = $('#result-view').height();
|
request['height'] = $('#result-image').height();
|
||||||
request['width'] = $('#result-view').width();
|
request['width'] = $('#result-image').width();
|
||||||
request['groupBy'] = groupBy();
|
request['groupBy'] = groupBy();
|
||||||
request['limitBy'] = $('#search-limit-by').val();
|
request['limitBy'] = $('#search-limit-by').val();
|
||||||
request['limit'] = parseInt($('#search-limit-value').val());
|
request['limit'] = parseInt($('#search-limit-value').val());
|
||||||
@@ -278,14 +387,14 @@ function plot(event){
|
|||||||
|
|
||||||
|
|
||||||
var success = function(response){
|
var success = function(response){
|
||||||
$('#result-view').html('<img src=\"'+response.imageUrls+'" />');
|
$('#result-image').html('<img src=\"'+response.imageUrls+'" />');
|
||||||
};
|
};
|
||||||
var error = function(e) {
|
var error = function(e) {
|
||||||
if (e.status == 404){
|
if (e.status == 404){
|
||||||
$('#result-view').text("No data points found.");
|
$('#result-image').text("No data points found for query: " + query);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$('#result-view').text("FAILED: " + JSON.parse(e.responseText).message);
|
$('#result-image').text("FAILED: " + JSON.parse(e.responseText).message);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -293,6 +402,20 @@ function plot(event){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function splitQueries(successCallback)
|
||||||
|
{
|
||||||
|
var request = {};
|
||||||
|
request['query'] = $('#search-input').val();
|
||||||
|
|
||||||
|
var error = function(e) {
|
||||||
|
$('#result_image').text("FAILED: " + JSON.parse(e.responseText).message);
|
||||||
|
};
|
||||||
|
|
||||||
|
var url = "/fields/"+encodeURIComponent($('#split-by').val())+"/values";
|
||||||
|
getJson(url, request, successCallback, error);
|
||||||
|
}
|
||||||
|
|
||||||
function groupBy()
|
function groupBy()
|
||||||
{
|
{
|
||||||
var result = [];
|
var result = [];
|
||||||
|
|||||||
@@ -25,13 +25,17 @@
|
|||||||
<form>
|
<form>
|
||||||
<div id="search-settings-bar">
|
<div id="search-settings-bar">
|
||||||
<div class="group">
|
<div class="group">
|
||||||
<label for="search-group-by-1">Group By:</label>
|
<label for="search-group-by-1">Group:</label>
|
||||||
<select id="search-group-by-1"></select>
|
<select id="search-group-by-1"></select>
|
||||||
<select id="search-group-by-2"></select>
|
<select id="search-group-by-2"></select>
|
||||||
<select id="search-group-by-3"></select>
|
<select id="search-group-by-3"></select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<label for="split-by">Split:</label>
|
||||||
|
<select id="split-by"></select>
|
||||||
|
|
||||||
<div class="group">
|
<div class="group">
|
||||||
<label for="search-limit-by">Limit By:</label>
|
<label for="search-limit-by">Limit:</label>
|
||||||
<select id="search-limit-by">
|
<select id="search-limit-by">
|
||||||
<option value="NO_LIMIT" selected="selected">no limit</option>
|
<option value="NO_LIMIT" selected="selected">no limit</option>
|
||||||
<option value="MOST_VALUES">most values</option>
|
<option value="MOST_VALUES">most values</option>
|
||||||
@@ -97,7 +101,10 @@
|
|||||||
<button id="nav_right_half"><i class="fa fa-angle-right" aria-hidden="true"></i></button>
|
<button id="nav_right_half"><i class="fa fa-angle-right" aria-hidden="true"></i></button>
|
||||||
<button id="nav_right"><i class="fa fa-angle-double-right" aria-hidden="true"></i></button>
|
<button id="nav_right"><i class="fa fa-angle-double-right" aria-hidden="true"></i></button>
|
||||||
</div>
|
</div>
|
||||||
<div id="result-view">
|
<div id="result">
|
||||||
|
<div id="prev_image"><i class="fa fa-angle-double-left" aria-hidden="true"></i></div>
|
||||||
|
<div id="next_image"><i class="fa fa-angle-double-right" aria-hidden="true"></i></div>
|
||||||
|
<div id="result-image"></div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Reference in New Issue
Block a user