mirror of
https://github.com/portainer/portainer.git
synced 2025-07-29 02:09:41 +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,105 +1,89 @@
|
|||
import { getVolumes } from '@/react/docker/volumes/queries/useVolumes';
|
||||
import { getVolume } from '@/react/docker/volumes/queries/useVolume';
|
||||
import { removeVolume } from '@/react/docker/volumes/queries/useRemoveVolumeMutation';
|
||||
import { createVolume } from '@/react/docker/volumes/queries/useCreateVolumeMutation';
|
||||
|
||||
import { VolumeViewModel } from '../models/volume';
|
||||
|
||||
angular.module('portainer.docker').factory('VolumeService', [
|
||||
'$q',
|
||||
'Volume',
|
||||
'VolumeHelper',
|
||||
function VolumeServiceFactory($q, Volume, VolumeHelper) {
|
||||
'use strict';
|
||||
var service = {};
|
||||
angular.module('portainer.docker').factory('VolumeService', VolumeServiceFactory);
|
||||
|
||||
service.volumes = function (params) {
|
||||
var deferred = $q.defer();
|
||||
Volume.query(params)
|
||||
.$promise.then(function success(data) {
|
||||
var volumes = data.Volumes || [];
|
||||
volumes = volumes.map(function (item) {
|
||||
return new VolumeViewModel(item);
|
||||
});
|
||||
deferred.resolve(volumes);
|
||||
})
|
||||
.catch(function error(err) {
|
||||
deferred.reject({ msg: 'Unable to retrieve volumes', err: err });
|
||||
});
|
||||
return deferred.promise;
|
||||
/* @ngInject */
|
||||
function VolumeServiceFactory(AngularToReact) {
|
||||
const { useAxios, injectEnvironmentId } = AngularToReact;
|
||||
|
||||
return {
|
||||
volumes: useAxios(injectEnvironmentId(volumesAngularJS)), // dashboard + service create + service edit + volume list
|
||||
volume: useAxios(injectEnvironmentId(volumeAngularJS)), // volume edit
|
||||
getVolumes: useAxios(injectEnvironmentId(getVolumesAngularJS)), // template list
|
||||
remove: useAxios(injectEnvironmentId(removeAngularJS)), // volume list + volume edit
|
||||
createVolume: useAxios(injectEnvironmentId(createAngularJS)), // volume create
|
||||
createVolumeConfiguration, // volume create
|
||||
createXAutoGeneratedLocalVolumes: useAxios(injectEnvironmentId(createXAutoGeneratedLocalVolumes)), // templates list
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {EnvironmentId} environmentId Injected
|
||||
* @param {Filters} filters
|
||||
*/
|
||||
async function volumesAngularJS(environmentId, filters) {
|
||||
const data = await getVolumes(environmentId, filters);
|
||||
return data.map((v) => new VolumeViewModel(v));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {EnvironmentId} environmentId Injected
|
||||
* @param {string} id
|
||||
*/
|
||||
async function volumeAngularJS(environmentId, id) {
|
||||
const data = await getVolume(environmentId, id);
|
||||
return new VolumeViewModel(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {EnvironmentId} environmentId Injected
|
||||
*/
|
||||
async function getVolumesAngularJS(environmentId) {
|
||||
return getVolumes(environmentId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {EnvironmentId} environmentId Injected
|
||||
* @param {string} name
|
||||
* @param {string?} nodeName
|
||||
*/
|
||||
async function removeAngularJS(environmentId, name, nodeName) {
|
||||
return removeVolume(environmentId, name, { nodeName });
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @param {string} driver
|
||||
* @param {{name: string; value: string;}[]} driverOptions
|
||||
*/
|
||||
function createVolumeConfiguration(name, driver, driverOptions) {
|
||||
return {
|
||||
Name: name,
|
||||
Driver: driver,
|
||||
DriverOpts: driverOptions.reduce((res, { name, value }) => ({ ...res, [name]: value }), {}),
|
||||
};
|
||||
}
|
||||
|
||||
service.volume = function (id) {
|
||||
var deferred = $q.defer();
|
||||
Volume.get({ id: id })
|
||||
.$promise.then(function success(data) {
|
||||
var volume = new VolumeViewModel(data);
|
||||
deferred.resolve(volume);
|
||||
})
|
||||
.catch(function error(err) {
|
||||
deferred.reject({ msg: 'Unable to retrieve volume details', err: err });
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
/**
|
||||
* @param {EnvironmentId} environmentId Injected
|
||||
* @param {VolumeConfiguration} volumeConfiguration
|
||||
* @param {string?} nodeName
|
||||
*/
|
||||
async function createAngularJS(environmentId, volumeConfiguration, nodeName) {
|
||||
const data = await createVolume(environmentId, volumeConfiguration, { nodeName });
|
||||
return new VolumeViewModel(data);
|
||||
}
|
||||
|
||||
service.getVolumes = function () {
|
||||
return Volume.query({}).$promise;
|
||||
};
|
||||
|
||||
service.remove = function (volume) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
Volume.remove({ id: volume.Id })
|
||||
.$promise.then(function success(data) {
|
||||
if (data.message) {
|
||||
deferred.reject({ msg: data.message, err: data.message });
|
||||
} else {
|
||||
deferred.resolve();
|
||||
}
|
||||
})
|
||||
.catch(function error(err) {
|
||||
deferred.reject({ msg: 'Unable to remove volume', err: err });
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
service.createVolumeConfiguration = function (name, driver, driverOptions) {
|
||||
var volumeConfiguration = {
|
||||
Name: name,
|
||||
Driver: driver,
|
||||
DriverOpts: VolumeHelper.createDriverOptions(driverOptions),
|
||||
};
|
||||
return volumeConfiguration;
|
||||
};
|
||||
|
||||
service.createVolume = function (volumeConfiguration) {
|
||||
var deferred = $q.defer();
|
||||
Volume.create(volumeConfiguration)
|
||||
.$promise.then(function success(data) {
|
||||
if (data.message) {
|
||||
deferred.reject({ msg: data.message });
|
||||
} else {
|
||||
var volume = new VolumeViewModel(data);
|
||||
deferred.resolve(volume);
|
||||
}
|
||||
})
|
||||
.catch(function error(err) {
|
||||
deferred.reject({ msg: 'Unable to create volume', err: err });
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
service.createVolumes = function (volumeConfigurations) {
|
||||
var createVolumeQueries = volumeConfigurations.map(function (volumeConfiguration) {
|
||||
return service.createVolume(volumeConfiguration);
|
||||
});
|
||||
return $q.all(createVolumeQueries);
|
||||
};
|
||||
|
||||
service.createXAutoGeneratedLocalVolumes = function (x) {
|
||||
var createVolumeQueries = [];
|
||||
for (var i = 0; i < x; i++) {
|
||||
createVolumeQueries.push(service.createVolume({ Driver: 'local' }));
|
||||
}
|
||||
return $q.all(createVolumeQueries);
|
||||
};
|
||||
|
||||
return service;
|
||||
},
|
||||
]);
|
||||
/**
|
||||
* @param {EnvironmentId} environmentId
|
||||
* @param {number} count
|
||||
*/
|
||||
async function createXAutoGeneratedLocalVolumes(environmentId, count) {
|
||||
const promises = Array(count).map(createVolume(environmentId, { Driver: 'local' }));
|
||||
return Promise.all(promises);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue