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/07/24 20:50:17 UTC

[1/2] incubator-trafficcontrol git commit: This closes #748

Repository: incubator-trafficcontrol
Updated Branches:
  refs/heads/master 7c0aea3b4 -> cd1e9929a


This closes #748


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

Branch: refs/heads/master
Commit: cd1e9929a69bd7b303e1da218ffb4780e852b5c6
Parents: 3a528d4
Author: Dewayne Richardson <de...@apache.org>
Authored: Mon Jul 24 14:49:52 2017 -0600
Committer: Dewayne Richardson <de...@apache.org>
Committed: Mon Jul 24 14:49:52 2017 -0600

----------------------------------------------------------------------

----------------------------------------------------------------------



[2/2] incubator-trafficcontrol git commit: implements configurable autorefresh or dashboard components

Posted by de...@apache.org.
implements configurable autorefresh or dashboard components


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/3a528d49
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/3a528d49
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/3a528d49

Branch: refs/heads/master
Commit: 3a528d4950eb9bdaf85a496df8ad07e122cbdc93
Parents: 7c0aea3
Author: Jeremy Mitchell <mi...@gmail.com>
Authored: Mon Jul 24 13:16:24 2017 -0600
Committer: Dewayne Richardson <de...@apache.org>
Committed: Mon Jul 24 14:49:52 2017 -0600

----------------------------------------------------------------------
 .../cacheGroups/WidgetCacheGroupsController.js  | 33 +++++++++-
 .../widget/capacity/WidgetCapacityController.js | 26 +++++++-
 .../widget/cdnChart/WidgetCDNChartController.js | 27 +++++++-
 .../widget/routing/WidgetRoutingController.js   | 26 +++++++-
 .../monitor/dashboard/DashboardController.js    | 66 +++++++++++++++++++-
 .../app/src/traffic_portal_properties.json      | 25 ++++++++
 6 files changed, 193 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3a528d49/traffic_portal/app/src/common/modules/widget/cacheGroups/WidgetCacheGroupsController.js
----------------------------------------------------------------------
diff --git a/traffic_portal/app/src/common/modules/widget/cacheGroups/WidgetCacheGroupsController.js b/traffic_portal/app/src/common/modules/widget/cacheGroups/WidgetCacheGroupsController.js
index 43cda07..78fdbc0 100644
--- a/traffic_portal/app/src/common/modules/widget/cacheGroups/WidgetCacheGroupsController.js
+++ b/traffic_portal/app/src/common/modules/widget/cacheGroups/WidgetCacheGroupsController.js
@@ -17,7 +17,29 @@
  * under the License.
  */
 
-var WidgetCacheGroupsController = function(cacheGroupHealth, $scope, locationUtils) {
+var WidgetCacheGroupsController = function(cacheGroupHealth, $scope, $interval, cacheGroupService, locationUtils, propertiesModel) {
+
+	var interval,
+		autoRefresh = propertiesModel.properties.dashboard.autoRefresh;
+
+	var getCacheGroupHealth = function() {
+		cacheGroupService.getCacheGroupHealth()
+			.then(function(result) {
+				$scope.cacheGroupHealth = result;
+			});
+	};
+
+	var createInterval = function() {
+		killInterval();
+		interval = $interval(function() { getCacheGroupHealth() }, propertiesModel.properties.dashboard.cacheGroupHealth.refreshRateInMS );
+	};
+
+	var killInterval = function() {
+		if (angular.isDefined(interval)) {
+			$interval.cancel(interval);
+			interval = undefined;
+		}
+	};
 
 	// pagination
 	$scope.currentCacheGroupsPage = 1;
@@ -29,15 +51,22 @@ var WidgetCacheGroupsController = function(cacheGroupHealth, $scope, locationUti
 		return (location.online / (location.online + location.offline)) * 100;
 	};
 
+	$scope.$on("$destroy", function() {
+		killInterval();
+	});
+
 	var init = function() {
 		if (cacheGroupHealth) {
 			// only set this if it's passed in
 			$scope.cacheGroupHealth = cacheGroupHealth;
 		}
+		if (autoRefresh) {
+			createInterval();
+		}
 	};
 	init();
 
 };
 
-WidgetCacheGroupsController.$inject = ['cacheGroupHealth', '$scope', 'locationUtils'];
+WidgetCacheGroupsController.$inject = ['cacheGroupHealth', '$scope', '$interval', 'cacheGroupService', 'locationUtils', 'propertiesModel'];
 module.exports = WidgetCacheGroupsController;

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3a528d49/traffic_portal/app/src/common/modules/widget/capacity/WidgetCapacityController.js
----------------------------------------------------------------------
diff --git a/traffic_portal/app/src/common/modules/widget/capacity/WidgetCapacityController.js b/traffic_portal/app/src/common/modules/widget/capacity/WidgetCapacityController.js
index e7c57cb..4f853eb 100644
--- a/traffic_portal/app/src/common/modules/widget/capacity/WidgetCapacityController.js
+++ b/traffic_portal/app/src/common/modules/widget/capacity/WidgetCapacityController.js
@@ -17,7 +17,10 @@
  * under the License.
  */
 
-var WidgetCapacityController = function($scope, cdnService) {
+var WidgetCapacityController = function($scope, $interval, cdnService, propertiesModel) {
+
+	var interval,
+		autoRefresh = propertiesModel.properties.dashboard.autoRefresh;
 
 	var getCapacity = function() {
 		cdnService.getCapacity()
@@ -85,17 +88,36 @@ var WidgetCapacityController = function($scope, cdnService) {
 		$.plot($("#capacityChart"), graphData, options);
 	};
 
+	var createInterval = function() {
+		killInterval();
+		interval = $interval(function() { getCapacity() }, propertiesModel.properties.dashboard.capacity.refreshRateInMS );
+	};
+
+	var killInterval = function() {
+		if (angular.isDefined(interval)) {
+			$interval.cancel(interval);
+			interval = undefined;
+		}
+	};
+
 	$scope.availablePercent = 0;
 	$scope.utilizedPercent = 0;
 	$scope.maintenancePercent = 0;
 	$scope.unavailablePercent = 0;
 
+	$scope.$on("$destroy", function() {
+		killInterval();
+	});
+
 	var init = function() {
 		getCapacity();
+		if (autoRefresh) {
+			createInterval();
+		}
 	};
 	init();
 
 };
 
-WidgetCapacityController.$inject = ['$scope', 'cdnService'];
+WidgetCapacityController.$inject = ['$scope', '$interval', 'cdnService', 'propertiesModel'];
 module.exports = WidgetCapacityController;

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3a528d49/traffic_portal/app/src/common/modules/widget/cdnChart/WidgetCDNChartController.js
----------------------------------------------------------------------
diff --git a/traffic_portal/app/src/common/modules/widget/cdnChart/WidgetCDNChartController.js b/traffic_portal/app/src/common/modules/widget/cdnChart/WidgetCDNChartController.js
index 286ba4e..94d3f3d 100644
--- a/traffic_portal/app/src/common/modules/widget/cdnChart/WidgetCDNChartController.js
+++ b/traffic_portal/app/src/common/modules/widget/cdnChart/WidgetCDNChartController.js
@@ -17,11 +17,15 @@
  * under the License.
  */
 
-var WidgetCDNChartController = function(cdn, $scope, $timeout, $filter, $q, cdnService, cacheStatsService, dateUtils, locationUtils, numberUtils) {
+var WidgetCDNChartController = function(cdn, $scope, $timeout, $filter, $q, $interval, cdnService, cacheStatsService, dateUtils, locationUtils, numberUtils, propertiesModel) {
 
 	var chartSeries,
 		chartOptions;
 
+	var chartInterval,
+		autoRefresh = propertiesModel.properties.dashboard.autoRefresh;
+
+
 	var getCDN = function(id) {
 		cdnService.getCDN(id)
 			.then(function(result) {
@@ -151,6 +155,18 @@ var WidgetCDNChartController = function(cdn, $scope, $timeout, $filter, $q, cdnS
 
 	};
 
+	var createIntervals = function(cdnId) {
+		killIntervals();
+		chartInterval = $interval(function() { getCDN(cdnId) }, propertiesModel.properties.dashboard.cdnChart.refreshRateInMS );
+	};
+
+	var killIntervals = function() {
+		if (angular.isDefined(chartInterval)) {
+			$interval.cancel(chartInterval);
+			chartInterval = undefined;
+		}
+	};
+
 	var registerResizeListener = function() {
 		$(window).resize(plotChart);
 	};
@@ -169,6 +185,10 @@ var WidgetCDNChartController = function(cdn, $scope, $timeout, $filter, $q, cdnS
 
 	$scope.navigateToPath = locationUtils.navigateToPath;
 
+	$scope.$on("$destroy", function() {
+		killIntervals();
+	});
+
 	angular.element(document).ready(function () {
 		var cdnId;
 		if (cdn) {
@@ -178,9 +198,12 @@ var WidgetCDNChartController = function(cdn, $scope, $timeout, $filter, $q, cdnS
 			cdnId = $('#' + $scope.randomId).closest('.chartContainer').data('cdnid');
 		}
 		getCDN(cdnId);
+		if (autoRefresh) {
+			createIntervals(cdnId);
+		}
 	});
 
 };
 
-WidgetCDNChartController.$inject = ['cdn', '$scope', '$timeout', '$filter', '$q', 'cdnService', 'cacheStatsService', 'dateUtils', 'locationUtils', 'numberUtils'];
+WidgetCDNChartController.$inject = ['cdn', '$scope', '$timeout', '$filter', '$q', '$interval', 'cdnService', 'cacheStatsService', 'dateUtils', 'locationUtils', 'numberUtils', 'propertiesModel'];
 module.exports = WidgetCDNChartController;

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3a528d49/traffic_portal/app/src/common/modules/widget/routing/WidgetRoutingController.js
----------------------------------------------------------------------
diff --git a/traffic_portal/app/src/common/modules/widget/routing/WidgetRoutingController.js b/traffic_portal/app/src/common/modules/widget/routing/WidgetRoutingController.js
index da97948..da339f6 100644
--- a/traffic_portal/app/src/common/modules/widget/routing/WidgetRoutingController.js
+++ b/traffic_portal/app/src/common/modules/widget/routing/WidgetRoutingController.js
@@ -17,7 +17,10 @@
  * under the License.
  */
 
-var WidgetRoutingController = function($scope, cdnService) {
+var WidgetRoutingController = function($scope, $interval, cdnService, propertiesModel) {
+
+	var interval,
+		autoRefresh = propertiesModel.properties.dashboard.autoRefresh;
 
 	var getRoutingMethods = function() {
 		cdnService.getRoutingMethods()
@@ -34,12 +37,31 @@ var WidgetRoutingController = function($scope, cdnService) {
 			});
 	};
 
+	var createInterval = function() {
+		killInterval();
+		interval = $interval(function() { getRoutingMethods() }, propertiesModel.properties.dashboard.routing.refreshRateInMS );
+	};
+
+	var killInterval = function() {
+		if (angular.isDefined(interval)) {
+			$interval.cancel(interval);
+			interval = undefined;
+		}
+	};
+
+	$scope.$on("$destroy", function() {
+		killInterval();
+	});
+
 	var init = function() {
 		getRoutingMethods();
+		if (autoRefresh) {
+			createInterval();
+		}
 	};
 	init();
 
 };
 
-WidgetRoutingController.$inject = ['$scope', 'cdnService'];
+WidgetRoutingController.$inject = ['$scope', '$interval', 'cdnService', 'propertiesModel'];
 module.exports = WidgetRoutingController;

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3a528d49/traffic_portal/app/src/modules/private/monitor/dashboard/DashboardController.js
----------------------------------------------------------------------
diff --git a/traffic_portal/app/src/modules/private/monitor/dashboard/DashboardController.js b/traffic_portal/app/src/modules/private/monitor/dashboard/DashboardController.js
index c08a4e6..b6f8446 100644
--- a/traffic_portal/app/src/modules/private/monitor/dashboard/DashboardController.js
+++ b/traffic_portal/app/src/modules/private/monitor/dashboard/DashboardController.js
@@ -17,7 +17,58 @@
  * under the License.
  */
 
-var DashboardController = function(cacheGroupHealth, cdns, currentStats, serverCount, $scope) {
+var DashboardController = function(cacheGroupHealth, cdns, currentStats, serverCount, $scope, $interval, cacheGroupService, cdnService, serverService, propertiesModel) {
+
+	var cacheGroupHealthInterval,
+		currentStatsInterval,
+		serverCountInterval,
+		autoRefresh = propertiesModel.properties.dashboard.autoRefresh;
+
+	var getCacheGroupHealth = function() {
+		cacheGroupService.getCacheGroupHealth()
+			.then(function(result) {
+				$scope.cacheGroupHealth = result;
+			});
+	};
+
+	var getCurrentStats = function() {
+		cdnService.getCurrentStats()
+			.then(function(result) {
+				$scope.totalStats = _.find(result.currentStats, function(item) {
+					// total stats are buried in a hash where cdn = total
+					return item.cdn == 'total';
+				});
+			});
+	};
+
+	var getServerCount = function() {
+		serverService.getStatusCount()
+			.then(function(result) {
+				$scope.serverCount = result;
+			});
+	};
+
+	var createIntervals = function() {
+		killIntervals();
+		cacheGroupHealthInterval = $interval(function() { getCacheGroupHealth() }, propertiesModel.properties.dashboard.healthyCacheCount.refreshRateInMS );
+		currentStatsInterval = $interval(function() { getCurrentStats() }, propertiesModel.properties.dashboard.currentStats.refreshRateInMS );
+		serverCountInterval = $interval(function() { getServerCount() }, propertiesModel.properties.dashboard.cacheStatusCount.refreshRateInMS );
+	};
+
+	var killIntervals = function() {
+		if (angular.isDefined(cacheGroupHealthInterval)) {
+			$interval.cancel(cacheGroupHealthInterval);
+			cacheGroupHealthInterval = undefined;
+		}
+		if (angular.isDefined(currentStatsInterval)) {
+			$interval.cancel(currentStatsInterval);
+			currentStatsInterval = undefined;
+		}
+		if (angular.isDefined(serverCountInterval)) {
+			$interval.cancel(serverCountInterval);
+			serverCountInterval = undefined;
+		}
+	};
 
 	$scope.cacheGroupHealth = cacheGroupHealth;
 
@@ -30,7 +81,18 @@ var DashboardController = function(cacheGroupHealth, cdns, currentStats, serverC
 
 	$scope.serverCount = serverCount;
 
+	$scope.$on("$destroy", function() {
+		killIntervals();
+	});
+
+	var init = function () {
+		if (autoRefresh) {
+			createIntervals();
+		}
+	};
+	init();
+
 };
 
-DashboardController.$inject = ['cacheGroupHealth', 'cdns', 'currentStats', 'serverCount', '$scope'];
+DashboardController.$inject = ['cacheGroupHealth', 'cdns', 'currentStats', 'serverCount', '$scope', '$interval', 'cacheGroupService', 'cdnService', 'serverService', 'propertiesModel'];
 module.exports = DashboardController;

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3a528d49/traffic_portal/app/src/traffic_portal_properties.json
----------------------------------------------------------------------
diff --git a/traffic_portal/app/src/traffic_portal_properties.json b/traffic_portal/app/src/traffic_portal_properties.json
index d7c7a4e..85b7c5e 100644
--- a/traffic_portal/app/src/traffic_portal_properties.json
+++ b/traffic_portal/app/src/traffic_portal_properties.json
@@ -2,6 +2,31 @@
   "_comment": "These are the default properties for Traffic Portal. To customize these values, create your own traffic_portal_properties.json and copy to your web root replacing the existing one.",
   "properties": {
     "name": "Traffic Portal",
+    "dashboard": {
+      "_comments": "These are configurable properties for the dashboard",
+      "autoRefresh": true,
+      "currentStats": {
+        "refreshRateInMS": 30000
+      },
+      "healthyCacheCount": {
+        "refreshRateInMS": 60000
+      },
+      "cacheStatusCount": {
+        "refreshRateInMS": 60000
+      },
+      "cdnChart": {
+        "refreshRateInMS": 60000
+      },
+      "capacity": {
+        "refreshRateInMS": 60000
+      },
+      "routing": {
+        "refreshRateInMS": 60000
+      },
+      "cacheGroupHealth": {
+        "refreshRateInMS": 60000
+      }
+    },
     "customMenu": {
       "_comments": "These are custom items you want to add to the menu. 'items' is an array of hashes where each hash has 'name' (the menu item name), 'embed' (true|false to determine if content is embedded in TP or not), and 'url' (the url of the content)",
       "name": "Other",