feat(agent): fix browse volume

pull/2337/head
Chaim Lev-Ari 2018-09-30 10:08:57 +03:00
parent e9496affa2
commit 70f025c50e
2 changed files with 31 additions and 29 deletions

View File

@ -1,22 +1,22 @@
angular.module('portainer.agent')
.factory('Browse', ['$resource', 'API_ENDPOINT_ENDPOINTS', 'EndpointProvider', function BrowseFactory($resource, API_ENDPOINT_ENDPOINTS, EndpointProvider) {
'use strict';
return $resource(API_ENDPOINT_ENDPOINTS + '/:endpointId/docker/browse/:id/:action', {
return $resource(API_ENDPOINT_ENDPOINTS + '/:endpointId/docker/browse/:action', {
endpointId: EndpointProvider.endpointID
},
{
ls: {
method: 'GET', isArray: true, params: { id: '@id', action: 'ls' }
method: 'GET', isArray: true, params: { action: 'ls' }
},
get: {
method: 'GET', params: { id: '@id', action: 'get' },
method: 'GET', params: { action: 'get' },
transformResponse: browseGetResponse
},
delete: {
method: 'DELETE', params: { id: '@id', action: 'delete' }
method: 'DELETE', params: { action: 'delete' }
},
rename: {
method: 'PUT', params: { id: '@id', action: 'rename' }
method: 'PUT', params: { action: 'rename' }
}
});
}]);

View File

@ -1,27 +1,29 @@
angular.module('portainer.agent')
.factory('VolumeBrowserService', ['$q', 'Browse', function VolumeBrowserServiceFactory($q, Browse) {
'use strict';
var service = {};
angular.module('portainer.agent').factory('VolumeBrowserService', [
'$q', 'Browse',
function VolumeBrowserServiceFactory($q, Browse) {
'use strict';
var service = {};
service.ls = function(volumeId, path) {
return Browse.ls({ 'id': volumeId, 'path': path }).$promise;
};
service.get = function(volumeId, path) {
return Browse.get({ 'id': volumeId, 'path': path }).$promise;
};
service.delete = function(volumeId, path) {
return Browse.delete({ 'id': volumeId, 'path': path }).$promise;
};
service.rename = function(volumeId, path, newPath) {
var payload = {
CurrentFilePath: path,
NewFilePath: newPath
service.ls = function(volumeId, path) {
return Browse.ls({ volumeID: volumeId, path: path }).$promise;
};
return Browse.rename({ 'id': volumeId }, payload).$promise;
};
return service;
}]);
service.get = function(volumeId, path) {
return Browse.get({ volumeID: volumeId, path: path }).$promise;
};
service.delete = function(volumeId, path) {
return Browse.delete({ volumeID: volumeId, path: path }).$promise;
};
service.rename = function(volumeId, path, newPath) {
var payload = {
CurrentFilePath: path,
NewFilePath: newPath
};
return Browse.rename({ volumeID: volumeId }, payload).$promise;
};
return service;
}
]);