mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Ensure that the macro query result should be download properly. Fixes #5965
This commit is contained in:
committed by
Akshay Joshi
parent
296d22ad83
commit
6475a70514
@@ -191,7 +191,7 @@ function keyboardShortcutsQueryTool(
|
||||
let executeKeys = sqlEditorController.preferences.execute_query;
|
||||
let explainKeys = sqlEditorController.preferences.explain_query;
|
||||
let explainAnalyzeKeys = sqlEditorController.preferences.explain_analyze_query;
|
||||
let downloadCsvKeys = sqlEditorController.preferences.download_csv;
|
||||
let downloadCsvKeys = sqlEditorController.preferences.download_results;
|
||||
let nextTabKeys = sqlEditorController.preferences.move_next;
|
||||
let previousTabKeys = sqlEditorController.preferences.move_previous;
|
||||
let switchPanelKeys = sqlEditorController.preferences.switch_panel;
|
||||
@@ -211,8 +211,10 @@ function keyboardShortcutsQueryTool(
|
||||
this._stopEventPropagation(event);
|
||||
queryToolActions.explainAnalyze(sqlEditorController);
|
||||
} else if (this.validateShortcutKeys(downloadCsvKeys, event)) {
|
||||
this._stopEventPropagation(event);
|
||||
queryToolActions.download(sqlEditorController);
|
||||
if(!sqlEditorController.is_save_results_to_file_disabled) {
|
||||
this._stopEventPropagation(event);
|
||||
queryToolActions.download(sqlEditorController);
|
||||
}
|
||||
} else if (this.validateShortcutKeys(toggleCaseKeys, event)) {
|
||||
this._stopEventPropagation(event);
|
||||
queryToolActions.toggleCaseOfSelectedText(sqlEditorController);
|
||||
|
||||
@@ -43,6 +43,7 @@ export function callRenderAfterPoll(sqlEditor, alertify, res) {
|
||||
if (isNotificationEnabled(sqlEditor)) {
|
||||
alertify.success(msg, sqlEditor.info_notifier_timeout);
|
||||
}
|
||||
sqlEditor.enable_disable_download_btn(true);
|
||||
}
|
||||
|
||||
if (isQueryTool(sqlEditor)) {
|
||||
|
||||
@@ -83,6 +83,7 @@ class ExecuteQuery {
|
||||
} else {
|
||||
self.loadingScreen.hide();
|
||||
self.enableSQLEditorButtons();
|
||||
self.disableDownloadButton();
|
||||
// Enable/Disable commit and rollback button.
|
||||
if (result.data.data.transaction_status == queryTxnStatus.TRANSACTION_STATUS_INTRANS
|
||||
|| result.data.data.transaction_status == queryTxnStatus.TRANSACTION_STATUS_INERROR) {
|
||||
@@ -201,7 +202,7 @@ class ExecuteQuery {
|
||||
this.loadingScreen.show(gettext('Running query...'));
|
||||
|
||||
$('#btn-flash').prop('disabled', true);
|
||||
$('#btn-download').prop('disabled', true);
|
||||
this.disableDownloadButton();
|
||||
|
||||
this.sqlServerObject.query_start_time = new Date();
|
||||
if (typeof sqlStatement === 'object') {
|
||||
@@ -281,6 +282,10 @@ class ExecuteQuery {
|
||||
}
|
||||
}
|
||||
|
||||
disableDownloadButton() {
|
||||
this.sqlServerObject.enable_disable_download_btn(true);
|
||||
}
|
||||
|
||||
enableSQLEditorButtons() {
|
||||
this.sqlServerObject.disable_tool_buttons(false);
|
||||
}
|
||||
|
||||
@@ -81,13 +81,7 @@ let queryToolActions = {
|
||||
},
|
||||
|
||||
download: function (sqlEditorController) {
|
||||
let sqlQuery = sqlEditorController.gridView.query_tool_obj.getSelection();
|
||||
|
||||
if (!sqlQuery) {
|
||||
sqlQuery = sqlEditorController.gridView.query_tool_obj.getValue();
|
||||
}
|
||||
|
||||
if (!sqlQuery) return;
|
||||
let extension = sqlEditorController.preferences.csv_field_separator === ',' ? '.csv': '.txt';
|
||||
let filename = 'data-' + new Date().getTime() + extension;
|
||||
|
||||
@@ -95,7 +89,7 @@ let queryToolActions = {
|
||||
filename = sqlEditorController.table_name + extension;
|
||||
}
|
||||
|
||||
sqlEditorController.trigger_csv_download(sqlQuery, filename);
|
||||
sqlEditorController.trigger_csv_download(filename);
|
||||
},
|
||||
|
||||
commentBlockCode: function (sqlEditorController) {
|
||||
|
||||
@@ -112,11 +112,11 @@ function updateUIPreferences(sqlEditor) {
|
||||
.attr('aria-label',
|
||||
shortcut_title(gettext('Explain Analyze'),preferences.explain_analyze_query));
|
||||
|
||||
$el.find('#btn-download')
|
||||
$el.find('#btn-save-results-to-file')
|
||||
.attr('title',
|
||||
shortcut_title(gettext('Download as CSV/TXT'),preferences.download_csv))
|
||||
shortcut_title(gettext('Save results to file'),preferences.download_results))
|
||||
.attr('aria-label',
|
||||
shortcut_title(gettext('Download as CSV/TXT'),preferences.download_csv));
|
||||
shortcut_title(gettext('Save results to file'),preferences.download_results));
|
||||
|
||||
$el.find('#btn-save-data')
|
||||
.attr('title',
|
||||
|
||||
Reference in New Issue
Block a user