eagle-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ji...@apache.org
Subject eagle git commit: [EAGLE-970] Alert list page show alert trend
Date Wed, 22 Mar 2017 02:26:45 GMT
Repository: eagle
Updated Branches:
  refs/heads/master 673a81e44 -> 368197f62


[EAGLE-970] Alert list page show alert trend

Alert list page show alert trend

Author: zombieJ <smith3816@gmail.com>

Closes #889 from zombieJ/EAGLE-970.


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

Branch: refs/heads/master
Commit: 368197f622b83ab342f1e245b318815fb8a96df0
Parents: 673a81e
Author: zombieJ <smith3816@gmail.com>
Authored: Wed Mar 22 10:26:36 2017 +0800
Committer: zombieJ <smith3816@gmail.com>
Committed: Wed Mar 22 10:26:36 2017 +0800

----------------------------------------------------------------------
 .../webapp/app/dev/partials/alert/list.html     | 29 ++++-----------
 .../webapp/app/dev/public/js/ctrls/alertCtrl.js | 39 +++++++++++++++++++-
 .../public/js/services/compatibleEntitySrv.js   |  7 +++-
 3 files changed, 50 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/eagle/blob/368197f6/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 371248f..7781264 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
@@ -19,11 +19,12 @@
 <div class="box box-primary">
 	<div class="box-header with-border">
 		<span class="fa fa-bell"></span>
-		<h3 class="box-title">
-			Alert Incidents
-		</h3>
+		<h3 class="box-title">Alert Incidents</h3>
 	</div>
 	<div class="box-body">
+		<div chart style="height: 200px;" series="alertTrend"></div>
+	</div>
+	<div class="box-footer">
 		<div sort-table="alertList" is-sorting="isSorting">
 			<table class="table table-bordered">
 				<thead>
@@ -50,27 +51,8 @@
 							</span>
 						</td>
 						<td>{{item.tags.siteId}}</td>
-						<!--<td>-->
-							<!--<ul class="list-unstyled">-->
-								<!--<li ng-repeat="app in item.appIds track by $index" class="label label-sm
label-primary">-->
-									<!--{{Application.findProvider(app).type || app}}-->
-								<!--</li>-->
-							<!--</ul>-->
-						<!--</td>-->
 						<td>{{item.tags.category || "N/A"}}</td>
 						<td><a ui-sref="alertDetail({siteId: site, alertId: item.tags.alertId, timestamp:
item.timestamp})" title="{{item.alertBody}}">{{item.alertSubject}}</a></td>
-						<!--td>{{item.streamId}}</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>
-						</td-->
 						<td>
 							<a ui-sref="policyDetail({siteId: site, name: item.tags.policyId})">{{item.tags.policyId}}</a>
 						</td>
@@ -82,4 +64,7 @@
 			</table>
 		</div>
 	</div>
+	<div class="overlay" ng-if="loading">
+		<i class="fa fa-refresh fa-spin"></i>
+	</div>
 </div>

http://git-wip-us.apache.org/repos/asf/eagle/blob/368197f6/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 88b44cd..743b4b6 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
@@ -19,12 +19,18 @@
 (function() {
 	'use strict';
 
+	var colorMapping = {
+		WARNING: '#f39c12',
+		CRITICAL: '#dd4b39',
+		FATAL: '#dd4b39',
+		OK: '#00a65a'
+	};
 	var eagleControllers = angular.module('eagleControllers');
 
 	// ======================================================================================
 	// =                                        Alert                                      
=
 	// ======================================================================================
-	eagleControllers.controller('alertListCtrl', function ($scope, $wrapState, PageConfig, CompatibleEntity,
Time) {
+	eagleControllers.controller('alertListCtrl', function ($q, $scope, $wrapState, PageConfig,
CompatibleEntity, Time) {
 		PageConfig.title = "Alert Incidents";
 		$scope.site = $wrapState.param.siteId;
 
@@ -33,6 +39,7 @@
 
 		function loadAlerts() {
 			$scope.loading = true;
+			// Alert List
 			var list = CompatibleEntity.query("LIST", {
 				query: "AlertService",
 				condition: {siteId: $scope.site},
@@ -41,6 +48,36 @@
 			});
 			list._then(function () {
 				$scope.alertList = list;
+			});
+
+			// Alert Trend
+			$scope.alertTrend = [];
+			var alertTrend = CompatibleEntity.timeSeries({
+				condition: { siteId: $scope.site },
+				groups: 'severity',
+				fields: ['count'],
+				query: 'AlertService',
+				startTime: new Time('startTime'),
+				endTime: new Time('endTime'),
+				limit: 100000,
+			});
+			alertTrend._promise.then(function () {
+				$scope.alertTrend = $.map(alertTrend, function (series) {
+					var type = series.group.key[0];
+					return $.extend({}, series, {
+						name: type,
+						type: 'bar',
+						stack: 'severity',
+						itemStyle: {
+							normal: {
+								color: colorMapping[type],
+							},
+						},
+					});
+				});
+			});
+
+			$q.all([list._promise, alertTrend._promise]).then(function () {
 				$scope.loading = false;
 			});
 		}

http://git-wip-us.apache.org/repos/asf/eagle/blob/368197f6/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
index 405af81..dfc9158 100644
--- 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
@@ -109,6 +109,7 @@
 
 		CompatibleEntity.QUERY_LIST = '/rest/entities?query=${query}[${condition}]{${fields}}&pageSize=${limit}';
 		CompatibleEntity.QUERY_GROUPS = '/rest/entities?query=${query}[${condition}]<${groups}>{${fields}}&pageSize=${limit}';
+		CompatibleEntity.QUERY_GROUPS_INTERVAL = '/rest/entities?query=${query}[${condition}]<${groups}>{${fields}}${order}${top}&pageSize=${limit}&startTime=${startTime}&endTime=${endTime}&intervalmin=${intervalMin}&timeSeries=true';
 		CompatibleEntity.QUERY_METRICS_INTERVAL = '/rest/entities?query=GenericMetricService[${condition}]<${groups}>{${fields}}${order}${top}&metricName=${metric}&pageSize=${limit}&startTime=${startTime}&endTime=${endTime}&intervalmin=${intervalMin}&timeSeries=true';
 
 		CompatibleEntity.query = function (queryName, param) {
@@ -175,7 +176,7 @@
 			var intervalMin = param.intervalMin ? param.intervalMin : Time.diffInterval(startTime,
endTime) / 1000 / 60;
 			var interval = intervalMin * 1000 * 60;
 
-			var innerList = CompatibleEntity.query('METRICS_INTERVAL', $.extend({}, param, {
+			var innerList = CompatibleEntity.query(param.metric ? 'METRICS_INTERVAL' : 'GROUPS_INTERVAL',
$.extend({}, param, {
 				groups: parseFields(param.groups).fields,
 				order: fields.order,
 				top: param.top ? "&top=" + param.top : "",
@@ -204,7 +205,9 @@
 									x: startTimestamp + interval * index,
 									y: value
 								};
-							})
+							}),
+
+							group: group,
 						};
 					});
 				});


Mime
View raw message