[EAGLE-1048] Delete an alert publisher on Eagle UI
https://issues.apache.org/jira/browse/EAGLE-1048
Administer can delete an alert publisher on Eagle UI
Request: DELETE /publishments/\{name\}
Response:
```
OpResult {
public int code = 200; // 200 = SUCCESS
public String message = "";
}
```
Author: zombieJ <smith3816@gmail.com>
Closes #955 from zombieJ/EAGLE-1048.
diff --git a/eagle-server/src/main/webapp/app/dev/partials/integration/publisherList.html b/eagle-server/src/main/webapp/app/dev/partials/integration/publisherList.html
index ff7c0e0..3976aeb 100644
--- a/eagle-server/src/main/webapp/app/dev/partials/integration/publisherList.html
+++ b/eagle-server/src/main/webapp/app/dev/partials/integration/publisherList.html
@@ -17,14 +17,16 @@
-->
<div class="box-body">
- <div sort-table="publisherList">
+ <span class="fa fa-refresh fa-spin no-animate" ng-show="!publisherList._done"></span>
+
+ <div sort-table="publisherList" ng-show="publisherList._done">
<table class="table table-bordered table-hover">
<thead>
<tr>
<th>Name</th>
<th>Policies</th>
<th>Properties</th>
- <th></th>
+ <th width="10"></th>
</tr>
</thead>
<tbody>
@@ -32,7 +34,11 @@
<td class="text-no-break"><a>{{item.name}}</a></td>
<td>{{item.policyIds.length}}</td>
<td><pre>{{item.properties | json: 4}}</pre></td>
- <td></td>
+ <td>
+ <button class="btn btn-xs btn-danger" ng-click="deletePublisher($event, item)">
+ <span class="fa fa-trash"></span> Delete
+ </button>
+ </td>
</tr>
</tbody>
</table>
diff --git a/eagle-server/src/main/webapp/app/dev/public/js/ctrls/integrationCtrl.js b/eagle-server/src/main/webapp/app/dev/public/js/ctrls/integrationCtrl.js
index 6cc17e5..5aa7036 100644
--- a/eagle-server/src/main/webapp/app/dev/public/js/ctrls/integrationCtrl.js
+++ b/eagle-server/src/main/webapp/app/dev/public/js/ctrls/integrationCtrl.js
@@ -447,11 +447,14 @@
// ======================================================================================
// = Publisher =
// ======================================================================================
- eagleControllers.controller('integrationPublisherListCtrl', function ($sce, $scope, $wrapState, PageConfig, Entity) {
+ eagleControllers.controller('integrationPublisherListCtrl', function ($sce, $scope, $wrapState, PageConfig, Entity, UI) {
PageConfig.title = "Integration";
PageConfig.subTitle = "Publishers";
- $scope.publisherList = Entity.queryMetadata("publishments");
+ function refreshPublishList() {
+ $scope.publisherList = Entity.queryMetadata("publishments");
+ }
+
$scope.gotoPolicy = function (policyName) {
var encodePolicyName = encodeURIComponent(policyName);
var policyList = Entity.queryMetadata("policies/" + encodePolicyName);
@@ -488,5 +491,26 @@
content: $ul,
});
};
+
+ $scope.deletePublisher = function ($event, publisher) {
+ $event.stopPropagation();
+
+ UI.deleteConfirm(publisher.name)(function (entity, closeFunc) {
+ Entity.deleteMetadata("publishments/" + publisher.name)._promise.finally(function (res) {
+ var data = res.data;
+ closeFunc();
+ refreshPublishList();
+
+ if (data.code !== 200) {
+ $.dialog({
+ title: 'OPS',
+ content: data.message,
+ });
+ }
+ });
+ });
+ };
+
+ refreshPublishList();
});
}());