Repository: eagle
Updated Branches:
  refs/heads/master 092ddbe48 -> ffbcfb372


[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 <[email protected]>

Closes #955 from zombieJ/EAGLE-1048.


Project: http://git-wip-us.apache.org/repos/asf/eagle/repo
Commit: http://git-wip-us.apache.org/repos/asf/eagle/commit/ffbcfb37
Tree: http://git-wip-us.apache.org/repos/asf/eagle/tree/ffbcfb37
Diff: http://git-wip-us.apache.org/repos/asf/eagle/diff/ffbcfb37

Branch: refs/heads/master
Commit: ffbcfb372fccbf8bedabad620817ba302a728584
Parents: 092ddbe
Author: zombieJ <[email protected]>
Authored: Tue Jun 20 20:11:09 2017 +0800
Committer: Zhao, Qingwen <[email protected]>
Committed: Tue Jun 20 20:11:09 2017 +0800

----------------------------------------------------------------------
 .../dev/partials/integration/publisherList.html | 12 ++++++---
 .../app/dev/public/js/ctrls/integrationCtrl.js  | 28 ++++++++++++++++++--
 2 files changed, 35 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/eagle/blob/ffbcfb37/eagle-server/src/main/webapp/app/dev/partials/integration/publisherList.html
----------------------------------------------------------------------
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>

http://git-wip-us.apache.org/repos/asf/eagle/blob/ffbcfb37/eagle-server/src/main/webapp/app/dev/public/js/ctrls/integrationCtrl.js
----------------------------------------------------------------------
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();
        });
 }());

Reply via email to