mirror of
https://github.com/portainer/portainer.git
synced 2025-07-23 15:29:42 +02:00
* feat(api): remove SnapshotRaw from EndpointList response * feat(api): add pagination for EndpointList operation * feat(api): rename last_id query parameter to start * feat(api): implement filter for EndpointList operation * feat(home): front - endpoint backend pagination (#2990) * feat(home): endpoint pagination with backend * feat(api): remove default limit value * fix(endpoints): fix a minor issue with column span * fix(endpointgroup-create): fix an issue with endpoint group creation * feat(app): minor loading optimizations * refactor(api): small refactor of EndpointList operation * fix(home): fix minor loading text display issue * refactor(api): document bolt services functions * feat(home): minor optimization * fix(api): replace seek with index scanning for EndpointPaginated * fix(api): fix invalid starting index issue * fix(api): first implementation of working filter * fix(home): endpoints list keeps backend pagination when it needs to * fix(api): endpoint pagination doesn't drop the first item on pages >=2 anymore * fix(home): UI flickering on page/filter load/change * feat(api): support searching in associated endpoint group data * feat(api): declare EndpointList params as optional * feat(endpoints): backend pagination for endpoints view (#3004) * feat(endpoint-group): enable backend pagination (#3017) * feat(api): support groupID filter on endpoints route * feat(api): add new API operations endpointGroupAddEndpoint and endpointGroupDeleteEndpoint * feat(endpoint-groups): backend pagination support for create and edit * feat(endpoint-groups): debounce on filter for create/edit views * feat(endpoint-groups): filter assigned on create view * (endpoint-groups): unassigned endpoints edit view * refactor(endpoint-groups): code clean * feat(endpoint-groups): remove message for Unassigned group * refactor(api): endpoint group endpoint association refactor * refactor(api): rename files and remove comments * refactor(api): remove usage of utils * refactor(api): optional parameters * feat(api): update endpointListOperation behavior and parameters * refactor(api): remove unused methods associated to EndpointService * refactor(api): remove unused methods associated to EndpointService * refactor(api): minor refactor
108 lines
3.6 KiB
JavaScript
108 lines
3.6 KiB
JavaScript
angular.module('portainer.app')
|
|
.factory('EndpointService', ['$q', 'Endpoints', 'FileUploadService',
|
|
function EndpointServiceFactory($q, Endpoints, FileUploadService) {
|
|
'use strict';
|
|
var service = {};
|
|
|
|
service.endpoint = function(endpointID) {
|
|
return Endpoints.get({id: endpointID}).$promise;
|
|
};
|
|
|
|
service.endpoints = function(start, limit, search) {
|
|
return Endpoints.query({start, limit, search}).$promise;
|
|
};
|
|
|
|
service.snapshotEndpoints = function() {
|
|
return Endpoints.snapshots({}, {}).$promise;
|
|
};
|
|
|
|
service.snapshotEndpoint = function(endpointID) {
|
|
return Endpoints.snapshot({ id: endpointID }, {}).$promise;
|
|
};
|
|
|
|
service.endpointsByGroup = function(start, limit, search, groupId) {
|
|
return Endpoints.query({ start, limit, search, groupId }).$promise;
|
|
};
|
|
|
|
service.updateAccess = function(id, userAccessPolicies, teamAccessPolicies) {
|
|
return Endpoints.updateAccess({id: id}, {UserAccessPolicies: userAccessPolicies, TeamAccessPolicies: teamAccessPolicies}).$promise;
|
|
};
|
|
|
|
service.updateEndpoint = function(id, payload) {
|
|
var deferred = $q.defer();
|
|
FileUploadService.uploadTLSFilesForEndpoint(id, payload.TLSCACert, payload.TLSCert, payload.TLSKey)
|
|
.then(function success() {
|
|
deferred.notify({upload: false});
|
|
return Endpoints.update({id: id}, payload).$promise;
|
|
})
|
|
.then(function success(data) {
|
|
deferred.resolve(data);
|
|
})
|
|
.catch(function error(err) {
|
|
deferred.notify({upload: false});
|
|
deferred.reject({msg: 'Unable to update endpoint', err: err});
|
|
});
|
|
return deferred.promise;
|
|
};
|
|
|
|
service.deleteEndpoint = function(endpointID) {
|
|
return Endpoints.remove({id: endpointID}).$promise;
|
|
};
|
|
|
|
service.createLocalEndpoint = function() {
|
|
var deferred = $q.defer();
|
|
|
|
FileUploadService.createEndpoint('local', 1, '', '', 1, [], false)
|
|
.then(function success(response) {
|
|
deferred.resolve(response.data);
|
|
})
|
|
.catch(function error(err) {
|
|
deferred.reject({msg: 'Unable to create endpoint', err: err});
|
|
});
|
|
|
|
return deferred.promise;
|
|
};
|
|
|
|
service.createRemoteEndpoint = function(name, type, URL, PublicURL, groupID, tags, TLS, TLSSkipVerify, TLSSkipClientVerify, TLSCAFile, TLSCertFile, TLSKeyFile) {
|
|
var deferred = $q.defer();
|
|
|
|
FileUploadService.createEndpoint(name, type, 'tcp://' + URL, PublicURL, groupID, tags, TLS, TLSSkipVerify, TLSSkipClientVerify, TLSCAFile, TLSCertFile, TLSKeyFile)
|
|
.then(function success(response) {
|
|
deferred.resolve(response.data);
|
|
})
|
|
.catch(function error(err) {
|
|
deferred.reject({msg: 'Unable to create endpoint', err: err});
|
|
});
|
|
|
|
return deferred.promise;
|
|
};
|
|
|
|
service.createAzureEndpoint = function(name, applicationId, tenantId, authenticationKey, groupId, tags) {
|
|
var deferred = $q.defer();
|
|
|
|
FileUploadService.createAzureEndpoint(name, applicationId, tenantId, authenticationKey, groupId, tags)
|
|
.then(function success(response) {
|
|
deferred.resolve(response.data);
|
|
})
|
|
.catch(function error(err) {
|
|
deferred.reject({msg: 'Unable to connect to Azure', err: err});
|
|
});
|
|
|
|
return deferred.promise;
|
|
};
|
|
|
|
service.executeJobFromFileUpload = function (image, jobFile, endpointId, nodeName) {
|
|
return FileUploadService.executeEndpointJob(image, jobFile, endpointId, nodeName);
|
|
};
|
|
|
|
service.executeJobFromFileContent = function (image, jobFileContent, endpointId, nodeName) {
|
|
var payload = {
|
|
Image: image,
|
|
FileContent: jobFileContent
|
|
};
|
|
|
|
return Endpoints.executeJob({ id: endpointId, method: 'string', nodeName: nodeName }, payload).$promise;
|
|
};
|
|
|
|
return service;
|
|
}]);
|