Merge pull request #1486 from coreos-inc/logsui
Fix logs UI around date time handling
This commit is contained in:
commit
f957fbe96d
3 changed files with 25 additions and 13 deletions
|
@ -48,12 +48,22 @@
|
|||
width: 122px;
|
||||
}
|
||||
|
||||
.logs-view-element .datepicker {
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.logs-view-element .datepicker button {
|
||||
border: 0px;
|
||||
}
|
||||
|
||||
.logs-view-element .manager-header input {
|
||||
font-size: 14px;
|
||||
text-align: center;
|
||||
border: 1px solid #eee;
|
||||
padding: 4px;
|
||||
border-radius: 4px;
|
||||
margin-left: 4px;
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
.logs-view-element .manager-header .right {
|
||||
|
|
|
@ -3,12 +3,19 @@
|
|||
<span id="logs-range" class="mini">
|
||||
<span class="date-line">
|
||||
<span class="date-line-caption">From</span>
|
||||
<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/>
|
||||
<input type="text" class="logs-date-picker input-sm" name="start"
|
||||
ng-model="options.logStartDate" data-min-date="{{ options.monthAgo }}"
|
||||
data-max-date="{{ options.logEndDate }}"
|
||||
bs-datepicker>
|
||||
</span>
|
||||
|
||||
<span class="date-line">
|
||||
<span class="date-line-caption add-on">to</span>
|
||||
<input type="text" class="logs-date-picker input-sm" name="end" ng-model="options.logEndDate" data-min-date="{{ options.logStartDate }}" bs-datepicker/>
|
||||
<input type="text" class="logs-date-picker input-sm" name="end"
|
||||
ng-model="options.logEndDate" data-min-date="{{ options.logStartDate }}"
|
||||
data-max-date="{{ options.now }}"
|
||||
data-placement="bottom-right"
|
||||
bs-datepicker>
|
||||
</span>
|
||||
</span>
|
||||
<span class="hidden-xs right">
|
||||
|
|
|
@ -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);
|
||||
|
|
Reference in a new issue