public inbox for [email protected]  
help / color / mirror / Atom feed
From: Surinder Kumar <[email protected]>
To: pgadmin-hackers <[email protected]>
Subject: Re: [pgAdmin4][Patch]: File Manager & Backform FileControl
Date: Fri, 20 May 2016 16:33:31 +0530
Message-ID: <CAM5-9D8mTSgwY8JEcSZv9e8o9VzjVL4O_qj2Gr82AYTY+YW_ww@mail.gmail.com> (raw)
In-Reply-To: <CAG7mmozsNKz7-HJZP2du9j9aX4mFJJBvsxNWaN8mp0ZtSvMzfg@mail.gmail.com>
References: <CAM5-9D8GX9gNZp95K11rfnpnn4msEH=F6hhZNpBE_WLX46vicg@mail.gmail.com>
	<CACCA4P22BrRBfxTvSRYaPb_VaOA+8HbNLkZDM=w-H8VXeo6HNQ@mail.gmail.com>
	<CACCA4P3s_TAbNP+piWawJA7dg1eS194MC0RGoHh461e1=cUAWw@mail.gmail.com>
	<CAM5-9D-KihU=fqFQ9jV9tDw83cyQnVYZ71UYQoUbLi4C1vVUuA@mail.gmail.com>
	<CAM5-9D8n54WPdpP-H_hN9-X0rxT-vhu4Y6rqJCf7FaCxuBDWAg@mail.gmail.com>
	<CAM5-9D_ZZ5MFX1xiiUa0k_oo12+U7KXBQ4fhZjz_u0_CDNH2dQ@mail.gmail.com>
	<CAM5-9D9jr0E9bsE-_exx-XGrmRq9LZSeA+emm8Sbc-jJR_Ny3Q@mail.gmail.com>
	<CAG7mmoxh-a-3HuWLrJ+Vod2bypc9eY7Ht5NaLW_xjQdv9nT2Nw@mail.gmail.com>
	<CAM5-9D9Dt6Nvm2V3z-S=QRc8c8eDeC3Yr-DzpOEmuumGRq2PXw@mail.gmail.com>
	<CAM5-9D-Atd3GmhDF4D1gvmnrcHAO-S9gW=v17V2Srg1NjkuzNw@mail.gmail.com>
	<CAG7mmozsNKz7-HJZP2du9j9aX4mFJJBvsxNWaN8mp0ZtSvMzfg@mail.gmail.com>
List-Unsubscribe:  <mailto:[email protected]?body=unsub%20pgadmin-hackers>

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 <
[email protected]> 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 <
> [email protected]> 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 <
>> [email protected]> 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 <
>>> [email protected]> 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 <
>>>> [email protected]> 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 <
>>>>> [email protected]> wrote:
>>>>>
>>>>>>
>>>>>> ---------- Forwarded message ----------
>>>>>> From: Surinder Kumar <[email protected]>
>>>>>> Date: Tue, May 10, 2016 at 11:43 PM
>>>>>> Subject: Re: [pgadmin-hackers][pgAdmin4][Patch]: File Manager &
>>>>>> Backform FileControl
>>>>>> To: Neel Patel <[email protected]>
>>>>>> Cc: pgadmin-hackers <[email protected]>
>>>>>>
>>>>>>
>>>>>> 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 <
>>>>>> [email protected]> wrote:
>>>>>>
>>>>>>> Hi
>>>>>>>
>>>>>>> PFA updated patch with resolved review comments.
>>>>>>>
>>>>>>> On Thu, Apr 28, 2016 at 6:39 PM, Neel Patel <
>>>>>>> [email protected]> 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 <
>>>>>>>> [email protected]> 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 <
>>>>>>>>> [email protected]> 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 (
>>>>>>>>>> [email protected])
>>>>>>>>>> To make changes to your subscription:
>>>>>>>>>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Sent via pgadmin-hackers mailing list ([email protected])
>>>>> To make changes to your subscription:
>>>>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>>>>
>>>>>
>>>>
>>>
>>
>


-- 
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Attachments:

  [application/octet-stream] FileManager_fixes.patch (45.9K, 3-FileManager_fixes.patch)
  download | inline diff:
diff --git a/web/pgadmin/misc/file_manager/__init__.py b/web/pgadmin/misc/file_manager/__init__.py
index bc67a59..96f61c8 100644
--- a/web/pgadmin/misc/file_manager/__init__.py
+++ b/web/pgadmin/misc/file_manager/__init__.py
@@ -677,6 +677,7 @@ class Filemanager(object):
         dir = self.dir
         err_msg = ''
         code = 1
+        name = unquote(name)
         try:
             orig_path = "{0}{1}".format(dir, path)
             newName = '{0}{1}'.format(orig_path, name)
@@ -689,40 +690,7 @@ class Filemanager(object):

         result = {
             'Path': path,
-            'Name': newName,
-            'Error': err_msg,
-            'Code': code
-        }
-
-        return result
-
-    def create_file(self, path, name, req=None):
-        """
-        Create new file functionality
-        """
-        if not self.validate_request('create'):
-            return {
-             'Error': gettext('Not allowed'),
-             'Code': 1
-            }
-
-        dir = self.dir
-        err_msg = ''
-        code = 1
-        try:
-            orig_path = "{0}{1}".format(dir, path)
-            newName = '{0}{1}'.format(orig_path, name)
-            if not os.path.exists(newName):
-                open(newName, 'w')
-                code = 0
-            else:
-                err_msg = gettext("Error: File already exists")
-        except Exception as e:
-            err_msg = "Error: {0}".format(e.strerror)
-
-        result = {
-            'Path': path,
-            'Name': newName,
+            'Name': name,
             'Error': err_msg,
             'Code': code
         }
diff --git a/web/pgadmin/misc/file_manager/static/css/file_manager.css b/web/pgadmin/misc/file_manager/static/css/file_manager.css
index 069d003..6d538f3 100755
--- a/web/pgadmin/misc/file_manager/static/css/file_manager.css
+++ b/web/pgadmin/misc/file_manager/static/css/file_manager.css
@@ -40,9 +40,12 @@
   overflow: auto;
   /* no margin or border allowed */
 }
+.file_listing #contents.grid li.selected {
+  border: 1px solid #D9EDF7;
+}

-.fileinfo #contents li.selected, .fileinfo #contents tbody tr.selected {
-  background: #D9EDF7;
+.file_listing #contents.grid li.selected, .fileinfo #contents tbody tr.selected {
+  background: #D9EDF7 !important;
 }

 .fileinfo #contents li .fm_file_rename,
@@ -54,6 +57,17 @@
   height: 17px;
 }

+.fileinfo #contents li p > span.less_text,
+.fileinfo table#contents tr td:first-child p span.less_text {
+  width: 100%;
+  display: inline-block;
+  text-overflow: ellipsis;
+  overflow: hidden;
+  text-align: center;
+  white-space: nowrap;
+  padding: 0 10px;
+}
+
 .fileinfo table#contents tr td p {
   display: inline-block;
   margin-bottom: 0;
@@ -164,13 +178,14 @@ x:-o-prefocus, .file-input-container {top:16px;width:198px;}
   display: block;
   float: left;
   width: 100px;
-  min-height: 80px;
+  height: 80px;
   text-align: center;
   overflow: hidden;
   margin-bottom: 10px;
   -webkit-border-radius: 2px;
   -moz-border-radius: 2px;
   border-radius: 2px;
+  border: 1px solid #fff;
 }

 div.clip {
@@ -199,12 +214,12 @@ div.clip {

 .file_listing #contents.list thead {
   background: rgb(244,241,237); /* Old browsers */
-  background: -moz-linear-gradient(top, rgba(244,241,237,1) 0%, rgba(214,212,209,1) 100%); /* FF3.6+ */
-  background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(244,241,237,1)), color-stop(100%,rgba(214,212,209,1))); /* Chrome,Safari4+ */
-  background: -webkit-linear-gradient(top, rgba(244,241,237,1) 0%,rgba(214,212,209,1) 100%); /* Chrome10+,Safari5.1+ */
-  background: -o-linear-gradient(top, rgba(244,241,237,1) 0%,rgba(214,212,209,1) 100%); /* Opera 11.10+ */
-  background: -ms-linear-gradient(top, rgba(244,241,237,1) 0%,rgba(214,212,209,1) 100%); /* IE10+ */
-  background: linear-gradient(to bottom, rgba(244,241,237,1) 0%,rgba(214,212,209,1) 100%); /* W3C */
+  background: -moz-linear-gradient(top, rgba(44, 118, 180, 0.71) 0%, rgba(44, 118, 180, 0.98) 100%); /* FF3.6+ */
+  background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(44, 118, 180, 0.71)), color-stop(100%,rgba(44, 118, 180, 0.98))); /* Chrome,Safari4+ */
+  background: -webkit-linear-gradient(top, rgba(44, 118, 180, 0.71) 0%,rgba(44, 118, 180, 0.98) 100%); /* Chrome10+,Safari5.1+ */
+  background: -o-linear-gradient(top, rgba(44, 118, 180, 0.71) 0%,rgba(44, 118, 180, 0.98) 100%); /* Opera 11.10+ */
+  background: -ms-linear-gradient(top, rgba(44, 118, 180, 0.71) 0%,rgba(44, 118, 180, 0.98) 100%); /* IE10+ */
+  background: linear-gradient(to bottom, rgba(44, 118, 180, 0.71) 0%,rgba(44, 118, 180, 0.98) 100%)
   border-bottom: 1px solid #ccc;
   display: inline-block;
   width: 100%;
@@ -213,6 +228,7 @@ div.clip {
 .file_listing #contents.list th {
   font-weight: bold;
   cursor: pointer;
+  color: #fff;
 }

 .file_listing #contents.list th.tablesorter-headerAsc,
@@ -226,15 +242,11 @@ div.clip {
   background: linear-gradient(to bottom, rgba(214,212,209,1) 0%,rgba(244,241,237,1) 100%); /* W3C */
 }

-.file_listing #contents.list td {
-  border-bottom: 1px dotted #ccc;
-}
-
 .file_listing #contents.list td:first-child {
   display: table-cell;
   padding-left: 0;
   width: 100%;
-  padding-left: 22px;
+  padding-left: 12px;
   background-repeat: no-repeat;
   background-position: 3px center;
 }
@@ -253,16 +265,15 @@ div.clip {
   margin-right: 5px;
 }

-.file_listing #contents.list tbody tr:hover {
-  background-color: #eee;
-  cursor: pointer;
+.file_listing #contents.list tbody tr:nth-child(even):hover {
+  background-color: #f5f5f5 !important;
 }

 .file_listing #contents.grid li:hover {
   border: 1px solid #E5E5E5;
   background-color: #F7F7F7;
   cursor: pointer;
-  max-height: 78px;
+  height: 80px;
 }

 .meta {
@@ -320,7 +331,8 @@ button.list span {
   top: 0;
 }

-.btn-group.filemanager-btn-group .btn:not(:first-child):not(:last-child) {
+.btn-group.filemanager-btn-group .btn:not(:first-child):not(:last-child),
+.btn-group.filemanager-path-group .btn:not(:first-child):not(:last-child) {
   border-left: 1px solid #A9A9A9;
 }

@@ -377,6 +389,14 @@ button.list span {
   width: 100%;
 }

+.file_manager .fileinfo #contents tbody tr:nth-child(even) {
+  background: #eee;
+}
+
+.file_manager .fileinfo #contents thead tr th:not(:first-child) {
+  border-left: 1px solid #fff;
+}
+
 .file_manager .fileinfo #contents thead tr th:nth-child(1),
 .file_manager .fileinfo #contents tbody tr td:nth-child(1) {
   position: relative;
@@ -389,6 +409,7 @@ button.list span {
   width: 152px;
   min-width: 152px;
   max-width: 152px;
+  padding-left: 10px;
 }

 .file_manager .fileinfo #contents tbody tr td:nth-child(2) {
@@ -401,12 +422,13 @@ button.list span {
   width: 197px;
   min-width: 197px;
   max-width: 197px;
+  padding-left: 10px;
 }

 .file_manager .fileinfo #contents tbody tr td:nth-child(3) {
-  width: 180px;
-  min-width: 180px;
-  max-width: 180px;
+  width: 177px;
+  min-width: 177px;
+  max-width: 177px;
 }

 .file_manager .fileinfo #contents tbody {
@@ -415,10 +437,12 @@ button.list span {
   width: 100%;
   height: calc(100% - 30px);
 }
+
 .file_manager .fileinfo #contents tbody tr{
-  display: table;
+  /*display: table;*/
   max-width: 100%;
   width: 100%;
+  cursor: pointer;
 }

 .file_manager .upload_file {
@@ -457,11 +481,14 @@ button.list span {
 }

 .file_manager #uploader .btn-group .show_selected_file {
-  float: left;
-  text-align: left;
   vertical-align: middle;
+  text-align: left;
   padding: 4px 0 0 5px;
-  height: 100%;
+  display: inline-block;
+  overflow: hidden;
+  width: calc(100% - 73px);
+  text-overflow: ellipsis;
+  white-space: nowrap;
 }

 .fileinfo .file_listing {
@@ -559,6 +586,7 @@ button.list span {
 }

 .file_upload_main .dz-progress {
+  height: 21px !important;
   top: 83px !important;
   border: 1px solid #8a6d3b;
   border-radius: 0 !important;
@@ -655,7 +683,7 @@ a.dz-remove {
 .file_manager .fileinfo #contents .fa-lock.tbl_lock_icon {
   color: red;
   position: absolute;
-  left: 29px;
+  left: 19px;
   top: 5px;
   font-size: 10px;
 }
@@ -676,8 +704,9 @@ a.dz-remove {
 .file_listing .no_folder_found {
   text-align: center;
   position: absolute;
-  top: 35;
+  top: 35px;
   width: 100%;
+  font-size: 14px;
 }

 .fileinfo .is_file_replace {
diff --git a/web/pgadmin/misc/file_manager/templates/file_manager/js/file_manager.js b/web/pgadmin/misc/file_manager/templates/file_manager/js/file_manager.js
index bf7171f..5ab77c1 100644
--- a/web/pgadmin/misc/file_manager/templates/file_manager/js/file_manager.js
+++ b/web/pgadmin/misc/file_manager/templates/file_manager/js/file_manager.js
@@ -131,7 +131,7 @@ define([
                 //closeEvent.cancel = true;
               }
               if (closeEvent.button.text == "{{ _('Select') }}") {
-                if($('.fileinfo').data('view') == 'grid'){
+                if($('.fileinfo').data('view') == 'grid') {
                   sel_file = $('.fileinfo').find('#contents li.selected p span').attr('title');
                 } else {
                   sel_file = $('.fileinfo tbody tr.selected td p span').attr('title');
@@ -239,7 +239,7 @@ define([
             },
             callback: function(closeEvent) {
               if (closeEvent.button.text == "{{ _('Select') }}") {
-                if($('.fileinfo').data('view') == 'grid'){
+                if($('.fileinfo').data('view') == 'grid') {
                   sel_file = $('.fileinfo').find('#contents li.selected  p span').attr('title');
                 } else {
                   sel_file = $('.fileinfo tbody tr.selected td p span').attr('title');
@@ -346,7 +346,7 @@ define([
             },
             callback: function(closeEvent) {
               if (closeEvent.button.text == "{{ _('Select') }}") {
-                if($('.fileinfo').data('view') == 'grid'){
+                if($('.fileinfo').data('view') == 'grid') {
                   sel_file = $('.fileinfo').find('#contents li.selected p span').attr('title');
                 } else {
                   sel_file = $('.fileinfo tbody tr.selected td p span').attr('title');
@@ -481,9 +481,9 @@ define([
                 dataType: 'json',
                 contentType: "application/x-download; charset=utf-8",
                 async: false,
-                success: function(resp){
+                success: function(resp) {
                   data = resp.data.result;
-                  if(data['Code'] === 0){
+                  if(data['Code'] === 0) {
                     is_exist = true;
                   } else {
                     is_exist = false;
@@ -492,39 +492,8 @@ define([
               });
               return is_exist;
             },
-            create_file: function() {
-              var selected_item = $('.allowed_file_types .create_input input[type="text"]').val(),
-                  is_exist = false,
-                  is_created = false;
-
-              var post_data = {
-                'path': $('.currentpath').val(),
-                'name': selected_item,
-                'mode': 'create_file'
-              };
-
-              $.ajax({
-                type: 'POST',
-                data: JSON.stringify(post_data),
-                url: fileConnector + trans_id+'/',
-                dataType: 'json',
-                contentType: "application/x-download; charset=utf-8",
-                async: false,
-                success: function(resp){
-                  data = resp.data.result;
-                  if(data['Code'] === 0){
-                    alertify.success("New File created successfully.");
-                    is_created = true;
-                  } else {
-                    alertify.error(data['Error']);
-                    return false;
-                  }
-                }
-              });
-              return is_created;
-            },
             callback: function(closeEvent) {
-              if (closeEvent.button.text == "{{ _('Create') }}"){
+              if (closeEvent.button.text == "{{ _('Create') }}") {
                 var selected_item = $('.allowed_file_types .create_input input[type="text"]').val();
                 var newFile = $('.currentpath').val() + selected_item;
                 newFile = newFile.substr(1);
@@ -533,17 +502,11 @@ define([
                   closeEvent.cancel = true;
                 }
                 else {
-                  var is_created = this.create_file();
-                  if (is_created) {
-                    pgAdmin.Browser.Events.trigger('pgadmin-storage:finish_btn:create_file', newFile);
-                    removeTransId(trans_id);
-                  }
-                  else {
-                    closeEvent.cancel = true;
-                  }
+                  pgAdmin.Browser.Events.trigger('pgadmin-storage:finish_btn:create_file', newFile);
+                  removeTransId(trans_id);
                 }
               }
-              if (closeEvent.button.text == "{{ _('Cancel') }}"){
+              if (closeEvent.button.text == "{{ _('Cancel') }}") {
                 removeTransId(trans_id);
               }
             },
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 f0b45ac..3dc70bb 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
@@ -12,108 +12,54 @@
 (function($) {
 "use strict";

-// User alertify object
-var alertify = require("alertify");
-
+// use alertify and underscore js
+var alertify = require("alertify"),
+    _ = require("underscore");

 /*---------------------------------------------------------
   Define functions used for various operations
 ---------------------------------------------------------*/

-// function to retrieve GET params
-$.urlParam = function(name) {
-  var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
-  if (results) {
-    return results[1];
-  } else {
-    return 0;
-  }
-};
-
+// return file extension
 var getFileExtension = function(name) {
-    var found = name.lastIndexOf('.') + 1;
-    return (found > 0 ? name.substr(found) : "");
+  var found = name.lastIndexOf('.') + 1;
+  return (found > 0 ? name.substr(found) : "");
 };

+// returns filename without extension
 var getFileName = function(name) {
   var fm_filename = name;
   if (fm_filename.length > 15 ) {
-      fm_filename = name.substr(0, 10) +'...';
+    fm_filename = name.substr(0, 10) +'...';
   }
   return fm_filename;
 };

-// send a request to get transaction id
-var getTransId = function() {
-  return $.ajax({
-    async: false,
-    url: "{{ url_for('file_manager.index') }}get_trans_id",
-    dataType: "jsonp"
-  });
-};
-
-// Load language file
-var loadLangFile = function(enjs) {
-  if ($.urlParam('langCode') !== 0 && file_exists (enjs)) {
-    culture = $.urlParam('langCode');
-  }
-  return $.ajax({
-    async: false,
-    url: enjs,
-    dataType: 'jsonp',
-    contentType: "application/json; charset=utf-8"
-  });
-};
-
-var userconfig = file_manager_config_json;
-
-// We retrieve config settings from filemanager.config.js
-var loadConfigFile = function (type) {
-  type = (typeof type === "undefined") ? "user" : type;
-  var url;
-  if (type == 'user') {
-    url = file_manager_config_json;
-  }
+/* Common function to load:
+ * en.js language file
+ * file_manager_config.js config file
+ * return transaction id
+ */
+var loadData = function(url) {
   return $.ajax({
     async: false,
     url: url,
-    dataType: "jsonp",
+    dataType: 'jsonp',
     contentType: "application/json; charset=utf-8"
   });
 };

-/*
- * Forces columns to fill the layout vertically.
- * Called on initial page load and on resize.
- */
-var setDimensions = function() {
-  var main_container_height = ( $(window).height() ) / 2 + 35;
-  var newH = main_container_height - $('#uploader').height() - 30;
-};
-
-// Display Min Path
-var displayPath = function(path) {
-  if (config.options.showFullPath === false) {
-    // if a "displayPathDecorator" function is defined, use it to decorate path
-    return 'function' === (typeof displayPathDecorator)
-         ? displayPathDecorator(path)
-         : path.replace(fileRoot, "/");
+// Set enable/disable state of list and grid view
+var setViewButtonsFor = function(viewMode) {
+  if (viewMode == 'grid') {
+      $('.grid').addClass('ON');
+      $('.list').removeClass('ON');
   } else {
-    return path;
+      $('.list').addClass('ON');
+      $('.grid').removeClass('ON');
   }
 };

-// Set the view buttons state
-var setViewButtonsFor = function(viewMode) {
-    if (viewMode == 'grid') {
-        $('.grid').addClass('ON');
-        $('.list').removeClass('ON');
-    } else {
-        $('.list').addClass('ON');
-        $('.grid').removeClass('ON');
-    }
-};
-
 /*
  * preg_replace
  */
@@ -193,10 +139,7 @@ var formatBytes = function(bytes) {
   }
 };

-/*
- * Handle Error. Freeze interactive buttons and display
- * error message. Also called when auth() function return false (Code == "-1")
- */
+// Freeze toolbar buttons and display errors
 var handleError = function(errMsg) {
   $('.storage_dialog .newfile').attr("disabled", "disabled");
   $('.storage_dialog .upload').attr("disabled", "disabled");
@@ -207,27 +150,12 @@ var handleError = function(errMsg) {
  * Test if Data structure has the 'cap' capability
  * 'cap' is one of 'select', 'rename', 'delete', 'download'
  */
-function has_capability(data, cap) {
+var has_capability = function(data, cap) {
   if (typeof(data.Capabilities) == "undefined") {
     return true;
   } else {
     return ($.inArray(cap, data.Capabilities) > -1);
   }
-}
-
-// Test if file is authorized
-var isAuthorizedFile = function(filename) {
-  return ((
-    config.security.uploadPolicy == 'DISALLOW_ALL' &&
-    $.inArray(
-      getExtension(filename), config.security.uploadRestrictions
-    ) != -1
-  ) || (
-    config.security.uploadPolicy == 'ALLOW_ALL' &&
-    $.inArray(
-      getExtension(filename), config.security.uploadRestrictions
-    ) == -1
-  ));
 };

 // return filename extension
@@ -238,7 +166,7 @@ var getExtension = function(filename) {
   return filename.split('.').pop();
 };

-// return filename without extension {
+// return filename without extension
 var getFilename = function(filename) {
   if (filename.lastIndexOf('.') != -1) {
     return filename.substring(0, filename.lastIndexOf('.'));
@@ -250,7 +178,8 @@ var getFilename = function(filename) {
 // helpful in show/hide toolbar button for Windows
 var hideButtons = function() {
     return (
-      config.options.platform_type == 'win32' && $('.currentpath').val() == ''
+      config.options.platform_type == 'win32' &&
+      $('.currentpath').val() === ''
     );
 };

@@ -265,7 +194,7 @@ var setUploader = function(path) {

   path = decodeURI(path);

-  var display_string = displayPath(path),
+  var display_string = path,
       mypath = '';

   // split path
@@ -401,7 +330,7 @@ var setUploader = function(path) {
       if (fname != '') {
         foldername = cleanString(fname);
         var d = new Date(); // to prevent IE cache issues
-        $.getJSON(fileConnector + '?mode=addfolder&path=' + $('.currentpath').val() + '&name=' + foldername + '&time=' + d.getMilliseconds(), function(resp) {
+        $.getJSON(fileConnector + '?mode=addfolder&path=' + $('.currentpath').val() + '&name=' + foldername, function(resp) {
           var result = resp.data.result;
           if (result.Code === 0) {
             alertify.success(lg.successful_added_folder);
@@ -423,16 +352,18 @@ var setUploader = function(path) {
  * and show/hide buttons
  */
 var bindToolbar = function(data) {
-  if (!has_capability(data, 'upload') || hideButtons()) {
-    $('.file_manager').find('button.upload').hide();
-  } else {
-    $('.file_manager').find('button.upload').show();
-  }

-  if (!has_capability(data, 'create') || hideButtons()) {
-    $('.file_manager').find('button.create').hide();
-  } else {
-      $('.file_manager').find('button.create').show();
+  // hide/show rename, upload and create button
+  if(_.has(data, 'Capabilities')) {
+    _.each(data.Capabilities, function(cap) {
+      var target_btn = 'button.' + cap,
+          $target_el = $('.file_manager').find(target_btn);
+      if (!has_capability(data, cap) || hideButtons()) {
+        $target_el.hide();
+      } else {
+        $target_el.show();
+      }
+    });
   }

   if (!has_capability(data, 'delete') || hideButtons()) {
@@ -484,12 +415,6 @@ var bindToolbar = function(data) {
       }
     });
   }
-
-  if (!has_capability(data, 'rename') || hideButtons()) {
-    $('.file_manager').find('button.rename').hide();
-  } else {
-      $('.file_manager').find('button.rename').show();
-  }
 };

 // enable/disable button when files/folder are loaded
@@ -522,26 +447,6 @@ var enable_disable_btn = function() {
   $('.file_manager #uploader .show_selected_file').remove();
 };

-// switch to folder view
-$('.file_manager .fileinfo').on('click', function(e) {
-  enable_disable_btn();
-});
-
-
-// refresh current directory
-$('.file_manager .refresh').on('click', function(e) {
-  enable_disable_btn();
-  var curr_path = $('.currentpath').val(),
-      path = curr_path.substring(
-        0, curr_path.lastIndexOf("/")
-      ) + "/";
-  getFolderInfo(path);
-});
-
-/*---------------------------------------------------------
-  Item Actions
----------------------------------------------------------*/
-
 /*
  * Rename the current item and returns the new name.
  * by double clicking or by clicking the "Rename" button in
@@ -660,12 +565,6 @@ var deleteItem = function(data) {
   return isDeleted;
 };

-
-// hide message prompt and dimmer if clicked no
-$('.delete_item button.btn_no').on('click', function() {
-  $('.delete_item, .fileinfo .fm_dimmer').hide();
-});
-
 /*---------------------------------------------------------
   Functions to Retrieve File and Folder Details
 ---------------------------------------------------------*/
@@ -771,12 +670,6 @@ var getFolderInfo = function(path, file_type) {
     "<img src='{{ url_for('browser.static', filename='css/aciTree/image/load-root.gif') }}'>"
   );

-  // Retrieve the data and generate the markup.
-  var d = new Date(); // to prevent IE cache issues
-  if ($.urlParam('type')) {
-    url += '&type=' + $.urlParam('type');
-  }
-
   var post_data = {
     'path': path,
     'mode': 'getfolder',
@@ -848,7 +741,7 @@ var getFolderInfo = function(path, file_type) {
             } else {
               result +=
                 '<p><input type="text" class="fm_file_rename" />' +
-                '<span title="' + file_name_original+'">' + fm_filename +
+                '<span class="less_text" title="' + file_name_original+'">' + fm_filename +
                 '</span></p>';
             }
             if (props.Width && props.Width != '') {
@@ -919,7 +812,7 @@ var getFolderInfo = function(path, file_type) {
               result += '<span title="' + (data[key]).Filename + '">' +
                 fm_filename + '</span></td>';
             } else {
-              result += '<p><input type="text" class="fm_file_rename"/><span title="' +
+              result += '<p><input type="text" class="fm_file_rename"/><span class="less_text" title="' +
                 file_name_original + '">' + fm_filename + '</span></p></td>';
             }
             if (props.Size && props.Size != '') {
@@ -994,11 +887,12 @@ var getFolderInfo = function(path, file_type) {
                 'table#contents tbody tr.selected td:first-child p'
               ),
               orig_value = decodeURI($this.find('span').html()),
-              newvalue = orig_value.substring(0, orig_value.indexOf('.'));
+              newvalue = orig_value.substring(0, orig_value.lastIndexOf('.'));

-          if (newvalue === '') {
-           newvalue = orig_value;
+          if (orig_value.lastIndexOf('/') == orig_value.length - 1 || newvalue === '') {
+            newvalue = decodeURI(orig_value);
           }
+
           $this.find('input').toggle().val(newvalue).focus();
           $this.find('span').toggle();

@@ -1116,14 +1010,13 @@ var getFolderInfo = function(path, file_type) {

       $('.fileinfo table#contents tr td p').on('dblclick', function(e) {
         e.stopPropagation();
-        // Prompt to rename file/folder
         var $this = $(this),
             orig_value = decodeURI(
               $this.find('span').attr('title')
-            ),
-            newvalue = orig_value.substring(0, orig_value.indexOf('.'));
+            );

-        if (newvalue === '') {
+        var newvalue = orig_value.substring(0, orig_value.lastIndexOf('.'));
+        if (orig_value.lastIndexOf('/') == orig_value.length - 1 || newvalue === '') {
           newvalue = orig_value;
         }

@@ -1181,6 +1074,7 @@ var getFolderInfo = function(path, file_type) {
       });

       var data_cap = {};
+      data_cap.Capabilities = capabilities;
       /*
        * Bind click events
        * Select items - afolder dblclick
@@ -1212,7 +1106,6 @@ var getFolderInfo = function(path, file_type) {
           }
         });

-        data_cap.Capabilities = capabilities;
         $('.fileinfo').find('#contents li').click(function(e) {
           e.stopPropagation();
           var path = decodeURI($(this).find('.clip span').attr('data-alt')),
@@ -1243,7 +1136,6 @@ var getFolderInfo = function(path, file_type) {
                 '.file_manager #uploader .filemanager-path-group'
               );
             }
-              //getFolderInfo(path);
           } else {
             if (
               has_capability(data_cap, 'select_file') &&
@@ -1291,12 +1183,14 @@ var getFolderInfo = function(path, file_type) {
               $('.file_manager_ok').removeClass('disabled');
               $('.file_manager button.download').attr('disabled', 'disabled');
               $('.file_manager button.delete, .file_manager button.rename').removeAttr('disabled');
+
               // set selected folder name in breadcrums
               $('.file_manager #uploader h1').hide();
               $('.file_manager #uploader .show_selected_file').remove();
-              $('<span class="show_selected_file">'+path+'</span>').appendTo('.file_manager #uploader .filemanager-path-group');
+              $('<span class="show_selected_file">'+path+'</span>').appendTo(
+                '.file_manager #uploader .filemanager-path-group'
+              );
             }
-            //getFolderInfo(path);
           } else {
             if (has_capability(data_cap, 'select_file') && is_protected == undefined) {
               $(this).parent().find('tr.selected').removeClass('selected');
@@ -1348,7 +1242,6 @@ var getFolderInfo = function(path, file_type) {

 // Enable/Disable level up button
 var enab_dis_level_up = function() {
-
   $('.file_manager #uploader h1').show();
   $('.show_selected_file').remove();

@@ -1367,11 +1260,16 @@ var enab_dis_level_up = function() {
   }, 100);
 };

-// Get transaction id to generate request url and
-// to generate config files on runtime
-var transId = getTransId(),
-    t_id = '',
-    t_res;
+/*---------------------------------------------------------
+  Initialization - Entry point
+---------------------------------------------------------*/
+/*
+ * get transaction id to generate request url and
+ * to generate config files on runtime
+ */
+var fm_url = "{{ url_for('file_manager.index') }}get_trans_id",
+    transId = loadData(fm_url),
+    t_id = '';

 if (transId.readyState == 4) {
   t_res = JSON.parse(transId.responseText);
@@ -1382,7 +1280,7 @@ var root_url = '{{ url_for("file_manager.index") }}',
     file_manager_config_json = root_url+t_id+'/file_manager_config.json',
     file_manager_config_js = root_url+'file_manager_config.js',
     fileConnector = root_url+'filemanager/'+t_id+'/',
-    cfg = loadConfigFile(),
+    cfg = loadData(file_manager_config_json),
     config;

 // load user configuration file
@@ -1390,6 +1288,7 @@ if (cfg.readyState == 4) {
   config = JSON.parse(cfg.responseText);
 }

+// set main url to filemanager and its capabilites
 var fileRoot = config.options.fileRoot,
     capabilities = config.options.capabilities;

@@ -1399,16 +1298,13 @@ var fileRoot = config.options.fileRoot,
  */
 var lg = [],
     enjs = '{{ url_for("file_manager.index") }}' + "en.js",
-    lgf = loadLangFile(enjs);
+    lgf = loadData(enjs);

 if (lgf.readyState == 4) {
   lg = JSON.parse(lgf.responseText);
 }

-// Disable home button on load
-$('.file_manager').find('button.home').attr('disabled', 'disabled');
-$('.file_manager').find('button.rename').attr('disabled', 'disabled');
-
+// create and enable user to create new file
 if (
   config.options.dialog_type == 'select_file' ||
   config.options.dialog_type == 'create_file' ||
@@ -1436,14 +1332,14 @@ if (
         have_all_types = (have_all_types || (t == '*'));
       } else {
         select_box += '<option value="' + t +'">' +
-          (t == '*' ? '{{ _('All Files') }}' : t) + "</option>";
+          (t == '*' ? '{{ _("All Files") }}' : t) + "</option>";
         have_all_types = (have_all_types || (t == '*'));
       }
       i++;
     }

     if (!have_all_types) {
-      select_box += '<option value="*">{{ _('All Files') }}</option>';
+      select_box += '<option value="*">{{ _("All Files") }}</option>';
     }
     select_box += "</select><label>{{ _('Format') }}: </label></div>";
   }
@@ -1464,7 +1360,6 @@ if (config.options.dialog_type == 'create_file') {
     '</div>';

   $('.create_mode_dlg').find('.allowed_file_types').prepend(create_file_html);
-
   $('.create_input input[type="text"]').on('keypress, keydown', function() {
     var input_text_len = $(this).val().length;
     if (input_text_len > 0 ) {
@@ -1474,258 +1369,218 @@ if (config.options.dialog_type == 'create_file') {
     }
   });
 }
+
 /*---------------------------------------------------------
-  Initialization
+  Item Actions - Object events
 ---------------------------------------------------------*/

-$(function() {
-  var expandedFolder = '';
-
-  if (config.extra_js) {
-    for(var i=0; i< config.extra_js.length; i++) {
-      $.ajax({
-        url: config.extra_js[i],
-        dataType: "script",
-        async: extra_js_async
-      });
-    }
-  }
+// switch to folder view
+$('.file_manager .fileinfo').on('click', function(e) {
+  enable_disable_btn();
+});

-  if ($.urlParam('expandedFolder') != 0) {
-    expandedFolder = $.urlParam('expandedFolder');
-  }
+// refresh current directory
+$('.file_manager .refresh').on('click', function(e) {
+  enable_disable_btn();
+  var curr_path = $('.currentpath').val(),
+      path = curr_path.substring(
+        0, curr_path.lastIndexOf("/")
+      ) + "/";
+  getFolderInfo(path);
+});

-  // Adjust layout.
-  setDimensions();
-
-  // we finalize the FileManager UI initialization
-  // with localized text if necessary
-  if (config.autoload == true) {
-    $('.upload').append(lg.upload);
-    $('.create').append(lg.new_folder);
-    $('.grid').attr('title', lg.grid_view);
-    $('.list').attr('title', lg.list_view);
-    $('.fileinfo h1').append(lg.select_from_left);
-    $('#itemOptions a[href$="#select"]').append(lg.select);
-    $('#itemOptions a[href$=".download"]').append(lg.download);
-    $('#itemOptions a[href$=".rename"]').append(lg.rename);
-    $('#itemOptions a[href$=".delete"]').append(lg.del);
-    /** Input file Replacement */
-    $('.browse').append('+');
-
-    $('.browse').attr('title', lg.browse);
-
-    $(".newfile").change(function() {
-      $(".filepath").val($(this).val());
-    });
-    /** Input file Replacement - end */
-  }
+// hide message prompt and dimmer if clicked no
+$('.delete_item button.btn_no').on('click', function() {
+  $('.delete_item, .fileinfo .fm_dimmer').hide();
+});

-  // stop click event on dimmer click
-  $('.fileinfo .fm_dimmer').on('click', function(e) {
-    e.stopPropagation();
-  });
+// Disable home button on load
+$('.file_manager').find('button.home').attr('disabled', 'disabled');
+$('.file_manager').find('button.rename').attr('disabled', 'disabled');

-  $('.fileinfo .replace_file').not(
-    $(this).find('span.pull-right')
-  ).on(
-  'click', function(e) {
-    $('#uploader .filemanager-btn-group').unbind().on(
-      'click', function() {
-        $('.fileinfo .delete_item, .fileinfo .replace_file, .fileinfo .fm_dimmer').hide();
-      });
-    e.stopPropagation();
-  });
+// stop click event on dimmer click
+$('.fileinfo .fm_dimmer').on('click', function(e) {
+  e.stopPropagation();
+});

-  // Set initial view state.
-  $('.fileinfo').data('view', config.options.defaultViewMode);
-  setViewButtonsFor(config.options.defaultViewMode);
-
-  // Upload click event
-  $('.file_manager .uploader').on('click', 'a', function(e) {
-    e.preventDefault();
-    var b = $('.currentpath').val();
-    var node_val = $(this).next().text();
-    parent = b.substring(0, b.slice(0, -1).lastIndexOf(node_val));
-    getFolderInfo(parent);
-  });
+$('.fileinfo .replace_file').not(
+  $(this).find('span.pull-right')
+).on(
+'click', function(e) {
+  $('#uploader .filemanager-btn-group').unbind().on(
+    'click', function() {
+      $('.fileinfo .delete_item, .fileinfo .replace_file, .fileinfo .fm_dimmer').hide();
+    });
+  e.stopPropagation();
+});

-  // re-render the home view
-  $('.file_manager .home').click(function() {
-    var currentViewMode = $('.fileinfo').data('view');
-    $('.fileinfo').data('view', currentViewMode);
-    getFolderInfo(fileRoot);
-    enab_dis_level_up();
-  });
+// Set initial view state.
+$('.fileinfo').data('view', config.options.defaultViewMode);
+setViewButtonsFor(config.options.defaultViewMode);
+
+// Upload click event
+$('.file_manager .uploader').on('click', 'a', function(e) {
+  e.preventDefault();
+  var b = $('.currentpath').val();
+  var node_val = $(this).next().text();
+  parent = b.substring(0, b.slice(0, -1).lastIndexOf(node_val));
+  getFolderInfo(parent);
+});

-  // Go one directory back
-  $(".file_manager .level-up").click(function() {
-    var b = $('.currentpath').val();
+// re-render the home view
+$('.file_manager .home').click(function() {
+  var currentViewMode = $('.fileinfo').data('view');
+  $('.fileinfo').data('view', currentViewMode);
+  getFolderInfo(fileRoot);
+  enab_dis_level_up();
+});

-    // Enable/Disable level up button
-    enab_dis_level_up();
+// Go one directory back
+$(".file_manager .level-up").click(function() {
+  var b = $('.currentpath').val();

-    if (b != fileRoot) {
-        parent = b.substring(0, b.slice(0, -1).lastIndexOf("/")) + "/";
-        var d = $(".fileinfo").data("view");
-        $(".fileinfo").data("view", d);
-        getFolderInfo(parent);
-    }
-  });
+  // Enable/Disable level up button
+  enab_dis_level_up();

-  // set buttons to switch between grid and list views.
-  $('.file_manager .grid').click(function() {
-    setViewButtonsFor('grid');
-    $('.fileinfo').data('view', 'grid');
-    enable_disable_btn();
-    getFolderInfo($('.currentpath').val());
-  });
+  if (b != fileRoot) {
+      parent = b.substring(0, b.slice(0, -1).lastIndexOf("/")) + "/";
+      var d = $(".fileinfo").data("view");
+      $(".fileinfo").data("view", d);
+      getFolderInfo(parent);
+  }
+});

-  // Show list mode
-  $('.file_manager .list').click(function() {
-    setViewButtonsFor('list');
-    $('.fileinfo').data('view', 'list');
-    enable_disable_btn();
-    getFolderInfo($('.currentpath').val());
-  });
+// set buttons to switch between grid and list views.
+$('.file_manager .grid').click(function() {
+  setViewButtonsFor('grid');
+  $('.fileinfo').data('view', 'grid');
+  enable_disable_btn();
+  getFolderInfo($('.currentpath').val());
+});

-  // Provide initial values for upload form, status, etc.
-  setUploader(fileRoot);
+// Show list mode
+$('.file_manager .list').click(function() {
+  setViewButtonsFor('list');
+  $('.fileinfo').data('view', 'list');
+  enable_disable_btn();
+  getFolderInfo($('.currentpath').val());
+});

-  $('#uploader').attr('action', fileConnector);
+// Provide initial values for upload form, status, etc.
+setUploader(fileRoot);

-  var data = {
-    'Capabilities': capabilities
-  };
+$('#uploader').attr('action', fileConnector);

-  if (has_capability(data, 'upload')) {
-    Dropzone.autoDiscover = false;
-    // we remove simple file upload element
-    $('.file-input-container').remove();
-    $('.upload').remove();
-    $( ".create" ).before( '<button value="Upload" type="button" title="Upload File" name="upload" id="upload" class="btn fa fa-upload upload"><span></span></button> ' );
-
-    $('.upload').unbind().click(function() {
-      // we create prompt
-      var msg  = '<div id="dropzone-container">' +
-            '<button class="fa fa-times dz_cross_btn"></button>' +
-            '<div id="multiple-uploads" class="dropzone"></div>' +
-            '<div class="prompt-info">' + lg.file_size_limit +
-            config.upload.fileSizeLimit + ' ' + lg.mb + '.</div>',
-            error_flag = false,
-            path = $('.currentpath').val(),
-            filesizelimit = config.upload.fileSizeLimit,
-            // default dropzone value
-            fileSize = (filesizelimit != 'auto') ? filesizelimit : 256,
-            acceptFiles;
-
-      if (config.security.uploadPolicy == 'DISALLOW_ALL') {
-        acceptFiles = '.' + config.security.uploadRestrictions.join(',.');
-      } else {
-        // We allow any extension since we have no easy way to handle the the
-        // built-in `acceptedFiles` params would be handled later by the
-        // connector.
-        acceptFiles = null;
-      }
+var data = {
+  'Capabilities': capabilities
+};

-      if ($.urlParam('type').toString().toLowerCase() == 'images' || config.upload.imagesOnly) {
-        acceptFiles = '.' + config.images.imagesExt.join(',.');
-      }
+// Upload file
+if (has_capability(data, 'upload')) {
+  Dropzone.autoDiscover = false;
+  // we remove simple file upload element
+  $('.file-input-container').remove();
+  $('.upload').remove();
+  $( ".create" ).before( '<button value="Upload" type="button" title="Upload File" name="upload" id="upload" class="btn fa fa-upload upload"><span></span></button> ' );
+
+  $('.upload').unbind().click(function() {
+    // we create prompt
+    var msg  = '<div id="dropzone-container">' +
+          '<button class="fa fa-times dz_cross_btn"></button>' +
+          '<div id="multiple-uploads" class="dropzone"></div>' +
+          '<div class="prompt-info">' + lg.file_size_limit +
+          config.upload.fileSizeLimit + ' ' + lg.mb + '.</div>',
+          error_flag = false,
+          path = $('.currentpath').val(),
+          filesizelimit = config.upload.fileSizeLimit,
+          // default dropzone value
+          fileSize = (filesizelimit != 'auto') ? filesizelimit : 256,
+          acceptFiles;
+
+    if (config.security.uploadPolicy == 'DISALLOW_ALL') {
+      acceptFiles = '.' + config.security.uploadRestrictions.join(',.');
+    } else {
+      // We allow any extension since we have no easy way to handle the the
+      // built-in `acceptedFiles` params would be handled later by the
+      // connector.
+      acceptFiles = null;
+    }

-      $('.file_manager .upload_file').toggle();
-      $('.file_manager .upload_file').html(msg);
-
-      //var previewTemplate = '<div id="dropzone-container">';
-      var previewTemplate = '<div class="file_upload_main dz-preview dz-file-preview">'+
-            '<div class="show_error">' +
-            '<p class="size dz-size" data-dz-size></p>' +
-            '<p class="name dz-filename" data-dz-name></p>' +
-            '</div>' +
-            '<div class="dz-progress"><span class="dz-upload" data-dz-uploadprogress></span></div>' +
-            '<div class="dz-success-mark"><span></span></div>' +
-            '<div class="dz-error-mark"><span></span></div>' +
-            '<div class="dz-error-message"><span data-dz-errormessage></span></div>' +
-            '<a href="javascript:void(0);" class="fa fa-trash dz_file_remove" data-dz-remove></a>' +
-            '</div>';
-
-      $("div#multiple-uploads").dropzone({
-        paramName: "newfile",
-        url: fileConnector + '?config=' + userconfig,
-        maxFilesize: fileSize,
-        maxFiles: config.upload.number,
-        addRemoveLinks: true,
-        previewTemplate: previewTemplate,
-        parallelUploads: config.upload.number,
-        dictMaxFilesExceeded: lg.dz_dictMaxFilesExceeded.replace(
-          "%s", config.upload.number
-        ),
-        dictDefaultMessage: lg.dz_dictDefaultMessage,
-        dictInvalidFileType: lg.dz_dictInvalidFileType,
-        dictFileTooBig: lg.file_too_big + ' ' + lg.file_size_limit +
-          config.upload.fileSizeLimit + ' ' + lg.mb,
-        acceptedFiles: acceptFiles,
-        autoProcessQueue: true,
-        init: function() {
-          var dropzone = this;
-
-          $('.dz_cross_btn').unbind().on('click', function() {
-            $('.file_manager .upload_file').toggle();
-          });
-        },
-        sending: function(file, xhr, formData) {
-          formData.append("mode", "add");
-          formData.append("currentpath", path);
-          $('.upload_file .dz_cross_btn').attr('disabled', 'disabled');
-          setTimeout(function() {}, 10000);
-        },
-        success: function(file, response) {
-          var response = jQuery.parseJSON(response),
-              data = response.data.result,
-              $this = $(file.previewTemplate);
-
-          if (data.Code == 0) {
-            setTimeout(function() {
-              $this.find(".dz-upload").addClass("success");
-            }, 1000);
-            $this.find(".dz-upload").css('width', "100%").html("100%");
-            alertify.success(lg.upload_success);
-          } else {
-            $this.find(".dz-upload").addClass("error");
-            $this.find(".dz-upload").css('width', "0%").html("0%");
-            alertify.error(data.Error);
-          }
-          getFolderInfo(path);
-        },
-        totaluploadprogress: function(progress) {},
-        complete: function(file) {
-          if (
-            this.getUploadingFiles().length === 0 &&
-            this.getQueuedFiles().length === 0
-          ) {}
-          if (file.status == "error") {
-            alertify.error(lg.ERROR_UPLOADING_FILE);
-          }
-          $('.upload_file .dz_cross_btn').removeAttr('disabled');
-          getFolderInfo(path);
+    $('.file_manager .upload_file').toggle();
+    $('.file_manager .upload_file').html(msg);
+
+    //var previewTemplate = '<div id="dropzone-container">';
+    var previewTemplate = '<div class="file_upload_main dz-preview dz-file-preview">'+
+          '<div class="show_error">' +
+          '<p class="size dz-size" data-dz-size></p>' +
+          '<p class="name dz-filename" data-dz-name></p>' +
+          '</div>' +
+          '<div class="dz-progress"><span class="dz-upload" data-dz-uploadprogress></span></div>' +
+          '<div class="dz-success-mark"><span></span></div>' +
+          '<div class="dz-error-mark"><span></span></div>' +
+          '<div class="dz-error-message"><span data-dz-errormessage></span></div>' +
+          '<a href="javascript:void(0);" class="fa fa-trash dz_file_remove" data-dz-remove></a>' +
+          '</div>';
+
+    $("div#multiple-uploads").dropzone({
+      paramName: "newfile",
+      url: fileConnector,
+      maxFilesize: fileSize,
+      maxFiles: config.upload.number,
+      addRemoveLinks: true,
+      previewTemplate: previewTemplate,
+      parallelUploads: config.upload.number,
+      dictMaxFilesExceeded: lg.dz_dictMaxFilesExceeded.replace(
+        "%s", config.upload.number
+      ),
+      dictDefaultMessage: lg.dz_dictDefaultMessage,
+      dictInvalidFileType: lg.dz_dictInvalidFileType,
+      dictFileTooBig: lg.file_too_big + ' ' + lg.file_size_limit +
+        config.upload.fileSizeLimit + ' ' + lg.mb,
+      acceptedFiles: acceptFiles,
+      autoProcessQueue: true,
+      init: function() {
+        var dropzone = this;
+
+        $('.dz_cross_btn').unbind().on('click', function() {
+          $('.file_manager .upload_file').toggle();
+        });
+      },
+      sending: function(file, xhr, formData) {
+        formData.append("mode", "add");
+        formData.append("currentpath", path);
+        $('.upload_file .dz_cross_btn').attr('disabled', 'disabled');
+        setTimeout(function() {}, 10000);
+      },
+      success: function(file, response) {
+        var response = jQuery.parseJSON(response),
+            data = response.data.result,
+            $this = $(file.previewTemplate);
+
+        if (data.Code == 0) {
+          setTimeout(function() {
+            $this.find(".dz-upload").addClass("success");
+          }, 1000);
+          $this.find(".dz-upload").css('width', "100%").html("100%");
+          alertify.success(lg.upload_success);
+        } else {
+          $this.find(".dz-upload").addClass("error");
+          $this.find(".dz-upload").css('width', "0%").html("0%");
+          alertify.error(data.Error);
         }
-      });
+        getFolderInfo(path);
+      },
+      totaluploadprogress: function(progress) {},
+      complete: function(file) {
+        if (file.status == "error") {
+          alertify.error(lg.ERROR_UPLOADING_FILE);
+        }
+        $('.upload_file .dz_cross_btn').removeAttr('disabled');
+        getFolderInfo(path);
+      }
     });
-  }
-
-  // Disable select function if no window.opener
-  if (! (window.opener || window.tinyMCEPopup) ) {
-    $('#itemOptions a[href$="#select"]').remove();
-  }
-  // Keep only browseOnly features if needed
-  if (config.options.browseOnly == true) {
-    $('.newfile').remove();
-    $('.upload').remove();
-    $('.create').remove();
-    $('#toolbar').remove('.rename');
-    $('.contextMenu .rename').remove();
-    $('.contextMenu .delete').remove();
-  }
-  getDetailView(fileRoot + expandedFolder);
-});
-
+  });
+}
+getDetailView(fileRoot);
 })(jQuery);
+//@ sourceURL=utility.js
diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js
index 4a81411..90d8880 100644
--- a/web/pgadmin/static/js/backform.pgadmin.js
+++ b/web/pgadmin/static/js/backform.pgadmin.js
@@ -2080,8 +2080,11 @@
         '</div>',
       '</div>'
     ].join("\n")),
-    events: {
-      "click .select_item": "onSelect",
+    events: function() {
+      // Inherit all default events of InputControl
+      return _.extend({}, Backform.InputControl.prototype.events, {
+        "click .select_item": "onSelect"
+      });
     },
     onSelect: function(e) {
       var dialog_type = this.field.get('dialog_type');


view thread (11+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: Re: [pgAdmin4][Patch]: File Manager & Backform FileControl
  In-Reply-To: <CAM5-9D8mTSgwY8JEcSZv9e8o9VzjVL4O_qj2Gr82AYTY+YW_ww@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox