eagle-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ji...@apache.org
Subject incubator-eagle git commit: [EAGLE-686] UI add site select on top nav bar
Date Thu, 27 Oct 2016 08:13:37 GMT
Repository: incubator-eagle
Updated Branches:
  refs/heads/master 8d26a4f12 -> 1add6d96f


[EAGLE-686] UI add site select on top nav bar

UI add site select on top nav bar for user quick access.

Author: zombieJ <smith3816@gmail.com>

Closes #569 from zombieJ/EAGLE-686.


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

Branch: refs/heads/master
Commit: 1add6d96f198fb3b8aecd20243bc087b3973f656
Parents: 8d26a4f
Author: zombieJ <smith3816@gmail.com>
Authored: Thu Oct 27 16:13:26 2016 +0800
Committer: zombieJ <smith3816@gmail.com>
Committed: Thu Oct 27 16:13:26 2016 +0800

----------------------------------------------------------------------
 eagle-server/src/main/webapp/app/dev/index.html | 21 +++++++++++++
 .../partials/alert/policyEdit/advancedMode.html |  2 +-
 .../src/main/webapp/app/dev/public/css/main.css | 13 ++++++--
 .../src/main/webapp/app/dev/public/js/app.js    | 33 ++++++++++++++++++++
 .../app/dev/public/js/ctrls/alertEditCtrl.js    | 16 +++++-----
 .../src/main/webapp/app/dev/public/js/index.js  | 27 ++++++++++++++--
 .../app/dev/public/js/services/siteSrv.js       | 11 +++++++
 7 files changed, 109 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/1add6d96/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 64c8c57..05ad602 100644
--- a/eagle-server/src/main/webapp/app/dev/index.html
+++ b/eagle-server/src/main/webapp/app/dev/index.html
@@ -77,6 +77,27 @@
 									<li><a ng-click="customizeTimeRange()"><i class="fa fa-clock-o"></i>Customize</a></li>
 								</ul>
 							</li>
+							<li class="hover-dropdown">
+								<a>
+									<span ng-if="!Site.current()">
+										<span class="fa fa-home"></span>
+										Overview
+									</span>
+									<span ng-if="Site.current()">
+										<span class="fa fa-server"></span>
+										{{Site.current().siteName || Site.current().siteId}}
+									</span>
+								</a>
+
+								<ul class="dropdown-menu">
+									<li><a ng-click="Site.switchSite()"><span class="fa fa-home"></span>
Overview</a></li>
+									<li ng-repeat="site in Site.list track by $index">
+										<a ng-click="Site.switchSite(site)">
+											<span class="fa fa-server"></span> {{site.siteName || site.siteId}}
+										</a>
+									</li>
+								</ul>
+							</li>
 							<li>
 								<a data-toggle="dropdown" aria-expanded="false">
 									<i class="glyphicon glyphicon-question-sign"></i>

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/1add6d96/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 624acaa..55ce0fa 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
@@ -89,7 +89,7 @@
 					<div class="col-md-8">
 						<div class="form-group">
 							<label>* Name</label>
-							<input type="text" class="form-control" ng-model="policy.name" ng-readonly="newPolicy"
ng-disabled="policyLock" />
+							<input type="text" class="form-control" ng-model="policy.name" ng-readonly="!newPolicy"
ng-disabled="policyLock" />
 						</div>
 					</div>
 					<div class="col-md-4">

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/1add6d96/eagle-server/src/main/webapp/app/dev/public/css/main.css
----------------------------------------------------------------------
diff --git a/eagle-server/src/main/webapp/app/dev/public/css/main.css b/eagle-server/src/main/webapp/app/dev/public/css/main.css
index 4b7a799..a447bdf 100644
--- a/eagle-server/src/main/webapp/app/dev/public/css/main.css
+++ b/eagle-server/src/main/webapp/app/dev/public/css/main.css
@@ -70,7 +70,7 @@ a {
  * ======================================================================== */
 
 @media (min-width: 1200px) {
-	.row.flex {
+	body:not(.safari) .row.flex {
 		display: -webkit-box;
 		display: -webkit-flex;
 		display: -ms-flexbox;
@@ -78,7 +78,7 @@ a {
 		flex-wrap: wrap;
 	}
 
-	.row.flex > [class*='col-'] {
+	body:not(.safari) .row.flex > [class*='col-'] {
 		display: -webkit-box;
 		display: -webkit-flex;
 		display: -ms-flexbox;
@@ -87,7 +87,7 @@ a {
 		flex-wrap: nowrap;
 	}
 
-	.row.flex > [class*='col-'] > * {
+	body:not(.safari) .row.flex > [class*='col-'] > * {
 		flex: auto;
 	}
 }
@@ -102,6 +102,13 @@ a {
 }
 
 /* ========================================================================
+ * =                              Drop Down                               =
+ * ======================================================================== */
+.hover-dropdown:hover .dropdown-menu {
+	display: block;
+}
+
+/* ========================================================================
  * =                                Table                                 =
  * ======================================================================== */
 table .info-wrapper .info-detail {

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/1add6d96/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 277d0fa..9b46e65 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
@@ -30,6 +30,11 @@ var app = {};
 		var param_next;
 		var param_current;
 
+		var modules = {};
+		$.each(register.moduleList, function (i, module) {
+			modules[module.application] = module;
+		});
+
 		// ======================================================================================
 		// =                                   Initialization                                 
 =
 		// ======================================================================================
@@ -60,6 +65,34 @@ var app = {};
 				return Application.getPromise();
 			};
 
+			resolve._router = function (Site, $wrapState, $q) {
+				var name = state_next.name;
+				var siteId = param_next.siteId;
+				if (siteId && name !== "site") {
+					return Site.getPromise(config).then(function () {
+						var match =  false;
+						$.each(common.getValueByPath(Site.find(siteId), ["applicationList"]), function (i,
app) {
+							var appType = app.descriptor.type;
+							var module = modules[appType];
+							if(!module) return;
+
+							if(common.array.find(name, module.routeList, ["state"])) {
+								match = true;
+								return false;
+							}
+						});
+
+						if(!match) {
+							console.log("[Application] No route match:", name);
+							$wrapState.go("site", {siteId: siteId});
+							return $q.reject(false);
+						}
+					});
+				} else {
+					return true;
+				}
+			};
+
 			resolve.Time = function (Time) {
 				return Time.getPromise(config, state_next, param_next);
 			};

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/1add6d96/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 8fde4b1..3629651 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
@@ -101,7 +101,7 @@
 		var searchApplications;
 		$scope.searchSourceKey = "";
 		$scope.applications = {};
-		$scope.newPolicy = !!$scope.policy.name;
+		$scope.newPolicy = !$scope.policy.name;
 
 		// ==============================================================
 		// =                             UI                             =
@@ -259,13 +259,15 @@
 		$scope.policyPublisherList = [];
 		$scope.publisher = {};
 
-		Entity.queryMetadata("policies/" + $scope.policy.name + "/publishments/")._then(function
(res) {
-			$scope.policyPublisherList = $.map(res.data, function (publisher) {
-				return $.extend({
-					_exist: true
-				}, publisher);
+		if(!$scope.newPolicy) {
+			Entity.queryMetadata("policies/" + $scope.policy.name + "/publishments/")._then(function
(res) {
+				$scope.policyPublisherList = $.map(res.data, function (publisher) {
+					return $.extend({
+						_exist: true
+					}, publisher);
+				});
 			});
-		});
+		}
 
 		$scope.addPublisher = function () {
 			$scope.publisher = {

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/1add6d96/eagle-server/src/main/webapp/app/dev/public/js/index.js
----------------------------------------------------------------------
diff --git a/eagle-server/src/main/webapp/app/dev/public/js/index.js b/eagle-server/src/main/webapp/app/dev/public/js/index.js
index 633832e..ea055ba 100644
--- a/eagle-server/src/main/webapp/app/dev/public/js/index.js
+++ b/eagle-server/src/main/webapp/app/dev/public/js/index.js
@@ -20,6 +20,21 @@
 	'use strict';
 
 	// ======================================================================================
+	// =                                   Browser Hooker                                  
=
+	// ======================================================================================
+	var is_chrome = navigator.userAgent.indexOf('Chrome') > -1;
+	var is_explorer = navigator.userAgent.indexOf('MSIE') > -1;
+	var is_firefox = navigator.userAgent.indexOf('Firefox') > -1;
+	var is_safari = navigator.userAgent.indexOf("Safari") > -1;
+	var is_opera = navigator.userAgent.toLowerCase().indexOf("op") > -1;
+	if(is_chrome && is_safari) is_safari = false;
+	if(is_chrome && is_opera) is_chrome = false;
+
+	if(is_safari) {
+		$("body").addClass("safari");
+	}
+
+	// ======================================================================================
 	// =                                        Host                                       
=
 	// ======================================================================================
 	var _host = "";
@@ -311,18 +326,24 @@
 			});
 
 			common.deferred.all(promiseList).then(function (moduleList) {
+				// Filter module list
+				moduleList = $.map(moduleList, function (module) {
+					return module;
+				});
+
 				var routeList = $.map(moduleList, function (module) {
-					return module && module.routeList;
+					return module.routeList;
 				});
 				var portalList = $.map(moduleList, function (module) {
-					return module && module.portalList;
+					return module.portalList;
 				});
 				var widgetList = $.map(moduleList, function (module) {
-					return module && module.widgetList;
+					return module.widgetList;
 				});
 
 				$(document).trigger("APPLICATION_READY", {
 					appList: _registerAppList,
+					moduleList: moduleList,
 					routeList: routeList,
 					portalList: portalList,
 					widgetList: widgetList

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/1add6d96/eagle-server/src/main/webapp/app/dev/public/js/services/siteSrv.js
----------------------------------------------------------------------
diff --git a/eagle-server/src/main/webapp/app/dev/public/js/services/siteSrv.js b/eagle-server/src/main/webapp/app/dev/public/js/services/siteSrv.js
index 399456d..b4aa622 100644
--- a/eagle-server/src/main/webapp/app/dev/public/js/services/siteSrv.js
+++ b/eagle-server/src/main/webapp/app/dev/public/js/services/siteSrv.js
@@ -79,6 +79,17 @@
 			return Site.find($wrapState.param.siteId);
 		};
 
+		Site.switchSite = function (site) {
+			var param = $wrapState.param;
+			if(!site) {
+				$wrapState.go("home");
+			} else if(param.siteId) {
+				$wrapState.go($wrapState.current.name, $.extend({}, param, {siteId: site.siteId}));
+			} else {
+				$wrapState.go("site", {siteId: site.siteId});
+			}
+		};
+
 		Site.getPromise = function (config) {
 			var siteList = Site.list;
 


Mime
View raw message