You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by mi...@apache.org on 2019/11/18 15:40:38 UTC

[trafficcontrol] branch master updated: Removed restangular from ./CacheStatsService.js (#3606)

This is an automated email from the ASF dual-hosted git repository.

mitchell852 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git


The following commit(s) were added to refs/heads/master by this push:
     new 34f7858  Removed restangular from ./CacheStatsService.js (#3606)
34f7858 is described below

commit 34f78587806a103720f0bc1d4a26ca0e2883a4f4
Author: ocket8888 <oc...@gmail.com>
AuthorDate: Mon Nov 18 08:40:30 2019 -0700

    Removed restangular from ./CacheStatsService.js (#3606)
---
 .../app/src/common/api/CacheStatsService.js        | 68 +++++++++++-----------
 1 file changed, 34 insertions(+), 34 deletions(-)

diff --git a/traffic_portal/app/src/common/api/CacheStatsService.js b/traffic_portal/app/src/common/api/CacheStatsService.js
index 4392806..1e5da46 100644
--- a/traffic_portal/app/src/common/api/CacheStatsService.js
+++ b/traffic_portal/app/src/common/api/CacheStatsService.js
@@ -17,49 +17,49 @@
  * under the License.
  */
 
-var CacheStatsService = function($http, $q, httpService, ENV, messageModel) {
+var CacheStatsService = function($http, ENV, messageModel) {
 
 	this.getBandwidth = function(cdnName, start, end) {
-		var request = $q.defer();
+		const url = ENV.api['root'] + "cache_stats";
+		const params = {
+			cdnName: cdnName,
+			metricType: 'bandwidth',
+			startDate: start.seconds(0).format(),
+			endDate: end.seconds(0).format()
+		};
 
-		var url = ENV.api['root'] + "cache_stats",
-			params = { cdnName: cdnName, metricType: 'bandwidth', startDate: start.seconds(00).format(), endDate: end.seconds(00).format()};
-
-		$http.get(url, { params: params })
-			.then(
-				function(result) {
-					request.resolve(result.data.response);
-				},
-				function(fault) {
-					messageModel.setMessages(fault.data.alerts, false);
-					request.reject();
-				}
-			);
-
-		return request.promise;
+		return $http.get(url, { params: params }).then(
+			function(result) {
+				return result.data.response;
+			},
+			function(err) {
+				messageModel.setMessages(err.data.alerts, false);
+				throw err;
+			}
+		);
 	};
 
 	this.getConnections = function(cdnName, start, end) {
-		var request = $q.defer();
-
-		var url = ENV.api['root'] + "cache_stats",
-			params = { cdnName: cdnName, metricType: 'connections', startDate: start.seconds(00).format(), endDate: end.seconds(00).format()};
-
-		$http.get(url, { params: params })
-			.then(
-				function(result) {
-					request.resolve(result.data.response);
-				},
-				function(fault) {
-					messageModel.setMessages(fault.data.alerts, false);
-					request.reject();
-				}
-			);
+		const url = ENV.api['root'] + "cache_stats";
+		const params = {
+			cdnName: cdnName,
+			metricType: 'connections',
+			startDate: start.seconds(0).format(),
+			endDate: end.seconds(0).format()
+		};
 
-		return request.promise;
+		return $http.get(url, { params: params }).then(
+			function(result) {
+				return result.data.response;
+			},
+			function(err) {
+				messageModel.setMessages(err.data.alerts, false);
+				throw err;
+			}
+		);
 	};
 
 };
 
-CacheStatsService.$inject = ['$http', '$q', 'httpService', 'ENV', 'messageModel'];
+CacheStatsService.$inject = ['$http', 'ENV', 'messageModel'];
 module.exports = CacheStatsService;