You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by de...@apache.org on 2017/05/02 20:51:54 UTC
[2/2] incubator-trafficcontrol git commit: places cachegroup markers
on google map
places cachegroup markers on google map
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/60f2ecc4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/60f2ecc4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/60f2ecc4
Branch: refs/heads/master
Commit: 60f2ecc4fb6770f8ffba08f2292b3ee83146efbc
Parents: 9082584
Author: Jeremy Mitchell <mi...@gmail.com>
Authored: Tue May 2 09:14:54 2017 -0600
Committer: Dewayne Richardson <de...@apache.org>
Committed: Tue May 2 14:51:50 2017 -0600
----------------------------------------------------------------------
traffic_ops/experimental/ui/app/src/app.js | 2 +-
.../ui/app/src/common/api/AuthService.js | 2 +-
.../ui/app/src/common/api/CacheGroupService.js | 20 ++++++-
.../modules/navigation/navigation.tpl.html | 2 +-
.../dashboards/map/DashboardsMapController.js | 62 ++++++++++++++++++++
.../monitor/dashboards/map/_dashboards.map.scss | 21 +++++++
.../dashboards/map/dashboards.map.tpl.html | 37 ++++++++++++
.../private/monitor/dashboards/map/index.js | 43 ++++++++++++++
.../dashboards/one/DashboardsOneController.js | 24 --------
.../monitor/dashboards/one/_dashboards.one.scss | 21 -------
.../dashboards/one/dashboards.one.tpl.html | 22 -------
.../private/monitor/dashboards/one/index.js | 35 -----------
.../experimental/ui/app/src/styles/main.scss | 2 +-
13 files changed, 185 insertions(+), 108 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/60f2ecc4/traffic_ops/experimental/ui/app/src/app.js
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/app.js b/traffic_ops/experimental/ui/app/src/app.js
index ecb1115..820ee28 100644
--- a/traffic_ops/experimental/ui/app/src/app.js
+++ b/traffic_ops/experimental/ui/app/src/app.js
@@ -155,7 +155,7 @@ var trafficOps = angular.module('trafficOps', [
// dashboards
require('./modules/private/monitor/dashboards').name,
- require('./modules/private/monitor/dashboards/one').name,
+ require('./modules/private/monitor/dashboards/map').name,
require('./modules/private/monitor/dashboards/two').name,
require('./modules/private/monitor/dashboards/three').name,
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/60f2ecc4/traffic_ops/experimental/ui/app/src/common/api/AuthService.js
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/common/api/AuthService.js b/traffic_ops/experimental/ui/app/src/common/api/AuthService.js
index b9975e7..da534fa 100644
--- a/traffic_ops/experimental/ui/app/src/common/api/AuthService.js
+++ b/traffic_ops/experimental/ui/app/src/common/api/AuthService.js
@@ -30,7 +30,7 @@ var AuthService = function($rootScope, $http, $state, $location, $q, $state, htt
$location.search('redirect', null); // remove the redirect query param
$location.url(redirect);
} else {
- $location.url('/monitor/dashboards/one');
+ $location.url('/monitor/dashboards/map');
}
},
function(fault) {
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/60f2ecc4/traffic_ops/experimental/ui/app/src/common/api/CacheGroupService.js
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/common/api/CacheGroupService.js b/traffic_ops/experimental/ui/app/src/common/api/CacheGroupService.js
index fe26d15..f2172cd 100644
--- a/traffic_ops/experimental/ui/app/src/common/api/CacheGroupService.js
+++ b/traffic_ops/experimental/ui/app/src/common/api/CacheGroupService.js
@@ -17,7 +17,7 @@
* under the License.
*/
-var CacheGroupService = function(Restangular, locationUtils, messageModel) {
+var CacheGroupService = function($http, $q, Restangular, locationUtils, messageModel, ENV) {
this.getCacheGroups = function(queryParams) {
return Restangular.all('cachegroups').getList(queryParams);
@@ -93,7 +93,23 @@ var CacheGroupService = function(Restangular, locationUtils, messageModel) {
return Restangular.one('parameters', paramId).getList('cachegroups');
};
+ this.getCacheGroupHealth = function() {
+ var deferred = $q.defer();
+
+ $http.get(ENV.api['root'] + "cdns/health")
+ .then(
+ function(result) {
+ deferred.resolve(result.data.response);
+ },
+ function(fault) {
+ deferred.reject(fault);
+ }
+ );
+
+ return deferred.promise;
+ };
+
};
-CacheGroupService.$inject = ['Restangular', 'locationUtils', 'messageModel'];
+CacheGroupService.$inject = ['$http', '$q', 'Restangular', 'locationUtils', 'messageModel', 'ENV'];
module.exports = CacheGroupService;
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/60f2ecc4/traffic_ops/experimental/ui/app/src/common/modules/navigation/navigation.tpl.html
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/common/modules/navigation/navigation.tpl.html b/traffic_ops/experimental/ui/app/src/common/modules/navigation/navigation.tpl.html
index f535a35..3e0821d 100644
--- a/traffic_ops/experimental/ui/app/src/common/modules/navigation/navigation.tpl.html
+++ b/traffic_ops/experimental/ui/app/src/common/modules/navigation/navigation.tpl.html
@@ -27,7 +27,7 @@ under the License.
<ul class="nav side-menu">
<li class="side-menu-category"><a href="javascript:void(0);"><i class="fa fa-bar-chart"></i> Monitor <span class="fa fa-chevron-down"></span></a>
<ul class="nav child_menu" style="display: none">
- <li class="side-menu-category-item" ng-class="{'current-page': isState('trafficOps.private.monitor.dashboards.one')}"><a ng-click="navigateToPath('/monitor/dashboards/one')">Map</a></li>
+ <li class="side-menu-category-item" ng-class="{'current-page': isState('trafficOps.private.monitor.dashboards.map')}"><a ng-click="navigateToPath('/monitor/dashboards/map')">Map</a></li>
<li class="side-menu-category-item" ng-class="{'current-page': isState('trafficOps.private.monitor.dashboards.two')}"><a ng-click="navigateToPath('/monitor/dashboards/two')">Graphs</a></li>
<li class="side-menu-category-item" ng-class="{'current-page': isState('trafficOps.private.monitor.dashboards.three')}"><a ng-click="navigateToPath('/monitor/dashboards/three')">Dashboard 3</a></li>
</ul>
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/60f2ecc4/traffic_ops/experimental/ui/app/src/modules/private/monitor/dashboards/map/DashboardsMapController.js
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/modules/private/monitor/dashboards/map/DashboardsMapController.js b/traffic_ops/experimental/ui/app/src/modules/private/monitor/dashboards/map/DashboardsMapController.js
new file mode 100644
index 0000000..192804b
--- /dev/null
+++ b/traffic_ops/experimental/ui/app/src/modules/private/monitor/dashboards/map/DashboardsMapController.js
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ */
+
+var DashboardsMapController = function(cacheGroups, cacheGroupHealth, $scope, NgMap) {
+
+ $scope.map = NgMap.getMap('cgMap');
+
+ $scope.cacheGroups = [];
+
+ $scope.parentCg = function(cg) {
+ return cg.parent ? cg.parent : 'None'
+ };
+
+ $scope.secondaryParentCg = function(cg) {
+ return cg.secondaryParent ? cg.secondaryParent : 'None'
+ };
+
+ var massageCacheGroups = function() {
+ var cgHealthCacheGroups = cacheGroupHealth.cachegroups,
+ cgHealth;
+ _.each(cacheGroups, function(cg) {
+ cgHealth = _.find(cgHealthCacheGroups, function(cghcg){ return cghcg.name == cg.name });
+ $scope.cacheGroups.push(
+ {
+ name: cg.name,
+ parent: cg.parentCachegroupName,
+ secondaryParent: cg.secondaryParentCachegroupName,
+ pos: [ cg.latitude, cg.longitude ],
+ type: cg.typeName,
+ offline: cgHealth ? cgHealth.offline : '-',
+ online: cgHealth ? cgHealth.online : '-'
+ }
+ );
+ });
+ };
+
+ var init = function() {
+ massageCacheGroups();
+ };
+ init();
+
+
+};
+
+DashboardsMapController.$inject = ['cacheGroups', 'cacheGroupHealth', '$scope', 'NgMap'];
+module.exports = DashboardsMapController;
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/60f2ecc4/traffic_ops/experimental/ui/app/src/modules/private/monitor/dashboards/map/_dashboards.map.scss
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/modules/private/monitor/dashboards/map/_dashboards.map.scss b/traffic_ops/experimental/ui/app/src/modules/private/monitor/dashboards/map/_dashboards.map.scss
new file mode 100644
index 0000000..72d3f1b
--- /dev/null
+++ b/traffic_ops/experimental/ui/app/src/modules/private/monitor/dashboards/map/_dashboards.map.scss
@@ -0,0 +1,21 @@
+/*
+
+
+ Licensed 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.
+
+*/
+ng-map {
+ position: absolute;
+ width:100%;
+ height:100%;
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/60f2ecc4/traffic_ops/experimental/ui/app/src/modules/private/monitor/dashboards/map/dashboards.map.tpl.html
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/modules/private/monitor/dashboards/map/dashboards.map.tpl.html b/traffic_ops/experimental/ui/app/src/modules/private/monitor/dashboards/map/dashboards.map.tpl.html
new file mode 100644
index 0000000..671e0d7
--- /dev/null
+++ b/traffic_ops/experimental/ui/app/src/modules/private/monitor/dashboards/map/dashboards.map.tpl.html
@@ -0,0 +1,37 @@
+<!--
+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="angular-google-map-container" map-lazy-load="https://maps.google.com/maps/api/js">
+ <ng-map id="cgMap" zoom="5" center="[41,-87]">
+ <marker ng-repeat="cg in ::cacheGroups"
+ position="{{::cg.pos}}"
+ on-click="map.showInfoWindow(event, cg.name)"></marker>
+ <info-window id="{{::cg.name}}" ng-repeat="cg in ::cacheGroups">
+ <div>
+ <h3>{{::cg.name}} ({{::cg.type}})</h3>
+ <hr>
+ <h5>Coordinates: {{::cg.pos}}</h5>
+ <h5>1st Parent: {{::parentCg(cg)}}</h5>
+ <h5>2nd Parent: {{::secondaryParentCg(cg)}}</h5>
+ <h5>Online Caches: {{::cg.online}}</h5>
+ <h5>Offline Caches: {{::cg.offline}}</h5>
+ </div>
+ </info-window>
+ </ng-map>
+</div>
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/60f2ecc4/traffic_ops/experimental/ui/app/src/modules/private/monitor/dashboards/map/index.js
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/modules/private/monitor/dashboards/map/index.js b/traffic_ops/experimental/ui/app/src/modules/private/monitor/dashboards/map/index.js
new file mode 100644
index 0000000..74fe61a
--- /dev/null
+++ b/traffic_ops/experimental/ui/app/src/modules/private/monitor/dashboards/map/index.js
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+
+module.exports = angular.module('trafficOps.private.monitor.dashboards.map', [])
+ .controller('DashboardsMapController', require('./DashboardsMapController'))
+ .config(function($stateProvider, $urlRouterProvider) {
+ $stateProvider
+ .state('trafficOps.private.monitor.dashboards.map', {
+ url: '/map',
+ views: {
+ dashboardsContent: {
+ templateUrl: 'modules/private/monitor/dashboards/map/dashboards.map.tpl.html',
+ controller: 'DashboardsMapController',
+ resolve: {
+ cacheGroups: function(cacheGroupService) {
+ return cacheGroupService.getCacheGroups();
+ },
+ cacheGroupHealth: function(cacheGroupService) {
+ return cacheGroupService.getCacheGroupHealth();
+ }
+ }
+ }
+ }
+ })
+ ;
+ $urlRouterProvider.otherwise('/');
+ });
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/60f2ecc4/traffic_ops/experimental/ui/app/src/modules/private/monitor/dashboards/one/DashboardsOneController.js
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/modules/private/monitor/dashboards/one/DashboardsOneController.js b/traffic_ops/experimental/ui/app/src/modules/private/monitor/dashboards/one/DashboardsOneController.js
deleted file mode 100644
index b37e1c0..0000000
--- a/traffic_ops/experimental/ui/app/src/modules/private/monitor/dashboards/one/DashboardsOneController.js
+++ /dev/null
@@ -1,24 +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.
- */
-
-var DashboardsOneController = function($scope) {
-};
-
-DashboardsOneController.$inject = ['$scope'];
-module.exports = DashboardsOneController;
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/60f2ecc4/traffic_ops/experimental/ui/app/src/modules/private/monitor/dashboards/one/_dashboards.one.scss
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/modules/private/monitor/dashboards/one/_dashboards.one.scss b/traffic_ops/experimental/ui/app/src/modules/private/monitor/dashboards/one/_dashboards.one.scss
deleted file mode 100644
index 72d3f1b..0000000
--- a/traffic_ops/experimental/ui/app/src/modules/private/monitor/dashboards/one/_dashboards.one.scss
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
-
-
- Licensed 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.
-
-*/
-ng-map {
- position: absolute;
- width:100%;
- height:100%;
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/60f2ecc4/traffic_ops/experimental/ui/app/src/modules/private/monitor/dashboards/one/dashboards.one.tpl.html
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/modules/private/monitor/dashboards/one/dashboards.one.tpl.html b/traffic_ops/experimental/ui/app/src/modules/private/monitor/dashboards/one/dashboards.one.tpl.html
deleted file mode 100644
index b1a8be8..0000000
--- a/traffic_ops/experimental/ui/app/src/modules/private/monitor/dashboards/one/dashboards.one.tpl.html
+++ /dev/null
@@ -1,22 +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="angular-google-map-container" map-lazy-load="https://maps.google.com/maps/api/js">
- <ng-map center="41,-87" zoom="3"></ng-map>
-</div>
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/60f2ecc4/traffic_ops/experimental/ui/app/src/modules/private/monitor/dashboards/one/index.js
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/modules/private/monitor/dashboards/one/index.js b/traffic_ops/experimental/ui/app/src/modules/private/monitor/dashboards/one/index.js
deleted file mode 100644
index 73a645a..0000000
--- a/traffic_ops/experimental/ui/app/src/modules/private/monitor/dashboards/one/index.js
+++ /dev/null
@@ -1,35 +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.
- */
-
-module.exports = angular.module('trafficOps.private.monitor.dashboards.one', [])
- .controller('DashboardsOneController', require('./DashboardsOneController'))
- .config(function($stateProvider, $urlRouterProvider) {
- $stateProvider
- .state('trafficOps.private.monitor.dashboards.one', {
- url: '/one',
- views: {
- dashboardsContent: {
- templateUrl: 'modules/private/monitor/dashboards/one/dashboards.one.tpl.html',
- controller: 'DashboardsOneController'
- }
- }
- })
- ;
- $urlRouterProvider.otherwise('/');
- });
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/60f2ecc4/traffic_ops/experimental/ui/app/src/styles/main.scss
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/styles/main.scss b/traffic_ops/experimental/ui/app/src/styles/main.scss
index b920346..8a3c1c5 100755
--- a/traffic_ops/experimental/ui/app/src/styles/main.scss
+++ b/traffic_ops/experimental/ui/app/src/styles/main.scss
@@ -61,7 +61,7 @@ $fa-font-path: "../assets/fonts";
// dashboards
@import "../modules/private/monitor/dashboards/dashboards";
-@import "../modules/private/monitor/dashboards/one/dashboards.one";
+@import "../modules/private/monitor/dashboards/map/dashboards.map";
@import "../modules/private/monitor/dashboards/two/dashboards.two";
@import "../modules/private/monitor/dashboards/three/dashboards.three";