Fix bug in the logs view UI

This commit is contained in:
Joseph Schorr 2015-06-15 17:26:58 -04:00
parent ae779cade2
commit b2d2fbe18f
2 changed files with 16 additions and 12 deletions

View file

@ -3,12 +3,12 @@
<span id="logs-range" class="mini"> <span id="logs-range" class="mini">
<span class="date-line"> <span class="date-line">
<span class="date-line-caption">From</span> <span class="date-line-caption">From</span>
<input type="text" class="logs-date-picker input-sm" name="start" ng-model="logStartDate" data-max-date="{{ logEndDate }}" data-container="body" bs-datepicker/> <input type="text" class="logs-date-picker input-sm" name="start" ng-model="options.logStartDate" data-max-date="{{ options.logEndDate }}" data-container="body" bs-datepicker/>
</span> </span>
<span class="date-line"> <span class="date-line">
<span class="date-line-caption add-on">to</span> <span class="date-line-caption add-on">to</span>
<input type="text" class="logs-date-picker input-sm" name="end" ng-model="logEndDate" data-min-date="{{ logStartDate }}" bs-datepicker/> <input type="text" class="logs-date-picker input-sm" name="end" ng-model="options.logEndDate" data-min-date="{{ options.logStartDate }}" bs-datepicker/>
</span> </span>
</span> </span>
<span class="hidden-xs right"> <span class="hidden-xs right">

View file

@ -24,9 +24,11 @@ angular.module('quay').directive('logsView', function () {
$scope.chartVisible = true; $scope.chartVisible = true;
$scope.logsPath = ''; $scope.logsPath = '';
$scope.options = {};
var datetime = new Date(); var datetime = new Date();
$scope.logStartDate = new Date(datetime.getUTCFullYear(), datetime.getUTCMonth(), datetime.getUTCDate() - 7); $scope.options.logStartDate = new Date(datetime.getUTCFullYear(), datetime.getUTCMonth(), datetime.getUTCDate() - 7);
$scope.logEndDate = new Date(datetime.getUTCFullYear(), datetime.getUTCMonth(), datetime.getUTCDate()); $scope.options.logEndDate = new Date(datetime.getUTCFullYear(), datetime.getUTCMonth(), datetime.getUTCDate());
var defaultPermSuffix = function(metadata) { var defaultPermSuffix = function(metadata) {
if (metadata.activating_username) { if (metadata.activating_username) {
@ -261,9 +263,10 @@ angular.module('quay').directive('logsView', function () {
return; return;
} }
var twoWeeksAgo = getOffsetDate($scope.logEndDate, -14); var twoWeeksAgo = getOffsetDate($scope.options.logEndDate, -14);
if ($scope.logStartDate > $scope.logEndDate || $scope.logStartDate < twoWeeksAgo) { if ($scope.options.logStartDate > $scope.options.logEndDate ||
$scope.logStartDate = twoWeeksAgo; $scope.options.logStartDate < twoWeeksAgo) {
$scope.options.logStartDate = twoWeeksAgo;
} }
$scope.loading = true; $scope.loading = true;
@ -282,8 +285,8 @@ angular.module('quay').directive('logsView', function () {
url = UtilService.getRestUrl('superuser', 'logs') url = UtilService.getRestUrl('superuser', 'logs')
} }
url += '?starttime=' + encodeURIComponent(getDateString($scope.logStartDate)); url += '?starttime=' + encodeURIComponent(getDateString($scope.options.logStartDate));
url += '&endtime=' + encodeURIComponent(getDateString($scope.logEndDate)); url += '&endtime=' + encodeURIComponent(getDateString($scope.options.logEndDate));
if ($scope.performer) { if ($scope.performer) {
url += '&performer=' + encodeURIComponent($scope.performer.name); url += '&performer=' + encodeURIComponent($scope.performer.name);
@ -300,7 +303,7 @@ angular.module('quay').directive('logsView', function () {
}); });
} }
$scope.chart.draw('bar-chart', resp.logs, $scope.logStartDate, $scope.logEndDate); $scope.chart.draw('bar-chart', resp.logs, $scope.options.logStartDate, $scope.options.logEndDate);
$scope.kindsAllowed = null; $scope.kindsAllowed = null;
$scope.logs = resp.logs; $scope.logs = resp.logs;
$scope.loading = false; $scope.loading = false;
@ -329,8 +332,9 @@ angular.module('quay').directive('logsView', function () {
$scope.$watch('repository', update); $scope.$watch('repository', update);
$scope.$watch('makevisible', update); $scope.$watch('makevisible', update);
$scope.$watch('performer', update); $scope.$watch('performer', update);
$scope.$watch('logStartDate', update);
$scope.$watch('logEndDate', update); $scope.$watch('options.logStartDate', update);
$scope.$watch('options.logEndDate', update);
} }
}; };