Repository: eagle Updated Branches: refs/heads/master 1fb60cc76 -> a37d2e1bc
[EAGLE-1032] Add policy duplication settings in the policy definition page https://issues.apache.org/jira/browse/EAGLE-1032 Add policy duplication settings in the policy definition page. 1. FieldName: dedupIntervalMin Type: string (text) - default: 30 e.g., 1, 2, 10 2. FieldName: dedupFields Type: array (checkbox) - default: all column checked Description: show all stream columns of STRING type e.g. ["site", "component"] Author: zombieJ <[email protected]> Closes #942 from zombieJ/EAGLE-1032. Project: http://git-wip-us.apache.org/repos/asf/eagle/repo Commit: http://git-wip-us.apache.org/repos/asf/eagle/commit/a37d2e1b Tree: http://git-wip-us.apache.org/repos/asf/eagle/tree/a37d2e1b Diff: http://git-wip-us.apache.org/repos/asf/eagle/diff/a37d2e1b Branch: refs/heads/master Commit: a37d2e1bc3082507ed2bad41e33920ac6ebc42ea Parents: 1fb60cc Author: zombieJ <[email protected]> Authored: Tue Jun 6 20:28:52 2017 +0800 Committer: Zhao, Qingwen <[email protected]> Committed: Tue Jun 6 20:28:52 2017 +0800 ---------------------------------------------------------------------- .../partials/alert/policyEdit/advancedMode.html | 21 ++++++++-- .../app/dev/public/js/ctrls/alertEditCtrl.js | 44 +++++++++++++++++++- 2 files changed, 59 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/eagle/blob/a37d2e1b/eagle-server/src/main/webapp/app/dev/partials/alert/policyEdit/advancedMode.html ---------------------------------------------------------------------- diff --git a/eagle-server/src/main/webapp/app/dev/partials/alert/policyEdit/advancedMode.html b/eagle-server/src/main/webapp/app/dev/partials/alert/policyEdit/advancedMode.html index f1952ec..db5d359 100644 --- a/eagle-server/src/main/webapp/app/dev/partials/alert/policyEdit/advancedMode.html +++ b/eagle-server/src/main/webapp/app/dev/partials/alert/policyEdit/advancedMode.html @@ -196,6 +196,23 @@ <div editor placeholder="Please input alert body (support template)" ng-model="policy.alertDefinition.body" ng-disabled="policyLock"></div> </div> + <div class="form-group"> + <label>Alert De-duplication Interval(min)</label><br/> + <input class="form-control" type="text" ng-model="policy.deduplication.dedupIntervalMin" ng-disabled="policyLock" /> + </div> + + <div class="form-group" ng-if="getOutputFields().length"> + <label>Alert De-duplication Fields</label><br/> + <ul class="sm-padding"> + <li ng-repeat="field in getOutputFields() track by $index"> + <label> + <input type="checkbox" ng-checked="isDedupFieldSelected(field)" ng-click="checkDedupField(field)" ng-disabled="policyLock" /> + {{field}} + </label> + </li> + </ul> + </div> + <label> Publish Alerts </label> @@ -331,10 +348,6 @@ <input class="form-control" ng-model="publisher.name" /> </div> <div class="form-group"> - <label>Dedup-Interval Minutes</label> - <input class="form-control" ng-model="publisher.dedupIntervalMin" /> - </div> - <div class="form-group"> <label>Type</label> <select class="form-control" ng-model="publisher.type"> <option ng-repeat="(type, fields) in Policy.publisherTypes track by type">{{type}}</option> http://git-wip-us.apache.org/repos/asf/eagle/blob/a37d2e1b/eagle-server/src/main/webapp/app/dev/public/js/ctrls/alertEditCtrl.js ---------------------------------------------------------------------- diff --git a/eagle-server/src/main/webapp/app/dev/public/js/ctrls/alertEditCtrl.js b/eagle-server/src/main/webapp/app/dev/public/js/ctrls/alertEditCtrl.js index 9e60b51..404c563 100644 --- a/eagle-server/src/main/webapp/app/dev/public/js/ctrls/alertEditCtrl.js +++ b/eagle-server/src/main/webapp/app/dev/public/js/ctrls/alertEditCtrl.js @@ -73,6 +73,10 @@ severity: "WARNING", category: "DEFAULT" }, + deduplication: { + dedupIntervalMin: '30', + dedupFields: [], + }, partitionSpec: [], parallelismHint: 5 }, $scope.policy); @@ -174,6 +178,7 @@ } var checkPromise; + $scope.definition = {}; $scope.definitionMessage = ""; $scope.checkDefinition = function () { $timeout.cancel(checkPromise); @@ -182,25 +187,33 @@ var data = res.data; console.log(data); if(data.success) { + $scope.definition = {}; $scope.definitionMessage = ""; + if(data.policyExecutionPlan) { + $scope.definition = data; + // Input streams $scope.policy.inputStreams = $.map(data.policyExecutionPlan.inputStreams, function (value, stream) { return stream; }); // Output streams - var outputStreams= $.map(data.policyExecutionPlan.outputStreams, function (value, stream) { + var outputStreams = $.map(data.policyExecutionPlan.outputStreams, function (value, stream) { return stream; }); $scope.policy.outputStreams = outputStreams.concat(); $scope.outputStreams = outputStreams; autoDescription(); + // Dedup fields + $scope.policy.deduplication.dedupFields = []; + // Partition $scope.policy.partitionSpec = data.policyExecutionPlan.streamPartitions; } } else { + $scope.definition = {}; $scope.definitionMessage = data.message; } }); @@ -225,6 +238,34 @@ autoDescription(); }; + $scope.getOutputFields = function () { + var defOutputStreams = common.getValueByPath($scope.definition || {}, 'policyExecutionPlan.outputStreams'); + if (!defOutputStreams) return []; + + var fields = $.map($scope.policy.outputStreams, function (outputStream) { + var fields = defOutputStreams[outputStream]; + return $.map(fields, function (field) { + return field.name; + }); + }); + + return fields; + }; + + $scope.isDedupFieldSelected = function (field) { + return $.inArray(field, $scope.policy.deduplication.dedupFields) >= 0; + }; + + $scope.checkDedupField = function (field) { + if($scope.isDedupFieldSelected(field)) { + $scope.policy.deduplication.dedupFields = common.array.remove(field, $scope.policy.deduplication.dedupFields); + } else { + $scope.policy.deduplication.dedupFields.push(field); + } + }; + + //$scope.policy.deduplication.dedupFields + // ============================================================== // = Partition = // ============================================================== @@ -281,7 +322,6 @@ $scope.publisher = { existPublisher: $scope.publisherList[0], type: "org.apache.eagle.alert.engine.publisher.impl.AlertEmailPublisher", - dedupIntervalMin: "PT1M", serializer : "org.apache.eagle.alert.engine.publisher.impl.StringEventSerializer", properties: {} };
