* chore(project): install prettier and lint-staged * chore(project): apply prettier to html too * chore(project): git ignore eslintcache * chore(project): add a comment about format script * chore(prettier): update printWidth * chore(prettier): remove useTabs option * chore(prettier): add HTML validation * refactor(prettier): fix closing tags * feat(prettier): define angular parser for html templates * style(prettier): run prettier on codebase Co-authored-by: Anthony Lapenna <lapenna.anthony@gmail.com>
39 lines
1.1 KiB
JavaScript
39 lines
1.1 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) {
|
|
return Webhooks.create({ ResourceID: serviceID, EndpointID: endpointID, WebhookType: 1 }).$promise;
|
|
};
|
|
|
|
service.deleteWebhook = function (id) {
|
|
return Webhooks.remove({ id: id }).$promise;
|
|
};
|
|
|
|
return service;
|
|
},
|
|
]);
|