Fix logs UI around date time handling

Makes the UI nicer looking and removes the 2 week limit; instead we have a 1 month limit, which is the max days we keep the logs in the database before being rotated.

Fixes #1480
This commit is contained in:
Joseph Schorr 2016-05-23 15:51:34 -04:00
parent 20dcb2053e
commit ad12df0f93
3 changed files with 25 additions and 13 deletions

View file

@ -29,6 +29,12 @@ angular.module('quay').directive('logsView', function () {
var datetime = new Date();
$scope.options.logStartDate = new Date(datetime.getUTCFullYear(), datetime.getUTCMonth(), datetime.getUTCDate() - 7);
$scope.options.logEndDate = new Date(datetime.getUTCFullYear(), datetime.getUTCMonth(), datetime.getUTCDate());
$scope.options.monthAgo = moment().subtract(1, 'month').calendar();
$scope.options.now = new Date(datetime.getUTCFullYear(), datetime.getUTCMonth(), datetime.getUTCDate());
var getOffsetDate = function(date, days) {
return new Date(date.getFullYear(), date.getMonth(), date.getDate() + days);
};
var defaultPermSuffix = function(metadata) {
if (metadata.activating_username) {
@ -283,10 +289,6 @@ angular.module('quay').directive('logsView', function () {
return (date.getMonth() + 1) + '/' + date.getDate() + '/' + date.getFullYear();
};
var getOffsetDate = function(date, days) {
return new Date(date.getFullYear(), date.getMonth(), date.getDate() + days);
};
var getUrl = function(suffix) {
var url = UtilService.getRestUrl('user/' + suffix);
if ($scope.organization) {
@ -320,16 +322,9 @@ angular.module('quay').directive('logsView', function () {
return;
}
var twoWeeksAgo = getOffsetDate($scope.options.logEndDate, -14);
if ($scope.options.logStartDate > $scope.options.logEndDate ||
$scope.options.logStartDate < twoWeeksAgo) {
$scope.options.logStartDate = twoWeeksAgo;
}
$scope.chartLoading = true;
var aggregateUrl = getUrl('aggregatelogs')
var loadAggregate = Restangular.one(aggregateUrl);
loadAggregate.customGET().then(function(resp) {
$scope.chart = new LogUsageChart(logKinds);