mirror of
https://github.com/portainer/portainer.git
synced 2025-07-25 08:19:40 +02:00
* feat(agent): get agent's version from ping * feat(agent): add version to api url * feat(agent): query agent with api version * feat(agent): rename agent api version name on state * feat(agent): disable feature based on agent's api version * style(agent): rename ping rest service + remove whitespaces * style(state): remove whitespace * style(agent): add whitespace * fix(agent): remove check for error status 403 * refactor(agent): rename ping file name * refactor(agent): move old services to v1 folder * refactor(agent): turn ping service to usual pattern * refactor(agent): change version to a global variable * refactor(agent): move ping to version2 * refactor(agent): restore ping to use root ping * fix(volumes): add volumeID to browse api path * feat(volume): add upload button to volume browser
33 lines
1 KiB
JavaScript
33 lines
1 KiB
JavaScript
angular.module('portainer.agent').factory('AgentPing', [
|
|
'$resource', 'API_ENDPOINT_ENDPOINTS', 'EndpointProvider', '$q',
|
|
function AgentPingFactory($resource, API_ENDPOINT_ENDPOINTS, EndpointProvider, $q) {
|
|
'use strict';
|
|
return $resource(
|
|
API_ENDPOINT_ENDPOINTS + '/:endpointId/docker/ping',
|
|
{
|
|
endpointId: EndpointProvider.endpointID
|
|
},
|
|
{
|
|
ping: {
|
|
method: 'GET',
|
|
interceptor: {
|
|
response: function versionInterceptor(response) {
|
|
var instance = response.resource;
|
|
var version =
|
|
response.headers('Portainer-Agent-Api-Version') || 1;
|
|
instance.version = Number(version);
|
|
return instance;
|
|
},
|
|
responseError: function versionResponseError(error) {
|
|
// 404 - agent is up - set version to 1
|
|
if (error.status === 404) {
|
|
return { version: 1 };
|
|
}
|
|
return $q.reject(error);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
);
|
|
}
|
|
]);
|