Fixed an issue on refreshing files in Query Tool. Fixes #6069

This commit is contained in:
Nikhil Mohite
2021-01-11 17:40:13 +05:30
committed by Akshay Joshi
parent d55555c544
commit 0fcfe63092
5 changed files with 62 additions and 48 deletions

View File

@@ -137,45 +137,51 @@ module.exports = Alertify.dialog('createModeDlg', function() {
return permission;
},
callback: function(closeEvent) {
closeEvent.cancel = false;
if (closeEvent.button.text == gettext('Create')) {
var newFile = $('.storage_dialog #uploader .input-path').val(),
file_data = {
'path': $('.currentpath').val(),
},
innerbody,
ext = $('.allowed_file_types select').val();
var act_variable = document.activeElement.id;
if(act_variable != 'refresh_list') {
var newFile = $('.storage_dialog #uploader .input-path').val(),
file_data = {
'path': $('.currentpath').val(),
},
innerbody,
ext = $('.allowed_file_types select').val();
/*
Add the file extension if necessary, and if the file type selector
isn't set to "All Files". If there's no . at all in the path, or
there is a . already but it's not following the last /, AND the
extension isn't *, then we add the extension.
*/
if ((!newFile.includes('.') ||
newFile.split('.').pop() != ext) &&
ext != '*') {
newFile = newFile + '.' + ext;
$('.storage_dialog #uploader .input-path').val(newFile);
}
/*
Add the file extension if necessary, and if the file type selector
isn't set to "All Files". If there's no . at all in the path, or
there is a . already but it's not following the last /, AND the
extension isn't *, then we add the extension.
*/
if ((!newFile.includes('.') ||
newFile.split('.').pop() != ext) &&
ext != '*') {
newFile = newFile + '.' + ext;
$('.storage_dialog #uploader .input-path').val(newFile);
}
if (!this.check_permission(newFile)) {
closeEvent.cancel = true;
return;
}
if (!this.check_permission(newFile)) {
closeEvent.cancel = true;
return;
}
if (!_.isUndefined(newFile) && newFile !== '' && this.is_file_exist()) {
this.replace_file();
this.$container.find('.replace_file').find('.btn_yes').trigger('focus');
closeEvent.cancel = true;
if (!_.isUndefined(newFile) && newFile !== '' && this.is_file_exist()) {
this.replace_file();
this.$container.find('.replace_file').find('.btn_yes').trigger('focus');
closeEvent.cancel = true;
} else {
pgAdmin.Browser.Events.trigger('pgadmin-storage:finish_btn:create_file', newFile);
innerbody = $(this.elements.body).find('.storage_content');
$(innerbody).find('*').off();
innerbody.remove();
removeTransId(this.trans_id);
}
set_last_traversed_dir(file_data, this.trans_id);
} else {
pgAdmin.Browser.Events.trigger('pgadmin-storage:finish_btn:create_file', newFile);
innerbody = $(this.elements.body).find('.storage_content');
$(innerbody).find('*').off();
innerbody.remove();
removeTransId(this.trans_id);
closeEvent.cancel = true;
}
set_last_traversed_dir(file_data, this.trans_id);
} else if (closeEvent.button.text == gettext('Cancel')) {
innerbody = $(this.elements.body).find('.storage_content');
$(innerbody).find('*').off();

View File

@@ -108,21 +108,26 @@ module.exports = Alertify.dialog('fileSelectionDlg', function() {
},
callback: function(closeEvent) {
var innerbody;
closeEvent.cancel = false;
if (closeEvent.button.text == gettext('Select')) {
var newFile = $('.storage_dialog #uploader .input-path').val(),
file_data = {
'path': $('.currentpath').val(),
};
var act_variable = document.activeElement.id;
if(act_variable !='refresh_list') {
var newFile = $('.storage_dialog #uploader .input-path').val(),
file_data = {
'path': $('.currentpath').val(),
};
pgAdmin.Browser.Events.trigger('pgadmin-storage:finish_btn:' + this.dialog_type, newFile);
innerbody = $(this.elements.body).find('.storage_content');
$(innerbody).find('*').off();
innerbody.remove();
removeTransId(this.trans_id);
// Ajax call to store the last directory visited once user press select button
pgAdmin.Browser.Events.trigger('pgadmin-storage:finish_btn:' + this.dialog_type, newFile);
innerbody = $(this.elements.body).find('.storage_content');
$(innerbody).find('*').off();
innerbody.remove();
removeTransId(this.trans_id);
// Ajax call to store the last directory visited once user press select button
set_last_traversed_dir(file_data, this.trans_id);
set_last_traversed_dir(file_data, this.trans_id);
} else {
closeEvent.cancel = true;
}
} else if (closeEvent.button.text == gettext('Cancel')) {
innerbody = $(this.elements.body).find('.storage_content');
$(innerbody).find('*').off();

View File

@@ -1584,12 +1584,14 @@ define([
if (config.options.dialog_type == 'create_file') {
var status = checkPermission(path);
if (status) {
$('.file_manager').trigger('enter-key');
//$('.file_manager').trigger('enter-key');
$('.file_manager_ok').trigger('click');
}
} else if (config.options.dialog_type == 'select_file') {
var file_status = getFileInfo(path);
if (file_status) {
$('.file_manager').trigger('enter-key');
$('.file_manager_ok').trigger('click');
//$('.file_manager').trigger('enter-key');
}
}
}

View File

@@ -25,7 +25,7 @@
<input class="mode" name="mode" type="hidden" value="add"/>
<input class="currentpath" name="currentpath" type="hidden"/>
<button type="button" title="{{ _('Refresh') }}" class="btn btn-sm btn-primary-icon refresh"
tabindex="0" aria-label="refresh">
tabindex="0" aria-label="refresh" id="refresh_list">
<span class="fa fa-sync-alt sql-icon-lg"></span>
</button>
<button type="button" title="{{ _('Download File') }}" class="btn btn-sm btn-primary-icon download"