display logs in local time while retaining iso format

This commit is contained in:
Matt Hill
2022-07-27 22:56:29 -06:00
committed by Aiden McClelland
parent a5c97d4c24
commit c2f9c6a38d
6 changed files with 63 additions and 11 deletions

View File

@@ -1,6 +1,7 @@
import { formatDate } from '@angular/common'
import { Component, Input, ViewChild } from '@angular/core'
import { IonContent } from '@ionic/angular'
import { ErrorToastService } from '@start9labs/shared'
import { ErrorToastService, toLocalIsoString } from '@start9labs/shared'
import { RR } from 'src/app/services/api/api.types'
var Convert = require('ansi-to-html')
var convert = new Convert({
@@ -53,8 +54,14 @@ export class LogsPage {
if (!(newLogs instanceof HTMLElement)) return
newLogs.innerHTML =
logs.map(l => `${l.timestamp} ${convert.toHtml(l.message)}`).join('\n') +
(logs.length ? '\n' : '')
logs
.map(
l =>
`<b>${toLocalIsoString(new Date(l.timestamp))}</b> ${convert.toHtml(
l.message,
)}`,
)
.join('\n') + (logs.length ? '\n' : '')
container?.append(newLogs)
this.loadingNext = false
this.scrollEvent()
@@ -87,8 +94,14 @@ export class LogsPage {
if (!(newLogs instanceof HTMLElement)) return
newLogs.innerHTML =
logs.map(l => `${l.timestamp} ${convert.toHtml(l.message)}`).join('\n') +
(logs.length ? '\n' : '')
logs
.map(
l =>
`<b>${toLocalIsoString(new Date(l.timestamp))}</b> ${convert.toHtml(
l.message,
)}`,
)
.join('\n') + (logs.length ? '\n' : '')
container?.prepend(newLogs)
const afterContainerHeight = container?.scrollHeight || 0

View File

@@ -84,7 +84,8 @@
<h2>
<b>
<span *ngIf="not['package-id'] as pkgId">
{{ packageData[pkgId]?.manifest?.title || pkgId }} -
<!-- @TODO remove $any when Angular gets smart enough -->
{{ $any(packageData[pkgId])?.manifest?.title || pkgId }} -
</span>
<ion-text [color]="getColor(not)"> {{ not.title }} </ion-text>
</b>

View File

@@ -949,13 +949,13 @@ export module Mock {
export const ServerLogs: Log[] = [
{
timestamp: '2019-12-26T14:20:30.872Z',
timestamp: '2022-07-28T03:52:54.808769Z',
message: '****** START *****',
},
{
timestamp: '2019-12-26T14:21:30.872Z',
message:
'2021/11/09 22:55:04 \u001b[34mPOST \u001b[0;32;49m200\u001b[0m photoview.embassy/api/graphql \u001b[0;36;49m1.169406ms\u001b[0m unauthenticated<p>TEST PARAGRAPH</p>',
'\u001b[34mPOST \u001b[0;32;49m200\u001b[0m photoview.embassy/api/graphql \u001b[0;36;49m1.169406ms\u001b[0m unauthenticated<p>TEST PARAGRAPH</p>',
},
{
timestamp: '2019-12-26T14:22:30.872Z',
@@ -965,7 +965,7 @@ export module Mock {
export const PackageLogs: Log[] = [
{
timestamp: '2019-12-26T14:20:30.872Z',
timestamp: '2022-07-28T03:52:54.808769Z',
message: '****** START *****',
},
{