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

View File

@ -1,27 +1,29 @@
angular.module('portainer.agent') angular.module('portainer.agent').factory('VolumeBrowserService', [
.factory('VolumeBrowserService', ['$q', 'Browse', function VolumeBrowserServiceFactory($q, Browse) { '$q', 'Browse',
'use strict'; function VolumeBrowserServiceFactory($q, Browse) {
var service = {}; 'use strict';
var service = {};
service.ls = function(volumeId, path) { service.ls = function(volumeId, path) {
return Browse.ls({ 'id': volumeId, 'path': path }).$promise; return Browse.ls({ volumeID: 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
}; };
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;
}
]);