mirror of
https://github.com/portainer/portainer.git
synced 2025-07-19 13:29:41 +02:00
* feat(webhook) EE-2125 add some helpers to registry utils * feat(webhook) EE-2125 persist registryID when creating a webhook * feat(webhook) EE-2125 send registry auth header when executing a webhook * feat(webhook) EE-2125 send registryID to backend when creating a service with webhook * feat(webhook) EE-2125 use the initial registry ID to create webhook on editing service screen * feat(webhook) EE-2125 update webhook when update registry * feat(webhook) EE-2125 add endpoint of update webhook * feat(webhook) EE-2125 code cleanup * feat(webhook) EE-2125 fix a typo * feat(webhook) EE-2125 fix circle import issue with unit test Co-authored-by: Simon Meng <simon.meng@portainer.io>
42 lines
1.3 KiB
JavaScript
42 lines
1.3 KiB
JavaScript
import { WebhookViewModel } from '../../models/webhook';
|
|
|
|
angular.module('portainer.app').factory('WebhookService', [
|
|
'$q',
|
|
'Webhooks',
|
|
function WebhookServiceFactory($q, Webhooks) {
|
|
'use strict';
|
|
var service = {};
|
|
|
|
service.webhooks = function (serviceID, endpointID) {
|
|
var deferred = $q.defer();
|
|
var filters = { ResourceID: serviceID, EndpointID: endpointID };
|
|
|
|
Webhooks.query({ filters: filters })
|
|
.$promise.then(function success(data) {
|
|
var webhooks = data.map(function (item) {
|
|
return new WebhookViewModel(item);
|
|
});
|
|
deferred.resolve(webhooks);
|
|
})
|
|
.catch(function error(err) {
|
|
deferred.reject({ msg: 'Unable to retrieve webhooks', err: err });
|
|
});
|
|
|
|
return deferred.promise;
|
|
};
|
|
|
|
service.createServiceWebhook = function (serviceID, endpointID, registryID) {
|
|
return Webhooks.create({ ResourceID: serviceID, EndpointID: endpointID, WebhookType: 1, registryID }).$promise;
|
|
};
|
|
|
|
service.updateServiceWebhook = function (id, registryID) {
|
|
return Webhooks.update({ id, registryID }).$promise;
|
|
};
|
|
|
|
service.deleteWebhook = function (id) {
|
|
return Webhooks.remove({ id: id }).$promise;
|
|
};
|
|
|
|
return service;
|
|
},
|
|
]);
|