diff --git a/web/pgadmin/misc/file_manager/__init__.py b/web/pgadmin/misc/file_manager/__init__.py index 3d4fb538e..843ec6190 100644 --- a/web/pgadmin/misc/file_manager/__init__.py +++ b/web/pgadmin/misc/file_manager/__init__.py @@ -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/", 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.""" diff --git a/web/pgadmin/misc/file_manager/templates/file_manager/js/utility.js b/web/pgadmin/misc/file_manager/templates/file_manager/js/utility.js index 2d3fcdd37..4a2754ce1 100755 --- a/web/pgadmin/misc/file_manager/templates/file_manager/js/utility.js +++ b/web/pgadmin/misc/file_manager/templates/file_manager/js/utility.js @@ -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.