You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@eagle.apache.org by ha...@apache.org on 2017/03/03 02:26:54 UTC
eagle git commit: [EAGLE-923] Integrate role-based Authentication in
UI
Repository: eagle
Updated Branches:
refs/heads/master 8d79f0888 -> 287a1c109
[EAGLE-923] Integrate role-based Authentication in UI
Support user role of web app control
Author: zombieJ <sm...@gmail.com>
Closes #853 from zombieJ/EAGLE-923.
Project: http://git-wip-us.apache.org/repos/asf/eagle/repo
Commit: http://git-wip-us.apache.org/repos/asf/eagle/commit/287a1c10
Tree: http://git-wip-us.apache.org/repos/asf/eagle/tree/287a1c10
Diff: http://git-wip-us.apache.org/repos/asf/eagle/diff/287a1c10
Branch: refs/heads/master
Commit: 287a1c109c003140959781870222b608778524e2
Parents: 8d79f08
Author: zombieJ <sm...@gmail.com>
Authored: Fri Mar 3 10:26:41 2017 +0800
Committer: Hao Chen <ha...@apache.org>
Committed: Fri Mar 3 10:26:41 2017 +0800
----------------------------------------------------------------------
eagle-server/src/main/webapp/app/dev/index.html | 53 ++++++--
.../app/dev/partials/alert/policyDetail.html | 2 +-
.../app/dev/partials/alert/policyList.html | 10 +-
.../app/dev/partials/alert/streamList.html | 4 +-
.../src/main/webapp/app/dev/partials/login.html | 45 +++++++
.../src/main/webapp/app/dev/public/css/main.css | 15 +++
.../src/main/webapp/app/dev/public/js/app.js | 16 ++-
.../webapp/app/dev/public/js/ctrls/alertCtrl.js | 4 +-
.../webapp/app/dev/public/js/ctrls/authCtrl.js | 49 ++++++++
.../webapp/app/dev/public/js/ctrls/mainCtrl.js | 2 +-
.../app/dev/public/js/services/authSrv.js | 120 +++++++++++++++++++
.../public/js/services/compatibleEntitySrv.js | 4 +-
.../app/dev/public/js/services/entitySrv.js | 10 +-
.../app/dev/public/js/services/pageSrv.js | 50 +++-----
14 files changed, 319 insertions(+), 65 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/eagle/blob/287a1c10/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 3408842..e2547bf 100644
--- a/eagle-server/src/main/webapp/app/dev/index.html
+++ b/eagle-server/src/main/webapp/app/dev/index.html
@@ -109,6 +109,22 @@
</ul>
</li>
+ <!-- FAQ -->
+ <li>
+ <a data-toggle="dropdown" aria-expanded="false">
+ <i class="glyphicon glyphicon-question-sign"></i>
+ </a>
+
+ <ul class="dropdown-menu">
+ <li><a>How to start using eagle</a></li>
+ <li><a>How to register new site</a></li>
+ <li><a>How to install application</a></li>
+ <li><a>How to manage application</a></li>
+ <li><a>How to develop application</a></li>
+ <li><a ui-sref="metricPreview()">Preview eagle metric</a></li>
+ </ul>
+ </li>
+
<!-- Notification -->
<li class="hover-dropdown">
<a>
@@ -130,19 +146,32 @@
</ul>
</li>
- <!-- FAQ -->
- <li>
- <a data-toggle="dropdown" aria-expanded="false">
- <i class="glyphicon glyphicon-question-sign"></i>
+ <!-- Auth -->
+ <li ng-if="!Auth.isLogin">
+ <a ui-sref="login">Login</a>
+ </li>
+ <li ng-if="Auth.isLogin" class="dropdown user user-menu">
+ <a class="dropdown-toggle" data-toggle="dropdown">
+ <i class="fa fa-user"></i>
+ {{Auth.user.name}}
</a>
-
<ul class="dropdown-menu">
- <li><a>How to start using eagle</a></li>
- <li><a>How to register new site</a></li>
- <li><a>How to install application</a></li>
- <li><a>How to manage application</a></li>
- <li><a>How to develop application</a></li>
- <li><a ui-sref="metricPreview()">Preview eagle metric</a></li>
+ <li class="user-header">
+ <div class="portrait fa fa-user">
+ </div>
+ <p>
+ {{Auth.user.name}}
+ <small>{{Auth.user.roles.join(', ')}}</small>
+ </p>
+ </li>
+ <li class="user-footer">
+ <div class="pull-left" ng-if="Auth.isAdmin">
+ <a ui-sref="integration.siteList()" class="btn btn-default btn-flat">Integration</a>
+ </div>
+ <div class="pull-right">
+ <a class="btn btn-default btn-flat" ng-click="Auth.logout()">Sign out</a>
+ </div>
+ </li>
</ul>
</li>
</ul>
@@ -305,6 +334,7 @@
<script src="public/js/services/policySrv.js" type="text/javascript" charset="utf-8"></script>
<script src="public/js/services/notificationSrv.js" type="text/javascript" charset="utf-8"></script>
<script src="public/js/services/alertSrv.js" type="text/javascript" charset="utf-8"></script>
+ <script src="public/js/services/authSrv.js" type="text/javascript" charset="utf-8"></script>
<!-- Components -->
<script src="public/js/components/main.js" type="text/javascript" charset="utf-8"></script>
@@ -323,6 +353,7 @@
<script src="public/js/ctrls/integrationCtrl.js" type="text/javascript" charset="utf-8"></script>
<script src="public/js/ctrls/siteCtrl.js" type="text/javascript" charset="utf-8"></script>
<script src="public/js/ctrls/metricCtrl.js" type="text/javascript" charset="utf-8"></script>
+ <script src="public/js/ctrls/authCtrl.js" type="text/javascript" charset="utf-8"></script>
<!-- endref -->
</body>
</html>
http://git-wip-us.apache.org/repos/asf/eagle/blob/287a1c10/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 031f71d..d5b3352 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
@@ -23,7 +23,7 @@
{{policy.name}}
</h3>
<div class="box-tools pull-right">
- <div class="btn-group">
+ <div class="btn-group" ng-if="Auth.isAdmin">
<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({siteId: site, name: policy.name})"></a>
http://git-wip-us.apache.org/repos/asf/eagle/blob/287a1c10/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 cb0936f..7cfee58 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
@@ -31,7 +31,7 @@
<th sortpath="policyStatus" width="10"></th>
<th sortpath="name" width="10%">Name</th>
<th>Description</th>
- <th width="85">Action</th>
+ <th width="85" ng-if="Auth.isAdmin">Action</th>
</tr>
</thead>
<tbody>
@@ -43,7 +43,7 @@
<a ui-sref="policyDetail({siteId: site, name: item.name})">{{item.name}}</a>
</td>
<td>{{item.description}}</td>
- <td class="text-center">
+ <td class="text-center" ng-if="Auth.isAdmin">
<div class="btn-group btn-group-xs">
<button class="btn btn-default opt" ng-if="item.policyStatus !== 'ENABLED'" ng-click="startPolicy(item)">
<span class="fa fa-play"></span>
@@ -62,7 +62,9 @@
<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({ siteId: site })">here</a> to create a new policy.</p>
+ <p>You have not create policy yet.
+ <span ng-if="Auth.isAdmin">Click <a ui-sref="policyCreate({ siteId: site })">here</a> to create a new policy.</span>
+ </p>
</div>
</div>
@@ -70,7 +72,7 @@
<i class="fa fa-refresh fa-spin"></i>
</div>
- <div class="box-footer text-right">
+ <div class="box-footer text-right" ng-if="Auth.isAdmin">
<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/287a1c10/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..3338160 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
@@ -29,7 +29,7 @@
<thead>
<tr>
<th>Stream</th>
- <th>Provider (App)</th>
+ <th>Provider (Source)</th>
<th>Site</th>
<th>Schema</th>
</tr>
@@ -38,7 +38,7 @@
<tr>
<td><span class="label label-primary">{{item.streamId}}</span></td>
<td class="text-no-break">
- {{item.application.type}}
+ {{item.streamSource}}
<a class="fa fa-plug" uib-tooltip="Click to view data source" ng-click="showDataSource(item)"></a>
</td>
<td>{{item.siteId}}</td>
http://git-wip-us.apache.org/repos/asf/eagle/blob/287a1c10/eagle-server/src/main/webapp/app/dev/partials/login.html
----------------------------------------------------------------------
diff --git a/eagle-server/src/main/webapp/app/dev/partials/login.html b/eagle-server/src/main/webapp/app/dev/partials/login.html
new file mode 100644
index 0000000..8546f72
--- /dev/null
+++ b/eagle-server/src/main/webapp/app/dev/partials/login.html
@@ -0,0 +1,45 @@
+<!--
+ 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="row">
+ <div class="
+ col-sm-12
+ col-md-8 col-md-offset-2
+ col-lg-6 col-lg-offset-3
+ ">
+ <div class="box box-primary">
+ <div class="box-header with-border">
+ <i class="fa fa-user"></i>
+ <h3 class="box-title">Authentication</h3>
+ </div>
+ <div class="box-body">
+ <div class="form-group">
+ <label>User Name</label>
+ <input type="text" class="form-control" ng-model="username" name="username">
+ </div>
+ <div class="form-group">
+ <label>Password</label>
+ <input type="password" class="form-control" ng-model="password" ng-keypress="onKeyPress($event)">
+ </div>
+ </div>
+ <div class="box-footer text-right">
+ <button class="btn btn-primary" ng-click="login()">Login</button>
+ </div>
+ </div>
+ </div>
+</div>
http://git-wip-us.apache.org/repos/asf/eagle/blob/287a1c10/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 594e248..30e10d7 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
@@ -28,6 +28,21 @@ a {
}
/* ========================================================================
+ * = Navigation =
+ * ======================================================================== */
+.navbar-nav > .user-menu > .dropdown-menu > li.user-header > .portrait {
+ display: inline-block;
+ width: 90px;
+ height: 90px;
+ border: 3px solid rgba(255, 255, 255, 0.5);
+ border-radius: 100%;
+ font-size: 60px;
+ padding-top: 10px;
+ background-color: rgba(0,0,0,0.1);
+ color: rgba(255,255,255,0.8);
+}
+
+/* ========================================================================
* = Side Bar =
* ======================================================================== */
.sidebar-mini.sidebar-collapse .main-header .logo > .logo-mini > img {
http://git-wip-us.apache.org/repos/asf/eagle/blob/287a1c10/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 e5b87e8..baa4d3e 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
@@ -109,7 +109,7 @@ var app = {};
eagleApp.config(function ($stateProvider, $urlRouterProvider, $httpProvider, $animateProvider) {
$urlRouterProvider.otherwise("/");
$stateProvider
- // ================================== Home ==================================
+ // ================================== Home ==================================
.state('home', {
url: "/",
templateUrl: "partials/home.html?_=" + window._TRS(),
@@ -123,6 +123,14 @@ var app = {};
resolve: routeResolve({ site: false, application: false })
})
+ // ================================== Auth ==================================
+ .state('login', {
+ url: "/login",
+ templateUrl: "partials/login.html?_=" + window._TRS(),
+ controller: "loginCtrl",
+ resolve: routeResolve()
+ })
+
// =============================== Integration ==============================
.state('integration', {
abstract: true,
@@ -274,9 +282,9 @@ var app = {};
// = Main Controller =
// ======================================================================================
eagleApp.controller('MainCtrl', function (
- $scope, $wrapState, $urlRouter, $notification,
+ $scope, $wrapState, $urlRouter, $notification, $authHttp,
Server, PageConfig, Portal, Widget, Entity, CompatibleEntity,
- Site, Application, UI, Time, Policy, Alert) {
+ Site, Application, UI, Time, Policy, Alert, Auth) {
window._WrapState = $scope.$wrapState = $wrapState;
window._Server = $scope.Server = Server;
window._PageConfig = $scope.PageConfig = PageConfig;
@@ -291,6 +299,8 @@ var app = {};
window._Policy = $scope.Policy = Policy;
window._Notification = $scope.$notification = $notification;
window._Alert = $scope.Alert = Alert;
+ window._Auth = $scope.Auth = Auth;
+ window._AuthHttp = $scope.$authHttp = $authHttp;
$scope.common = common;
$scope._TRS = window._TRS();
http://git-wip-us.apache.org/repos/asf/eagle/blob/287a1c10/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 be0a97c..9871ab7 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
@@ -153,7 +153,7 @@
PageConfig.title = "Policy";
PageConfig.subTitle = "Detail";
PageConfig.navPath = [
- {title: "Policy List", path: "/policies"},
+ {title: "Policy List", path: "/site/" + $wrapState.param.siteId + "/policies"},
{title: "Detail"}
];
@@ -191,7 +191,7 @@
Entity.queryMetadata("schedulestates")._then(function (res) {
var schedule = res.data || {};
- $scope.assignment = common.array.find(policyName, schedule.assignments, ["policyName"]) || {};
+ $scope.assignment = common.array.find(policyName, schedule.assignments || [], ["policyName"]) || {};
var queueList = $.map(schedule.monitoredStreams, function (stream) {
return stream.queues;
http://git-wip-us.apache.org/repos/asf/eagle/blob/287a1c10/eagle-server/src/main/webapp/app/dev/public/js/ctrls/authCtrl.js
----------------------------------------------------------------------
diff --git a/eagle-server/src/main/webapp/app/dev/public/js/ctrls/authCtrl.js b/eagle-server/src/main/webapp/app/dev/public/js/ctrls/authCtrl.js
new file mode 100644
index 0000000..e4b3329
--- /dev/null
+++ b/eagle-server/src/main/webapp/app/dev/public/js/ctrls/authCtrl.js
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+
+(function() {
+ 'use strict';
+
+ var eagleControllers = angular.module('eagleControllers');
+
+ eagleControllers.controller('loginCtrl', function ($scope, $wrapState, Auth) {
+ $scope.username = '';
+ $scope.password = '';
+
+ $scope.login = function () {
+ Auth.login($scope.username, $scope.password).then(function (result) {
+ if (result) {
+ $wrapState.go('home');
+ } else {
+ $.dialog({
+ title: 'OPS',
+ content: 'Username or password not correct.'
+ });
+ }
+ });
+ };
+
+ $scope.onKeyPress = function (event) {
+ if (event.which === 13) {
+ $scope.login();
+ }
+ };
+
+ $('[name="username"]').focus();
+ });
+})();
http://git-wip-us.apache.org/repos/asf/eagle/blob/287a1c10/eagle-server/src/main/webapp/app/dev/public/js/ctrls/mainCtrl.js
----------------------------------------------------------------------
diff --git a/eagle-server/src/main/webapp/app/dev/public/js/ctrls/mainCtrl.js b/eagle-server/src/main/webapp/app/dev/public/js/ctrls/mainCtrl.js
index 015bd4f..97b4704 100644
--- a/eagle-server/src/main/webapp/app/dev/public/js/ctrls/mainCtrl.js
+++ b/eagle-server/src/main/webapp/app/dev/public/js/ctrls/mainCtrl.js
@@ -25,7 +25,7 @@
// = Home =
// ======================================================================================
eagleControllers.controller('homeCtrl', function ($scope, $wrapState, PageConfig) {
- PageConfig.title = "Home";
+ PageConfig.title = "Overveiw";
$scope.colorList = [
"bg-aqua",
http://git-wip-us.apache.org/repos/asf/eagle/blob/287a1c10/eagle-server/src/main/webapp/app/dev/public/js/services/authSrv.js
----------------------------------------------------------------------
diff --git a/eagle-server/src/main/webapp/app/dev/public/js/services/authSrv.js b/eagle-server/src/main/webapp/app/dev/public/js/services/authSrv.js
new file mode 100644
index 0000000..0fa2d4a
--- /dev/null
+++ b/eagle-server/src/main/webapp/app/dev/public/js/services/authSrv.js
@@ -0,0 +1,120 @@
+/*
+ * 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.
+ */
+
+(function() {
+ 'use strict';
+
+ var serviceModule = angular.module('eagle.service');
+
+ serviceModule.service('Auth', function ($http) {
+ //$http.defaults.withCredentials = true;
+ var Auth = {
+ isLogin: false,
+ user: {},
+ };
+
+ var _host = "";
+ if(localStorage) {
+ _host = localStorage.getItem("host") || "";
+ }
+
+ Auth.login = function (username, password) {
+ var _hash = btoa(username + ':' + password);
+
+ return Auth.sync(_hash);
+ };
+
+ Auth.logout = function () {
+ Auth.isLogin = false;
+ Auth.user = {};
+ if (localStorage) {
+ localStorage.removeItem('auth');
+ }
+ };
+
+ Auth.sync = function (hash) {
+ return $http.get(_host + "/rest/auth/principal", {
+ headers: {
+ 'Authorization': "Basic " + hash
+ }
+ }).then(function (result) {
+ if (result.data.success) {
+ Auth.user = result.data.data;
+ Auth.isLogin = true;
+ if (localStorage) {
+ localStorage.setItem('auth', hash);
+ }
+ }
+ return result.data.success;
+ }, function () {
+ return false;
+ });
+ };
+
+ if (localStorage && localStorage.getItem('auth')) {
+ Auth.sync(localStorage.getItem('auth'));
+ }
+
+ Object.defineProperties(Auth, {
+ isAdmin: {
+ get: function () {
+ return (Auth.user.roles || []).indexOf('ADMINISTRATOR') !== -1;
+ }
+ },
+ hash: {
+ get: function () {
+ if (localStorage && localStorage.getItem('auth')) {
+ return localStorage.getItem('auth');
+ }
+ return null;
+ }
+ },
+ });
+
+ return Auth;
+ });
+
+ serviceModule.service('$authHttp', function ($http, Auth) {
+ function mergeConfig(config) {
+ config = config || {};
+ if (Auth.hash) {
+ config.headers = config.headers || {};
+ config.headers.Authorization = "Basic " + Auth.hash;
+ }
+ return config;
+ }
+
+ var $authHttp = function (config) {
+ return $http(mergeConfig(config));
+ };
+
+ $authHttp.get = function (url, config) {
+ return $http.get(url, mergeConfig(config));
+ };
+
+ $authHttp.post = function (url, data, config) {
+ return $http.post(url, data, mergeConfig(config));
+ };
+
+ $authHttp.delete = function (url, config) {
+ return $http.delete(url, mergeConfig(config));
+ };
+
+ return $authHttp;
+ });
+})();
http://git-wip-us.apache.org/repos/asf/eagle/blob/287a1c10/eagle-server/src/main/webapp/app/dev/public/js/services/compatibleEntitySrv.js
----------------------------------------------------------------------
diff --git a/eagle-server/src/main/webapp/app/dev/public/js/services/compatibleEntitySrv.js b/eagle-server/src/main/webapp/app/dev/public/js/services/compatibleEntitySrv.js
index 8296451..405af81 100644
--- a/eagle-server/src/main/webapp/app/dev/public/js/services/compatibleEntitySrv.js
+++ b/eagle-server/src/main/webapp/app/dev/public/js/services/compatibleEntitySrv.js
@@ -26,7 +26,7 @@
_host = localStorage.getItem("host") || "";
}
- serviceModule.service('CompatibleEntity', function($http, Time) {
+ serviceModule.service('CompatibleEntity', function($authHttp, Time) {
function CompatibleEntity() {}
function wrapList(list, promise) {
@@ -131,7 +131,7 @@
}
var url = common.template(url_tpl, myParam);
- return wrapList(list, $http.get(_host + url));
+ return wrapList(list, $authHttp.get(_host + url));
};
return list._refresh();
http://git-wip-us.apache.org/repos/asf/eagle/blob/287a1c10/eagle-server/src/main/webapp/app/dev/public/js/services/entitySrv.js
----------------------------------------------------------------------
diff --git a/eagle-server/src/main/webapp/app/dev/public/js/services/entitySrv.js b/eagle-server/src/main/webapp/app/dev/public/js/services/entitySrv.js
index 986e0d1..54b3694 100644
--- a/eagle-server/src/main/webapp/app/dev/public/js/services/entitySrv.js
+++ b/eagle-server/src/main/webapp/app/dev/public/js/services/entitySrv.js
@@ -26,7 +26,7 @@
_host = localStorage.getItem("host") || "";
}
- serviceModule.service('Entity', function($http, $q) {
+ serviceModule.service('Entity', function($authHttp, $q) {
function Entity() {}
function wrapList(list, promise) {
@@ -64,7 +64,7 @@
list._refresh = function () {
var config = {};
if(param) config.params = param;
- return wrapList(list, $http.get(_host + "/rest/" + url, config));
+ return wrapList(list, $authHttp.get(_host + "/rest/" + url, config));
};
return list._refresh();
@@ -72,7 +72,7 @@
Entity.create = Entity.post = function (url, entity) {
var list = [];
- return wrapList(list, $http({
+ return wrapList(list, $authHttp({
method: 'POST',
url: _host + "/rest/" + url,
headers: {
@@ -84,7 +84,7 @@
Entity.delete = function (url, uuid) {
var list = [];
- return wrapList(list, $http({
+ return wrapList(list, $authHttp({
method: 'DELETE',
url: _host + "/rest/" + url,
headers: {
@@ -148,7 +148,7 @@
Entity.deleteMetadata = function (url) {
return {
- _promise: $http.delete(_host + "/rest/metadata/" + url).then(function (res) {
+ _promise: $authHttp.delete(_host + "/rest/metadata/" + url).then(function (res) {
console.log(res);
})
};
http://git-wip-us.apache.org/repos/asf/eagle/blob/287a1c10/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 7b699be..2faa059 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
@@ -80,29 +80,13 @@
// ============================================================
// = Portal =
// ============================================================
- serviceModule.service('Portal', function($wrapState, Site, Application) {
+ serviceModule.service('Portal', function($wrapState, Site, Application, Auth) {
function checkSite() {
return Site.list.length !== 0;
}
- function checkApplication() {
- return checkSite() && Application.list.length !== 0;
- }
-
var defaultPortalList = [
- {name: "Home", icon: "home", path: "#/"},
- /* {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: [
- {name: "Sites", path: "#/integration/siteList"},
- {name: "Applications", path: "#/integration/applicationList"}
- ]}
+ {name: "Overview", icon: "home", path: "#/"},
];
var Portal = {};
@@ -117,15 +101,22 @@
};
function getDefaultSitePortal(site) {
+ var alertPortal = [
+ {name: "Alerts", path: "#/site/" + site.siteId + "/alerts"},
+ {name: "Policies", path: "#/site/" + site.siteId + "/policies"},
+ {name: "Streams", path: "#/site/" + site.siteId + "/streams"},
+ ];
+
+ if (Auth.isAdmin) {
+ alertPortal.push(
+ {name: "Define Policy", path: "#/site/" + site.siteId + "/policy/create"}
+ );
+ }
+
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"}
- ]},
+ {name: "Alert", icon: "bell", list: alertPortal},
];
}
@@ -160,17 +151,8 @@
}
Portal.refresh = function () {
- // TODO: check admin
-
// Main level
- connectedMainPortalList = defaultPortalList.concat(adminPortalList);
- var siteList = $.map(Site.list, function (site) {
- return {
- name: site.siteName || site.siteId,
- path: "#/site/" + site.siteId
- };
- });
- connectedMainPortalList.push({name: "Sites", icon: "server", showFunc: checkApplication, list: siteList});
+ connectedMainPortalList = defaultPortalList.concat();
connectedMainPortalList = mergePortalList(connectedMainPortalList);
// Site level