Store the file dialog view on toggle.

REL-1_X
Harshal Dhumal 2017-07-26 14:35:43 +01:00 committed by Dave Page
parent af26d983e5
commit 831c614a60
2 changed files with 27 additions and 1 deletions

View File

@ -155,7 +155,8 @@ class FileManagerModule(PgAdminModule):
'file_manager.index',
'file_manager.get_trans_id',
'file_manager.delete_trans_id',
'file_manager.save_last_dir'
'file_manager.save_last_dir',
'file_manager.save_file_dialog_view'
]
def get_file_size_preference(self):
@ -288,6 +289,17 @@ def save_last_directory_visited(trans_id):
data={'status': True}
)
@blueprint.route(
"/save_file_dialog_view/<int:trans_id>", methods=["POST"],
endpoint='save_file_dialog_view'
)
@login_required
def save_file_dialog_view(trans_id):
blueprint.file_dialog_view.set(req.json['view'])
return make_json_response(
data={'status': True}
)
class Filemanager(object):
"""FileManager Class."""

View File

@ -60,6 +60,17 @@ var setViewButtonsFor = function(viewMode) {
}
};
var save_file_dialog_view = function(view, trans_id) {
return $.ajax({
url: url_for('file_manager.save_file_dialog_view', {'trans_id': trans_id}),
type: 'POST',
async: true,
data: JSON.stringify({'view':view}),
contentType: 'application/json'
});
};
/*
* preg_replace
*/
@ -1066,6 +1077,7 @@ pgAdmin.FileUtils = {
config;
this.fileConnector = fileConnector;
this.transId = t_id;
// load user configuration file
if (cfg.readyState == 4) {
this.config = config = JSON.parse(cfg.responseText);
@ -1235,6 +1247,7 @@ pgAdmin.FileUtils = {
$('.fileinfo').data('view', 'grid');
enable_disable_btn();
getFolderInfo($('.currentpath').val());
save_file_dialog_view('grid', pgAdmin.FileUtils.transId);
});
// Show list mode
@ -1243,6 +1256,7 @@ pgAdmin.FileUtils = {
$('.fileinfo').data('view', 'list');
enable_disable_btn();
getFolderInfo($('.currentpath').val());
save_file_dialog_view('list', pgAdmin.FileUtils.transId);
});
// Provide initial values for upload form, status, etc.