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 @@ +
+
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 = $(''+split_path[i]+''); + mypath = $(''+split_path[i]+'/'); $(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 += '