|
From: <tob...@us...> - 2014-02-28 01:21:56
|
Revision: 7899
http://sourceforge.net/p/bigdata/code/7899
Author: tobycraig
Date: 2014-02-28 01:21:52 +0000 (Fri, 28 Feb 2014)
Log Message:
-----------
#822 - Display results as well as explanation when explain query is selected
Modified Paths:
--------------
branches/RDR/bigdata-war/src/html/new.html
branches/RDR/bigdata-war/src/html/style.css
branches/RDR/bigdata-war/src/html/workbench.js
Modified: branches/RDR/bigdata-war/src/html/new.html
===================================================================
--- branches/RDR/bigdata-war/src/html/new.html 2014-02-28 00:21:09 UTC (rev 7898)
+++ branches/RDR/bigdata-war/src/html/new.html 2014-02-28 01:21:52 UTC (rev 7899)
@@ -104,7 +104,7 @@
<a href="#" id="advanced-features-toggle">Advanced features</a>
<div id="advanced-features">
- <input type="checkbox" name="explain" value="details" id="query-explain"> <label for="query-explain">Explain</label>
+ <input type="checkbox" id="query-explain"> <label for="query-explain">Explain</label>
<input type="checkbox" name="analytic" value="true" id="query-analytic"> <label for="query-analytic">Analytic</label>
<input type="checkbox" name="RTO" value="true" id="query-rto"> <label for="query-rto">Runtime Query Optimizer</label>
</div>
@@ -122,6 +122,9 @@
<div id="query-response" class="box">
</div>
+ <div id="query-explanation" class="box">
+ </div>
+
<div class="bottom">
<button id="query-export">Export</button>
<button id="query-response-clear">Clear</button>
Modified: branches/RDR/bigdata-war/src/html/style.css
===================================================================
--- branches/RDR/bigdata-war/src/html/style.css 2014-02-28 00:21:09 UTC (rev 7898)
+++ branches/RDR/bigdata-war/src/html/style.css 2014-02-28 01:21:52 UTC (rev 7899)
@@ -163,7 +163,7 @@
text-align: right;
}
-#advanced-features {
+#advanced-features, #query-explanation {
display: none;
}
Modified: branches/RDR/bigdata-war/src/html/workbench.js
===================================================================
--- branches/RDR/bigdata-war/src/html/workbench.js 2014-02-28 00:21:09 UTC (rev 7898)
+++ branches/RDR/bigdata-war/src/html/workbench.js 2014-02-28 01:21:52 UTC (rev 7899)
@@ -335,51 +335,61 @@
var settings = {
type: 'POST',
data: $(this).serialize(),
+ dataType: 'json',
+ accepts: {'json': 'application/sparql-results+json'},
success: showQueryResults,
error: queryResultsError
}
- // queries return JSON, explanations return HTML
+ $.ajax(NAMESPACE_URL, settings);
+
+ $('#query-explanation').empty();
if($('#query-explain').is(':checked')) {
- settings.dataType = 'html';
+ settings = {
+ type: 'POST',
+ data: $(this).serialize() + '&explain=details',
+ dataType: 'html',
+ success: showQueryExplanation,
+ error: queryResultsError
+ };
+ $.ajax(NAMESPACE_URL, settings);
} else {
- settings.dataType = 'json';
- settings.accepts = {'json': 'application/sparql-results+json'};
+ $('#query-explanation').hide();
}
- $.ajax(NAMESPACE_URL, settings);
return false;
});
$('#query-response-clear').click(function() {
- $('#query-response').html('');
+ $('#query-response, #query-explanation').empty('');
+ $('#query-explanation').hide();
});
function showQueryResults(data) {
- if(this.dataType == 'html') {
- $('#query-response').html(data);
- } else {
- $('#query-response').html('');
- var table = $('<table>').appendTo($('#query-response'));
- var thead = $('<thead>').appendTo(table);
- var vars = [];
+ $('#query-response').empty();
+ var table = $('<table>').appendTo($('#query-response'));
+ var thead = $('<thead>').appendTo(table);
+ var vars = [];
+ var tr = $('<tr>');
+ for(var i=0; i<data.head.vars.length; i++) {
+ tr.append('<td>' + data.head.vars[i] + '</td>');
+ vars.push(data.head.vars[i]);
+ }
+ thead.append(tr);
+ table.append(thead);
+ for(var i=0; i<data.results.bindings.length; i++) {
var tr = $('<tr>');
- for(var i=0; i<data.head.vars.length; i++) {
- tr.append('<td>' + data.head.vars[i] + '</td>');
- vars.push(data.head.vars[i]);
+ for(var j=0; j<vars.length; j++) {
+ tr.append('<td>' + data.results.bindings[i][vars[j]].value + '</td>');
}
- thead.append(tr);
- table.append(thead);
- for(var i=0; i<data.results.bindings.length; i++) {
- var tr = $('<tr>');
- for(var j=0; j<vars.length; j++) {
- tr.append('<td>' + data.results.bindings[i][vars[j]].value + '</td>');
- }
- table.append(tr);
- }
+ table.append(tr);
}
}
+function showQueryExplanation(data) {
+ $('#query-explanation').html(data).show();
+}
+
function queryResultsError(jqXHR, textStatus, errorThrown) {
$('#query-response').text('Error! ' + textStatus + ' ' + errorThrown);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|