Better busy handling in filemanager on slow storage
This commit is contained in:
@@ -127,8 +127,11 @@ app.controller('FileManagerController', ['$scope', '$translate', '$timeout', 'Cl
|
||||
function openPath(path) {
|
||||
path = sanitize(path);
|
||||
|
||||
// we always show the parent path, even if overlayed by a mediaviewer
|
||||
var parentPath = sanitize(path + '/..');
|
||||
|
||||
$scope.busy = true;
|
||||
|
||||
// nothing changes here, mostly triggered when editor is closed
|
||||
if ($scope.cwd === path) {
|
||||
$scope.busy = false;
|
||||
@@ -140,7 +143,11 @@ app.controller('FileManagerController', ['$scope', '$translate', '$timeout', 'Cl
|
||||
if (!entry) return Client.error('No such file or folder: ' + path);
|
||||
|
||||
if (entry.isDirectory) {
|
||||
$scope.changeDirectory(path);
|
||||
$scope.cwd = path;
|
||||
$scope.cwdParts = path.split('/').filter(function (p) { return !!p; }).map(function (p, i) { return { name: decodeURIComponent(p), path: path.split('/').slice(0, i+1).join('/') }; });
|
||||
|
||||
// refresh will set busy to false once done
|
||||
$scope.refresh();
|
||||
} else if (entry.isFile) {
|
||||
var mimeType = Mimer().get(entry.fileName);
|
||||
var mimeGroup = mimeType.split('/')[0];
|
||||
@@ -154,15 +161,15 @@ app.controller('FileManagerController', ['$scope', '$translate', '$timeout', 'Cl
|
||||
} else {
|
||||
Client.filesGet($scope.id, $scope.type, path, 'open', function (error) { if (error) return Client.error(error); });
|
||||
}
|
||||
}
|
||||
|
||||
$scope.busy = false;
|
||||
$scope.busy = false;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Client.filesGet($scope.id, $scope.type, parentPath, 'data', function (error, result) {
|
||||
if (error) return Client.error(error);
|
||||
if (error) return openPath(path); // try again
|
||||
|
||||
// amend icons
|
||||
result.entries.forEach(function (e) {
|
||||
@@ -183,10 +190,9 @@ app.controller('FileManagerController', ['$scope', '$translate', '$timeout', 'Cl
|
||||
});
|
||||
|
||||
$scope.entries = result.entries;
|
||||
$scope.cwd = parentPath;
|
||||
$scope.cwdParts = parentPath.split('/').filter(function (p) { return !!p; }).map(function (p, i) { return { name: decodeURIComponent(p), path: path.split('/').slice(0, i+1).join('/') }; });
|
||||
|
||||
// call itself now that we know
|
||||
$scope.cwd = parentPath;
|
||||
openPath(path);
|
||||
});
|
||||
}
|
||||
@@ -363,7 +369,6 @@ app.controller('FileManagerController', ['$scope', '$translate', '$timeout', 'Cl
|
||||
$scope.busy = true;
|
||||
|
||||
Client.filesGet($scope.id, $scope.type, $scope.cwd, 'data', function (error, result) {
|
||||
$scope.busy = false;
|
||||
if (error) return Client.error(error);
|
||||
|
||||
// amend icons
|
||||
@@ -385,6 +390,8 @@ app.controller('FileManagerController', ['$scope', '$translate', '$timeout', 'Cl
|
||||
});
|
||||
|
||||
$scope.entries = result.entries;
|
||||
|
||||
$scope.busy = false;
|
||||
});
|
||||
};
|
||||
|
||||
@@ -536,7 +543,7 @@ app.controller('FileManagerController', ['$scope', '$translate', '$timeout', 'Cl
|
||||
};
|
||||
|
||||
$scope.goDirectoryUp = function () {
|
||||
$scope.changeDirectory($scope.cwd + '/..');
|
||||
$scope.openPath($scope.cwd + '/..');
|
||||
};
|
||||
|
||||
$scope.changeDirectory = function (path) {
|
||||
@@ -545,11 +552,6 @@ app.controller('FileManagerController', ['$scope', '$translate', '$timeout', 'Cl
|
||||
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: decodeURIComponent(p), path: path.split('/').slice(0, i+1).join('/') }; });
|
||||
|
||||
$scope.refresh();
|
||||
};
|
||||
|
||||
$scope.uploadStatus = {
|
||||
|
||||
Reference in New Issue
Block a user