You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@eagle.apache.org by ji...@apache.org on 2016/12/07 08:49:13 UTC

incubator-eagle git commit: [EAGLE-813] UI update alert & publishment api

Repository: incubator-eagle
Updated Branches:
  refs/heads/master 6a7842fc5 -> dcf9e32f7


[EAGLE-813] UI update alert & publishment api

Add `CompatibleEntity` for api support

Author: zombieJ <sm...@gmail.com>

Closes #718 from zombieJ/EAGLE-813.


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

Branch: refs/heads/master
Commit: dcf9e32f70ed92cf2bacc8f021ca908ecc132f06
Parents: 6a7842f
Author: zombieJ <sm...@gmail.com>
Authored: Wed Dec 7 16:46:09 2016 +0800
Committer: zombieJ <sm...@gmail.com>
Committed: Wed Dec 7 16:46:09 2016 +0800

----------------------------------------------------------------------
 eagle-server/src/main/webapp/app/dev/index.html |  1 +
 .../webapp/app/dev/partials/alert/detail.html   | 44 ++++++---
 .../webapp/app/dev/partials/alert/list.html     | 27 ++++--
 .../app/dev/partials/alert/policyDetail.html    | 28 +++---
 .../partials/alert/policyEdit/advancedMode.html | 59 +++++++-----
 .../src/main/webapp/app/dev/public/js/app.js    |  3 +-
 .../webapp/app/dev/public/js/ctrls/alertCtrl.js | 31 +++++--
 .../app/dev/public/js/ctrls/alertEditCtrl.js    | 10 +-
 .../public/js/services/compatibleEntitySrv.js   | 96 ++++++++++++++++++++
 .../app/dev/public/js/services/policySrv.js     | 30 +++++-
 10 files changed, 255 insertions(+), 74 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/dcf9e32f/eagle-server/src/main/webapp/app/dev/index.html
----------------------------------------------------------------------
diff --git a/eagle-server/src/main/webapp/app/dev/index.html b/eagle-server/src/main/webapp/app/dev/index.html
index da00bd0..93018b4 100644
--- a/eagle-server/src/main/webapp/app/dev/index.html
+++ b/eagle-server/src/main/webapp/app/dev/index.html
@@ -263,6 +263,7 @@
 		<script src="public/js/services/widgetSrv.js" type="text/javascript" charset="utf-8"></script>
 		<script src="public/js/services/wrapStateSrv.js" type="text/javascript" charset="utf-8"></script>
 		<script src="public/js/services/entitySrv.js" type="text/javascript" charset="utf-8"></script>
+		<script src="public/js/services/compatibleEntitySrv.js" type="text/javascript" charset="utf-8"></script>
 		<script src="public/js/services/siteSrv.js" type="text/javascript" charset="utf-8"></script>
 		<script src="public/js/services/applicationSrv.js" type="text/javascript" charset="utf-8"></script>
 		<script src="public/js/services/uiSrv.js" type="text/javascript" charset="utf-8"></script>

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/dcf9e32f/eagle-server/src/main/webapp/app/dev/partials/alert/detail.html
----------------------------------------------------------------------
diff --git a/eagle-server/src/main/webapp/app/dev/partials/alert/detail.html b/eagle-server/src/main/webapp/app/dev/partials/alert/detail.html
index 7aac11e..96f7bd5 100644
--- a/eagle-server/src/main/webapp/app/dev/partials/alert/detail.html
+++ b/eagle-server/src/main/webapp/app/dev/partials/alert/detail.html
@@ -20,7 +20,7 @@
 	<div class="box-header with-border">
 		<span class="fa fa-bell"></span>
 		<h3 class="box-title">
-			ID: {{alert.alertId}}
+			ID: {{alert.tags.alertId}}
 			<span class="fa fa-refresh fa-spin no-animate" ng-show="!alertList._done"></span>
 		</h3>
 	</div>
@@ -28,20 +28,24 @@
 		<table class="table">
 			<tbody>
 				<tr>
-					<th width="15%">Policy</th>
-					<td width="35%"><a ui-sref="policyDetail({name: item.policyId})">{{alert.policyId}}</a></td>
-					<th width="15%">Id</th>
-					<td width="35%">{{alert.alertId}}</td>
+					<th width="15%">severity</th>
+					<td width="35%">
+						<span class="label label-{{Policy.getSeverityClass(alert.tags.severity)}}">
+							{{alert.tags.severity}}
+						</span>
+					</td>
+					<th width="15%">Time</th>
+					<td width="35%">{{Time.format(alert.timestamp)}}</td>
 				</tr>
 				<tr>
-					<th>Site</th>
-					<td>{{alert.siteId}}</td>
-					<th>Time</th>
-					<td>{{Time.format(alert.alertTimestamp)}}</td>
+					<th>Policy</th>
+					<td><a ui-sref="policyDetail({name: item.policyId})">{{alert.tags.policyId}}</a></td>
+					<th>Category</th>
+					<td>{{alert.tags.category}}</td>
 				</tr>
 				<tr>
-					<th>Stream</th>
-					<td>{{alert.streamId}}</td>
+					<th>Site</th>
+					<td>{{alert.tags.siteId}}</td>
 					<th>Applications</th>
 					<td>
 						<ul class="list-unstyled">
@@ -52,11 +56,27 @@
 					</td>
 				</tr>
 				<tr>
-					<th>Alert Content</th>
+					<th>Policy</th>
+					<td colspan="3">
+						<pre class="inline">{{alert.policyValue}}</pre>
+					</td>
+				</tr>
+				<tr>
+					<th>Alert Data</th>
 					<td colspan="3">
 						<pre>{{alert.alertData | json}}</pre>
 					</td>
 				</tr>
+				<tr>
+					<th>Alert Subject</th>
+					<td colspan="3">{{alert.alertSubject}}</td>
+				</tr>
+				<tr>
+					<th>Alert Body</th>
+					<td colspan="3">
+						<div ng-bind-html="alertBody"></div>
+					</td>
+				</tr>
 			</tbody>
 		</table>
 	</div>

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/dcf9e32f/eagle-server/src/main/webapp/app/dev/partials/alert/list.html
----------------------------------------------------------------------
diff --git a/eagle-server/src/main/webapp/app/dev/partials/alert/list.html b/eagle-server/src/main/webapp/app/dev/partials/alert/list.html
index e518fa7..e326e47 100644
--- a/eagle-server/src/main/webapp/app/dev/partials/alert/list.html
+++ b/eagle-server/src/main/webapp/app/dev/partials/alert/list.html
@@ -41,23 +41,29 @@
 				<thead>
 					<tr>
 						<th sortpath="alertTimestamp" width="135">
-							Alert Time
+							Time
 							<span class="fa fa-refresh fa-spin no-animate" ng-show="!alertList._done || isSorting"></span>
 						</th>
-						<th sortpath="siteId" width="75">Site</th>
-						<th sortpath="policyId" width="75">Policy</th>
+						<th sortpath="tags.siteId" width="75">Site</th>
+						<th sortpath="tags.policyId" width="75">Policy</th>
+						<th sortpath="tags.severity" width="85">Severity</th>
 						<!--th sortpath="streamId" width="75">Stream</th-->
 						<th width="100">Application</th>
-						<th>Alert Data</th>
+						<th>Alert Subject</th>
 						<th width="10"></th>
 					</tr>
 				</thead>
 				<tbody>
 					<tr>
-						<td>{{Time.format(item.alertTimestamp)}}</td>
-						<td>{{item.siteId}}</td>
+						<td>{{Time.format(item.timestamp)}}</td>
+						<td>{{item.tags.siteId}}</td>
 						<td>
-							<a ui-sref="policyDetail({name: item.policyId})">{{item.policyId}}</a>
+							<a ui-sref="policyDetail({name: item.tags.policyId})">{{item.tags.policyId}}</a>
+						</td>
+						<td>
+							<span class="label label-{{Policy.getSeverityClass(item.tags.severity)}}">
+								{{item.tags.severity}}
+							</span>
 						</td>
 						<!--td>{{item.streamId}}</td-->
 						<td>
@@ -67,7 +73,7 @@
 								</li>
 							</ul>
 						</td>
-						<td class="text-break">
+						<!--td class="text-break">
 							<span ng-if="displayType === 'raw'" na-block="item.alertData"></span>
 							<div ng-if="displayType === 'format'" na-block="!!item.alertData">
 								<ul>
@@ -77,9 +83,10 @@
 									</li>
 								</ul>
 							</div>
-						</td>
+						</td-->
+						<td>{{item.alertSubject}}</td>
 						<td>
-							<a ui-sref="alertDetail({alertId: item.alertId})">Detail</a>
+							<a ui-sref="alertDetail({alertId: item.tags.alertId})">Detail</a>
 						</td>
 					</tr>
 				</tbody>

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/dcf9e32f/eagle-server/src/main/webapp/app/dev/partials/alert/policyDetail.html
----------------------------------------------------------------------
diff --git a/eagle-server/src/main/webapp/app/dev/partials/alert/policyDetail.html b/eagle-server/src/main/webapp/app/dev/partials/alert/policyDetail.html
index 65721ac..7118c85 100644
--- a/eagle-server/src/main/webapp/app/dev/partials/alert/policyDetail.html
+++ b/eagle-server/src/main/webapp/app/dev/partials/alert/policyDetail.html
@@ -128,10 +128,12 @@
 											{{publisher.name}}
 										</strong>
 									</span>
-									<p class="offset" ng-repeat="field in Policy.publisherTypes[publisher.type].displayFields track by $index">
-										<span>{{field}}:</span>
-										<span>{{publisher.properties[field]}}</span>
-									</p>
+									<ul>
+										<li class="offset" ng-repeat="field in Policy.publisherTypes[publisher.type].displayFields track by $index">
+											<span>{{field.name}}:</span>
+											<span>{{publisher.properties[field.name]}}</span>
+										</li>
+									</ul>
 								</li>
 							</ul>
 						</td>
@@ -177,30 +179,22 @@
 				<table class="table table-bordered">
 					<thead>
 					<tr>
-						<th sortpath="alertTimestamp" width="135">
+						<th sortpath="timestamp" width="135">
 							Alert Time
 							<span class="fa fa-refresh fa-spin no-animate" ng-show="!alertList._done || isSorting"></span>
 						</th>
-						<th>Alert Data</th>
+						<th>Alert Subject</th>
 						<th width="10"></th>
 					</tr>
 					</thead>
 					<tbody>
 					<tr>
-						<td>{{Time.format(item.alertTimestamp)}}</td>
+						<td>{{Time.format(item.timestamp)}}</td>
 						<td class="text-break">
-							<span ng-if="displayType === 'raw'" na-block="item.alertData"></span>
-							<div ng-if="displayType === 'format'" na-block="!!item.alertData">
-								<ul>
-									<li ng-repeat="(key, value) in item.alertData track by $index">
-										<strong>{{key}}:</strong>
-										{{value}}
-									</li>
-								</ul>
-							</div>
+							{{item.alertSubject}}
 						</td>
 						<td>
-							<a ui-sref="alertDetail({alertId: item.alertId})">Detail</a>
+							<a ui-sref="alertDetail({alertId: item.tags.alertId})">Detail</a>
 						</td>
 					</tr>
 					</tbody>

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/dcf9e32f/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 d5829c5..16e210d 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
@@ -153,27 +153,39 @@
 					</li>
 				</ul>
 
+				<label>Alert Definition*</label><br/>
 				<div class="form-group">
-					<label>Alert Definition*</label><br/>
-					<span class="text-muted">Category</span>
+					<p class="text-muted">Category</p>
 					<input class="form-control" type="text" ng-model="policy.alertDefinition.category" ng-disabled="policyLock" />
-					<span class="text-muted">Severity</span>
+				</div>
+
+				<div class="form-group">
+					<p class="text-muted">Severity</p>
 					<select class="form-control" ng-model="policy.alertDefinition.severity" ng-disabled="policyLock" >
-						<option value="WARNING" class="text-warning">WARNING</option>
-						<option value="CRITICAL" class="text-danger">CRITICAL</option>
-						<option value="FATAL" class="text-danger">FATAL</option>
-						<option value="OK" class="text-success">OK</option>
+						<option value="WARNING" class="text-{{Policy.getSeverityClass('WARNING')}}">WARNING</option>
+						<option value="CRITICAL" class="text-{{Policy.getSeverityClass('CRITICAL')}}">CRITICAL</option>
+						<option value="FATAL" class="text-{{Policy.getSeverityClass('FATAL')}}">FATAL</option>
+						<option value="OK" class="text-{{Policy.getSeverityClass('OK')}}">OK</option>
 					</select>
-					<span class="text-muted">Alert Subject</span>
-					<span class="fa fa-question-circle ng-scope"
-						  uib-tooltip="Alert subject, support template with alert stream fields and built-in context like: STREAM_ID, ALERT_ID, CREATED_BY, POLICY_ID, CREATED_TIMESTAMP, CREATED_TIME, ALERT_TIMESTAMP, ALERT_TIME, ALERT_SCHEMA, POLICY_DESC, POLICY_TYPE, POLICY_DEFINITION, POLICY_HANDLER">
-					</span>
+				</div>
+
+				<div class="form-group">
+					<p class="text-muted">
+						Alert Subject
+						<span class="fa fa-question-circle ng-scope"
+							  uib-tooltip="Alert subject, support template with alert stream fields and built-in context like: STREAM_ID, ALERT_ID, CREATED_BY, POLICY_ID, CREATED_TIMESTAMP, CREATED_TIME, ALERT_TIMESTAMP, ALERT_TIME, ALERT_SCHEMA, POLICY_DESC, POLICY_TYPE, POLICY_DEFINITION, POLICY_HANDLER">
+						</span>
+					</p>
 					<input type="text" class="form-control" placeholder="Please input alert subject (support template)" ng-model="policy.alertDefinition.subject" ng-disabled="policyLock"/>
-					<span class="text-muted">Alert Body</span>
-					<span class="fa fa-question-circle ng-scope"
-						  uib-tooltip="Alert body, support template with alert stream fields and built-in  context like: STREAM_ID, ALERT_ID, CREATED_BY, POLICY_ID, CREATED_TIMESTAMP, CREATED_TIME, ALERT_TIMESTAMP, ALERT_TIME, ALERT_SCHEMA, POLICY_DESC, POLICY_TYPE, POLICY_DEFINITION, POLICY_HANDLER">
-					</span>
-					<!--<textarea class="form-control" rows="3" placeholder="Please input alert body (support template)" ng-model="policy.alertDefinition.body" ng-disabled="policyLock"></textarea>-->
+				</div>
+
+				<div class="form-group">
+					<p class="text-muted">
+						Alert Body
+						<span class="fa fa-question-circle ng-scope"
+							  uib-tooltip="Alert body, support template with alert stream fields and built-in  context like: STREAM_ID, ALERT_ID, CREATED_BY, POLICY_ID, CREATED_TIMESTAMP, CREATED_TIME, ALERT_TIMESTAMP, ALERT_TIME, ALERT_SCHEMA, POLICY_DESC, POLICY_TYPE, POLICY_DEFINITION, POLICY_HANDLER">
+						</span>
+					</p>
 					<div editor placeholder="Please input alert body (support template)" ng-model="policy.alertDefinition.body" ng-disabled="policyLock"></div>
 				</div>
 
@@ -191,10 +203,13 @@
 								{{publisher.name}}
 							</strong>
 						</span>
-						<p class="offset" ng-repeat="field in Policy.publisherTypes[publisher.type].displayFields track by $index">
-							<span>{{field}}:</span>
-							<span>{{publisher.properties[field]}}</span>
-						</p>
+
+						<ul>
+							<li class="offset" ng-repeat="field in Policy.publisherTypes[publisher.type].displayFields track by $index">
+								<span>{{field.name}}:</span>
+								<span>{{publisher.properties[field.name]}}</span>
+							</li>
+						</ul>
 					</li>
 					<li>
 						<a ng-click="addPublisher()">+ Add Publisher</a>
@@ -319,8 +334,8 @@
 						</select>
 					</div>
 					<div class="form-group" ng-repeat="field in Policy.publisherTypes[publisher.type].fields track by $index">
-						<label>{{field}}</label>
-						<input class="form-control" ng-model="publisher.properties[field]" />
+						<label>{{field.name}}</label>
+						<input class="form-control" ng-model="publisher.properties[field.name]" />
 					</div>
 				</div>
 			</div>

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/dcf9e32f/eagle-server/src/main/webapp/app/dev/public/js/app.js
----------------------------------------------------------------------
diff --git a/eagle-server/src/main/webapp/app/dev/public/js/app.js b/eagle-server/src/main/webapp/app/dev/public/js/app.js
index 577ba4d..1eb833f 100644
--- a/eagle-server/src/main/webapp/app/dev/public/js/app.js
+++ b/eagle-server/src/main/webapp/app/dev/public/js/app.js
@@ -256,12 +256,13 @@ var app = {};
 		// ======================================================================================
 		// =                                   Main Controller                                  =
 		// ======================================================================================
-		eagleApp.controller('MainCtrl', function ($scope, $wrapState, $urlRouter, PageConfig, Portal, Widget, Entity, Site, Application, UI, Time, Policy) {
+		eagleApp.controller('MainCtrl', function ($scope, $wrapState, $urlRouter, PageConfig, Portal, Widget, Entity, CompatibleEntity, Site, Application, UI, Time, Policy) {
 			window._WrapState = $scope.$wrapState = $wrapState;
 			window._PageConfig = $scope.PageConfig = PageConfig;
 			window._Portal = $scope.Portal = Portal;
 			window._Widget = $scope.Widget = Widget;
 			window._Entity = $scope.Entity = Entity;
+			window._CompatibleEntity = $scope.CompatibleEntity = CompatibleEntity;
 			window._Site = $scope.Site = Site;
 			window._Application = $scope.Application = Application;
 			window._UI = $scope.UI = UI;

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/dcf9e32f/eagle-server/src/main/webapp/app/dev/public/js/ctrls/alertCtrl.js
----------------------------------------------------------------------
diff --git a/eagle-server/src/main/webapp/app/dev/public/js/ctrls/alertCtrl.js b/eagle-server/src/main/webapp/app/dev/public/js/ctrls/alertCtrl.js
index b82f88e..52f9796 100644
--- a/eagle-server/src/main/webapp/app/dev/public/js/ctrls/alertCtrl.js
+++ b/eagle-server/src/main/webapp/app/dev/public/js/ctrls/alertCtrl.js
@@ -24,11 +24,15 @@
 	// ======================================================================================
 	// =                                        Alert                                       =
 	// ======================================================================================
-	eagleControllers.controller('alertListCtrl', function ($scope, $wrapState, $interval, PageConfig, Entity) {
+	eagleControllers.controller('alertListCtrl', function ($scope, $wrapState, $interval, PageConfig, CompatibleEntity, Time) {
 		PageConfig.title = "Alerts";
 
 		$scope.displayType = "raw";
-		$scope.alertList = Entity.queryMetadata("alerts", {size: 10000});
+		$scope.alertList = CompatibleEntity.query("LIST", {
+			query: "AlertService",
+			startTime: new Time().subtract(7, 'day'),
+			endTime: new Time()
+		});
 
 		// ================================================================
 		// =                             Sync                             =
@@ -39,18 +43,28 @@
 		});
 	});
 
-	eagleControllers.controller('alertDetailCtrl', function ($scope, $wrapState, PageConfig, Entity) {
+	eagleControllers.controller('alertDetailCtrl', function ($sce, $scope, $wrapState, PageConfig, CompatibleEntity) {
 		PageConfig.title = "Alert Detail";
 
-		$scope.alertList = Entity.queryMetadata("alerts/" + encodeURIComponent($wrapState.param.alertId));
+		$scope.alertList = CompatibleEntity.query("LIST", {
+			query: "AlertService",
+			condition: { alertId: $wrapState.param.alertId }
+		});
 		$scope.alertList._then(function () {
 			$scope.alert = $scope.alertList[0];
+
 			if(!$scope.alert) {
 				$.dialog({
 					title: "OPS",
 					content: "Alert '" + $wrapState.param.alertId + "' not found!"
 				});
+				return;
 			}
+
+			$scope.alertBody = $sce.trustAsHtml(($scope.alert.alertBody + "")
+				.replace(/\\r/g, '\r')
+				.replace(/\\n/g, '\n')
+			);
 		});
 	});
 
@@ -114,7 +128,7 @@
 		};
 	});
 
-	eagleControllers.controller('policyDetailCtrl', function ($scope, $wrapState, $interval, PageConfig, Entity, Policy) {
+	eagleControllers.controller('policyDetailCtrl', function ($scope, $wrapState, $interval, PageConfig, Time, Entity, CompatibleEntity, Policy) {
 		PageConfig.title = "Policy";
 		PageConfig.subTitle = "Detail";
 		PageConfig.navPath = [
@@ -166,7 +180,12 @@
 		}
 		updatePolicy();
 
-		$scope.alertList = Entity.queryMetadata("policies/" + encodeURIComponent($wrapState.param.name) + "/alerts", {size: 1000});
+		$scope.alertList = CompatibleEntity.query("LIST", {
+			query: "AlertService",
+			condition: {policyId: $wrapState.param.name},
+			startTime: new Time().subtract(7, 'day'),
+			endTime: new Time()
+		});
 
 		$scope.deletePolicy = function() {
 			Policy.delete($scope.policy).then(function () {

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/dcf9e32f/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 3bb5609..7c8e0b7 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
@@ -57,8 +57,6 @@
 	});
 
 	function policyEditController(policy, $scope, $q, $wrapState, $timeout, PageConfig, Entity, Policy) {
-		$scope.publisherTypes = Policy.publisherTypes;
-
 		$scope.policy = policy;
 		$scope.policy = common.merge({
 			name: "",
@@ -286,6 +284,12 @@
 				$scope.addPublisherType = "new";
 			}
 
+			$.each(Policy.publisherTypeList, function (i, publisherType) {
+				$.each(publisherType.fields, function (j, field) {
+					if(field.value) $scope.publisher.properties[field.name] = field.value;
+				});
+			});
+
 			$(".modal[data-id='publisherMDL']").modal();
 		};
 
@@ -308,7 +312,7 @@
 			}
 			var properties = {};
 			$.each(Policy.publisherTypes[$scope.publisher.type].fields, function (i, field) {
-				properties[field] = $scope.publisher.properties[field] || "";
+				properties[field.name] = $scope.publisher.properties[field.name] || "";
 			});
 			$scope.policyPublisherList.push($.extend({}, $scope.publisher, {properties: properties}));
 		};

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/dcf9e32f/eagle-server/src/main/webapp/app/dev/public/js/services/compatibleEntitySrv.js
----------------------------------------------------------------------
diff --git a/eagle-server/src/main/webapp/app/dev/public/js/services/compatibleEntitySrv.js b/eagle-server/src/main/webapp/app/dev/public/js/services/compatibleEntitySrv.js
new file mode 100644
index 0000000..d9d4ce7
--- /dev/null
+++ b/eagle-server/src/main/webapp/app/dev/public/js/services/compatibleEntitySrv.js
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+(function() {
+	'use strict';
+
+	var serviceModule = angular.module('eagle.service');
+
+	var _host = "";
+	if(localStorage) {
+		_host = localStorage.getItem("host") || "";
+	}
+
+	serviceModule.service('CompatibleEntity', function($http, Time) {
+		function CompatibleEntity() {}
+
+		function wrapList(list, promise) {
+			list._done = false;
+			list._promise = promise.then(function (res) {
+				var data = res.data;
+				list.splice(0);
+				Array.prototype.push.apply(list, data.obj);
+				list._done = true;
+
+				return res;
+			});
+			return withThen(list);
+		}
+
+		function withThen(list) {
+			list._then = list._promise.then.bind(list._promise);
+			return list;
+		}
+
+		function parseCondition(condition) {
+			condition = condition || {};
+			return $.map(condition, function (value, key) {
+				return '@' + key + '="' + value + '"';
+			}).join(' AND ');
+		}
+
+		function parseFields(fields) {
+			fields = fields || [];
+			if(fields.length === 0) return '*';
+
+			return $.map(fields, function (field) {
+				return '@' + field;
+			}).join(',');
+		}
+
+		CompatibleEntity.QUERY_LIST = '/rest/entities?query=${query}[${condition}]{${fields}}&pageSize=${size}';
+
+		CompatibleEntity.query = function (queryName, param) {
+			var list = [];
+			param = param || {};
+
+			list._refresh = function () {
+				var myParam = $.extend({
+					size: 10000,
+				}, param || {}, {
+					condition: parseCondition(param.condition),
+					fields: parseFields(param.fields),
+					startTime: Time.format(param.startTime),
+					endTime: Time.format(param.endTime)
+				});
+
+				var url_tpl = CompatibleEntity["QUERY_" + queryName];
+				if(param.startTime || param.endTime) {
+					url_tpl += '&startTime=${startTime}&endTime=${endTime}';
+				}
+
+				var url = common.template(url_tpl, myParam);
+				return wrapList(list, $http.get(_host + url));
+			};
+
+			return list._refresh();
+		};
+
+		return CompatibleEntity;
+	});
+})();

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/dcf9e32f/eagle-server/src/main/webapp/app/dev/public/js/services/policySrv.js
----------------------------------------------------------------------
diff --git a/eagle-server/src/main/webapp/app/dev/public/js/services/policySrv.js b/eagle-server/src/main/webapp/app/dev/public/js/services/policySrv.js
index c91449c..80e3964 100644
--- a/eagle-server/src/main/webapp/app/dev/public/js/services/policySrv.js
+++ b/eagle-server/src/main/webapp/app/dev/public/js/services/policySrv.js
@@ -22,8 +22,10 @@
 	var serviceModule = angular.module('eagle.service');
 
 	serviceModule.service('Policy', function($q, UI, Entity) {
-		return {
-			publisherTypes: {
+		var Policy = {
+			publisherTypes: {},
+			publisherTypeList: Entity.queryMetadata('publishmentTypes'),
+			/* publisherTypes: {
 				'org.apache.eagle.alert.engine.publisher.impl.AlertEmailPublisher': {
 					name: "Email",
 					displayFields: ["recipients"],
@@ -44,7 +46,7 @@
 					displayFields: [],
 					fields: []
 				}
-			},
+			}, */
 
 			delete: function (policy) {
 				var deferred = $q.defer();
@@ -69,5 +71,27 @@
 				return Entity.post("metadata/policies/" + encodeURIComponent(policy.name) + "/status/DISABLED", {})._promise;
 			}
 		};
+
+		Policy.publisherTypeList._then(function () {
+			$.each(Policy.publisherTypeList, function (i, type) {
+				type.displayFields = type.displayFields || type.fields;
+				Policy.publisherTypes[type.type] = type;
+			});
+		});
+
+		Policy.getSeverityClass = function (severity) {
+			switch ((severity || "").toUpperCase()) {
+				case "WARNING":
+					return "warning";
+				case "CRITICAL":
+				case "FATAL":
+					return "danger";
+				case "OK":
+					return "success";
+			}
+			return "default";
+		};
+
+		return Policy;
 	});
 })();