Browse Source

FR #63: Option to show hidden folders on Unix

pull/423/merge
Safihre 9 years ago
committed by shypike
parent
commit
c7d9e5ce90
  1. 7
      interfaces/Config/templates/_inc_footer_uc.tmpl
  2. 15
      interfaces/Config/templates/staticcfg/css/style.css
  3. 14
      interfaces/Config/templates/staticcfg/js/script.js
  4. 4
      sabnzbd/api.py
  5. 6
      sabnzbd/utils/pathbrowser.py

7
interfaces/Config/templates/_inc_footer_uc.tmpl

@ -12,6 +12,13 @@
<div class="modal-body">
</div>
<div class="modal-footer">
<!--#if not $nt#-->
<div class="checkbox">
<label>
<input type="checkbox" id="show_hidden_folders"> <span>$T('systemFolders')</span>
</label>
</div>
<!--#end if#-->
<button type="button" class="btn btn-danger" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span> $T('cancel')</button>
<button type="button" class="btn btn-default" id="filebrowser_modal_accept"><span class="glyphicon glyphicon-ok"></span> $T('rss-accept')</button>
</div>

15
interfaces/Config/templates/staticcfg/css/style.css

@ -408,6 +408,21 @@ textarea:hover, input[type="date"]:hover, input[type="datetime"]:hover, input[ty
margin-right: 10px;
top: 0;
}
#filebrowser_modal .checkbox {
float: left;
margin: 8px 5px 0x;
}
#filebrowser_modal .checkbox input {
margin-top: 1px;
}
#filebrowser_modal .checkbox input+span {
opacity: 0.6;
font-weight: bold;
}
#filebrowser_modal .checkbox input:checked+span,
#filebrowser_modal .checkbox span:hover {
opacity: 1;
}
/* Fix for shifting scrollbars when opening modals */
.modal-open[style="padding-right: 17px;"] .navbar-fixed-top {
padding-right: 17px;

14
interfaces/Config/templates/staticcfg/js/script.js

@ -113,6 +113,12 @@
$('#filebrowser_modal').modal('hide');
return false;
})
// Show hidden folders
$('#show_hidden_folders').off('change')
$('#show_hidden_folders').on('change', function() {
self.browse(self.currentBrowserPath , folderBrowseUrl);
})
// Use custom title instead of default and open modal
$('#filebrowser_modal .modal-header h4').text(this.fileBrowserTitle);
@ -124,15 +130,15 @@
// Self-reference
var self = this;
// Nothing changed
if (this.currentBrowserPath === path) return;
// Still loading
if (this.currentRequest) this.currentRequest.abort();
// Show hidden folders on Linux?
var extraHidden = $('#show_hidden_folders').is(':checked') ? '&show_hidden_folders=1' : '';
// Get current folders
this.currentBrowserPath = path;
this.currentRequest = $.getJSON(endpoint, { name: path }, function (data) {
this.currentRequest = $.getJSON(endpoint + extraHidden, { name: path }, function (data) {
// Clean
self.fileBrowserDialog.empty();

4
sabnzbd/api.py

@ -775,6 +775,7 @@ def _api_undefined(name, output, kwargs):
def _api_browse(name, output, kwargs):
""" Return tree of local path """
compact = kwargs.get('compact')
if compact and compact == '1':
paths = []
name = platform_encode(kwargs.get('term', ''))
@ -782,7 +783,8 @@ def _api_browse(name, output, kwargs):
return report(output, keyword='', data=paths)
else:
name = platform_encode(name)
paths = folders_at_path(name, True)
show_hidden = kwargs.get('show_hidden_folders')
paths = folders_at_path(name, True, show_hidden)
return report(output, keyword='paths', data=paths)

6
sabnzbd/utils/pathbrowser.py

@ -52,7 +52,7 @@ def get_win_drives():
bitmask >>= 1
return drives
def folders_at_path(path, include_parent = False):
def folders_at_path(path, include_parent = False, show_hidden = False):
""" Returns a list of dictionaries with the folders contained at the given path
Give the empty string as the path to list the contents of the root path
under Unix this means "/", on Windows this will be a list of drive letters)
@ -90,8 +90,10 @@ def folders_at_path(path, include_parent = False):
try:
if NT:
doit = (win32api.GetFileAttributes(fpath) & MASK) == TMASK and filename != 'PerfLogs'
else:
elif not show_hidden:
doit = not filename.startswith('.')
else:
doit = True
except:
doit = False
if doit:

Loading…
Cancel
Save