mirror of https://github.com/portainer/portainer
refactor(agent): refactor rest factories to es6 (#4090)
* refactor(agent): replace v1 browse with es6 module * refactor(agent): refactor agentv1 to es6 * refactor(agent): replace agent factory with es6 * refactor(agent): refactor browse response to es6 * refactor(agent): refactor browse to es6 * refactor(agent): import angular * refactor(agent): refactor host to es6 * refactor(agent): refactor ping to es6pull/4098/head
parent
435f15ec6a
commit
7eb8d5449a
|
@ -1,12 +1,10 @@
|
||||||
angular.module('portainer.agent').factory('Agent', [
|
import angular from 'angular';
|
||||||
'$resource',
|
|
||||||
'API_ENDPOINT_ENDPOINTS',
|
angular.module('portainer.agent').factory('Agent', AgentFactory);
|
||||||
'EndpointProvider',
|
|
||||||
'StateManager',
|
function AgentFactory($resource, API_ENDPOINT_ENDPOINTS, EndpointProvider, StateManager) {
|
||||||
function AgentFactory($resource, API_ENDPOINT_ENDPOINTS, EndpointProvider, StateManager) {
|
|
||||||
'use strict';
|
|
||||||
return $resource(
|
return $resource(
|
||||||
API_ENDPOINT_ENDPOINTS + '/:endpointId/docker/v:version/agents',
|
`${API_ENDPOINT_ENDPOINTS}/:endpointId/docker/v:version/agents`,
|
||||||
{
|
{
|
||||||
endpointId: EndpointProvider.endpointID,
|
endpointId: EndpointProvider.endpointID,
|
||||||
version: StateManager.getAgentApiVersion,
|
version: StateManager.getAgentApiVersion,
|
||||||
|
@ -15,5 +13,4 @@ angular.module('portainer.agent').factory('Agent', [
|
||||||
query: { method: 'GET', isArray: true },
|
query: { method: 'GET', isArray: true },
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
}
|
||||||
]);
|
|
||||||
|
|
|
@ -1,14 +1,12 @@
|
||||||
|
import angular from 'angular';
|
||||||
|
|
||||||
import { browseGetResponse } from './response/browse';
|
import { browseGetResponse } from './response/browse';
|
||||||
|
|
||||||
angular.module('portainer.agent').factory('Browse', [
|
angular.module('portainer.agent').factory('Browse', BrowseFactory);
|
||||||
'$resource',
|
|
||||||
'API_ENDPOINT_ENDPOINTS',
|
function BrowseFactory($resource, API_ENDPOINT_ENDPOINTS, EndpointProvider, StateManager) {
|
||||||
'EndpointProvider',
|
|
||||||
'StateManager',
|
|
||||||
function BrowseFactory($resource, API_ENDPOINT_ENDPOINTS, EndpointProvider, StateManager) {
|
|
||||||
'use strict';
|
|
||||||
return $resource(
|
return $resource(
|
||||||
API_ENDPOINT_ENDPOINTS + '/:endpointId/docker/v:version/browse/:action',
|
`${API_ENDPOINT_ENDPOINTS}/:endpointId/docker/v:version/browse/:action`,
|
||||||
{
|
{
|
||||||
endpointId: EndpointProvider.endpointID,
|
endpointId: EndpointProvider.endpointID,
|
||||||
version: StateManager.getAgentApiVersion,
|
version: StateManager.getAgentApiVersion,
|
||||||
|
@ -35,5 +33,4 @@ angular.module('portainer.agent').factory('Browse', [
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
}
|
||||||
]);
|
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
angular.module('portainer.agent').factory('Host', [
|
import angular from 'angular';
|
||||||
'$resource',
|
|
||||||
'API_ENDPOINT_ENDPOINTS',
|
angular.module('portainer.agent').factory('Host', HostFactory);
|
||||||
'EndpointProvider',
|
|
||||||
'StateManager',
|
function HostFactory($resource, API_ENDPOINT_ENDPOINTS, EndpointProvider, StateManager) {
|
||||||
function AgentFactory($resource, API_ENDPOINT_ENDPOINTS, EndpointProvider, StateManager) {
|
|
||||||
'use strict';
|
|
||||||
return $resource(
|
return $resource(
|
||||||
API_ENDPOINT_ENDPOINTS + '/:endpointId/docker/v:version/host/:action',
|
`${API_ENDPOINT_ENDPOINTS}/:endpointId/docker/v:version/host/:action`,
|
||||||
{
|
{
|
||||||
endpointId: EndpointProvider.endpointID,
|
endpointId: EndpointProvider.endpointID,
|
||||||
version: StateManager.getAgentApiVersion,
|
version: StateManager.getAgentApiVersion,
|
||||||
|
@ -15,5 +13,4 @@ angular.module('portainer.agent').factory('Host', [
|
||||||
info: { method: 'GET', params: { action: 'info' } },
|
info: { method: 'GET', params: { action: 'info' } },
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
}
|
||||||
]);
|
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
angular.module('portainer.agent').factory('AgentPing', [
|
import angular from 'angular';
|
||||||
'$resource',
|
|
||||||
'API_ENDPOINT_ENDPOINTS',
|
angular.module('portainer.agent').factory('AgentPing', AgentPingFactory);
|
||||||
'EndpointProvider',
|
|
||||||
'$q',
|
function AgentPingFactory($resource, API_ENDPOINT_ENDPOINTS, EndpointProvider, $q) {
|
||||||
function AgentPingFactory($resource, API_ENDPOINT_ENDPOINTS, EndpointProvider, $q) {
|
|
||||||
'use strict';
|
|
||||||
return $resource(
|
return $resource(
|
||||||
API_ENDPOINT_ENDPOINTS + '/:endpointId/docker/ping',
|
`${API_ENDPOINT_ENDPOINTS}/:endpointId/docker/ping`,
|
||||||
{
|
{
|
||||||
endpointId: EndpointProvider.endpointID,
|
endpointId: EndpointProvider.endpointID,
|
||||||
},
|
},
|
||||||
|
@ -15,8 +13,8 @@ angular.module('portainer.agent').factory('AgentPing', [
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
interceptor: {
|
interceptor: {
|
||||||
response: function versionInterceptor(response) {
|
response: function versionInterceptor(response) {
|
||||||
var instance = response.resource;
|
const instance = response.resource;
|
||||||
var version = response.headers('Portainer-Agent-Api-Version') || 1;
|
const version = response.headers('Portainer-Agent-Api-Version') || 1;
|
||||||
instance.version = Number(version);
|
instance.version = Number(version);
|
||||||
return instance;
|
return instance;
|
||||||
},
|
},
|
||||||
|
@ -31,5 +29,4 @@ angular.module('portainer.agent').factory('AgentPing', [
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
}
|
||||||
]);
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
// This functions simply creates a response object and assign
|
// This functions simply creates a response object and assign
|
||||||
// the data to a field.
|
// the data to a field.
|
||||||
export function browseGetResponse(data) {
|
export function browseGetResponse(data) {
|
||||||
var response = {};
|
const response = {};
|
||||||
response.file = data;
|
response.file = data;
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
angular.module('portainer.agent').factory('AgentVersion1', [
|
import angular from 'angular';
|
||||||
'$resource',
|
|
||||||
'API_ENDPOINT_ENDPOINTS',
|
angular.module('portainer.agent').factory('AgentVersion1', AgentFactory);
|
||||||
'EndpointProvider',
|
|
||||||
function AgentFactory($resource, API_ENDPOINT_ENDPOINTS, EndpointProvider) {
|
function AgentFactory($resource, API_ENDPOINT_ENDPOINTS, EndpointProvider) {
|
||||||
'use strict';
|
|
||||||
return $resource(
|
return $resource(
|
||||||
API_ENDPOINT_ENDPOINTS + '/:endpointId/docker/agents',
|
`${API_ENDPOINT_ENDPOINTS}/:endpointId/docker/agents`,
|
||||||
{
|
{
|
||||||
endpointId: EndpointProvider.endpointID,
|
endpointId: EndpointProvider.endpointID,
|
||||||
},
|
},
|
||||||
|
@ -13,5 +12,4 @@ angular.module('portainer.agent').factory('AgentVersion1', [
|
||||||
query: { method: 'GET', isArray: true },
|
query: { method: 'GET', isArray: true },
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
}
|
||||||
]);
|
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
|
import angular from 'angular';
|
||||||
|
|
||||||
import { browseGetResponse } from '../response/browse';
|
import { browseGetResponse } from '../response/browse';
|
||||||
|
|
||||||
angular.module('portainer.agent').factory('BrowseVersion1', [
|
angular.module('portainer.agent').factory('BrowseVersion1', BrowseFactory);
|
||||||
'$resource',
|
|
||||||
'API_ENDPOINT_ENDPOINTS',
|
function BrowseFactory($resource, API_ENDPOINT_ENDPOINTS, EndpointProvider) {
|
||||||
'EndpointProvider',
|
|
||||||
function BrowseFactory($resource, API_ENDPOINT_ENDPOINTS, EndpointProvider) {
|
|
||||||
'use strict';
|
|
||||||
return $resource(
|
return $resource(
|
||||||
API_ENDPOINT_ENDPOINTS + '/:endpointId/docker/browse/:volumeID/:action',
|
`${API_ENDPOINT_ENDPOINTS}/:endpointId/docker/browse/:volumeID/:action`,
|
||||||
{
|
{
|
||||||
endpointId: EndpointProvider.endpointID,
|
endpointId: EndpointProvider.endpointID,
|
||||||
},
|
},
|
||||||
|
@ -33,5 +32,4 @@ angular.module('portainer.agent').factory('BrowseVersion1', [
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
}
|
||||||
]);
|
|
||||||
|
|
Loading…
Reference in New Issue