|
From: <tob...@us...> - 2014-06-27 21:26:57
|
Revision: 8506
http://sourceforge.net/p/bigdata/code/8506
Author: tobycraig
Date: 2014-06-27 21:26:52 +0000 (Fri, 27 Jun 2014)
Log Message:
-----------
Merged query history into 1.3 branch
Modified Paths:
--------------
branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css
branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html
branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js
Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css
===================================================================
--- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css 2014-06-26 22:47:58 UTC (rev 8505)
+++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/css/style.css 2014-06-27 21:26:52 UTC (rev 8506)
@@ -158,7 +158,6 @@
.modal {
display: none;
- z-index: 1;
position: fixed;
top: 0;
left: 0;
@@ -167,6 +166,7 @@
margin-left: 25%;
background-color: white;
padding: 20px;
+ z-index: 4;
}
#overlay {
@@ -178,6 +178,7 @@
height: 100%;
background-color: grey;
opacity: 0.5;
+ z-index: 3;
}
.modal-open #overlay {
@@ -248,7 +249,7 @@
border: none;
}
-.advanced-features, #query-response, #query-pagination, #query-explanation, #query-export-container, #update-response, #update-clear-container, #explore-results, #namespace-properties {
+.advanced-features, #query-response, #query-pagination, #query-explanation, #query-history, #query-export-container, #update-response, #update-clear-container, #explore-results, #namespace-properties {
display: none;
}
@@ -353,3 +354,8 @@
.health-bad {
background-color: red;
}
+
+#links {
+ text-align: center;
+ margin-top: 20px;
+}
Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html
===================================================================
--- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-06-26 22:47:58 UTC (rev 8505)
+++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-06-27 21:26:52 UTC (rev 8506)
@@ -135,6 +135,20 @@
<div id="query-explanation" class="box">
</div>
+ <div id="query-history" class="box">
+ <table>
+ <thead>
+ <tr>
+ <th>Time</th>
+ <th>Namespace</th>
+ <th>Query</th>
+ <th>Results</th>
+ </tr>
+ </thead>
+ <tbody></tbody>
+ </table>
+ </div>
+
<div id="query-export-container" class="box">
<button id="query-export">Export</button>
<button id="query-response-clear">Clear</button>
@@ -231,7 +245,7 @@
</div>
- <div class="clear"> </div>
+ <div id="links"><a href="http://www.bigdata.com" target="_blank">Bigdata</a> - <a href="http://wiki.bigdata.com/" target="_blank">Wiki</a></div>
</div>
Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js
===================================================================
--- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-06-26 22:47:58 UTC (rev 8505)
+++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-06-27 21:26:52 UTC (rev 8506)
@@ -261,7 +261,7 @@
data: data,
contentType: 'application/xml',
success: function() { $('#new-namespace-name').val(''); getNamespaces(); },
- error: function(jqXHR, textStatus, errorThrown) { debugger;alert(jqXHR.responseText); }
+ error: function(jqXHR, textStatus, errorThrown) { alert(jqXHR.responseText); }
};
$.ajax(RW_URL_PREFIX + 'namespace', settings);
}
@@ -333,22 +333,28 @@
/* Update */
-function handleDragOver(e) {
+function handleDragOver(cm, e) {
e.stopPropagation();
e.preventDefault();
- e.originalEvent.dataTransfer.dropEffect = 'copy';
+ e.dataTransfer.dropEffect = 'copy';
}
-function handleFile(e) {
+function handleDrop(cm, e) {
e.stopPropagation();
e.preventDefault();
+ var files = e.dataTransfer.files;
+ handleFile(files);
+}
- if(e.type == 'drop') {
- var files = e.originalEvent.dataTransfer.files;
- } else {
- var files = e.originalEvent.target.files;
- }
-
+function handleFileInput(e) {
+ e.stopPropagation();
+ e.preventDefault();
+ var files = e.originalEvent.target.files;
+ handleFile(files);
+ $('#update-file').val('');
+}
+
+function handleFile(files) {
// only one file supported
if(files.length > 1) {
alert('Ignoring all but first file');
@@ -359,31 +365,29 @@
// if file is too large, tell user to supply local path
if(f.size > 1048576 * 100) {
alert('File too large, enter local path to file');
- $('#update-box').val('/path/to/' + f.name);
+ EDITORS.update.setValue('/path/to/' + f.name);
setType('path');
- $('#update-box').prop('disabled', false)
+ EDITORS.update.setOption('readOnly', false)
$('#large-file-message, #clear-file').hide();
} else {
var fr = new FileReader();
- fr.onload = function(e2) {
+ fr.onload = function(e) {
if(f.size > 10240) {
// do not use textarea
- $('#update-box').prop('disabled', true)
+ EDITORS.update.setOption('readOnly', true)
$('#filename').html(f.name);
$('#large-file-message, #clear-file').show()
- $('#update-box').val('');
- FILE_CONTENTS = e2.target.result;
+ EDITORS.update.setValue('');
+ FILE_CONTENTS = e.target.result;
} else {
// display file contents in the textarea
clearFile();
- $('#update-box').val(e2.target.result);
+ EDITORS.update.setValue(e.target.result);
}
- guessType(f.name.split('.').pop().toLowerCase(), e2.target.result);
+ guessType(f.name.split('.').pop().toLowerCase(), e.target.result);
};
fr.readAsText(f);
}
-
- $('#update-file').val('');
}
function clearFile(e) {
@@ -501,11 +505,11 @@
var sparql_update_commands = ['INSERT', 'DELETE', 'LOAD', 'CLEAR'];
-$('#update-file').change(handleFile);
-$('#update-box').on('dragover', handleDragOver)
- .on('drop', handleFile)
- .on('paste', handlePaste)
- .on('input propertychange', function() { $('#update-errors').hide(); });
+$('#update-file').change(handleFileInput);
+// $('#update-box').on('dragover', handleDragOver)
+// .on('drop', handleFile)
+// .on('paste', handlePaste)
+// .on('input propertychange', function() { $('#update-errors').hide(); });
$('#clear-file').click(clearFile);
$('#update-update').click(submitUpdate);
@@ -517,6 +521,9 @@
ERROR_CHARACTER_MARKERS.update.clear();
}
});
+EDITORS.update.on('dragover', handleDragOver);
+EDITORS.update.on('drop', handleDrop);
+EDITORS.update.on('paste', handlePaste);
EDITORS.update.addKeyMap({'Ctrl-Enter': submitUpdate});
function submitUpdate(e) {
@@ -645,6 +652,14 @@
});
EDITORS.query.addKeyMap({'Ctrl-Enter': submitQuery});
+$('#query-history').on('click', '.query', loadHistory);
+
+function loadHistory() {
+ EDITORS.query.setValue(this.innerText);
+ useNamespace($(this).prev('.query-namespace').text());
+ EDITORS.query.focus();
+}
+
function submitQuery(e) {
try {
e.preventDefault();
@@ -654,10 +669,39 @@
EDITORS.query.save();
// do nothing if query is empty
- if($('#query-box').val().trim() == '') {
+ var query = $('#query-box').val().trim();
+ if(query == '') {
return;
}
+ var queryExists = false;
+
+ // see if this query is already in the history
+ $('#query-history tbody tr').each(function(i, row) {
+ if($(row).find('.query')[0].innerText == query && $(row).find('.query-namespace').text() == NAMESPACE) {
+ // clear the old results and set the time to now
+ $(row).find('.query-time').text(new Date().toISOString());
+ $(row).find('.query-results').text('...');
+ // move it to the top
+ $(row).prependTo('#query-history tbody');
+ queryExists = true;
+ return false;
+ }
+ });
+
+ if(!queryExists) {
+ // add this query to the history
+ var row = $('<tr>').prependTo($('#query-history tbody'));
+ row.append('<td class="query-time">' + new Date().toISOString() + '</td>');
+ row.append('<td class="query-namespace">' + NAMESPACE + '</td>');
+ var cell = $('<td class="query">').appendTo(row);
+ cell.text(query);
+ cell.html(cell.html().replace('\n', '<br>'));
+ row.append('<td class="query-results">...</td>');
+ }
+
+ $('#query-history').show();
+
var url = RO_URL_PREFIX + 'namespace/' + NAMESPACE + '/sparql';
var settings = {
type: 'POST',
@@ -817,6 +861,10 @@
$('#download-link').remove();
}
+function updateResultCount(count) {
+ $('#query-history tbody tr:first td.query-results').text(count);
+}
+
function showQueryResults(data) {
$('#query-response').empty();
$('#query-export-rdf').hide();
@@ -846,6 +894,7 @@
table.append(tr);
}
}
+ updateResultCount(rows.length);
} else {
// JSON
// save data for export and pagination
@@ -854,6 +903,7 @@
if(typeof(data.boolean) != 'undefined') {
// ASK query
table.append('<tr><td>' + data.boolean + '</td></tr>').addClass('boolean');
+ updateResultCount('' + data.boolean);
return;
}
@@ -895,6 +945,7 @@
table.append(thead);
$('#total-results').html(data.results.bindings.length);
+ updateResultCount(data.results.bindings.length);
setNumberOfPages();
showPage(1);
@@ -1138,10 +1189,10 @@
} else {
var uri = col.value;
if(col.type == 'uri') {
- uri = '<' + uri + '>';
+ uri = abbreviate(uri);
}
}
- output = escapeHTML(uri).replace(/\n/g, '<br>');
+ var output = escapeHTML(uri).replace(/\n/g, '<br>');
if(col.type == 'uri' || col.type == 'sid') {
output = '<a href="' + buildExploreHash(uri) + '">' + output + '</a>';
}
@@ -1383,9 +1434,11 @@
}
function abbreviate(uri) {
- for(var ns in NAMESPACE_SHORTCUTS) {
- if(uri.indexOf(NAMESPACE_SHORTCUTS[ns]) == 0) {
- return uri.replace(NAMESPACE_SHORTCUTS[ns], ns + ':');
+ for(var nsGroup in NAMESPACE_SHORTCUTS) {
+ for(var ns in NAMESPACE_SHORTCUTS[nsGroup]) {
+ if(uri.indexOf(NAMESPACE_SHORTCUTS[nsGroup][ns]) == 0) {
+ return uri.replace(NAMESPACE_SHORTCUTS[nsGroup][ns], ns + ':');
+ }
}
}
return '<' + uri + '>';
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|