mirror of
https://github.com/sismics/docs.git
synced 2024-11-22 05:57:57 +01:00
Closes #243: webhooks UI
This commit is contained in:
parent
884239bc26
commit
0dce279fd0
@ -48,7 +48,7 @@ public class WebhookAsyncListener {
|
||||
@Subscribe
|
||||
@AllowConcurrentEvents
|
||||
public void on(final DocumentDeletedAsyncEvent event) {
|
||||
triggerWebhook(WebhookEvent.DOCUMENT_UPDATED, event.getDocumentId());
|
||||
triggerWebhook(WebhookEvent.DOCUMENT_DELETED, event.getDocumentId());
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
@ -29,7 +29,7 @@ public class WebhookResource extends BaseResource {
|
||||
*
|
||||
* @api {get} /webhook Get webhooks
|
||||
* @apiName GetWebhook
|
||||
* @apiWebhook Webhook
|
||||
* @apiGroup Webhook
|
||||
* @apiSuccess {Object[]} webhooks List of webhooks
|
||||
* @apiSuccess {String} webhooks.id ID
|
||||
* @apiSuccess {String} webhooks.event Event
|
||||
@ -69,7 +69,7 @@ public class WebhookResource extends BaseResource {
|
||||
* @api {put} /webhook Add a webhook
|
||||
* @apiDescription Each time the specified event is raised, the webhook URL will be POST-ed with the following JSON payload: {"event": "Event name", "id": "ID of the document or file"}
|
||||
* @apiName PutWebhook
|
||||
* @apiWebhook Webhook
|
||||
* @apiGroup Webhook
|
||||
* @apiParam {String="DOCUMENT_CREATED","DOCUMENT_UPDATED","DOCUMENT_DELETED","FILE_CREATED","FILE_UPDATED","FILE_DELETED"} event Event
|
||||
* @apiParam {String} url URL
|
||||
* @apiSuccess {String} status Status OK
|
||||
@ -109,7 +109,7 @@ public class WebhookResource extends BaseResource {
|
||||
*
|
||||
* @api {delete} /webhook/:id Delete a webhook
|
||||
* @apiName DeleteWebhook
|
||||
* @apiWebhook Webhook
|
||||
* @apiGroup Webhook
|
||||
* @apiParam {String} id Webhook ID
|
||||
* @apiSuccess {String} status Status OK
|
||||
* @apiError (client) ForbiddenError Access denied
|
||||
|
@ -82,4 +82,30 @@ angular.module('docs').controller('SettingsConfig', function($scope, $rootScope,
|
||||
$scope.editGeneralConfig = function () {
|
||||
Restangular.one('app').post('config', $scope.general);
|
||||
};
|
||||
|
||||
// Get the webhooks
|
||||
$scope.loadWebhooks = function () {
|
||||
Restangular.one('webhook').get().then(function (data) {
|
||||
$scope.webhooks = data.webhooks;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.loadWebhooks();
|
||||
|
||||
// Add a webhook
|
||||
$scope.webhook = {
|
||||
event: 'DOCUMENT_CREATED'
|
||||
};
|
||||
$scope.addWebhook = function () {
|
||||
Restangular.one('webhook').put($scope.webhook).then(function () {
|
||||
$scope.loadWebhooks();
|
||||
})
|
||||
};
|
||||
|
||||
// Delete a webhook
|
||||
$scope.deleteWebhook = function (webhook) {
|
||||
Restangular.one('webhook', webhook.id).remove().then(function () {
|
||||
$scope.loadWebhooks();
|
||||
});
|
||||
};
|
||||
});
|
@ -377,7 +377,13 @@
|
||||
"smtp_from": "Sender e-mail",
|
||||
"smtp_username": "SMTP username",
|
||||
"smtp_password": "SMTP password",
|
||||
"smtp_updated": "SMTP configuration updated successfully"
|
||||
"smtp_updated": "SMTP configuration updated successfully",
|
||||
"webhooks": "Webhooks",
|
||||
"webhooks_explain": "Webhooks will be called when the specified event occur. The given URL will be POST-ed with a JSON payload containing the event name and the ID of the concerned resource.",
|
||||
"webhook_event": "Event",
|
||||
"webhook_url": "URL",
|
||||
"webhook_create_date": "Create date",
|
||||
"webhook_add": "Add a webhook"
|
||||
},
|
||||
"inbox": {
|
||||
"title": "Inbox scanning",
|
||||
|
@ -142,4 +142,58 @@
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</form>
|
||||
|
||||
<h2 translate="settings.config.webhooks"></h2>
|
||||
<p translate="settings.config.webhooks_explain"></p>
|
||||
|
||||
<form class="form-horizontal" name="webhookForm" novalidate>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label" for="webhookEvent">{{ 'settings.config.webhook_event' | translate }}</label>
|
||||
<div class="col-sm-7">
|
||||
<select name="event" class="form-control" id="webhookEvent" ng-model="webhook.event" required>
|
||||
<option>DOCUMENT_CREATED</option>
|
||||
<option>DOCUMENT_UPDATED</option>
|
||||
<option>DOCUMENT_DELETED</option>
|
||||
<option>FILE_CREATED</option>
|
||||
<option>FILE_UPDATED</option>
|
||||
<option>FILE_DELETED</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group" ng-class="{ 'has-error': !webhookForm.url.$valid && webhookForm.$dirty }">
|
||||
<label class="col-sm-2 control-label" for="webhookUrl">{{ 'settings.config.webhook_url' | translate }}</label>
|
||||
<div class="col-sm-7">
|
||||
<input name="url" type="text" class="form-control" id="webhookUrl" ng-model="webhook.url" required />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-10">
|
||||
<button type="submit" class="btn btn-primary" ng-click="addWebhook()" ng-disabled="!webhookForm.$valid">
|
||||
<span class="fas fa-plus"></span> {{ 'settings.config.webhook_add' | translate }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="col-sm-10">
|
||||
<table class="table" ng-show="webhooks.length > 0">
|
||||
<tr>
|
||||
<th style="width: 20%">{{ 'settings.config.webhook_event' | translate }}</th>
|
||||
<th>{{ 'settings.config.webhook_url' | translate }}</th>
|
||||
<th style="width: 20%">{{ 'settings.config.webhook_create_date' | translate }}</th>
|
||||
<th style="width: 10%"></th>
|
||||
</tr>
|
||||
|
||||
<tr ng-repeat="webhook in webhooks">
|
||||
<td>{{ webhook.event }}</td>
|
||||
<td>{{ webhook.url }}</td>
|
||||
<td>{{ webhook.create_date | date: dateFormat }}</td>
|
||||
<td>
|
||||
<span ng-click="deleteWebhook(webhook)" class="fas fa-trash pointer text-danger"></span>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user