public inbox for [email protected]
help / color / mirror / Atom feedFrom: Surinder Kumar <[email protected]>
To: pgadmin-hackers <[email protected]>
Subject: Re: [pgAdmin4][Patch]: File Manager & Backform FileControl
Date: Fri, 13 May 2016 16:33:55 +0530
Message-ID: <CAM5-9D9Dt6Nvm2V3z-S=QRc8c8eDeC3Yr-DzpOEmuumGRq2PXw@mail.gmail.com> (raw)
In-Reply-To: <CAG7mmoxh-a-3HuWLrJ+Vod2bypc9eY7Ht5NaLW_xjQdv9nT2Nw@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>
List-Unsubscribe: <mailto:[email protected]?body=unsub%20pgadmin-hackers>
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_changes_v1.patch (14.8K, 3-FileManager_changes_v1.patch)
download | inline diff:
diff --git a/TODO.txt b/TODO.txt
index 7ec3ef0..7abac8f 100644
--- a/TODO.txt
+++ b/TODO.txt
@@ -17,7 +17,7 @@ New functionality added in PG 9.5 for this module as below:
- SET WITH OIDS
- SET WITHOUT OIDS
-To add this functionality we need to add Columns, Triggers and Constraints as
+To add this functionality we need to add Columns, Triggers and Constraints as
separate Nodes under the Foreign Table Node.
Query Tool updateable recordset support
@@ -26,3 +26,12 @@ Query Tool updateable recordset support
Add smarts to the Query Tool to allow it to recognise if a query produces a
data set that would be updateable (e.g. from a single table, all primary key
columns present), and if so, allow editing.
+
+Add support for file type description in File type selection combo box
+----------------------------------------------------------------------
+
+File type selection combo box should support file type description.
+i.e.
+Query/SQL File (*.sql)
+CSV File (*.csv)
+All Files (*.* | *)
diff --git a/web/pgadmin/misc/file_manager/__init__.py b/web/pgadmin/misc/file_manager/__init__.py
index e6c4e00..81b2984 100644
--- a/web/pgadmin/misc/file_manager/__init__.py
+++ b/web/pgadmin/misc/file_manager/__init__.py
@@ -233,36 +233,6 @@ def delete_trans_id(trans_id):
data={'status': True}
)
-
-def __get_drives(drive_name=None):
- """
- This is a generic function which returns the default path for storage
- manager dialog irrespective of any Platform type to list all
- files and directories.
- Platform windows:
- if no path is given, it will list volumes, else list directory
- Platform unix:
- it returns path to root directory if no path is specified.
- """
- if _platform == "win32":
- try:
- drives = []
- bitmask = ctypes.windll.kernel32.GetLogicalDrives()
- for letter in letters:
- if bitmask & 1:
- drives.append(letter)
- bitmask >>= 1
- if (drive_name != '' and drive_name is not None and
- drive_name in drives):
- return "{0}{1}".format(drive_name, ':/')
- else:
- return drives # return drives if no argument is passed
- except Exception:
- return 'C:/'
- else:
- return '/'
-
-
class Filemanager(object):
"""FileManager Class."""
def __init__(self, trans_id):
@@ -396,14 +366,43 @@ class Filemanager(object):
return make_json_response(data={'status': True})
@staticmethod
+ def _get_drives(drive_name=None):
+ """
+ This is a generic function which returns the default path for storage
+ manager dialog irrespective of any Platform type to list all
+ files and directories.
+ Platform windows:
+ if no path is given, it will list volumes, else list directory
+ Platform unix:
+ it returns path to root directory if no path is specified.
+ """
+ if _platform == "win32":
+ try:
+ drives = []
+ bitmask = ctypes.windll.kernel32.GetLogicalDrives()
+ for letter in letters:
+ if bitmask & 1:
+ drives.append(letter)
+ bitmask >>= 1
+ if (drive_name != '' and drive_name is not None and
+ drive_name in drives):
+ return "{0}{1}".format(drive_name, ':/')
+ else:
+ return drives # return drives if no argument is passed
+ except Exception:
+ return ['C:/']
+ else:
+ return '/'
+
+ @staticmethod
def list_filesystem(dir, path, trans_data, file_type):
"""
It lists all file and folders within the given
directory.
"""
files = {}
- if (_platform == "win32" and path == '/') and (not dir):
- drives = __get_drives()
+ if (_platform == "win32" and path == '/') and dir is None:
+ drives = Filemanager._get_drives()
for drive in drives:
protected = 0
path = file_name = "{0}:/".format(drive)
@@ -426,6 +425,8 @@ class Filemanager(object):
}
return files
+ if dir is None:
+ dir = ""
orig_path = "{0}{1}".format(dir, path)
user_dir = path
folders_only = trans_data['folders_only'] if 'folders_only' in \
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 cebed17..fcf1e8f 100755
--- a/web/pgadmin/misc/file_manager/static/css/file_manager.css
+++ b/web/pgadmin/misc/file_manager/static/css/file_manager.css
@@ -596,14 +596,27 @@ a.dz-remove {
border: 1px solid black;
}
+.fileinfo .fm_dimmer {
+ height: calc(100% - 32px);
+ display: none;
+ top: 32px;
+ background: black;
+ opacity: 0.5;
+ z-index: 1;
+ width: 100%;
+ position: absolute;
+}
+
.fileinfo .delete_item, .fileinfo .replace_file {
display: none;
padding: 7px 5px;
opacity: 0.8;
color: #fff;
border: 1px solid darkgrey;
+ border-left: 0;
+ border-right: 0;
background: #000;
- box-shadow: 1px 0px 3px 1px red;
+ box-shadow: 1px 0px 3px 1px white;
}
.fileinfo .delete_item span.pull-right .btn,
@@ -612,11 +625,7 @@ a.dz-remove {
color: #000;
background: #fff;
font-size: 12px;
-}
-
-.fileinfo .delete_item span,
-.fileinfo .replace_file span {
- margin-right: 10px;
+ margin-right: 4px;
}
.upload_file .dz_cross_btn {
@@ -658,3 +667,16 @@ a.dz-remove {
background: #F9F8F7;
border: 1px inset #ccc;
}
+
+.file_listing .no_folder_found {
+ text-align: center;
+ position: absolute;
+ top: 35;
+ width: 100%;
+}
+
+.fileinfo .is_file_replace {
+ width: 100%;
+ height: 100%;
+ background: #ccc;
+}
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 51044da..d1f1bbb 100755
--- a/web/pgadmin/misc/file_manager/templates/file_manager/index.html
+++ b/web/pgadmin/misc/file_manager/templates/file_manager/index.html
@@ -43,6 +43,8 @@
<button type='button' class='btn btn_no'>NO</button>
</span>
</div>
+ <div class='fm_dimmer'>
+ </div>
<div class="file_listing">
</div>
<div class="upload_file dropzone">
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 535a890..bf7171f 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
@@ -451,9 +451,9 @@ define([
};
},
replace_file: function() {
- $('.replace_file').show();
+ $('.replace_file, .fm_dimmer').show();
$('.replace_file .btn_yes').click(function(self) {
- $('.replace_file').hide();
+ $('.replace_file, .fm_dimmer').hide();
var selected_item = $('.allowed_file_types .create_input input[type="text"]').val(),
newFile = $('.currentpath').val() + selected_item,
newFile = newFile.substr(1);
@@ -461,7 +461,7 @@ define([
$('.file_manager_create_cancel').trigger('click');
});
$('.replace_file .btn_no').click(function() {
- $('.replace_file').hide();
+ $('.replace_file, .fm_dimmer').hide();
});
},
is_file_exist: function() {
diff --git a/web/pgadmin/misc/file_manager/templates/file_manager/js/languages/en.js b/web/pgadmin/misc/file_manager/templates/file_manager/js/languages/en.js
index dba85e8..cc2b91b 100644
--- a/web/pgadmin/misc/file_manager/templates/file_manager/js/languages/en.js
+++ b/web/pgadmin/misc/file_manager/templates/file_manager/js/languages/en.js
@@ -37,5 +37,6 @@
"successful_delete": "Delete successful.",
"successful_rename": "Rename successful.",
"upload": "Upload",
- "yes": "Yes"
+ "yes": "Yes",
+ "could_not_retrieve_folder": "No files/folders found"
}
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 7fcb2b9..75b4982 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
@@ -231,7 +231,7 @@ var getFilename = function(filename) {
// helpful in show/hide toolbar button for Windows
var hideButtons = function() {
var current_path = $('.currentpath').val();
- if(config.options.platform_type == 'win32' && current_path == "/")
+ if(config.options.platform_type == 'win32' && current_path === "")
return true;
return false;
};
@@ -254,7 +254,7 @@ var setUploader = function(path){
split_path = split_path.filter(function(e){return e;});
// set empty path if it is windows
- if (config.options.platform_type === "win32" && config.options.show_volumes) {
+ if (config.options.platform_type === "win32" && config.options.show_volumes == "True") {
mypath = "";
}
else if (split_path.length === 0)
@@ -269,7 +269,7 @@ var setUploader = function(path){
$(mypath).appendTo($('.storage_dialog #uploader h1'));
}
else {
- mypath = $('<b>'+split_path[i]+'</b>');
+ mypath = $('<b>'+split_path[i]+'/</b>');
$(mypath).appendTo($('.storage_dialog #uploader h1'));
}
}
@@ -284,7 +284,7 @@ var setUploader = function(path){
// create new folder
$('.create').unbind().click(function(){
- var foldername = lg.default_foldername;
+ var foldername = lg.new_folder;
var $file_element,
$file_element_list;
@@ -408,7 +408,8 @@ var bindToolbar = function(data){
$('.file_manager').find('button.delete').hide();
} else {
$('.file_manager').find('button.delete').click(function(){
- $('.fileinfo .delete_item').show();
+ // hide dimmer
+ $('.fileinfo .delete_item, .fm_dimmer').show();
});
// take action based on pressed button yes or no
@@ -433,6 +434,8 @@ var bindToolbar = function(data){
deleteItem(data);
}
}
+ // hide dimmer
+ $('.fileinfo .fm_dimmer').hide();
});
}
@@ -627,9 +630,9 @@ var deleteItem = function(data){
};
-// hide message prompt if clicked no
+// hide message prompt and dimmer if clicked no
$('.delete_item button.btn_no').on('click', function() {
- $('.delete_item').hide();
+ $('.delete_item, .fileinfo .fm_dimmer').hide();
});
/*---------------------------------------------------------
@@ -642,7 +645,10 @@ $('.delete_item button.btn_no').on('click', function() {
var getDetailView = function(path){
if(path.lastIndexOf('/') == path.length - 1){
var allowed_types = config.options.allowed_file_types;
- getFolderInfo(path, allowed_types[0]);
+ var set_type = allowed_types[0];
+ if(allowed_types[0] == "*")
+ set_type = allowed_types[1];
+ getFolderInfo(path, set_type);
}
};
@@ -747,7 +753,7 @@ var getFolderInfo = function(path, file_type=''){
}
// generate HTML for files/folder and render into container
- if(data){
+ if(!_.isEmpty(data)){
if($('.fileinfo').data('view') == 'grid') {
result += '<ul id="contents" class="grid">';
for(key in data) {
@@ -862,7 +868,18 @@ var getFolderInfo = function(path, file_type=''){
result += '</table>';
}
} else {
- result += '<h1>' + lg.could_not_retrieve_folder + '</h1>';
+ if($('.fileinfo').data('view') == 'grid') {
+ result += '<ul id="contents" class="grid"></ul>';
+ }
+ else {
+ result += '<table id="contents" class="list">';
+ result += '<thead><tr><th class="headerSortDown"><span>' + lg.name + '</span></th><th><span>' + lg.size + '</span></th><th><span>' + lg.modified + '</span></th></tr></thead>';
+ result += '<tbody>';
+ }
+ result += '<h1 class="no_folder_found">' + lg.could_not_retrieve_folder + '</h1>';
+ cap_no_folders = ['upload', 'create']
+ data['Capabilities'] = cap_no_folders;
+ bindToolbar(data);
}
// Add the new markup to the DOM.
@@ -1258,10 +1275,25 @@ if (config.options.dialog_type == 'select_file' ||
var allowed_types = config.options.allowed_file_types,
types_len = allowed_types.length;
if(types_len > 0) {
- var i = 0,
+ var i = 0, j = 0
select_box = "<div class='change_file_types'><select name='type'>";
while(i < types_len) {
- select_box += "<option value="+allowed_types[i]+">"+(allowed_types[i] == '*' ? 'All Files': allowed_types[i])+"</option>";
+
+ if(j == 1) {
+ select_box += "<option value="+allowed_types[i]+" selected>"+allowed_types[i]+"</option>";
+ j = 0;
+ }
+ else {
+ if(allowed_types[i] == '*'){
+ j = 1;
+ file_type = "All Files";
+ }
+ else {
+ file_type = allowed_types[i];
+ }
+
+ select_box += "<option value="+allowed_types[i]+">"+file_type+"</option>";
+ }
i++;
}
select_box += "</select>";
@@ -1341,10 +1373,22 @@ $(function(){
$(".newfile").change(function() {
$(".filepath").val($(this).val());
});
-
/** Input file Replacement - end */
}
+ // stop click event on dimmer click
+ $('.fileinfo .fm_dimmer').on('click', function(e) {
+ e.stopPropagation();
+ });
+
+ $('.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();
+ });
+
+
// Set initial view state.
$('.fileinfo').data('view', config.options.defaultViewMode);
setViewButtonsFor(config.options.defaultViewMode);
diff --git a/web/pgadmin/utils/paths.py b/web/pgadmin/utils/paths.py
index 19c88a2..81b0f74 100644
--- a/web/pgadmin/utils/paths.py
+++ b/web/pgadmin/utils/paths.py
@@ -28,12 +28,15 @@ def get_storage_directory():
), 'storage'
)
)
+
+ if storage_dir is None:
+ return None
+
username = current_user.email.split('@')[0]
if len(username) == 0 or username[0].isdigit():
username = 'pga_user_' + username
storage_dir = os.path.join(storage_dir, username)
- print(storage_dir)
if not os.path.exists(storage_dir):
os.makedirs(storage_dir, int('700', 8))
@@ -55,7 +58,7 @@ def init_app(app):
)
)
- if not os.path.isdir(storage_dir):
+ if storage_dir and not os.path.isdir(storage_dir):
if os.path.exists(storage_dir):
raise Exception(
'The value specified for as the storage directory is not a directory!'
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-9D9Dt6Nvm2V3z-S=QRc8c8eDeC3Yr-DzpOEmuumGRq2PXw@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