Hi Dave, EnterpriseDB India: http://www.enterprisedb.com The Enterprise PostgreSQL Company
On Wed, Jul 26, 2017 at 5:41 PM, Dave Page <dp...@pgadmin.org> wrote: > > > On Wed, Jul 26, 2017 at 11:06 AM, Harshal Dhumal < > harshal.dhu...@enterprisedb.com> wrote: > >> Hi, >> >> On Mon, Jul 24, 2017 at 4:23 PM, Dave Page <dp...@pgadmin.org> wrote: >> >>> Hi >>> >>> On Mon, Jul 24, 2017 at 11:34 AM, Harshal Dhumal < >>> harshal.dhu...@enterprisedb.com> wrote: >>> >>>> Hi, >>>> >>>> Please find attached patch to set default layout of file listing as a >>>> list in file manager. >>>> Also replaced alertify with out custom alertifywrapper in file manager >>>> utils.js >>>> >>> >>> This isn't a bad idea on the face of it, but there are some things to >>> fix/consider: >>> >>> - The HTML file seems to be missing translation markers. Can you add >>> them throughout please? >>> - We should save the users preference in the config database. >>> - The grid view seems to underline the file size and for no apparent >>> reason change the mouse cursor to ? on mouseover. Let's change the text >>> style to be consistent and get rid of the mouseover. >>> >> Please find updated patch >> > > Thanks, committed with some naming tweaks... however, I do think the > setting should be updated when the user toggles it within the file > dialogue. Can you add code to set that config option when the user toggles > the mode on the fly please? > Yes... and patch attached. > > Thanks. > > -- > Dave Page > Blog: http://pgsnake.blogspot.com > Twitter: @pgsnake > > EnterpriseDB UK: http://www.enterprisedb.com > The Enterprise PostgreSQL Company >
diff --git a/web/pgadmin/misc/file_manager/__init__.py b/web/pgadmin/misc/file_manager/__init__.py index 3d4fb53..843ec61 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/<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.""" 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 2d3fcdd..4a2754c 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.