mgr/dashboard: Log's time from UTC to local (#27777)

mgr/dashboard: Log's time from UTC to local

Reviewed-by: Alfonso Martínez <almartin@redhat.com>
Reviewed-by: Stephan Müller <smueller@suse.com>
Reviewed-by: Tatjana Dehler <tdehler@suse.com>
This commit is contained in:
Lenz Grimmer 2019-06-18 12:14:09 +02:00 committed by GitHub
commit 363c81a858
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View File

@ -6,7 +6,7 @@
<div class="well">
<div *ngIf="clog">
<p *ngFor="let line of clog">
<span class="timestamp">{{ line.stamp }}</span>
<span class="timestamp">{{ line.stamp | cdDate }}</span>
<span class="priority {{ line.priority | logPriority }}">{{ line.priority }}</span>
<span class="message">{{ line.message }}</span>
</p>
@ -22,7 +22,7 @@
<div class="well">
<div *ngIf="audit_log">
<p *ngFor="let line of audit_log">
<span class="timestamp">{{ line.stamp }}</span>
<span class="timestamp">{{ line.stamp | cdDate }}</span>
<span class="priority {{ line.priority | logPriority }}">{{ line.priority }}</span>
<span class="message">{{ line.message }}</span>
</p>
@ -42,7 +42,7 @@
<select class="form-control"
[(ngModel)]="priority"
(ngModelChange)="filterLogs()">
<option class="form-control"
<option class="form-control"
*ngFor="let prio of prioritys"
[value]="prio.value">{{ prio.name }}</option>
</select>

View File

@ -1,3 +1,4 @@
import { DatePipe } from '@angular/common';
import { Component, OnDestroy, OnInit } from '@angular/core';
import { LogsService } from '../../../shared/api/logs.service';
@ -28,7 +29,7 @@ export class LogsComponent implements OnInit, OnDestroy {
selectedDate: Date;
startTime: Date = new Date();
endTime: Date = new Date();
constructor(private logsService: LogsService) {
constructor(private logsService: LogsService, private datePipe: DatePipe) {
this.startTime.setHours(0, 0);
this.endTime.setHours(23, 59);
}
@ -81,8 +82,9 @@ export class LogsComponent implements OnInit, OnDestroy {
filterExecutor(logs: Array<any>, filters: any): Array<any> {
return logs.filter((line) => {
const hour = parseInt(line.stamp.slice(11, 13), 10);
const minutes = parseInt(line.stamp.slice(14, 16), 10);
const localDate = this.datePipe.transform(line.stamp, 'mediumTime');
const hour = parseInt(localDate.split(':')[0], 10);
const minutes = parseInt(localDate.split(':')[1], 10);
let prio: string, y_m_d: string, timeSpan: number;
prio = filters.priority === 'All' ? line.priority : filters.priority;