Re: [pgAdmin4][Patch]: File Manager & Backform FileControl

From: Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>
To: Surinder Kumar <surinder(dot)kumar(at)enterprisedb(dot)com>
Cc: pgadmin-hackers <pgadmin-hackers(at)postgresql(dot)org>
Subject: Re: [pgAdmin4][Patch]: File Manager & Backform FileControl
Date: 2016-05-21 09:33:29
Message-ID: CAG7mmoygcTyJS0kYX9fgtwWYf3m7-PqiaHMEyAxXjAmVck1w=Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-hackers

Thanks - committed with small tweak.

--

Thanks & Regards,

Ashesh Vashi
EnterpriseDB INDIA: Enterprise PostgreSQL Company
<http://www.enterprisedb.com>

*http://www.linkedin.com/in/asheshvashi*
<http://www.linkedin.com/in/asheshvashi>

On Fri, May 20, 2016 at 4:33 PM, Surinder Kumar <
surinder(dot)kumar(at)enterprisedb(dot)com> wrote:

> Hi,
>
> Please find patch with following issues/changes fixed:
>
> 1. Rename file/folder not working in list view.
> 2. Selection folder only should not allow to select file.
> 3. Ui changes in *table list* to match with the pgadmin color styles.
> 4. Custom *STORAGE_DIR* path don't list files/folders when opened in
> window system.
> 5. Code cleanup, formatting & did proper commenting.
> 6. In file selection mode, the value typed in text box not setting into
> backbone model.
> 7. Removed create file code, it should be handled on module using it.
> 8. Written a common function to make ajax request, instead of writing
> individual functions for same task.
>
> *Issue to be fixed*: When FileControl is used with 'nested' type, it
> redirects to some url when it is opened up.
> Once it gets fixed. I will send patch for this issue.
>
>
> Thanks
> Surinder Kumar
>
> On Sat, May 14, 2016 at 12:40 AM, Ashesh Vashi <
> ashesh(dot)vashi(at)enterprisedb(dot)com> wrote:
>
>> Thanks - committed with some tweaks!
>>
>> --
>>
>> Thanks & Regards,
>>
>> Ashesh Vashi
>> EnterpriseDB INDIA: Enterprise PostgreSQL Company
>> <http://www.enterprisedb.com>
>>
>>
>> *http://www.linkedin.com/in/asheshvashi*
>> <http://www.linkedin.com/in/asheshvashi>
>>
>> On Fri, May 13, 2016 at 7:36 PM, Surinder Kumar <
>> surinder(dot)kumar(at)enterprisedb(dot)com> wrote:
>>
>>> Hi,
>>>
>>> PFA patch with changes:
>>> 1. Line of code shouldn't exceed greater than 80.
>>> 2. Can't consider boolean as string while comparing.
>>>
>>> On Fri, May 13, 2016 at 4:33 PM, Surinder Kumar <
>>> surinder(dot)kumar(at)enterprisedb(dot)com> wrote:
>>>
>>>> Hi,
>>>>
>>>> Please find the patch for the following improvements:
>>>> 1. FileManager won't show Volumes on Windows when STORAGE_DIR is set to
>>>> None.
>>>>
>>>>
>>>> On Fri, May 13, 2016 at 12:24 AM, Ashesh Vashi <
>>>> ashesh(dot)vashi(at)enterprisedb(dot)com> wrote:
>>>>
>>>>> Hi Surinder,
>>>>>
>>>>> Thanks - it was committed!
>>>>>
>>>>> As discussed personally, there are few improvement needed.
>>>>>
>>>>> * Do not show non applicable buttons, whenever no files/directory
>>>>> available in the storage root directory.
>>>>>
>>>> Done
>>>>
>>>>> * In crate mode, use dimmer with the overwrite warning, so that - it
>>>>> does not allow to deselect the current selection.
>>>>>
>>>> Done
>>>>
>>>>> * The default selection for the file type selection combo box should
>>>>> be other than 'All Files'.
>>>>>
>>>> Done
>>>>
>>>>> * File type selection combo box should support file type description.
>>>>> i.e.
>>>>> Query/SQL File (*.sql)
>>>>> CSV File (*.csv)
>>>>> All Files (*.* | *)
>>>>>
>>>>> Please put that in the TODO file, we will handle that in future.
>>>>>
>>>> I have added it into TODO file.
>>>>
>>>>>
>>>>> I must apologies for a mistake for not giving you the credit for the
>>>>> work, I forgot to set the author while committing it.
>>>>> I tried setting it again to set the author without any success. :-(
>>>>>
>>>>> Thanks for the patch.
>>>>> I will be more careful next time.
>>>>>
>>>>> --
>>>>>
>>>>> Thanks & Regards,
>>>>>
>>>>> Ashesh Vashi
>>>>> EnterpriseDB INDIA: Enterprise PostgreSQL Company
>>>>> <http://www.enterprisedb.com>
>>>>>
>>>>>
>>>>> *http://www.linkedin.com/in/asheshvashi*
>>>>> <http://www.linkedin.com/in/asheshvashi>
>>>>>
>>>>> On Thu, May 12, 2016 at 12:18 AM, Surinder Kumar <
>>>>> surinder(dot)kumar(at)enterprisedb(dot)com> wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> PFA updated patch with following issues fixed:
>>>>>> 1. not listing files based on default file type selected.
>>>>>> 2. load css file using 'get_own_stylesheets' method instead of
>>>>>> loading from 'base.html'.
>>>>>> 3. setting custom dialog title and button not working.
>>>>>>
>>>>>> On Wed, May 11, 2016 at 3:03 PM, Surinder Kumar <
>>>>>> surinder(dot)kumar(at)enterprisedb(dot)com> wrote:
>>>>>>
>>>>>>>
>>>>>>> ---------- Forwarded message ----------
>>>>>>> From: Surinder Kumar <surinder(dot)kumar(at)enterprisedb(dot)com>
>>>>>>> Date: Tue, May 10, 2016 at 11:43 PM
>>>>>>> Subject: Re: [pgadmin-hackers][pgAdmin4][Patch]: File Manager &
>>>>>>> Backform FileControl
>>>>>>> To: Neel Patel <neel(dot)patel(at)enterprisedb(dot)com>
>>>>>>> Cc: pgadmin-hackers <pgadmin-hackers(at)postgresql(dot)org>
>>>>>>>
>>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> Please find updated path with couple of review comments given by
>>>>>>> Ashesh Vashi.
>>>>>>> 1. Add variable *STORAGE_DIR* in configuration settings which
>>>>>>> decides the directory to list when *File manager* is opens,
>>>>>>> previously
>>>>>>> we have provided this option in preferences which is removed due to
>>>>>>> security issues.
>>>>>>> 2. List all available Volumes by default when *STORAGE_DIR *is set
>>>>>>> to empty for *Windows* platform.
>>>>>>> 3. Also, added support to allow user to provide
>>>>>>> *Dialog title and custom name for primary(OK) button,*
>>>>>>>
>>>>>>> Usage:
>>>>>>>
>>>>>>> 1. Set variable *STORAGE_DIR *to some value in config.py.
>>>>>>> 2. Import it in your module as following:
>>>>>>> * import config*
>>>>>>> * config.**STORAGE_DIR*
>>>>>>>
>>>>>>> *Usage*: Backform FilleControl
>>>>>>>
>>>>>>> schema:[{
>>>>>>> id: 'select_file', label: '{{ _('Select File')}}',
>>>>>>> type: 'text', *control*: *Backform.FileControl*,
>>>>>>> *dialog_type: '*select_file*'*, *supp_types: [*'*', 'pdf',
>>>>>>> 'text', 'patch', 'py'*],*
>>>>>>> * dialog_title: '*Title to appear on dialog*", *
>>>>>>> * btn_primary: '*Save File*'*
>>>>>>> }]
>>>>>>>
>>>>>>> Please review the patch.
>>>>>>>
>>>>>>> On Wed, May 4, 2016 at 6:35 PM, Surinder Kumar <
>>>>>>> surinder(dot)kumar(at)enterprisedb(dot)com> wrote:
>>>>>>>
>>>>>>>> Hi
>>>>>>>>
>>>>>>>> PFA updated patch with resolved review comments.
>>>>>>>>
>>>>>>>> On Thu, Apr 28, 2016 at 6:39 PM, Neel Patel <
>>>>>>>> neel(dot)patel(at)enterprisedb(dot)com> wrote:
>>>>>>>>
>>>>>>>>> Hi Surinder,
>>>>>>>>>
>>>>>>>>> Please find additional comments as below.
>>>>>>>>>
>>>>>>>>> 1. In Windows OS, when we try to open the dialog with default
>>>>>>>>> preference value then it gives error as below.
>>>>>>>>>
>>>>>>>>> 2016-04-28 13:07:44,716: ERROR pgadmin: Exception on
>>>>>>>>> /file_manager/filemanager/2530270/ [POST]
>>>>>>>>> Traceback (most recent call last):
>>>>>>>>> File
>>>>>>>>> "C:\Projects\venv_python_2_7\Lib\site-packages\flask\app.py", line 1817, in
>>>>>>>>> wsgi_app
>>>>>>>>> response = self.full_dispatch_request()
>>>>>>>>> File
>>>>>>>>> "C:\Projects\venv_python_2_7\Lib\site-packages\flask\app.py", line 1477, in
>>>>>>>>> full_dispatch_request
>>>>>>>>> rv = self.handle_user_exception(e)
>>>>>>>>> File
>>>>>>>>> "C:\Projects\venv_python_2_7\Lib\site-packages\flask\app.py", line 1381, in
>>>>>>>>> handle_user_exception
>>>>>>>>> reraise(exc_type, exc_value, tb)
>>>>>>>>> File
>>>>>>>>> "C:\Projects\venv_python_2_7\Lib\site-packages\flask\app.py", line 1475, in
>>>>>>>>> full_dispatch_request
>>>>>>>>> rv = self.dispatch_request()
>>>>>>>>> File
>>>>>>>>> "C:\Projects\venv_python_2_7\Lib\site-packages\flask\app.py", line 1461, in
>>>>>>>>> dispatch_request
>>>>>>>>> return self.view_functions[rule.endpoint](**req.view_args)
>>>>>>>>> File
>>>>>>>>> "C:\Projects\venv_python_2_7\Lib\site-packages\flask_login.py", line 758,
>>>>>>>>> in decorated_view
>>>>>>>>> return func(*args, **kwargs)
>>>>>>>>> File
>>>>>>>>> "C:\Projects\pgadmin4\web\pgadmin\misc\file_manager\__init__.py", line 629,
>>>>>>>>> in file_manager
>>>>>>>>> return getattr(myFilemanager, mode)(**kwargs)
>>>>>>>>> File
>>>>>>>>> "C:\Projects\pgadmin4\web\pgadmin\misc\file_manager\__init__.py", line 421,
>>>>>>>>> in getfolder
>>>>>>>>> filelist = self.list_filesystem(dir, path, trans_data,
>>>>>>>>> file_type)
>>>>>>>>> File
>>>>>>>>> "C:\Projects\pgadmin4\web\pgadmin\misc\file_manager\__init__.py", line 331,
>>>>>>>>> in list_filesystem
>>>>>>>>> for f in sorted(os.listdir(orig_path)):
>>>>>>>>> WindowsError: [Error 161] The specified path is invalid: '//*.*'
>>>>>>>>>
>>>>>>>>> Now the default path will always be the users directory. I have
>>>>>>>> used *os.path.expanduser('~') *which prints user directory. It
>>>>>>>> works for all operating systems.
>>>>>>>>
>>>>>>>>>
>>>>>>>>> 2. Folder having write only permission should not allow to read
>>>>>>>>> the directory. Same way read only permission folder should not allow to
>>>>>>>>> create the folder. Currently it gives below error.
>>>>>>>>>
>>>>>>>>> PermissionError: [Errno 13] Permission denied:
>>>>>>>>> '/home/neel/Projects/pgadmin4_file_manager/write_only_premission/'
>>>>>>>>>
>>>>>>>> Fixed.
>>>>>>>>
>>>>>>>>>
>>>>>>>>> 3. In Windows OS, when we open the file manager dialog, no
>>>>>>>>> directories listed though we have directories in the folder. Due to that we
>>>>>>>>> are not able to
>>>>>>>>> test all the functionality in windows. Once we fix this issue
>>>>>>>>> then we test all the functionality in windows OS.
>>>>>>>>>
>>>>>>>>> We debug the issue and found that issue is with the json
>>>>>>>>> response which includes the HTML tags.
>>>>>>>>>
>>>>>>>> Fixed. It still have issues in very older browsers. I will fix it.
>>>>>>>>
>>>>>>>>>
>>>>>>>>> 4. In Windows OS, file manager dialog have issue with layout. We
>>>>>>>>> are getting some margin at top before buttons.
>>>>>>>>>
>>>>>>>> Fixed.
>>>>>>>>
>>>>>>>>>
>>>>>>>>> 5. When we give any special characters to folder name that it
>>>>>>>>> gives error saying "Folder does not exist".
>>>>>>>>> Same is applicable when we give dialog_type to create_file
>>>>>>>>>
>>>>>>>> Fixed.
>>>>>>>>
>>>>>>>>>
>>>>>>>>> 6. In create_file mode, after giving the filename it should
>>>>>>>>> display the name of the file to text control.
>>>>>>>>>
>>>>>>>> Fixed.
>>>>>>>>
>>>>>>>>>
>>>>>>>>> 7. In create_file mode, when user gives the filename and click on
>>>>>>>>> the any blank area of dialog then name is getting cleared.
>>>>>>>>>
>>>>>>>> Fixed.
>>>>>>>>
>>>>>>>>>
>>>>>>>>> 8. When we upload the new file through file manager then it is not
>>>>>>>>> showing in the list though we have selected "All files" options.
>>>>>>>>>
>>>>>>>> Fixed.
>>>>>>>>
>>>>>>>>>
>>>>>>>>> 9. When we rename the folder in "Table mode" then font-family gets
>>>>>>>>> changed. It is not happened in "Grid" mode.
>>>>>>>>>
>>>>>>>> Fixed.
>>>>>>>>
>>>>>>>>>
>>>>>>>>> 10. When we try to download the file then it goes into loop and
>>>>>>>>> opens up 20-30 dialogs at the same time.
>>>>>>>>>
>>>>>>>> Fixed.
>>>>>>>>
>>>>>>>>>
>>>>>>>>> 11. "Rename" button is enabled even though we have not selected
>>>>>>>>> the files/folder to rename and when we click on the "Rename" button it
>>>>>>>>> gives below
>>>>>>>>> error.
>>>>>>>>>
>>>>>>>>> TypeError: orig_value is undefined
>>>>>>>>>
>>>>>>>> Fixed.
>>>>>>>>
>>>>>>>>> 12. "Delete" button is enabled even though we have not selected
>>>>>>>>> the files/folder to delete and when we click on the "Delete" button it
>>>>>>>>> gives below error.
>>>>>>>>> TypeError: path is undefined
>>>>>>>>>
>>>>>>>> Fixed.
>>>>>>>>
>>>>>>>>>
>>>>>>>>> Do let us know if you have queries.
>>>>>>>>>
>>>>>>>>> Thanks,
>>>>>>>>> Neel Patel
>>>>>>>>>
>>>>>>>>> On Wed, Apr 27, 2016 at 9:15 PM, Neel Patel <
>>>>>>>>> neel(dot)patel(at)enterprisedb(dot)com> wrote:
>>>>>>>>>
>>>>>>>>>> Hi Surinder,
>>>>>>>>>>
>>>>>>>>>> I have applied the patch file and below are some observations.
>>>>>>>>>>
>>>>>>>>>> - When we create the new folder and hit the enter then we are
>>>>>>>>>> getting the below error.
>>>>>>>>>>
>>>>>>>>>> TypeError: argument of type 'NoneType' is not
>>>>>>>>>> iterable
>>>>>>>>>>
>>>>>>>>>> - I have just added the new control in "Import" dialog and
>>>>>>>>>> observed that new control is getting added in new tab called "General". I
>>>>>>>>>> think it should not create the new "General" tab.
>>>>>>>>>> - "Select" and "Cancel" buttons font is different then other
>>>>>>>>>> dialogs.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Thanks,
>>>>>>>>>> Neel Patel
>>>>>>>>>>
>>>>>>>>>> On Wed, Apr 27, 2016 at 6:18 PM, Surinder Kumar <
>>>>>>>>>> surinder(dot)kumar(at)enterprisedb(dot)com> wrote:
>>>>>>>>>>
>>>>>>>>>>> Hi,
>>>>>>>>>>>
>>>>>>>>>>> The patch is for *File Manager and Backform FileControl*.
>>>>>>>>>>>
>>>>>>>>>>> *File Manager:* It allows user to store their files at one
>>>>>>>>>>> place. The user can set path to this directory in preferences which file
>>>>>>>>>>> manger will use.
>>>>>>>>>>>
>>>>>>>>>>> It will be used by various modules of pgAdmin4 such as
>>>>>>>>>>> *import data from file, query tool, backup & recovery tool* so
>>>>>>>>>>> on.. It allows user to perform various operations such as:
>>>>>>>>>>>
>>>>>>>>>>> - File deletion
>>>>>>>>>>> - File upload
>>>>>>>>>>> - Create new directory
>>>>>>>>>>> - File rename
>>>>>>>>>>> - File download and
>>>>>>>>>>> - List files & folders in list and grid view.
>>>>>>>>>>>
>>>>>>>>>>> *FileControl: *This control is used with *File Manager. *It can
>>>>>>>>>>> be used for:
>>>>>>>>>>>
>>>>>>>>>>> - File Selection
>>>>>>>>>>> - Folder Selection
>>>>>>>>>>> - File Creation
>>>>>>>>>>> - Storage Manager Dialog.( it supports all operations listed
>>>>>>>>>>> above).
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Usage*:*
>>>>>>>>>>>
>>>>>>>>>>> schema:[{
>>>>>>>>>>> id: 'select_file', label: '{{ _('Select File')}}',
>>>>>>>>>>> type: 'text', *control*: *Backform.FileControl*,
>>>>>>>>>>> *dialog_type: 'select_file'*, *supp_types: ['*', 'pdf',
>>>>>>>>>>> 'text', 'patch', 'py']*
>>>>>>>>>>> }
>>>>>>>>>>>
>>>>>>>>>>> Where:
>>>>>>>>>>>
>>>>>>>>>>> - *control* - It should be *Backform.FileControl*
>>>>>>>>>>> - *dialog_type *- the type of dialog to use.
>>>>>>>>>>> - options can be: *select_file, select_folder, create_file
>>>>>>>>>>> & storage_dialog*.
>>>>>>>>>>> - *supp_types(*not mandatory) - the types of files allowed
>>>>>>>>>>> to show and upload.
>>>>>>>>>>>
>>>>>>>>>>> Please review the patch and let me know for the review comments.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Thanks
>>>>>>>>>>> Surinder Kumar
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>>> Sent via pgadmin-hackers mailing list (
>>>>>>>>>>> pgadmin-hackers(at)postgresql(dot)org)
>>>>>>>>>>> To make changes to your subscription:
>>>>>>>>>>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Sent via pgadmin-hackers mailing list (pgadmin-hackers(at)postgresql(dot)org
>>>>>> )
>>>>>> To make changes to your subscription:
>>>>>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>
>
> --
> Sent via pgadmin-hackers mailing list (pgadmin-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgadmin-hackers
>
>

In response to

Browse pgadmin-hackers by date

  From Date Subject
Next Message Ashesh Vashi 2016-05-21 09:36:59 pgAdmin 4 commit: Renaming the label of the browser left node after edi
Previous Message Ashesh Vashi 2016-05-21 09:33:20 pgAdmin 4 commit: Fixes few issues with File Manager.