Change from manual URL construction to using a lib

Makes the code cleaner to read and more resilient to changes

Fixes https://jira.coreos.com/browse/QUAY-940
This commit is contained in:
Joseph Schorr 2018-05-22 13:09:48 -04:00
parent e33760fcd2
commit 648590c356
13 changed files with 85 additions and 56 deletions

View file

@ -1,5 +1,5 @@
import { LogUsageChart } from '../../graphing';
import { parse } from 'path';
/**
* Element which displays usage logs for the given entity.
@ -383,8 +383,8 @@ angular.module('quay').directive('logsView', function () {
url = UtilService.getRestUrl('superuser', suffix)
}
url += '?starttime=' + encodeURIComponent(getDateString($scope.options.logStartDate));
url += '&endtime=' + encodeURIComponent(getDateString($scope.options.logEndDate));
url.setQueryParameter('starttime', getDateString($scope.options.logStartDate));
url.setQueryParameter('endtime', getDateString($scope.options.logEndDate));
return url;
};
@ -405,7 +405,7 @@ angular.module('quay').directive('logsView', function () {
$scope.chartLoading = true;
var aggregateUrl = getUrl('aggregatelogs')
var aggregateUrl = getUrl('aggregatelogs').toString();
var loadAggregate = Restangular.one(aggregateUrl);
loadAggregate.customGET().then(function(resp) {
$scope.chart = new LogUsageChart(logKinds);
@ -430,12 +430,10 @@ angular.module('quay').directive('logsView', function () {
$scope.loading = true;
var logsUrl = getUrl('logs');
if ($scope.nextPageToken) {
logsUrl = logsUrl + '&next_page=' + encodeURIComponent($scope.nextPageToken);
}
var url = getUrl('logs');
url.setQueryParameter('next_page', $scope.nextPageToken);
var loadLogs = Restangular.one(logsUrl);
var loadLogs = Restangular.one(url.toString());
loadLogs.customGET().then(function(resp) {
resp.logs.forEach(function(log) {
$scope.logs.push(log);