eagle-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h..@apache.org
Subject eagle git commit: [EAGLE-901] add site filter
Date Thu, 16 Feb 2017 06:16:42 GMT
Repository: eagle
Updated Branches:
  refs/heads/master 49ca3b0ec -> 000ac3c00


[EAGLE-901] add site filter

* Alert -> Alert List
* Alert -> Stream

Author: zombieJ <smith3816@gmail.com>

Closes #806 from zombieJ/EAGLE-901.


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

Branch: refs/heads/master
Commit: 000ac3c0012c79f6eb1f6d7384a254a1e5f8ac9c
Parents: 49ca3b0
Author: zombieJ <smith3816@gmail.com>
Authored: Thu Feb 16 14:16:31 2017 +0800
Committer: Hao Chen <hao@apache.org>
Committed: Thu Feb 16 14:16:31 2017 +0800

----------------------------------------------------------------------
 .../webapp/app/dev/partials/alert/list.html     | 10 +++++
 .../app/dev/partials/alert/streamList.html      | 10 +++++
 .../webapp/app/dev/public/js/ctrls/alertCtrl.js | 43 +++++++++++++++-----
 3 files changed, 53 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/eagle/blob/000ac3c0/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 d06b41f..fce2f7f 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
@@ -24,6 +24,16 @@
 		</h3>
 	</div>
 	<div class="box-body">
+		<!-- Site Filter -->
+		<ul class="nav nav-pills with-border">
+			<li><span>Site Filter:</span></li>
+			<li ng-class="{active: siteFilter === ''}" ng-click="updateSiteFilter('')"><a>All</a></li>
+			<li ng-class="{active: siteFilter === site.siteId}" ng-click="updateSiteFilter(site.siteId)"
+			    ng-repeat="site in Site.list track by $index">
+				<a>{{site.siteName || site.siteId}}</a>
+			</li>
+		</ul>
+
 		<div sort-table="alertList" is-sorting="isSorting">
 			<table class="table table-bordered">
 				<thead>

http://git-wip-us.apache.org/repos/asf/eagle/blob/000ac3c0/eagle-server/src/main/webapp/app/dev/partials/alert/streamList.html
----------------------------------------------------------------------
diff --git a/eagle-server/src/main/webapp/app/dev/partials/alert/streamList.html b/eagle-server/src/main/webapp/app/dev/partials/alert/streamList.html
index 0824188..a6b6183 100644
--- a/eagle-server/src/main/webapp/app/dev/partials/alert/streamList.html
+++ b/eagle-server/src/main/webapp/app/dev/partials/alert/streamList.html
@@ -24,6 +24,16 @@
 		</h3>
 	</div>
 	<div class="box-body">
+		<!-- Site Filter -->
+		<ul class="nav nav-pills with-border">
+			<li><span>Site Filter:</span></li>
+			<li ng-class="{active: siteFilter === ''}" ng-click="updateSiteFilter('')"><a>All</a></li>
+			<li ng-class="{active: siteFilter === site.siteId}" ng-click="updateSiteFilter(site.siteId)"
+			    ng-repeat="site in Site.list track by $index">
+				<a>{{site.siteName || site.siteId}}</a>
+			</li>
+		</ul>
+
 		<div sort-table="streamList">
 			<table class="table table-bordered table-hover">
 				<thead>

http://git-wip-us.apache.org/repos/asf/eagle/blob/000ac3c0/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 4b5cdf7..c866efb 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
@@ -27,9 +27,23 @@
 	eagleControllers.controller('alertListCtrl', function ($scope, $wrapState, PageConfig, CompatibleEntity,
Time) {
 		PageConfig.title = "Alerts";
 
+		var originAlertList = [];
 		$scope.alertList = [];
+		$scope.siteFilter = '';
 		$scope.loading = false;
 
+		$scope.updateSiteFilter = function (siteId) {
+			if (siteId !== undefined) $scope.siteFilter = siteId;
+
+			if ($scope.siteFilter) {
+				$scope.alertList = $.grep(originAlertList, function (alert) {
+					return alert.tags.siteId === $scope.siteFilter;
+				});
+			} else {
+				$scope.alertList = originAlertList;
+			}
+		};
+
 		function loadAlerts() {
 			$scope.loading = true;
 			var list = CompatibleEntity.query("LIST", {
@@ -38,21 +52,14 @@
 				endTime: new Time('endTime')
 			});
 			list._then(function () {
-				$scope.alertList = list;
+				originAlertList = list;
+				$scope.updateSiteFilter();
 				$scope.loading = false;
 			});
 		}
 		loadAlerts();
 
 		Time.onReload(loadAlerts, $scope);
-
-		// ================================================================
-		// =                             Sync                             =
-		// ================================================================
-		/* var refreshInterval = $interval($scope.alertList._refresh, 1000 * 10);
-		$scope.$on('$destroy', function() {
-			$interval.cancel(refreshInterval);
-		}); */
 	});
 
 	eagleControllers.controller('alertDetailCtrl', function ($sce, $scope, $wrapState, PageConfig,
CompatibleEntity) {
@@ -86,12 +93,28 @@
 	eagleControllers.controller('alertStreamListCtrl', function ($scope, $wrapState, PageConfig,
Application, Entity) {
 		PageConfig.title = "Streams";
 
+		var originStreamList = [];
 		$scope.streamList = [];
+		$scope.siteFilter = '';
+
+		$scope.updateSiteFilter = function (siteId) {
+			if (siteId !== undefined) $scope.siteFilter = siteId;
+
+			if ($scope.siteFilter) {
+				$scope.streamList = $.grep(originStreamList, function (stream) {
+					return stream.siteId === $scope.siteFilter;
+				});
+			} else {
+				$scope.streamList = originStreamList;
+			}
+		};
+
 		Entity.queryMetadata("streams")._then(function (res) {
-			$scope.streamList = $.map(res.data, function (stream) {
+			originStreamList = $.map(res.data, function (stream) {
 				var application = Application.findProvider(stream.dataSource);
 				return $.extend({application: application}, stream);
 			});
+			$scope.updateSiteFilter();
 		});
 
 		$scope.dataSources = {};


Mime
View raw message