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-725] Update timeSrv logic & policy detail
Date Thu, 03 Nov 2016 09:37:31 GMT
Repository: incubator-eagle
Updated Branches:
  refs/heads/master e39c76ce8 -> 3595f29dc


[EAGLE-725] Update timeSrv logic & policy detail

* Fix timeSrv logic
* Update policy detail page

Author: zombieJ <smith3816@gmail.com>

Closes #604 from zombieJ/EAGLE-725.


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

Branch: refs/heads/master
Commit: 3595f29dc800a52cc6b8932a1fa3bc7a5a660c8b
Parents: e39c76c
Author: zombieJ <smith3816@gmail.com>
Authored: Thu Nov 3 17:37:20 2016 +0800
Committer: zombieJ <smith3816@gmail.com>
Committed: Thu Nov 3 17:37:20 2016 +0800

----------------------------------------------------------------------
 .../app/dev/partials/alert/policyDetail.html    |  21 ++--
 .../app/dev/partials/alert/policyList.html      |   2 -
 .../src/main/webapp/app/dev/public/css/main.css |   4 +
 .../src/main/webapp/app/dev/public/js/app.js    |   9 +-
 .../webapp/app/dev/public/js/ctrls/alertCtrl.js | 101 +++++++++++++------
 .../app/dev/public/js/services/timeSrv.js       |  35 +++----
 .../app/dev/public/js/services/wrapStateSrv.js  |   5 +-
 eagle-server/src/main/webapp/app/package.json   |   2 +-
 8 files changed, 110 insertions(+), 69 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/3595f29d/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 5173d65..d504d1e 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
@@ -22,15 +22,13 @@
 		<li><a href="#definition" data-toggle="tab">Definition</a></li>
 		<li><a href="#publisher" data-toggle="tab">Publisher</a></li>
 
-		<li class="pull-right tab-sm">
-			<a class="fa fa-edit" ui-sref="policyEdit({name: policy.name})"></a>
-		</li>
-		<li class="pull-right tab-xs">
-			<a>
-				<span class="label" ng-class="{'label-default': policy.policyStatus !== 'ENABLED',
'label-success': policy.policyStatus === 'ENABLED'}">
-					{{policy.policyStatus}}
-				</span>
-			</a>
+		<li class="box-tools pull-right">
+			<div class="btn-group">
+				<button class="btn btn-default fa fa-play" ng-click="startPolicy()" ng-if="policy.policyStatus
!== 'ENABLED'"></button>
+				<button class="btn btn-default fa fa-square" ng-click="stopPolicy()" ng-if="policy.policyStatus
=== 'ENABLED'"></button>
+				<a class="btn btn-default fa fa-pencil" ui-sref="policyEdit({name: policy.name})"></a>
+				<button class="btn btn-danger fa fa-trash" ng-click="deletePolicy()"></button>
+			</div>
 		</li>
 	</ul>
 	<div class="tab-content">
@@ -39,7 +37,10 @@
 				<tbody>
 					<tr>
 						<th>Name</th>
-						<td>{{policy.name}}</td>
+						<td>
+							<span class="fa fa-square" ng-class="policy.policyStatus === 'ENABLED' ? 'text-green'
: 'text-muted'"></span>
+							{{policy.name}}
+						</td>
 						<th>Parallelism Hint</th>
 						<td>{{policy.parallelismHint}}</td>
 					</tr>

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/3595f29d/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 46bf082..a52c51f 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
@@ -30,7 +30,6 @@
 					<tr>
 						<th sortpath="policyStatus" width="10"></th>
 						<th sortpath="name" width="20%">Name</th>
-						<th sortpath="definition.type" width="70">Type</th>
 						<th>Description</th>
 						<th width="85">Action</th>
 					</tr>
@@ -43,7 +42,6 @@
 						<td>
 							<a ui-sref="policyDetail({name: item.name})">{{item.name}}</a>
 						</td>
-						<td class="text-center"><span class="label label-primary">{{item.definition.type}}</span></td>
 						<td>{{item.description}}</td>
 						<td class="text-center">
 							<div class="btn-group btn-group-xs">

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/3595f29d/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 a282d93..8da7c5f 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
@@ -287,6 +287,10 @@ ul.stepGuide li > .title {
 	padding-right: 0;
 }
 
+.nav-tabs-custom > .nav-tabs > li.box-tools {
+	padding: 4px 2px 0 0;
+}
+
 /* ========================================================================
  * =                                Modal                                 =
  * ======================================================================== */

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/3595f29d/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 ca5c6ef..55a6eb6 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
@@ -296,7 +296,14 @@ var app = {};
 				}
 			});
 
-			$scope.$on('$stateChangeSuccess ', function (event) {
+			$scope.$on('$stateChangeSuccess', function (event) {
+				var _innerSearch = Time._innerSearch;
+				Time._innerSearch = null;
+				if(_innerSearch) {
+					setTimeout(function () {
+						$wrapState.go(".", $.extend({}, $wrapState.param, _innerSearch), {location: "replace",
notify: false});
+					}, 0);
+				}
 				console.log("[Switch] done ->", event);
 			});
 

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/3595f29d/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 6c3b930..c33c9ff 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
@@ -21,6 +21,35 @@
 
 	var eagleControllers = angular.module('eagleControllers');
 
+	var serviceModule = angular.module('eagle.service');
+
+	serviceModule.service('Policy', function($q, UI, Entity) {
+		return {
+			delete: function (policy) {
+				var deferred = $q.defer();
+
+				UI.deleteConfirm(policy.name)(function (entity, closeFunc) {
+					Entity.deleteMetadata("policies/" + policy.name)._promise.finally(function () {
+						closeFunc();
+						deferred.resolve();
+					});
+				}, function () {
+					deferred.reject();
+				});
+
+				return deferred.promise;
+			},
+
+			start: function (policy) {
+				return Entity.post("metadata/policies/" + encodeURIComponent(policy.name) + "/status/ENABLED",
{})._promise;
+			},
+
+			stop: function (policy) {
+				return Entity.post("metadata/policies/" + encodeURIComponent(policy.name) + "/status/DISABLED",
{})._promise;
+			}
+		};
+	});
+
 	// ======================================================================================
 	// =                                        Alert                                      
=
 	// ======================================================================================
@@ -74,7 +103,7 @@
 	// ======================================================================================
 	// =                                       Policy                                      
=
 	// ======================================================================================
-	eagleControllers.controller('policyListCtrl', function ($scope, $wrapState, PageConfig,
Entity, UI) {
+	eagleControllers.controller('policyListCtrl', function ($scope, $wrapState, PageConfig,
Entity, Policy) {
 		PageConfig.title = "Policies";
 
 		$scope.policyList = [];
@@ -87,29 +116,20 @@
 		}
 		updateList();
 
-		$scope.deletePolicy = function (item) {
-			UI.deleteConfirm(item.name)(function (entity, closeFunc) {
-				Entity.deleteMetadata("policies/" + item.name)._promise.finally(function () {
-					closeFunc();
-					updateList();
-				});
-			});
+		$scope.deletePolicy = function(policy) {
+			Policy.delete(policy).then(updateList);
 		};
 
-		$scope.startPolicy = function (policy) {
-			Entity
-				.post("metadata/policies/" + encodeURIComponent(policy.name) + "/status/ENABLED", {})
-				._then(updateList);
+		$scope.startPolicy = function(policy) {
+			Policy.start(policy).then(updateList);
 		};
 
-		$scope.stopPolicy = function (policy) {
-			Entity
-				.post("metadata/policies/" + encodeURIComponent(policy.name) + "/status/DISABLED", {})
-				._then(updateList);
+		$scope.stopPolicy = function(policy) {
+			Policy.stop(policy).then(updateList);
 		};
 	});
 
-	eagleControllers.controller('policyDetailCtrl', function ($scope, $wrapState, PageConfig,
Entity, UI) {
+	eagleControllers.controller('policyDetailCtrl', function ($scope, $wrapState, PageConfig,
Entity, Policy) {
 		PageConfig.title = $wrapState.param.name;
 		PageConfig.subTitle = "Detail";
 		PageConfig.navPath = [
@@ -117,21 +137,38 @@
 			{title: "Detail"}
 		];
 
-		var policyList = Entity.queryMetadata("policies/" + encodeURIComponent($wrapState.param.name));
-		policyList._promise.then(function () {
-			$scope.policy = policyList[0];
-			console.log("[Policy]", $scope.policy);
+		function updatePolicy() {
+			var policyList = Entity.queryMetadata("policies/" + encodeURIComponent($wrapState.param.name));
+			policyList._promise.then(function () {
+				$scope.policy = policyList[0];
+				console.log("[Policy]", $scope.policy);
+
+				if(!$scope.policy) {
+					$.dialog({
+						title: "OPS",
+						content: "Policy '" + $wrapState.param.name + "' not found!"
+					}, function () {
+						$wrapState.go("policyList");
+					});
+				} else {
+					$scope.publisherList = Entity.queryMetadata("policies/" + encodeURIComponent($scope.policy.name)
+ "/publishments");
+				}
+			});
+		}
+		updatePolicy();
 
-			if(!$scope.policy) {
-				$.dialog({
-					title: "OPS",
-					content: "Policy '" + $wrapState.param.name + "' not found!"
-				}, function () {
-					$wrapState.go("policyList");
-				});
-			} else {
-				$scope.publisherList = Entity.queryMetadata("policies/" + encodeURIComponent($scope.policy.name)
+ "/publishments");
-			}
-		});
+		$scope.deletePolicy = function() {
+			Policy.delete($scope.policy).then(function () {
+				$wrapState.go("policyList");
+			});
+		};
+
+		$scope.startPolicy = function() {
+			Policy.start($scope.policy).then(updatePolicy);
+		};
+
+		$scope.stopPolicy = function() {
+			Policy.stop($scope.policy).then(updatePolicy);
+		};
 	});
 }());

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/3595f29d/eagle-server/src/main/webapp/app/dev/public/js/services/timeSrv.js
----------------------------------------------------------------------
diff --git a/eagle-server/src/main/webapp/app/dev/public/js/services/timeSrv.js b/eagle-server/src/main/webapp/app/dev/public/js/services/timeSrv.js
index a80de86..c8f367d 100644
--- a/eagle-server/src/main/webapp/app/dev/public/js/services/timeSrv.js
+++ b/eagle-server/src/main/webapp/app/dev/public/js/services/timeSrv.js
@@ -233,7 +233,6 @@
 				common.string.preFill(s, "0");
 		};
 
-		var promiseLock = false;
 		$Time.getPromise = function (config, state, param) {
 			var deferred = $q.defer();
 
@@ -244,29 +243,21 @@
 				if (config.time === true) {
 					$Time.pickerType = $Time.TIME_RANGE_PICKER;
 
-					if (!promiseLock) {
-						startTime = $Time.verifyTime(param.startTime);
-						endTime = $Time.verifyTime(param.endTime);
-
-						if (!startTime || !endTime) {
-							endTime = $Time();
-							startTime = endTime.clone().subtract(2, "hour");
-
-							setTimeout(function () {
-								promiseLock = true;
-								keepTime = true;
-								$wrapState.go(state.name, $.extend({}, param, {
-									startTime: $Time.format(startTime),
-									endTime: $Time.format(endTime)
-								}), {location: "replace", notify: false});
-
-								setTimeout(function () {
-									promiseLock = false;
-								}, 150);
-							}, 100);
-						}
+					startTime = $Time.verifyTime(param.startTime);
+					endTime = $Time.verifyTime(param.endTime);
+
+					if (!startTime || !endTime) {
+						endTime = $Time();
+						startTime = endTime.clone().subtract(2, "hour");
+
+						keepTime = true;
+						$Time._innerSearch = {
+							startTime: $Time.format(startTime),
+							endTime: $Time.format(endTime)
+						};
 					}
 				} else {
+					$Time._innerSearch = null;
 					$Time.pickerType = null;
 				}
 				deferred.resolve($Time);

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/3595f29d/eagle-server/src/main/webapp/app/dev/public/js/services/wrapStateSrv.js
----------------------------------------------------------------------
diff --git a/eagle-server/src/main/webapp/app/dev/public/js/services/wrapStateSrv.js b/eagle-server/src/main/webapp/app/dev/public/js/services/wrapStateSrv.js
index 43e8cc2..fc62857 100644
--- a/eagle-server/src/main/webapp/app/dev/public/js/services/wrapStateSrv.js
+++ b/eagle-server/src/main/webapp/app/dev/public/js/services/wrapStateSrv.js
@@ -106,7 +106,7 @@
 				}
 			},
 
-			// Parameter
+			// State
 			state: {
 				get: function() {
 					return $state;
@@ -114,6 +114,9 @@
 			}
 		});
 
+		$wrapState.search = $location.search.bind($location);
+		$wrapState.$location = $location;
+
 		return $wrapState;
 	});
 })();

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/3595f29d/eagle-server/src/main/webapp/app/package.json
----------------------------------------------------------------------
diff --git a/eagle-server/src/main/webapp/app/package.json b/eagle-server/src/main/webapp/app/package.json
index a2d0dab..6df70d8 100644
--- a/eagle-server/src/main/webapp/app/package.json
+++ b/eagle-server/src/main/webapp/app/package.json
@@ -20,7 +20,7 @@
     "angular-resource": "1.5.0",
     "angular-route": "1.5.0",
     "angular-ui-bootstrap": "1.1.2",
-    "angular-ui-router": "~0.2.18",
+    "angular-ui-router": "0.3.1",
     "bootstrap": "3.3.6",
     "d3": "3.5.16",
     "echarts": "^3.2.3",


Mime
View raw message