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! > > -- > 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 5d7ef93..81c9041 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.grid_layout_view = self.preference.register( + 'options', 'grid_layout_view', + gettext("Grid layout 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') + grid_layout_view = pref.preference('grid_layout_view').get() + return Response(response=render_template( "file_manager/js/file_manager_config.json", _=gettext, - data=data), + data=data, + grid_layout_view=grid_layout_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 1933895..e0341ee 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 @@ <div class="file_manager"> <div id="uploader" class='col-xs-12'> <div class="btn-group filemanager-path-group col-sm-7 col-xs-12" role="group"> - <button name="home" type="button" value="Home" title="Home" class="fa fa-home btn home"><span></span> + <button name="home" type="button" value="Home" title="{{ _('Home') }}" class="fa fa-home btn home"><span></span> </button> - <button name="level-up" type="button" title="Back" value="LevelUp" class="btn fa fa-level-up level-up" + <button name="level-up" type="button" title="{{ _('Back') }}" value="LevelUp" class="btn fa fa-level-up level-up" disabled><span></span></button> <input class='input-path' title='' type="text"/> @@ -17,17 +17,17 @@ <div class="uploadresponse"></div> <input class="mode" name="mode" type="hidden" value="add"/> <input class="currentpath" name="currentpath" type="hidden"/> - <button type="button" title="Refresh" class="btn fa fa-refresh refresh"></button> - <button type="button" title="Download File" class="btn fa fa-download download" disabled><span></span> + <button type="button" title="{{ _('Refresh') }}" class="btn fa fa-refresh refresh"></button> + <button type="button" title="{{ _('Download File') }}" class="btn fa fa-download download" disabled><span></span> </button> - <button name="delete" type="button" title="Delete File/Folder" class="btn fa fa-trash delete" disabled> + <button name="delete" type="button" title="{{ _('Delete File/Folder') }}" class="btn fa fa-trash delete" disabled> <span></span></button> - <button name="rename" type="button" title="Rename File/Folder" class="btn fa fa-pencil-square-o rename"> + <button name="rename" type="button" title="{{ _('Rename File/Folder') }}" class="btn fa fa-pencil-square-o rename"> <span></span></button> - <button name="newfolder" type="button" title="Create new folder" value="New Folder" + <button name="newfolder" type="button" title="{{ _('Create new folder') }}" value="New Folder" class="btn fa fa-folder-open create"><span></span></button> - <button class="ON fa fa-th btn grid" type="button" title="View as grid"><span></span></button> - <button type="button" class="btn fa fa-list list" title="View as Table"><span></span></button> + <button class="ON fa fa-th btn grid" type="button" title="{{ _('View as grid') }}"><span></span></button> + <button type="button" class="btn fa fa-list list" title="{{ _('View as Table') }}"><span></span></button> </div> </div> <div class="fileinfo"> @@ -39,17 +39,17 @@ <div class="allowed_file_types"></div> <div class='fm_dimmer'></div> <div class='delete_item'> - <span>Are you sure you want to delete this item ?</span> + <span>{{ _('Are you sure you want to delete this item ?') }}</span> <span class="pull-right"> - <button type='button' class='btn btn_yes'>YES</button> - <button type='button' class='btn btn_no'>NO</button> + <button type='button' class='btn btn_yes'>{{ _('YES') }}</button> + <button type='button' class='btn btn_no'>{{ _('NO') }}</button> </span> </div> <div class='replace_file'> - <span>Are you sure you want to replace this file ?</span> + <span>{{ _('Are you sure you want to replace this file?') }}</span> <span class="pull-right"> - <button type='button' class='btn btn_yes'>YES</button> - <button type='button' class='btn btn_no'>NO</button> + <button type='button' class='btn btn_yes'>{{ _('YES') }}</button> + <button type='button' class='btn btn_no'>{{ _('NO') }}</button> </span> </div> </div> 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 f74430d..ed8efcf 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": "{{grid_layout_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 fd8f25c..2d3fcdd 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 + '</span></p></td>'; } if (props.Size && props.Size != '') { - result += '<td><abbr title="' + props.Size + '">' + - props.Size + '</abbr></td>'; + result += '<td><span title="' + props.Size + '">' + + props.Size + '</span></td>'; } else { result += '<td></td>'; } @@ -1566,7 +1566,7 @@ pgAdmin.FileUtils = { "<td title='' class='fa fa-folder-open tbl_folder'>" + "<p><input type='text' class='fm_file_rename'><span>" + lg.new_folder + "</span></p>" + - "</td><td><abbr title=''></abbr></td>" + + "</td><td><span title=''></span></td>" + "<td></td>" + "</tr>" );