Add button to export to CSV (wip)

This commit is contained in:
Dan Sosedoff 2014-10-18 08:07:19 -07:00
parent a8c53294df
commit f955131728
2 changed files with 29 additions and 0 deletions

View File

@ -33,6 +33,7 @@
<div class="actions">
<input type="button" id="run" value="Run Query" class="btn btn-sm btn-primary" />
<input type="button" id="explain" value="Explain Query" class="btn btn-sm btn-default" />
<input type="button" id="csv" value="Download CSV" class="btn btn-sm btn-default" />
<div id="query_progress">Please wait, query is executing...</div>
</div>

View File

@ -173,6 +173,7 @@ function runQuery() {
$("#run").attr("disabled", "disabled");
$("#explain").attr("disabled", "disabled");
$("#csv").attr("disabled", "disabled");
$("#query_progress").show();
var query = $.trim(editor.getValue());
@ -180,6 +181,7 @@ function runQuery() {
if (query.length == 0) {
$("#run").removeAttr("disabled");
$("#explain").removeAttr("disabled");
$("#csv").removeAttr("disabled");
$("#query_progress").hide();
return;
}
@ -200,6 +202,7 @@ function runExplain() {
$("#run").attr("disabled", "disabled");
$("#explain").attr("disabled", "disabled");
$("#csv").attr("disabled", "disabled");
$("#query_progress").show();
var query = $.trim(editor.getValue());
@ -207,6 +210,7 @@ function runExplain() {
if (query.length == 0) {
$("#run").removeAttr("disabled");
$("#explain").removeAttr("disabled");
$("#csv").removeAttr("disabled");
$("#query_progress").hide();
return;
}
@ -216,12 +220,32 @@ function runExplain() {
$("#run").removeAttr("disabled");
$("#explain").removeAttr("disabled");
$("#csv").removeAttr("disabled");
$("#query_progress").hide();
$("#input").show();
$("#output").removeClass("full");
});
}
function exportToCSV() {
setCurrentTab("table_query");
$("#run").attr("disabled", "disabled");
$("#explain").attr("disabled", "disabled");
$("#csv").attr("disabled", "disabled");
$("#query_progress").show();
var query = $.trim(editor.getValue());
if (query.length == 0) {
$("#run").removeAttr("disabled");
$("#explain").removeAttr("disabled");
$("#csv").removeAttr("disabled");
$("#query_progress").hide();
return;
}
}
var editor;
$(document).ready(function() {
@ -250,6 +274,10 @@ $(document).ready(function() {
runExplain();
});
$("#csv").on("click", function() {
exportToCSV();
});
$("#results").on("click", "tr", function() {
$("#results tr.selected").removeClass();
$(this).addClass("selected");