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-604] Support view/editing application configuration after installed
Date Thu, 13 Oct 2016 08:13:19 GMT
Repository: incubator-eagle
Updated Branches:
  refs/heads/master 4dfb528c4 -> 1d0f9f5b0


[EAGLE-604] Support view/editing application configuration after installed

Support view/editing application configuration after installed

Author: zombieJ <smith3816@gmail.com>

Closes #500 from zombieJ/EAGLE-604.


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

Branch: refs/heads/master
Commit: 1d0f9f5b03acefbfb9af97a83ca19ad3d02d638a
Parents: 4dfb528
Author: zombieJ <smith3816@gmail.com>
Authored: Thu Oct 13 16:13:08 2016 +0800
Committer: zombieJ <smith3816@gmail.com>
Committed: Thu Oct 13 16:13:08 2016 +0800

----------------------------------------------------------------------
 .../webapp/app/dev/partials/alert/main.html     |  63 ++++----
 .../app/dev/partials/alert/policyDetail.html    |  40 ++---
 .../app/dev/partials/alert/streamList.html      |  47 ++++++
 .../app/dev/partials/integration/main.html      |   1 -
 .../app/dev/partials/integration/site.html      | 145 +++++++++++++++++--
 .../dev/partials/integration/streamList.html    |  52 -------
 .../src/main/webapp/app/dev/public/js/app.js    |  14 +-
 .../src/main/webapp/app/dev/public/js/common.js |  18 ++-
 .../webapp/app/dev/public/js/ctrls/alertCtrl.js |  19 +++
 .../app/dev/public/js/ctrls/alertEditCtrl.js    |   5 +-
 .../app/dev/public/js/ctrls/integrationCtrl.js  | 135 ++++++++++++-----
 .../src/main/webapp/app/dev/public/js/index.js  |   9 +-
 .../dev/public/js/services/applicationSrv.js    |   4 +
 .../app/dev/public/js/services/pageSrv.js       |   6 +-
 14 files changed, 386 insertions(+), 172 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/1d0f9f5b/eagle-server/src/main/webapp/app/dev/partials/alert/main.html
----------------------------------------------------------------------
diff --git a/eagle-server/src/main/webapp/app/dev/partials/alert/main.html b/eagle-server/src/main/webapp/app/dev/partials/alert/main.html
index 2e062a8..2e14db9 100644
--- a/eagle-server/src/main/webapp/app/dev/partials/alert/main.html
+++ b/eagle-server/src/main/webapp/app/dev/partials/alert/main.html
@@ -1,29 +1,34 @@
-<!--
-  Licensed to the Apache Software Foundation (ASF) under one
-  or more contributor license agreements.  See the NOTICE file
-  distributed with this work for additional information
-  regarding copyright ownership.  The ASF licenses this file
-  to you under the Apache License, Version 2.0 (the
-  "License"); you may not use this file except in compliance
-  with the License.  You may obtain a copy of the License at
-
-      http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing, software
-  distributed under the License is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
-  -->
-
-<div class="nav-tabs-custom">
-	<ul class="nav nav-tabs">
-		<li ng-class="{active: getState() === 'alert.list'}"><a href="#/alert/">Explore
Triggered Alerts</a></li>
-		<li ng-class="{active: getState() === 'alert.policyList'}"><a href="#/alert/policyList">Manage
Policies</a></li>
-		<li ng-class="{active: ['alert.policyCreate', 'alert.policyEdit'].indexOf(getState())
>= 0}"><a href="#/alert/policyCreate">Define Alert Policy</a></li>
-	</ul>
-	<div class="tab-content no-padding">
-		<div ui-view></div>
-	</div>
-</div>
-
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+
+<div class="nav-tabs-custom">
+	<ul class="nav nav-tabs">
+		<li ng-class="{active: getState() === 'alert.list'}"><a href="#/alert/">Alerts</a></li>
+		<li ng-class="{active: getState() === 'alert.policyList'}"><a href="#/alert/policyList">Policies</a></li>
+		<li ng-class="{active: getState() === 'alert.streamList'}"><a href="#/alert/streamList">Streams</a></li>
+
+		<li
+			ng-class="{active: ['alert.policyCreate', 'alert.policyEdit'].indexOf(getState()) >=
0}"
+			ng-if="['alert.policyCreate', 'alert.policyEdit'].indexOf(getState()) >= 0"
+		><a href="#/alert/policyCreate">Define Alert Policy</a></li>
+	</ul>
+	<div class="tab-content no-padding">
+		<div ui-view></div>
+	</div>
+</div>
+

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/1d0f9f5b/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 b04a8a8..7ec5f39 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
@@ -18,7 +18,8 @@
 
 <div class="nav-tabs-custom">
 	<ul class="nav nav-tabs">
-		<li class="active"><a href="#policy" data-toggle="tab">Policy</a></li>
+		<li class="active"><a href="#basic" data-toggle="tab">Basic</a></li>
+		<li><a href="#definition" data-toggle="tab">Definition</a></li>
 		<li><a href="#publisher" data-toggle="tab">Publisher</a></li>
 
 		<li class="pull-right">
@@ -30,7 +31,7 @@
 		</li>
 	</ul>
 	<div class="tab-content">
-		<div class="tab-pane active" id="policy">
+		<div class="tab-pane active" id="basic">
 			<table class="table">
 				<tbody>
 					<tr>
@@ -61,26 +62,29 @@
 							</ul>
 						</td>
 					</tr>
-					<tr>
-						<th>Definition</th>
-						<td colspan="3"><pre class="inline">{{policy.definition.value}}</pre></td>
-					</tr>
-					<tr>
-						<th>Partition</th>
-						<td colspan="3">
-							<ul class="no-margin">
-								<li ng-repeat="partition in policy.partitionSpec track by $index">
-									[<span class="text-primary">{{partition.type}}</span>]
-									{{partition.streamId}}:
-									<strong class="text-success">{{partition.columns.join(", ")}}</strong>
-								</li>
-							</ul>
-						</td>
-					</tr>
 				</tbody>
 			</table>
 		</div>
+		<div class="tab-pane" id="definition">
+			<label>Definition</label>
+			<pre>{{policy.definition.value}}</pre>
+
+			<label>Partition</label>
+			<ul class="no-margin">
+				<li ng-repeat="partition in policy.partitionSpec track by $index">
+					[<span class="text-primary">{{partition.type}}</span>]
+					{{partition.streamId}}:
+					<strong class="text-success">{{partition.columns.join(", ")}}</strong>
+				</li>
+				<li ng-if="policy.partitionSpec.length === 0" class="text-muted">
+					No partition
+				</li>
+			</ul>
+		</div>
 		<div class="tab-pane" id="publisher">
+			<p ng-if="publisherList.length === 0" class="text-muted">
+				<span class="fa fa-exclamation-triangle"></span> No publisher configured
+			</p>
 			<table class="table table-bordered" ng-repeat="publisher in publisherList track by
publisher.name">
 				<tbody>
 					<tr>

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/1d0f9f5b/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
new file mode 100644
index 0000000..79f15a6
--- /dev/null
+++ b/eagle-server/src/main/webapp/app/dev/partials/alert/streamList.html
@@ -0,0 +1,47 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+
+<div class="box-body">
+	<div sort-table="streamList">
+		<table class="table table-bordered table-hover">
+			<thead>
+				<tr>
+					<th>Stream</th>
+					<th>Provider (App)</th>
+					<th>Site</th>
+					<th>Schema</th>
+				</tr>
+			</thead>
+			<tbody>
+				<tr>
+					<td><span class="label label-primary">{{item.streamId}}</span></td>
+					<td>{{item.appType}}</td>
+					<td>{{item.siteId}}</td>
+					<td>
+						<ul class="no-margin">
+							<li ng-repeat="column in item.schema.columns track by $index">
+								<strong>{{column.name}}</strong>:
+								{{column.type}}
+							</li>
+						</ul>
+					</td>
+				</tr>
+			</tbody>
+		</table>
+	</div>
+</div>

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/1d0f9f5b/eagle-server/src/main/webapp/app/dev/partials/integration/main.html
----------------------------------------------------------------------
diff --git a/eagle-server/src/main/webapp/app/dev/partials/integration/main.html b/eagle-server/src/main/webapp/app/dev/partials/integration/main.html
index daea22e..3a063d7 100644
--- a/eagle-server/src/main/webapp/app/dev/partials/integration/main.html
+++ b/eagle-server/src/main/webapp/app/dev/partials/integration/main.html
@@ -20,7 +20,6 @@
 	<ul class="nav nav-tabs">
 		<li ng-class="{active: getState().indexOf('integration.site') !== -1}"><a href="#/integration/siteList">Sites</a></li>
 		<li ng-class="{active: getState() === 'integration.applicationList'}"><a href="#/integration/applicationList">Applications</a></li>
-		<li ng-class="{active: getState() === 'integration.streamList'}"><a href="#/integration/streamList">Streams</a></li>
 	</ul>
 	<div class="tab-content no-padding">
 		<div ui-view></div>

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/1d0f9f5b/eagle-server/src/main/webapp/app/dev/partials/integration/site.html
----------------------------------------------------------------------
diff --git a/eagle-server/src/main/webapp/app/dev/partials/integration/site.html b/eagle-server/src/main/webapp/app/dev/partials/integration/site.html
index 4c118dc..e320c48 100644
--- a/eagle-server/src/main/webapp/app/dev/partials/integration/site.html
+++ b/eagle-server/src/main/webapp/app/dev/partials/integration/site.html
@@ -17,17 +17,33 @@
   -->
 
 <div class="box-body">
-	<p class="text-danger" ng-if="site.applicationList.length === 0">
-		<span class="fa fa-exclamation-triangle"></span> Site must install at least
one application to start up.
-	</p>
-	<p class="text-warning" ng-if="site.applicationList.length !== 0 && getStartedAppCount()
=== 0">
-		<span class="fa fa-exclamation-triangle"></span> No application started.
-	</p>
+
+
+	<div class="form-group">
+		<label>Site</label>
+		<input type="text" class="form-control" readonly ng-model="siteName">
+	</div>
+	<div class="form-group">
+		<label>Description</label>
+		<textarea class="form-control" readonly ng-model="site.description" rows="2"></textarea>
+	</div>
+
+	<label>Application</label>
+	<span class="text-danger" ng-if="site.applicationList.length === 0">
+		(<span class="fa fa-exclamation-triangle"></span> Site must install at least
one application to start up.)
+	</span>
+	<span class="text-warning" ng-if="site.applicationList.length !== 0 && getStartedAppCount()
=== 0">
+		(<span class="fa fa-exclamation-triangle"></span> No application started.)
+	</span>
 
 	<table class="table table-bordered table-hover">
 		<thead>
 			<tr>
-				<th>App</th>
+				<th>
+					<small class="pull-right"><a ng-click="refreshApplications()">Refresh</a></small>
+					Name
+					<span class="fa fa-refresh fa-spin no-animate" ng-show="!Application.list._done"></span>
+				</th>
 				<th width="10">Status</th>
 				<th>Version</th>
 				<th>Description</th>
@@ -48,9 +64,24 @@
 				<td class="text-center">
 					<div class="btn-group btn-group-xs" ng-if="app.installed">
 						<!--button class="btn btn-default btn-sm">Monitor</button-->
-						<button class="btn btn-default btn-sm" ng-click="startApp(app)">Start</button>
-						<button class="btn btn-default btn-sm" ng-click="stopApp(app)">Stop</button>
-						<button class="btn btn-default btn-sm" ng-click="uninstallApp(app)">Uninstall</button>
+						<button class="btn btn-default btn-sm" ng-click="startApp(app)" ng-if="app.descriptor.executable">
+							<span class="fa fa-play"></span>
+						</button>
+						<button class="btn btn-default btn-sm" ng-click="stopApp(app)" ng-if="app.descriptor.executable">
+							<span class="fa fa-stop"></span>
+						</button>
+						<button class="btn btn-default btn-sm" disabled="disabled" ng-if="!app.descriptor.executable">
+							<span class="fa fa-ban"></span>
+						</button>
+						<button class="btn btn-default btn-sm" disabled="disabled" ng-if="!app.descriptor.executable">
+							<span class="fa fa-ban"></span>
+						</button>
+						<button class="btn btn-default btn-sm" ng-click="editApp(app)">
+							<span class="fa fa-pencil"></span>
+						</button>
+						<button class="btn btn-danger btn-sm" ng-click="uninstallApp(app)">
+							<span class="fa fa-trash"></span>
+						</button>
 					</div>
 					<div class="btn-group btn-group-xs" ng-if="!app.installed">
 						<button class="btn btn-primary btn-sm" ng-click="installApp(app)">Install Application</button>
@@ -75,11 +106,80 @@
 			</div>
 			<div class="modal-body">
 				<ul class="nav nav-tabs">
-					<li class="active"><a href="[data-id='install']" data-toggle="tab">Install</a></li>
+					<li><a href="[data-id='intro']" data-toggle="tab" data-id="introTab">Application</a></li>
+					<li><a href="[data-id='install']" data-toggle="tab">Install</a></li>
 					<li><a href="[data-id='uninstall']" data-toggle="tab">Uninstall</a></li>
 				</ul>
 				<div class="tab-content">
-					<div class="tab-pane active" data-id="install">
+					<div class="tab-pane" data-id="intro">
+						<table class="table">
+							<tbody>
+								<tr>
+									<th>Application Name</th>
+									<td>{{application.name}}</td>
+									<th>Type</th>
+									<td>{{application.type}}</td>
+								</tr>
+								<tr ng-if="tmpApp.uuid">
+									<th>Application Id</th>
+									<td>{{tmpApp.appId}}</td>
+									<th>UUID</th>
+									<td>{{tmpApp.uuid}}</td>
+								</tr>
+								<tr ng-if="tmpApp.uuid">
+									<th>Mode</th>
+									<td>{{tmpApp.mode}}</td>
+									<th>Status</th>
+									<td>{{tmpApp.status}}</td>
+								</tr>
+								<tr>
+									<th>View Path</th>
+									<td>{{application.viewPath}}</td>
+									<th>Version</th>
+									<td>{{application.version}}</td>
+								</tr>
+								<tr>
+									<th>Jar Path</th>
+									<td colspan="3">{{tmpApp.jarPath || application.jarPath}}</td>
+								</tr>
+								<tr>
+									<th>Application Class</th>
+									<td colspan="3">{{application.appClass}}</td>
+								</tr>
+								<tr>
+									<th>Provider Class</th>
+									<td colspan="3">{{application.providerClass}}</td>
+								</tr>
+								<tr>
+									<th>Description</th>
+									<td colspan="3">{{application.description}}</td>
+								</tr>
+								<tr>
+									<th>Dependencies</th>
+									<td colspan="3">
+										<ul>
+											<li ng-repeat="dep in application.dependencies track by $index">
+												{{Application.findProvider(dep.type).name}}
+												({{dep.type}})
+											</li>
+										</ul>
+									</td>
+								</tr>
+								<tr ng-if="tmpApp.uuid">
+									<th>Configuration</th>
+									<td colspan="3">
+										<ul>
+											<li ng-repeat="(key, value) in tmpApp.configuration track by $index">
+												<strong>{{key}}:</strong>
+												{{value}}
+											</li>
+										</ul>
+									</td>
+								</tr>
+							</tbody>
+						</table>
+					</div>
+					<div class="tab-pane" data-id="install">
 						<pre ng-bind-html="installHTML"></pre>
 					</div>
 					<div class="tab-pane" data-id="uninstall">
@@ -106,11 +206,28 @@
 			</div>
 			<div class="modal-body">
 				<ul class="nav nav-tabs">
-					<li class="active"><a href="[data-id='environment']" data-toggle="tab">Environment</a></li>
+					<li><a href="[data-id='guide']" data-toggle="tab" data-id="guideTab">Guide</a></li>
+					<li><a href="[data-id='environment']" data-toggle="tab">Environment</a></li>
 					<li><a href="[data-id='configuration']" data-toggle="tab" data-id="configTab">Configuration</a></li>
 				</ul>
 				<div class="tab-content">
-					<div class="tab-pane active" data-id="environment">
+					<div class="tab-pane" data-id="guide">
+						<label>Dependencies</label>
+						<ul>
+							<li ng-repeat="dep in application.dependencies track by $index">
+								<strong class="text-success" ng-if="!!Application.find(dep.type, site.siteId)[0]">[
Installed ]</strong>
+								<strong class="text-danger" ng-if="!Application.find(dep.type, site.siteId)[0]">[
+									<span class="fa fa-exclamation-triangle"></span>Require
+								]</strong>
+								{{Application.findProvider(dep.type).name}}
+								({{dep.type}})
+							</li>
+						</ul>
+
+						<label>Install</label>
+						<pre ng-bind-html="installHTML"></pre>
+					</div>
+					<div class="tab-pane" data-id="environment">
 						<div class="form-group">
 							<label>Mode</label>
 							<select class="form-control" ng-model="tmpApp.mode">

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/1d0f9f5b/eagle-server/src/main/webapp/app/dev/partials/integration/streamList.html
----------------------------------------------------------------------
diff --git a/eagle-server/src/main/webapp/app/dev/partials/integration/streamList.html b/eagle-server/src/main/webapp/app/dev/partials/integration/streamList.html
deleted file mode 100644
index beaf743..0000000
--- a/eagle-server/src/main/webapp/app/dev/partials/integration/streamList.html
+++ /dev/null
@@ -1,52 +0,0 @@
-<!--
-  Licensed to the Apache Software Foundation (ASF) under one
-  or more contributor license agreements.  See the NOTICE file
-  distributed with this work for additional information
-  regarding copyright ownership.  The ASF licenses this file
-  to you under the Apache License, Version 2.0 (the
-  "License"); you may not use this file except in compliance
-  with the License.  You may obtain a copy of the License at
-
-      http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing, software
-  distributed under the License is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
-  -->
-
-<div class="box-body">
-	<div sort-table="streamList">
-		<table class="table table-bordered table-hover">
-			<thead>
-				<tr>
-					<th>Stream</th>
-					<th>Provider (App)</th>
-					<th>Site</th>
-					<th>Schema</th>
-					<th width="10">Actions</th>
-				</tr>
-			</thead>
-			<tbody>
-				<tr>
-					<td><span class="label label-primary">{{item.streamId}}</span></td>
-					<td>{{item.appType}}</td>
-					<td>{{item.siteId}}</td>
-					<td>
-						<ul class="no-margin">
-							<li ng-repeat="column in item.schema.columns track by $index">
-								<strong>{{column.name}}</strong>:
-								{{column.type}}
-							</li>
-						</ul>
-					</td>
-					<td>
-						<!-- TODO:link with alert -->
-						<button class="btn btn-primary btn-sm">New Alert</button>
-					</td>
-				</tr>
-			</tbody>
-		</table>
-	</div>
-</div>

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/1d0f9f5b/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 fb40ed4..cdb705c 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
@@ -103,6 +103,12 @@ var app = {};
 					controller: "policyListCtrl",
 					resolve: routeResolve()
 				})
+				.state('alert.streamList', {
+					url: "streamList",
+					templateUrl: "partials/alert/streamList.html?_=" + window._TRS(),
+					controller: "alertStreamListCtrl",
+					resolve: routeResolve()
+				})
 				.state('alert.policyCreate', {
 					url: "policyCreate",
 					templateUrl: "partials/alert/policyEdit.html?_=" + window._TRS(),
@@ -122,6 +128,7 @@ var app = {};
 					controller: "policyDetailCtrl",
 					resolve: routeResolve()
 				})
+
 				// =============================== Integration ==============================
 				.state('integration', {
 					abstract: true,
@@ -148,12 +155,7 @@ var app = {};
 					controller: "integrationApplicationListCtrl",
 					resolve: routeResolve({ application: false })
 				})
-				.state('integration.streamList', {
-					url: "streamList",
-					templateUrl: "partials/integration/streamList.html?_=" + window._TRS(),
-					controller: "integrationStreamListCtrl",
-					resolve: routeResolve()
-				})
+
 				// ================================== Site ==================================
 				.state('site', {
 					url: "/site/:siteId",

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/1d0f9f5b/eagle-server/src/main/webapp/app/dev/public/js/common.js
----------------------------------------------------------------------
diff --git a/eagle-server/src/main/webapp/app/dev/public/js/common.js b/eagle-server/src/main/webapp/app/dev/public/js/common.js
index 0e9cc7c..7d41371 100644
--- a/eagle-server/src/main/webapp/app/dev/public/js/common.js
+++ b/eagle-server/src/main/webapp/app/dev/public/js/common.js
@@ -97,15 +97,17 @@
 	};
 
 	common.parseJSON = function (str, defaultVal) {
-		try {
-			str = (str + "").trim();
-			if(Number(str).toString() === str) throw "Number format";
-			return JSON.parse(str);
-		} catch(err) {
-			if(defaultVal === undefined) {
-				console.warn("Can't parse JSON: " + str);
-			}
+		if(str && Number(str).toString() !== str) {
+			try {
+				str = (str + "").trim();
+				return JSON.parse(str);
+			} catch(err) {}
+		}
+
+		if(arguments.length === 1) {
+			console.warn("Can't parse JSON: " + str);
 		}
+
 		return defaultVal === undefined ? null : defaultVal;
 	};
 

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/1d0f9f5b/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 b5eba07..eeea083 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
@@ -58,6 +58,25 @@
 	});
 
 	// ======================================================================================
+	// =                                       Stream                                      
=
+	// ======================================================================================
+	eagleControllers.controller('alertStreamListCtrl', function ($scope, $wrapState, PageConfig,
Application) {
+		PageConfig.title = "Alert";
+		PageConfig.subTitle = "Streams";
+
+		$scope.streamList = $.map(Application.list, function (app) {
+			return (app.streams || []).map(function (stream) {
+				return {
+					streamId: stream.streamId,
+					appType: app.descriptor.type,
+					siteId: app.site.siteId,
+					schema: stream.schema
+				};
+			});
+		});
+	});
+
+	// ======================================================================================
 	// =                                       Policy                                      
=
 	// ======================================================================================
 	eagleControllers.controller('policyListCtrl', function ($scope, $wrapState, PageConfig,
Entity, UI) {

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/1d0f9f5b/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 3e9d13e..3bcd8d8 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
@@ -281,9 +281,10 @@
 			common.deferred.all(publisherPromiseList.concat(policyPromise)).then(function () {
 				$.dialog({
 					title: "Done",
-					content: "Click confirm to go to the policy detail page."
+					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});
 			}, function (failedList) {
 				$.dialog({
 					title: "OPS",

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/1d0f9f5b/eagle-server/src/main/webapp/app/dev/public/js/ctrls/integrationCtrl.js
----------------------------------------------------------------------
diff --git a/eagle-server/src/main/webapp/app/dev/public/js/ctrls/integrationCtrl.js b/eagle-server/src/main/webapp/app/dev/public/js/ctrls/integrationCtrl.js
index 8674df3..ca6c92e 100644
--- a/eagle-server/src/main/webapp/app/dev/public/js/ctrls/integrationCtrl.js
+++ b/eagle-server/src/main/webapp/app/dev/public/js/ctrls/integrationCtrl.js
@@ -62,7 +62,7 @@
 		};
 	});
 
-	eagleControllers.controller('integrationSiteCtrl', function ($sce, $scope, $wrapState, PageConfig,
Entity, UI, Site, Application) {
+	eagleControllers.controller('integrationSiteCtrl', function ($sce, $scope, $wrapState, $interval,
PageConfig, Entity, UI, Site, Application) {
 		PageConfig.title = "Site";
 		PageConfig.subTitle = $wrapState.param.id;
 
@@ -77,6 +77,9 @@
 			});
 			return;
 		}
+		console.log("[Site]", $scope.site);
+
+		$scope.siteName = $scope.site.siteId + ($scope.site.siteName ? "(" + $scope.site.siteName
+ ")" : "");
 
 		// Map applications
 		function mapApplications() {
@@ -94,9 +97,9 @@
 		mapApplications();
 
 		// Application refresh
-		function refreshApplications() {
+		var refreshApplications = $scope.refreshApplications = function() {
 			Application.reload().getPromise().then(mapApplications);
-		}
+		};
 
 		// Application status class
 		$scope.getAppStatusClass = function (application) {
@@ -124,6 +127,9 @@
 
 		// Application detail
 		$scope.showAppDetail = function (application) {
+			$("a[data-id='introTab']").click();
+
+			$scope.tmpApp = application;
 			application = application.origin;
 			var docs = application.docs || {install: "", uninstall: ""};
 			$scope.application = application;
@@ -167,11 +173,12 @@
 
 		$scope.removeField = function (field) {
 			$scope.tmpAppConfigFields = common.array.remove(field, $scope.tmpAppConfigFields);
+			delete $scope.tmpApp.configuration[field.name];
 		};
 
 		$scope.checkFields = function () {
 			var pass = true;
-			var config = common.getValueByPath($scope, ["tmpApp", "configuration"]);
+			var config = common.getValueByPath($scope, ["tmpApp", "configuration"], {});
 			$.each($scope.tmpAppConfigFields, function (i, field) {
 				if(field.required && !config[field.name]) {
 					pass = false;
@@ -184,38 +191,86 @@
 		$scope.installAppConfirm = function () {
 			$scope.installLock = true;
 
-			Entity.create("apps/install", $scope.tmpApp)._then(function () {
-				refreshApplications();
-				$("#installMDL").modal("hide");
-			}, function (res) {
-				$.dialog({
-					title: "OPS",
-					content: res.data.message
+			var uuid = $scope.tmpApp.uuid;
+			delete $scope.tmpApp.uuid;
+
+			if(uuid) {
+				Entity.create("apps/" + uuid, $scope.tmpApp)._then(function () {
+					refreshApplications();
+					$("#installMDL").modal("hide");
+				}, function (res) {
+					$.dialog({
+						title: "OPS",
+						content: res.data.message
+					});
+					$scope.installLock = false;
 				});
-				$scope.installLock = false;
-			});
+			} else {
+				Entity.create("apps/install", $scope.tmpApp)._then(function () {
+					refreshApplications();
+					$("#installMDL").modal("hide");
+				}, function (res) {
+					$.dialog({
+						title: "OPS",
+						content: res.data.message
+					});
+					$scope.installLock = false;
+				});
+			}
 		};
 
 		// Install application
-		$scope.installApp = function (application) {
+		$scope.installApp = function (application, entity) {
+			entity = entity || {};
 			application = application.origin;
 			$scope.installLock = false;
 			$scope.application = application;
 			$scope.tmpApp = {
-				siteId: $scope.site.siteId,
-				appType: application.type,
 				mode: "CLUSTER",
 				jarPath: application.jarPath,
 				configuration: {}
 			};
 
-			$scope.tmpAppConfigFields = common.getValueByPath(application, "configuration.properties",
[]);
-			$.each($scope.tmpAppConfigFields, function (i, field) {
+			if(!entity.uuid) {
+				common.merge($scope.tmpApp, {
+					siteId: $scope.site.siteId,
+					appType: application.type
+				});
+			}
+
+			var fields = $scope.tmpAppConfigFields = common.getValueByPath(application, "configuration.properties",
[]).concat();
+
+			$.each(fields, function (i, field) {
 				$scope.tmpApp.configuration[field.name] = field.value;
 			});
 
+			// Fill miss field of entity
+			common.merge($scope.tmpApp, entity);
+			$.each(entity.configuration || {}, function (key) {
+				if(!common.array.find(key, fields, ["name"])) {
+					fields.push({
+						name: key,
+						_customize: true,
+						required: true
+					});
+				}
+			});
+
+			// Dependencies check
+			var missDep = false;
+			$.each(application.dependencies, function (i, dep) {
+				if(!Application.find(dep.type, $scope.site.siteId)[0]) {
+					missDep = true;
+					return false;
+				}
+			});
+
 			$("#installMDL").modal();
-			$("a[data-id='configTab']").click();
+			if(missDep) {
+				$("a[data-id='guideTab']").click();
+			} else {
+				$("a[data-id='configTab']").click();
+			}
 		};
 
 		// Uninstall application
@@ -229,6 +284,9 @@
 			});
 		};
 
+		// ================================================================
+		// =                          Management                          =
+		// ================================================================
 		// Start application
 		$scope.startApp = function (application) {
 			Entity.post("apps/start", { uuid: application.uuid })._then(function () {
@@ -242,6 +300,26 @@
 				refreshApplications();
 			});
 		};
+
+		$scope.editApp = function (application) {
+			var type = application.descriptor.type;
+			var provider = Application.findProvider(type);
+
+			$scope.installApp({origin: provider}, {
+				mode: application.mode,
+				jarPath: application.jarPath,
+				uuid: application.uuid,
+				configuration: $.extend({}, application.configuration)
+			});
+		};
+
+		// ================================================================
+		// =                             Sync                             =
+		// ================================================================
+		var refreshInterval = $interval(refreshApplications, 1000 * 60);
+		$scope.$on('$destroy', function() {
+			$interval.cancel(refreshInterval);
+		});
 	});
 
 	// ======================================================================================
@@ -259,23 +337,4 @@
 			$("#appMDL").modal();
 		};
 	});
-
-	// ======================================================================================
-	// =                                       Stream                                      
=
-	// ======================================================================================
-	eagleControllers.controller('integrationStreamListCtrl', function ($scope, $wrapState, PageConfig,
Application) {
-		PageConfig.title = "Integration";
-		PageConfig.subTitle = "Streams";
-
-		$scope.streamList = $.map(Application.list, function (app) {
-			return (app.streams || []).map(function (stream) {
-				return {
-					streamId: stream.streamId,
-					appType: app.descriptor.type,
-					siteId: app.site.siteId,
-					schema: stream.schema
-				};
-			});
-		});
-	});
 }());

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/1d0f9f5b/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 906479f..633832e 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
@@ -26,7 +26,7 @@
 	var _app = {};
 	if(localStorage) {
 		_host = localStorage.getItem("host") || "";
-		_app = common.parseJSON(localStorage.getItem("app") || "") || {};
+		_app = common.parseJSON(localStorage.getItem("app"), {});
 	}
 
 	window._host = function (host) {
@@ -51,6 +51,13 @@
 		return _app;
 	};
 
+	window._app.clear = function () {
+		if(localStorage) {
+			_app = {};
+			localStorage.removeItem("app");
+		}
+	};
+
 	// ======================================================================================
 	// =                                      Register                                     
=
 	// ======================================================================================

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/1d0f9f5b/eagle-server/src/main/webapp/app/dev/public/js/services/applicationSrv.js
----------------------------------------------------------------------
diff --git a/eagle-server/src/main/webapp/app/dev/public/js/services/applicationSrv.js b/eagle-server/src/main/webapp/app/dev/public/js/services/applicationSrv.js
index fac44f9..31c6fb6 100644
--- a/eagle-server/src/main/webapp/app/dev/public/js/services/applicationSrv.js
+++ b/eagle-server/src/main/webapp/app/dev/public/js/services/applicationSrv.js
@@ -57,6 +57,10 @@
 			});
 		});
 
+		Application.findProvider = function (type) {
+			return common.array.find(type, Application.providerList, ["type"]);
+		};
+
 		Application.getPromise = function () {
 			return Application.list._promise.then(function() {
 				return Application;

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/1d0f9f5b/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 732f820..04e3b77 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
@@ -49,15 +49,15 @@
 		]},*/
 		{name: "Alert", icon: "bell", list: [
 			{name: "Explore Alerts", path: "#/alert/"},
-			{name: "Manage Policies", path: "#/alert/policyList"},
+			{name: "Policies", path: "#/alert/policyList"},
+			{name: "Streams", path: "#/alert/streamList"},
 			{name: "Define Policy", path: "#/alert/policyCreate"}
 		]}
 	];
 	var adminPortalList = [
 		{name: "Integration", icon: "puzzle-piece", list: [
 			{name: "Sites", path: "#/integration/siteList"},
-			{name: "Applications", path: "#/integration/applicationList"},
-			{name: "Streams", path: "#/integration/streamList"}
+			{name: "Applications", path: "#/integration/applicationList"}
 		]}
 	];
 


Mime
View raw message