diff --git a/src/filemanager.html b/src/filemanager.html index 8f5b7570a..26ce3dfbd 100644 --- a/src/filemanager.html +++ b/src/filemanager.html @@ -326,7 +326,7 @@
  • {{ 'filemanager.toolbar.openTerminal' | tr }}
  • Volumes
  • -
  • {{ volume.name }}
  • +
  • {{ volume.name }}
  • diff --git a/src/js/client.js b/src/js/client.js index 535a47296..b77a51a6c 100644 --- a/src/js/client.js +++ b/src/js/client.js @@ -2882,8 +2882,14 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout // FileManager API // mode can be 'download', 'open', 'link' or 'data' + function getObjpath(id, type) { + if (type === 'mail') return 'mailserver'; + if (type === 'app') return 'apps/' + id; + if (type === 'volume') return 'volumes/' + id; + } + Client.prototype.filesGet = function (id, type, path, mode, callback) { - var objpath = (type === 'app' ? 'apps/' : 'volumes/') + id; + var objpath = getObjpath(id, type); if (mode === 'download') { window.open(client.apiOrigin + '/api/v1/' + objpath + '/files/' + path + '?download=true&access_token=' + token); @@ -2909,7 +2915,7 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout }; Client.prototype.filesRemove = function (id, type, path, callback) { - var objpath = (type === 'app' ? 'apps/' : 'volumes/') + id; + var objpath = getObjpath(id, type); del('/api/v1/' + objpath + '/files/' + path, null, function (error, data, status) { if (error) return callback(error); @@ -2920,7 +2926,7 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout }; Client.prototype.filesExtract = function (id, type, path, callback) { - var objpath = (type === 'app' ? 'apps/' : 'volumes/') + id; + var objpath = getObjpath(id, type); put('/api/v1/' + objpath + '/files/' + path, { action: 'extract' }, {}, function (error, data, status) { if (error) return callback(error); @@ -2931,7 +2937,7 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout }; Client.prototype.filesChown = function (id, type, path, uid, recursive, callback) { - var objpath = (type === 'app' ? 'apps/' : 'volumes/') + id; + var objpath = getObjpath(id, type); put('/api/v1/' + objpath + '/files/' + path, { action: 'chown', uid: uid, recursive: recursive }, {}, function (error, data, status) { if (error) return callback(error); @@ -2942,7 +2948,7 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout }; Client.prototype.filesRename = function (id, type, path, newPath, callback) { - var objpath = (type === 'app' ? 'apps/' : 'volumes/') + id; + var objpath = getObjpath(id, type); put('/api/v1/' + objpath + '/files/' + path, { action: 'rename', newFilePath: decodeURIComponent(newPath) }, {}, function (error, data, status) { if (error) return callback(error); @@ -2955,7 +2961,7 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout Client.prototype.filesCopy = function (id, type, path, newPath, callback) { var that = this; - var objpath = (type === 'app' ? 'apps/' : 'volumes/') + id; + var objpath = getObjpath(id, type); put('/api/v1/' + objpath + '/files/' + path, { action: 'copy', newFilePath: decodeURIComponent(newPath) }, {}, function (error, data, status) { if (error && error.statusCode === 409) return that.filesCopy(id, type, path, newPath + '-copy', callback); @@ -2967,7 +2973,7 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout }; Client.prototype.filesCreateDirectory = function (id, type, path, callback) { - var objpath = (type === 'app' ? 'apps/' : 'volumes/') + id; + var objpath = getObjpath(id, type); post('/api/v1/' + objpath + '/files/' + path, { directory: decodeURIComponent(path) }, {}, function (error, data, status) { if (error) return callback(error); @@ -2978,7 +2984,7 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout }; Client.prototype.filesCreateFile = function (id, type, path, callback) { - var objpath = (type === 'app' ? 'apps/' : 'volumes/') + id; + var objpath = getObjpath(id, type); post('/api/v1/' + objpath + '/files/' + path, {}, {}, function (error, data, status) { if (error) return callback(error); @@ -2989,7 +2995,7 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout }; Client.prototype.filesUpload = function (id, type, path, file, overwrite, progressHandler, callback) { - var objpath = (type === 'app' ? 'apps/' : 'volumes/') + id; + var objpath = getObjpath(id, type); var fd = new FormData(); fd.append('file', file); diff --git a/src/js/filemanager.js b/src/js/filemanager.js index c3db87ccf..3180ff7c5 100644 --- a/src/js/filemanager.js +++ b/src/js/filemanager.js @@ -65,8 +65,8 @@ app.controller('FileManagerController', ['$scope', '$translate', '$timeout', 'Cl $scope.client = Client; $scope.cwd = null; $scope.cwdParts = []; - $scope.id = search.appId || search.volumeId; - $scope.type = search.appId ? 'app' : 'volume'; + $scope.id = search.id; + $scope.type = search.type; $scope.rootDirLabel = ''; $scope.title = ''; $scope.entries = []; @@ -996,7 +996,14 @@ app.controller('FileManagerController', ['$scope', '$translate', '$timeout', 'Cl Client.refreshUserInfo(function (error) { if (error) return Client.initError(error, init); - var getter = $scope.type === 'app' ? Client.getApp.bind(Client, $scope.id) : Client.getVolume.bind(Client, $scope.id); + var getter; + if ($scope.type === 'app') { + getter = Client.getApp.bind(Client, $scope.id); + } else if ($scope.type === 'volume') { + getter = Client.getVolume.bind(Client, $scope.id); + } else if ($scope.type === 'mail') { + getter = function (next) { next(null, null); }; + } getter(function (error, result) { if (error) { @@ -1005,10 +1012,23 @@ app.controller('FileManagerController', ['$scope', '$translate', '$timeout', 'Cl } // fine to do async - fetchVolumesInfo(result.mounts || []); + if ($scope.type === 'app') fetchVolumesInfo(result.mounts || []); + + switch ($scope.type) { + case 'app': + $scope.title = result.label || result.fqdn; + $scope.rootDirLabel = '/app/data/'; + break; + case 'volume': + $scope.title = result.name; + $scope.rootDirLabel = result.hostPath; + break; + case 'mail': + $scope.title = 'mail'; + $scope.rootDirLabel = 'mail'; + break; + } - $scope.title = $scope.type === 'app' ? (result.label || result.fqdn) : result.name; - $scope.rootDirLabel = $scope.type === 'app' ? '/app/data/' : result.hostPath; window.document.title = $scope.title + ' - ' + $translate.instant('filemanager.title'); // now mark the Client to be ready diff --git a/src/logs.html b/src/logs.html index 877de27cd..4cadc71f4 100644 --- a/src/logs.html +++ b/src/logs.html @@ -70,7 +70,7 @@
    {{ 'terminal.title' | tr }} - {{ 'filemanager.title' | tr }} + {{ 'filemanager.title' | tr }} {{ 'logs.clear' | tr }} {{ 'logs.download' | tr }}
    diff --git a/src/views/app.html b/src/views/app.html index e64196222..c5e41756c 100644 --- a/src/views/app.html +++ b/src/views/app.html @@ -512,7 +512,7 @@
    - +
    - \ No newline at end of file +