diff --git a/res/app/control-panes/explorer/explorer-controller.js b/res/app/control-panes/explorer/explorer-controller.js index dfa487a0..478023e5 100644 --- a/res/app/control-panes/explorer/explorer-controller.js +++ b/res/app/control-panes/explorer/explorer-controller.js @@ -1,14 +1,25 @@ module.exports = function ExplorerCtrl($scope) { - $scope.search = '' - $scope.files = [] - $scope.paths = [] + $scope.explorer = { + search: '', + files: [], + paths: [] + } - var listDir = function () { - var path = '/' + $scope.paths.join('/') + $scope.getAbsolutePath = function () { + return ('/' + $scope.explorer.paths.join('/')).replace(/\/\/+/g, '/') + } + + function resetPaths(path) { + $scope.explorer.paths = path.split('/') + } + + var listDir = function listDir() { + var path = $scope.getAbsolutePath() + $scope.explorer.search = path $scope.control.fslist(path) .then(function (result) { - $scope.files = result.body; + $scope.explorer.files = result.body; $scope.$digest(); }) .catch(function (err) { @@ -16,26 +27,37 @@ module.exports = function ExplorerCtrl($scope) { }) } - $scope.dirEnter = function (name) { - if (name) { - $scope.paths.push(name) + $scope.dirEnterLocation = function () { + if ($scope.explorer.search) { + resetPaths($scope.explorer.search) + listDir() + $scope.explorer.search = $scope.getAbsolutePath() } - listDir() - $scope.search = '' } - $scope.dirJump = function () { - if ($scope.paths.length !== 0) { - $scope.paths.pop() + $scope.dirEnter = function (name) { + if (name) { + $scope.explorer.paths.push(name) } listDir() + $scope.explorer.search = $scope.getAbsolutePath() + } + + $scope.dirUp = function () { + if ($scope.explorer.paths.length !== 0) { + $scope.explorer.paths.pop() + } + listDir() + $scope.explorer.search = $scope.getAbsolutePath() } $scope.getFile = function (file) { - var path = '/' + $scope.paths.join('/') + '/' + file + var path = $scope.getAbsolutePath() + '/' + file $scope.control.fsretrieve(path) .then(function (result) { - location.href = result.body.href + "?download" + if (result.body) { + location.href = result.body.href + "?download" + } }) .catch(function (err) { alert(err.message) diff --git a/res/app/control-panes/explorer/explorer.jade b/res/app/control-panes/explorer/explorer.jade index 8d582586..40b420f2 100644 --- a/res/app/control-panes/explorer/explorer.jade +++ b/res/app/control-panes/explorer/explorer.jade @@ -1,22 +1,19 @@ -//.stf-fs(ng-controller='ExplorerCtrl') .widget-container.fluid-height(ng-controller='ExplorerCtrl').stf-explorer .heading - //.row: .col-md-6 - span /{{paths.join("/")}} - button.btn.btn-xm.btn-primary-outline(ng-click='dirJump()') - span(translate) Back - - form.input-group.form-inline(ng-submit='dirEnter(search)') - input(type='text', ng-model='search', placeholder="Dir or file ...").form-control + form.input-group.form-inline(name='explorerForm', ng-submit='dirEnterLocation()') span.input-group-btn - button.btn.btn-default.btn-primary-outline(type='submit') - i.fa.fa-search - span(translate) Go + button.btn.btn-primary-outline(ng-click='dirUp()') + i.fa.fa-level-up + input(type='text', ng-model='explorer.search', + ng-enter='dirEnterLocation()' + autocorrect='off', autocapitalize='off', spellcheck='false').form-control + span.input-group-btn + button.btn.btn-primary-outline(type='submit') + i.fa.fa-play .widget-content.padded.selectable - - table.table.table-hover.dataTable.ng-table + table.table.table-hover.table-condensed.dataTable.ng-table thead tr th @@ -28,7 +25,7 @@ th div(translate) Permissions tbody - tr.header(ng-repeat='f in files | filter:search | orderBy: ["-mode|fileIsDir", "+name"]') + tr.header(ng-repeat='f in explorer.files | filter:search | orderBy: ["-mode|fileIsDir", "+name"]') td button.btn.btn-sm.btn-primary-outline( ng-click='dirEnter(f.name)', ng-show='f.mode|fileIsDir')