From 97cd74a3737aed12bd5d73905018752923b4bc98 Mon Sep 17 00:00:00 2001 From: Harshal Dhumal Date: Wed, 26 Jul 2017 13:09:52 +0100 Subject: [PATCH] Default the file browser view to list, and make it configurable. Fixes #2579 --- web/pgadmin/misc/file_manager/__init__.py | 14 ++++++++- .../templates/file_manager/index.html | 30 +++++++++---------- .../file_manager/js/file_manager_config.json | 2 +- .../templates/file_manager/js/utility.js | 6 ++-- 4 files changed, 32 insertions(+), 20 deletions(-) diff --git a/web/pgadmin/misc/file_manager/__init__.py b/web/pgadmin/misc/file_manager/__init__.py index 5d7ef932f..3d4fb538e 100644 --- a/web/pgadmin/misc/file_manager/__init__.py +++ b/web/pgadmin/misc/file_manager/__init__.py @@ -26,6 +26,7 @@ from flask_security import login_required from pgadmin.utils import PgAdminModule from pgadmin.utils import get_storage_directory from pgadmin.utils.ajax import make_json_response +from pgadmin.utils.preferences import Preferences # Checks if platform is Windows if _platform == "win32": @@ -172,6 +173,13 @@ class FileManagerModule(PgAdminModule): gettext("Last directory visited"), 'text', '/', category_label=gettext('Options') ) + self.file_dialog_view = self.preference.register( + 'options', 'file_dialog_view', + gettext("File dialog view"), 'options', 'list', + category_label=gettext('Options'), + options=[{'label': gettext('List'), 'value': 'list'}, + {'label': gettext('Grid'), 'value': 'grid'}] + ) # Initialise the module @@ -232,9 +240,13 @@ def file_manager_config(trans_id): """render the required json""" # trans_id = Filemanager.create_new_transaction() data = Filemanager.get_trasaction_selection(trans_id) + pref = Preferences.module('file_manager') + file_dialog_view = pref.preference('file_dialog_view').get() + return Response(response=render_template( "file_manager/js/file_manager_config.json", _=gettext, - data=data), + data=data, + file_dialog_view=file_dialog_view), status=200, mimetype="application/json") diff --git a/web/pgadmin/misc/file_manager/templates/file_manager/index.html b/web/pgadmin/misc/file_manager/templates/file_manager/index.html index 1933895cb..4d2429648 100755 --- a/web/pgadmin/misc/file_manager/templates/file_manager/index.html +++ b/web/pgadmin/misc/file_manager/templates/file_manager/index.html @@ -6,9 +6,9 @@
- - @@ -17,17 +17,17 @@
- - + - - - - - + +
@@ -39,17 +39,17 @@
- Are you sure you want to delete this item ? + {{ _('Are you sure you want to delete this item?') }} - - + +
- Are you sure you want to replace this file ? + {{ _('Are you sure you want to replace this file?') }} - - + +
diff --git a/web/pgadmin/misc/file_manager/templates/file_manager/js/file_manager_config.json b/web/pgadmin/misc/file_manager/templates/file_manager/js/file_manager_config.json index f74430df7..d73fd05a1 100644 --- a/web/pgadmin/misc/file_manager/templates/file_manager/js/file_manager_config.json +++ b/web/pgadmin/misc/file_manager/templates/file_manager/js/file_manager_config.json @@ -2,7 +2,7 @@ "options": { "culture": "en", "lang": "py", - "defaultViewMode": "grid", + "defaultViewMode": "{{file_dialog_view}}", "autoload": true, "showFullPath": false, "dialog_type": "{{data.dialog_type}}", 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 fd8f25c64..2d3fcdd37 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 @@ -668,8 +668,8 @@ var getFolderInfo = function(path, file_type) { file_name_original + '">' + fm_filename + '

'; } if (props.Size && props.Size != '') { - result += '' + - props.Size + ''; + result += '' + + props.Size + ''; } else { result += ''; } @@ -1566,7 +1566,7 @@ pgAdmin.FileUtils = { "" + "

" + lg.new_folder + "

" + - "" + + "" + "" + "" );