Re: [RM2579][pgAdmin4] Set default file listing layout as list instead of grid

2017-07-26 Thread Dave Page
Awesome - thanks, committed.

On Wed, Jul 26, 2017 at 1:56 PM, Harshal Dhumal <
harshal.dhu...@enterprisedb.com> wrote:

> Hi Dave,
>
> EnterpriseDB India: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> On Wed, Jul 26, 2017 at 5:41 PM, Dave Page  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  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
>>
>
>


-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


Re: [RM2579][pgAdmin4] Set default file listing layout as list instead of grid

2017-07-26 Thread Harshal Dhumal
Hi Dave,

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On Wed, Jul 26, 2017 at 5:41 PM, Dave Page  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  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/", 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.


Re: [RM2579][pgAdmin4] Set default file listing layout as list instead of grid

2017-07-26 Thread Dave Page
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  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?

Thanks.

-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


Re: [RM2579][pgAdmin4] Set default file listing layout as list instead of grid

2017-07-26 Thread Harshal Dhumal
Hi,

On Mon, Jul 24, 2017 at 4:23 PM, Dave Page  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 @@
 
 
 
-
+
 
-
 
 
@@ -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 ?') }}
 
-  YES
-  NO
+  {{ _('YES') }}
+  {{ _('NO') }}
 
 
 
-Are you sure you want to replace this file ?
+{{ _('Are you sure you want to replace this file?') }}
 
-  YES
-  NO
+  {{ _('YES') }}
+  {{ _('NO') }}
 
 
 
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_

Re: [RM2579][pgAdmin4] Set default file listing layout as list instead of grid

2017-07-24 Thread Dave Page
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.

Thanks!

-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company