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-914] UI move alert & policy to site spec
Date Mon, 20 Feb 2017 09:00:23 GMT
Repository: eagle
Updated Branches:
  refs/heads/master 579e83f5f -> c85056736


[EAGLE-914] UI move alert & policy to site spec

UI move alert & policy to site spec

Author: zombieJ <smith3816@gmail.com>

Closes #822 from zombieJ/EAGLE-914.


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

Branch: refs/heads/master
Commit: c85056736b9d41df17dd895ecf9cb66ecce2f433
Parents: 579e83f
Author: zombieJ <smith3816@gmail.com>
Authored: Mon Feb 20 17:00:17 2017 +0800
Committer: Hao Chen <hao@apache.org>
Committed: Mon Feb 20 17:00:17 2017 +0800

----------------------------------------------------------------------
 .../webapp/app/dev/partials/alert/list.html     | 10 ---
 .../app/dev/partials/alert/policyList.html      | 14 +--
 .../app/dev/partials/alert/streamList.html      | 10 ---
 .../src/main/webapp/app/dev/public/js/app.js    | 94 ++++++++++----------
 .../webapp/app/dev/public/js/ctrls/alertCtrl.js | 59 ++----------
 .../app/dev/public/js/ctrls/alertEditCtrl.js    |  3 +-
 .../app/dev/public/js/services/pageSrv.js       | 24 +++--
 7 files changed, 79 insertions(+), 135 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/eagle/blob/c8505673/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 fce2f7f..d06b41f 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,16 +24,6 @@
 		</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/c8505673/eagle-server/src/main/webapp/app/dev/partials/alert/policyList.html
----------------------------------------------------------------------
diff --git a/eagle-server/src/main/webapp/app/dev/partials/alert/policyList.html b/eagle-server/src/main/webapp/app/dev/partials/alert/policyList.html
index 6351674..b41c320 100644
--- a/eagle-server/src/main/webapp/app/dev/partials/alert/policyList.html
+++ b/eagle-server/src/main/webapp/app/dev/partials/alert/policyList.html
@@ -24,16 +24,6 @@
 		</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="policyList" ng-show="policyList.length">
 			<table class="table table-bordered">
 				<thead>
@@ -72,7 +62,7 @@
 
 		<div class="callout callout-warning no-margin" ng-show="!loading && policyList.length
=== 0">
 			<h4>No Policy yet</h4>
-			<p>You have not create policy yet. Click <a ui-sref="policyCreate()">here</a>
to create a new policy.</p>
+			<p>You have not create policy yet. Click <a ui-sref="policyCreate({ siteId: site
})">here</a> to create a new policy.</p>
 		</div>
 	</div>
 
@@ -81,6 +71,6 @@
 	</div>
 
 	<div class="box-footer text-right">
-		<a ui-sref="policyCreate()" class="btn btn-primary">New Policy</a>
+		<a ui-sref="policyCreate({ siteId: site })" class="btn btn-primary">New Policy</a>
 	</div>
 </div>

http://git-wip-us.apache.org/repos/asf/eagle/blob/c8505673/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 a6b6183..0824188 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,16 +24,6 @@
 		</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/c8505673/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 f28f362..c593406 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
@@ -43,6 +43,8 @@ var app = {};
 		// ======================================================================================
 		// =                                   Router config                                  
 =
 		// ======================================================================================
+		var defaultRouterStates = ['site', 'alertList', 'policyList', 'streamList', 'policyCreate',
'policyEdit', 'alertDetail', 'policyDetail'];
+
 		function routeResolve(config) {
 			var resolve = {};
 			if(config === false) return resolve;
@@ -72,7 +74,7 @@ var app = {};
 			resolve._router = function (Site, $wrapState, $q) {
 				var name = state_next.name;
 				var siteId = param_next.siteId;
-				if (siteId && name !== "site") {
+				if (siteId && defaultRouterStates.indexOf(name) === -1) {
 					return Site.getPromise(config).then(function () {
 						var match =  false;
 						$.each(common.getValueByPath(Site.find(siteId), ["applicationList"]), function (i,
app) {
@@ -120,50 +122,6 @@ var app = {};
 					controller: "setupCtrl",
 					resolve: routeResolve({ site: false, application: false })
 				})
-				// ================================= Alerts =================================
-				.state('alertList', {
-					url: "/alerts?startTime&endTime",
-					templateUrl: "partials/alert/list.html?_=" + window._TRS(),
-					controller: "alertListCtrl",
-					resolve: routeResolve({ time: { autoRefresh: true } })
-				})
-				.state('policyList', {
-					url: "/policies",
-					templateUrl: "partials/alert/policyList.html?_=" + window._TRS(),
-					controller: "policyListCtrl",
-					resolve: routeResolve()
-				})
-				.state('streamList', {
-					url: "/streams",
-					templateUrl: "partials/alert/streamList.html?_=" + window._TRS(),
-					controller: "alertStreamListCtrl",
-					resolve: routeResolve()
-				})
-				.state('policyCreate', {
-					url: "/policy/create",
-					templateUrl: "partials/alert/policyEdit/main.html?_=" + window._TRS(),
-					controller: "policyCreateCtrl",
-					resolve: routeResolve()
-				})
-				.state('policyEdit', {
-					url: "/policy/edit/{name}",
-					templateUrl: "partials/alert/policyEdit/main.html?_=" + window._TRS(),
-					controller: "policyEditCtrl",
-					resolve: routeResolve()
-				})
-
-				.state('alertDetail', {
-					url: "/alert/detail/{alertId}",
-					templateUrl: "partials/alert/detail.html?_=" + window._TRS(),
-					controller: "alertDetailCtrl",
-					resolve: routeResolve()
-				})
-				.state('policyDetail', {
-					url: "/policy/detail/{name}",
-					templateUrl: "partials/alert/policyDetail.html?_=" + window._TRS(),
-					controller: "policyDetailCtrl",
-					resolve: routeResolve()
-				})
 
 				// =============================== Integration ==============================
 				.state('integration', {
@@ -208,6 +166,52 @@ var app = {};
 					controller: "siteCtrl",
 					resolve: routeResolve()
 				})
+
+				// ============================== Site: Alerts ==============================
+				.state('alertList', {
+					url: "/site/:siteId/alerts?startTime&endTime",
+					templateUrl: "partials/alert/list.html?_=" + window._TRS(),
+					controller: "alertListCtrl",
+					resolve: routeResolve({ time: { autoRefresh: true } })
+				})
+				.state('policyList', {
+					url: "/site/:siteId/policies",
+					templateUrl: "partials/alert/policyList.html?_=" + window._TRS(),
+					controller: "policyListCtrl",
+					resolve: routeResolve()
+				})
+				.state('streamList', {
+					url: "/site/:siteId/streams",
+					templateUrl: "partials/alert/streamList.html?_=" + window._TRS(),
+					controller: "alertStreamListCtrl",
+					resolve: routeResolve()
+				})
+
+				.state('policyCreate', {
+					url: "/site/:siteId/policy/create",
+					templateUrl: "partials/alert/policyEdit/main.html?_=" + window._TRS(),
+					controller: "policyCreateCtrl",
+					resolve: routeResolve()
+				})
+				.state('policyEdit', {
+					url: "/site/:siteId/policy/edit/{name}",
+					templateUrl: "partials/alert/policyEdit/main.html?_=" + window._TRS(),
+					controller: "policyEditCtrl",
+					resolve: routeResolve()
+				})
+
+				.state('alertDetail', {
+					url: "/site/:siteId/alert/detail/{alertId}",
+					templateUrl: "partials/alert/detail.html?_=" + window._TRS(),
+					controller: "alertDetailCtrl",
+					resolve: routeResolve()
+				})
+				.state('policyDetail', {
+					url: "/site/:siteId/policy/detail/{name}",
+					templateUrl: "partials/alert/policyDetail.html?_=" + window._TRS(),
+					controller: "policyDetailCtrl",
+					resolve: routeResolve()
+				})
 			;
 
 			// =========================== Application States ===========================

http://git-wip-us.apache.org/repos/asf/eagle/blob/c8505673/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 d464858..5360571 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
@@ -26,34 +26,21 @@
 	// ======================================================================================
 	eagleControllers.controller('alertListCtrl', function ($scope, $wrapState, PageConfig, CompatibleEntity,
Time) {
 		PageConfig.title = "Alerts";
+		$scope.site = $wrapState.param.siteId;
 
-		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", {
 				query: "AlertService",
+				condition: {siteId: $scope.site},
 				startTime: new Time('startTime'),
 				endTime: new Time('endTime')
 			});
 			list._then(function () {
-				originAlertList = list;
-				$scope.updateSiteFilter();
+				$scope.alertList = list;
 				$scope.loading = false;
 			});
 		}
@@ -93,28 +80,14 @@
 	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;
+		$scope.site = $wrapState.param.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) {
-			originStreamList = $.map(res.data, function (stream) {
+		Entity.queryMetadata("streams", { siteId: $scope.site })._then(function (res) {
+			$scope.streamList = $.map(res.data, function (stream) {
 				var application = Application.findProvider(stream.dataSource);
 				return $.extend({application: application}, stream);
 			});
-			$scope.updateSiteFilter();
 		});
 
 		$scope.dataSources = {};
@@ -141,30 +114,16 @@
 		PageConfig.title = "Policies";
 		$scope.loading = false;
 
-		var originPolicyList = [];
 		$scope.policyList = [];
-		$scope.siteFilter = '';
-
-		$scope.updateSiteFilter = function (siteId) {
-			if (siteId !== undefined) $scope.siteFilter = siteId;
-
-			if ($scope.siteFilter) {
-				$scope.policyList = $.grep(originPolicyList, function (policy) {
-					return policy.siteId === $scope.siteFilter;
-				});
-			} else {
-				$scope.policyList = originPolicyList;
-			}
-		};
+		$scope.site = $wrapState.param.siteId;
 
 		function updateList() {
-			var list = Entity.queryMetadata("policies");
+			var list = Entity.queryMetadata("policies", { siteId: $scope.site });
 			$scope.loading = true;
 
 			list._then(function () {
 				$scope.loading = false;
-				originPolicyList = list;
-				$scope.updateSiteFilter();
+				$scope.policyList = list;
 			});
 		}
 		updateList();

http://git-wip-us.apache.org/repos/asf/eagle/blob/c8505673/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 9b62f6a..b32a87f 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
@@ -76,6 +76,7 @@
 			partitionSpec: [],
 			parallelismHint: 5
 		}, $scope.policy);
+		$scope.policy.siteId = $scope.policy.siteId || $wrapState.param.siteId;
 		console.log("[Policy]", $scope.policy);
 
 		var cacheSiteId;
@@ -388,7 +389,7 @@
 								title: "Done",
 								content: "Close dialog to go to the policy detail page."
 							}, function () {
-								$wrapState.go("policyDetail", {name: $scope.policy.name});
+								$wrapState.go("policyDetail", {name: $scope.policy.name, siteId: $scope.policy.siteId});
 							});
 						}, function (res) {
 							// Link Failed

http://git-wip-us.apache.org/repos/asf/eagle/blob/c8505673/eagle-server/src/main/webapp/app/dev/public/js/services/pageSrv.js
----------------------------------------------------------------------
diff --git a/eagle-server/src/main/webapp/app/dev/public/js/services/pageSrv.js b/eagle-server/src/main/webapp/app/dev/public/js/services/pageSrv.js
index 6f7e3c6..f68789d 100644
--- a/eagle-server/src/main/webapp/app/dev/public/js/services/pageSrv.js
+++ b/eagle-server/src/main/webapp/app/dev/public/js/services/pageSrv.js
@@ -91,12 +91,12 @@
 
 		var defaultPortalList = [
 			{name: "Home", icon: "home", path: "#/"},
-			{name: "Alert", icon: "bell", showFunc: checkApplication, list: [
+			/* {name: "Alert", icon: "bell", showFunc: checkApplication, list: [
 				{name: "Alerts", path: "#/alerts"},
 				{name: "Policies", path: "#/policies"},
 				{name: "Streams", path: "#/streams"},
 				{name: "Define Policy", path: "#/policy/create"}
-			]}
+			]} */
 		];
 		var adminPortalList = [
 			{name: "Integration", icon: "puzzle-piece", showFunc: checkSite, list: [
@@ -112,12 +112,23 @@
 		var connectedMainPortalList = [];
 		var sitePortals = {};
 
-		var backHome = {name: "Back", icon: "arrow-left", path: "#/"};
-
 		Portal.register = function (portal, isSite) {
 			(isSite ? sitePortalList : mainPortalList).push(portal);
 		};
 
+		function getDefaultSitePortal(site) {
+			return[
+				{name: "Back", icon: "arrow-left", path: "#/"},
+				{name: site.siteName || site.siteId + " Home", icon: "home", path: "#/site/" + site.siteId},
+				{name: "Alert", icon: "bell", list: [
+					{name: "Alerts", path: "#/site/" + site.siteId + "/alerts"},
+					{name: "Policies", path: "#/site/" + site.siteId + "/policies"},
+					{name: "Streams", path: "#/site/" + site.siteId + "/streams"},
+					{name: "Define Policy", path: "#/site/" + site.siteId + "/policy/create"}
+				]},
+			];
+		}
+
 		function convertSitePortal(site, portal) {
 			portal = $.extend({}, portal, {
 				path: portal.path ? "#/site/" + site.siteId + "/" + portal.path.replace(/^[\\\/]/, "")
: null
@@ -165,15 +176,14 @@
 			// Site level
 			sitePortals = {};
 			$.each(Site.list, function (i, site) {
-				var siteHome = {name: site.siteName || site.siteId + " Home", icon: "home", path: "#/site/"
+ site.siteId};
-				var sitePortalList = [backHome, siteHome].concat($.map(sitePortalList, function (portal)
{
+				var tmpSitePortalList = getDefaultSitePortal(site).concat($.map(sitePortalList, function
(portal) {
 					var hasApp = !!common.array.find(portal.application, site.applicationList, "descriptor.type");
 					if(hasApp) {
 						return convertSitePortal(site, portal);
 					}
 				}));
 
-				sitePortals[site.siteId] = mergePortalList(sitePortalList);
+				sitePortals[site.siteId] = mergePortalList(tmpSitePortalList);
 			});
 		};
 


Mime
View raw message