diff --git a/src/filemanager.html b/src/filemanager.html index 2eb1bf273..92d0ccf99 100644 --- a/src/filemanager.html +++ b/src/filemanager.html @@ -232,7 +232,7 @@ -
+
diff --git a/src/js/filemanager.js b/src/js/filemanager.js index 6f02f79f7..b56388b53 100644 --- a/src/js/filemanager.js +++ b/src/js/filemanager.js @@ -57,6 +57,7 @@ app.controller('FileManagerController', ['$scope', '$timeout', 'Client', functio $scope.initialized = false; $scope.status = null; + $scope.busy = true; $scope.client = Client; $scope.cwd = '/'; $scope.cwdParts = []; @@ -112,6 +113,16 @@ app.controller('FileManagerController', ['$scope', '$timeout', 'Client', functio return '/' + filePath; } + function download(entry) { + var filePath = sanitize($scope.cwd + '/' + entry.fileName); + + if (entry.isDirectory) return; + + Client.filesGet($scope.appId, filePath, true, function (error) { + if (error) return Client.error(error); + }); + }; + $scope.dragEnter = function ($event, entry) { $event.originalEvent.stopPropagation(); $event.originalEvent.preventDefault(); @@ -187,7 +198,10 @@ app.controller('FileManagerController', ['$scope', '$timeout', 'Client', functio } $scope.refresh = function () { + $scope.busy = true; + Client.filesGet($scope.appId, $scope.cwd, false, function (error, result) { + $scope.busy = false; if (error) return Client.error(error); $scope.entries = result.entries; @@ -195,42 +209,32 @@ app.controller('FileManagerController', ['$scope', '$timeout', 'Client', functio }; $scope.open = function (entry) { + if ($scope.busy) return; + var filePath = sanitize($scope.cwd + '/' + entry.fileName); if (entry.isDirectory) { - setDirectory(filePath); + $scope.changeDirectory(filePath); } else if (entry.isFile) { $scope.textEditor.show(entry); } else {} }; - function download(entry) { - var filePath = sanitize($scope.cwd + '/' + entry.fileName); - - if (entry.isDirectory) return; - - Client.filesGet($scope.appId, filePath, true, function (error) { - if (error) return Client.error(error); - }); - }; - $scope.goDirectoryUp = function () { - setDirectory($scope.cwd + '/..'); + $scope.changeDirectory($scope.cwd + '/..'); }; $scope.changeDirectory = function (path) { - setDirectory(path); - }; - - function setDirectory(path) { path = sanitize(path); if ($scope.cwd === path) return; + location.hash = path; + $scope.cwd = path; $scope.cwdParts = path.split('/').filter(function (p) { return !!p; }).map(function (p, i) { return { name: p, path: path.split('/').slice(0, i+2).join('/') }; }); $scope.refresh(); - } + }; $scope.uploadStatus = { busy: false, @@ -532,6 +536,12 @@ app.controller('FileManagerController', ['$scope', '$timeout', 'Client', functio init(); + window.addEventListener('hashchange', function () { + $scope.$apply(function () { + $scope.changeDirectory(window.location.hash.slice(1)); + }); + }); + // setup all the dialog focus handling ['newDirectoryModal', 'renameEntryModal'].forEach(function (id) { $('#' + id).on('shown.bs.modal', function () { @@ -547,5 +557,4 @@ app.controller('FileManagerController', ['$scope', '$timeout', 'Client', functio elem[0].setSelectionRange(0, text.indexOf('.')); }); }); - }]); diff --git a/src/theme.scss b/src/theme.scss index 95c2be2a0..71562257c 100644 --- a/src/theme.scss +++ b/src/theme.scss @@ -1691,6 +1691,10 @@ tag-input { .file-list { overflow: auto; border: 2px solid transparent; + + &.busy { + opacity: 0.5; + } } table {