mirror of
https://github.com/portainer/portainer.git
synced 2025-07-25 00:09:40 +02:00
feat(app): limit the docker API version supported by the frontend (#12295)
Some checks failed
ci / build_images (map[arch:amd64 platform:linux version:]) (push) Has been cancelled
ci / build_images (map[arch:amd64 platform:windows version:1809]) (push) Has been cancelled
ci / build_images (map[arch:amd64 platform:windows version:ltsc2022]) (push) Has been cancelled
ci / build_images (map[arch:arm platform:linux version:]) (push) Has been cancelled
ci / build_images (map[arch:arm64 platform:linux version:]) (push) Has been cancelled
ci / build_images (map[arch:ppc64le platform:linux version:]) (push) Has been cancelled
/ triage (push) Has been cancelled
Lint / Run linters (push) Has been cancelled
Test / test-client (push) Has been cancelled
Test / test-server (map[arch:amd64 platform:linux]) (push) Has been cancelled
Test / test-server (map[arch:amd64 platform:windows version:1809]) (push) Has been cancelled
Test / test-server (map[arch:amd64 platform:windows version:ltsc2022]) (push) Has been cancelled
Test / test-server (map[arch:arm64 platform:linux]) (push) Has been cancelled
ci / build_manifests (push) Has been cancelled
Some checks failed
ci / build_images (map[arch:amd64 platform:linux version:]) (push) Has been cancelled
ci / build_images (map[arch:amd64 platform:windows version:1809]) (push) Has been cancelled
ci / build_images (map[arch:amd64 platform:windows version:ltsc2022]) (push) Has been cancelled
ci / build_images (map[arch:arm platform:linux version:]) (push) Has been cancelled
ci / build_images (map[arch:arm64 platform:linux version:]) (push) Has been cancelled
ci / build_images (map[arch:ppc64le platform:linux version:]) (push) Has been cancelled
/ triage (push) Has been cancelled
Lint / Run linters (push) Has been cancelled
Test / test-client (push) Has been cancelled
Test / test-server (map[arch:amd64 platform:linux]) (push) Has been cancelled
Test / test-server (map[arch:amd64 platform:windows version:1809]) (push) Has been cancelled
Test / test-server (map[arch:amd64 platform:windows version:ltsc2022]) (push) Has been cancelled
Test / test-server (map[arch:arm64 platform:linux]) (push) Has been cancelled
ci / build_manifests (push) Has been cancelled
This commit is contained in:
parent
8cbd23c059
commit
ac5491e864
227 changed files with 4702 additions and 3411 deletions
|
@ -1,73 +1,43 @@
|
|||
import { getNode } from '@/react/docker/proxy/queries/nodes/useNode';
|
||||
import { getNodes } from '@/react/docker/proxy/queries/nodes/useNodes';
|
||||
import { updateNode } from '@/react/docker/proxy/queries/nodes/useUpdateNodeMutation';
|
||||
|
||||
import { NodeViewModel } from '../models/node';
|
||||
|
||||
angular.module('portainer.docker').factory('NodeService', [
|
||||
'$q',
|
||||
'Node',
|
||||
function NodeServiceFactory($q, Node) {
|
||||
'use strict';
|
||||
var service = {};
|
||||
angular.module('portainer.docker').factory('NodeService', NodeServiceFactory);
|
||||
|
||||
service.nodes = nodes;
|
||||
service.node = node;
|
||||
service.updateNode = updateNode;
|
||||
service.getActiveManager = getActiveManager;
|
||||
/* @ngInject */
|
||||
function NodeServiceFactory(AngularToReact) {
|
||||
const { useAxios, injectEnvironmentId } = AngularToReact;
|
||||
|
||||
function node(id) {
|
||||
var deferred = $q.defer();
|
||||
Node.get({ id: id })
|
||||
.$promise.then(function onNodeLoaded(rawNode) {
|
||||
var node = new NodeViewModel(rawNode);
|
||||
return deferred.resolve(node);
|
||||
})
|
||||
.catch(function onFailed(err) {
|
||||
deferred.reject({ msg: 'Unable to retrieve node', err: err });
|
||||
});
|
||||
return {
|
||||
nodes: useAxios(injectEnvironmentId(nodesAngularJS)), // macvlan form + services list + service create + service edit + swarm visualizer + stack edit
|
||||
node: useAxios(injectEnvironmentId(nodeAngularJS)), // node browser + node details
|
||||
updateNode: useAxios(injectEnvironmentId(updateNodeAngularJS)), // swarm node details panel
|
||||
};
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
/**
|
||||
* @param {EnvironmentId} environmentId
|
||||
* @param {NodeId} id
|
||||
*/
|
||||
async function nodeAngularJS(environmentId, id) {
|
||||
const data = await getNode(environmentId, id);
|
||||
return new NodeViewModel(data);
|
||||
}
|
||||
|
||||
function nodes() {
|
||||
var deferred = $q.defer();
|
||||
/**
|
||||
* @param {EnvironmentId} environmentId
|
||||
*/
|
||||
async function nodesAngularJS(environmentId) {
|
||||
const data = await getNodes(environmentId);
|
||||
return data.map((n) => new NodeViewModel(n));
|
||||
}
|
||||
|
||||
Node.query({})
|
||||
.$promise.then(function success(data) {
|
||||
var nodes = data.map(function (item) {
|
||||
return new NodeViewModel(item);
|
||||
});
|
||||
deferred.resolve(nodes);
|
||||
})
|
||||
.catch(function error(err) {
|
||||
deferred.reject({ msg: 'Unable to retrieve nodes', err: err });
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function updateNode(node) {
|
||||
return Node.update({ id: node.Id, version: node.Version }, node).$promise;
|
||||
}
|
||||
|
||||
function getActiveManager() {
|
||||
var deferred = $q.defer();
|
||||
|
||||
service
|
||||
.nodes()
|
||||
.then(function success(data) {
|
||||
for (var i = 0; i < data.length; ++i) {
|
||||
var node = data[i];
|
||||
if (node.Role === 'manager' && node.Availability === 'active' && node.Status === 'ready' && node.Addr !== '0.0.0.0') {
|
||||
deferred.resolve(node);
|
||||
break;
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(function error(err) {
|
||||
deferred.reject({ msg: 'Unable to retrieve nodes', err: err });
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
return service;
|
||||
},
|
||||
]);
|
||||
/**
|
||||
* @param {EnvironmentId} environmentId
|
||||
* @param {NodeSpec & { Id: string; Version: number }} nodeConfig
|
||||
*/
|
||||
async function updateNodeAngularJS(environmentId, nodeConfig) {
|
||||
return updateNode(environmentId, nodeConfig.Id, nodeConfig, nodeConfig.Version);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue