Refactor code responsible for opening export pages in new window
This commit is contained in:
parent
2a4434a04a
commit
e13c6d0d1a
@ -237,15 +237,11 @@ function performTableAction(table, action, el) {
|
|||||||
var format = el.data("format");
|
var format = el.data("format");
|
||||||
var db = $("#current_database").text();
|
var db = $("#current_database").text();
|
||||||
var filename = db + "." + table + "." + format;
|
var filename = db + "." + table + "." + format;
|
||||||
var query = window.encodeURI("SELECT * FROM " + table);
|
var query = "SELECT * FROM " + table;
|
||||||
var url = window.location.href.split("#")[0] + "api/query?format=" + format + "&filename=" + filename + "&query=" + query + "&_session_id=" + getSessionId();
|
openInNewWindow("api/query", { "format": format, "filename": filename, "query": query, "_session_id": getSessionId() });
|
||||||
var win = window.open(url, "_blank");
|
|
||||||
win.focus();
|
|
||||||
break;
|
break;
|
||||||
case "dump":
|
case "dump":
|
||||||
var url = window.location.href.split("#")[0] + "api/export?table=" + table + "&_session_id=" + getSessionId();
|
openInNewWindow("api/export", { "table": table, "_session_id": getSessionId() });
|
||||||
var win = window.open(url, "_blank");
|
|
||||||
win.focus();
|
|
||||||
break;
|
break;
|
||||||
case "copy":
|
case "copy":
|
||||||
copyToClipboard(table.split('.')[1]);
|
copyToClipboard(table.split('.')[1]);
|
||||||
@ -271,10 +267,8 @@ function performViewAction(view, action, el) {
|
|||||||
var format = el.data("format");
|
var format = el.data("format");
|
||||||
var db = $("#current_database").text();
|
var db = $("#current_database").text();
|
||||||
var filename = db + "." + view + "." + format;
|
var filename = db + "." + view + "." + format;
|
||||||
var query = window.encodeURI("SELECT * FROM " + view);
|
var query = "SELECT * FROM " + view;
|
||||||
var url = window.location.href.split("#")[0] + "api/query?format=" + format + "&filename=" + filename + "&query=" + query + "&_session_id=" + getSessionId();
|
openInNewWindow("api/query", { "format": format, "filename": filename, "query": query, "_session_id": getSessionId() });
|
||||||
var win = window.open(url, "_blank");
|
|
||||||
win.focus();
|
|
||||||
break;
|
break;
|
||||||
case "copy":
|
case "copy":
|
||||||
copyToClipboard(view.split('.')[1]);
|
copyToClipboard(view.split('.')[1]);
|
||||||
@ -765,22 +759,25 @@ function exportURL(path, params) {
|
|||||||
return url.toString();
|
return url.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function openInNewWindow(path, params) {
|
||||||
|
var url = exportURL(path, params);
|
||||||
|
var win = window.open(url, '_blank');
|
||||||
|
win.focus();
|
||||||
|
}
|
||||||
|
|
||||||
function exportTo(format) {
|
function exportTo(format) {
|
||||||
var query = getEditorSelection();
|
var query = getEditorSelection();
|
||||||
if (query.length == 0) {
|
if (query.length == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var url = exportURL("api/query", {
|
setCurrentTab("table_query");
|
||||||
|
|
||||||
|
openInNewWindow("api/query", {
|
||||||
"format": format,
|
"format": format,
|
||||||
"query": encodeQuery(query),
|
"query": encodeQuery(query),
|
||||||
"_session_id": getSessionId()
|
"_session_id": getSessionId()
|
||||||
})
|
})
|
||||||
|
|
||||||
var win = window.open(url, '_blank');
|
|
||||||
|
|
||||||
setCurrentTab("table_query");
|
|
||||||
win.focus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch all unique values for the selected column in the table
|
// Fetch all unique values for the selected column in the table
|
||||||
@ -1076,9 +1073,7 @@ function bindCurrentDatabaseMenu() {
|
|||||||
|
|
||||||
switch(menuItem.data("action")) {
|
switch(menuItem.data("action")) {
|
||||||
case "export":
|
case "export":
|
||||||
var url = window.location.href.split("#")[0] + "api/export?_session_id=" + getSessionId();
|
openInNewWindow("api/export", { "_session_id": getSessionId() });
|
||||||
var win = window.open(url, "_blank");
|
|
||||||
win.focus();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user