ActivityPub-federated video streaming platform using P2P directly in your web browser
More precise date for jobs
Chocobozzzf228e9f064f2
diff --git a/client/src/app/+admin/system/jobs/job.service.ts b/client/src/app/+admin/system/jobs/job.service.tsindex 6c4a07469f..ef8ddd3b49 100644--- a/client/src/app/+admin/system/jobs/job.service.ts+++ b/client/src/app/+admin/system/jobs/job.service.ts@@ -34,9 +34,7 @@ export class JobService {return this.authHttp.get<ResultList<Job>>(JobService.BASE_JOB_URL + `/${jobState || ''}`, { params }).pipe(- map(res => {- return this.restExtractor.convertResultListDateToHuman(res, [ 'createdAt', 'processedOn', 'finishedOn' ])- }),+ map(res => this.restExtractor.convertResultListDateToHuman(res, [ 'createdAt', 'processedOn', 'finishedOn' ], 'precise')),map(res => this.restExtractor.applyToResultListData(res, this.prettyPrintData)),map(res => this.restExtractor.applyToResultListData(res, this.buildUniqId)),catchError(err => this.restExtractor.handleError(err))diff --git a/client/src/app/+admin/system/jobs/jobs.component.html b/client/src/app/+admin/system/jobs/jobs.component.htmlindex b53fafeba1..a5266bde51 100644--- a/client/src/app/+admin/system/jobs/jobs.component.html+++ b/client/src/app/+admin/system/jobs/jobs.component.html@@ -69,7 +69,7 @@<ng-container *ngIf="hasProgress(job)">{{ getProgress(job) }}</ng-container></td>- <td class="job-date c-hand" [pRowToggler]="job">{{ job.createdAt | date: 'short' }}</td>+ <td class="job-date c-hand" [pRowToggler]="job">{{ job.createdAt }}</td></tr></ng-template>diff --git a/client/src/app/core/rest/rest-extractor.service.ts b/client/src/app/core/rest/rest-extractor.service.tsindex 8a29745633..7eec2eca62 100644--- a/client/src/app/core/rest/rest-extractor.service.ts+++ b/client/src/app/core/rest/rest-extractor.service.ts@@ -1,14 +1,17 @@import { throwError as observableThrowError } from 'rxjs'-import { Injectable } from '@angular/core'+import { Inject, Injectable, LOCALE_ID } from '@angular/core'import { Router } from '@angular/router'-import { dateToHuman } from '@app/helpers'-import { HttpStatusCode, ResultList } from '@shared/models'+import { DateFormat, dateToHuman } from '@app/helpers'import { logger } from '@root-helpers/logger'+import { HttpStatusCode, ResultList } from '@shared/models'@Injectable()export class RestExtractor {- constructor (private router: Router) { }+ constructor (+ @Inject(LOCALE_ID) private localeId: string,+ private router: Router+ ) { }applyToResultListData <T, A, U> (result: ResultList<T>,@@ -23,13 +26,17 @@ export class RestExtractor {}}- convertResultListDateToHuman <T> (result: ResultList<T>, fieldsToConvert: string[] = [ 'createdAt' ]): ResultList<T> {- return this.applyToResultListData(result, this.convertDateToHuman, [ fieldsToConvert ])+ convertResultListDateToHuman <T> (+ result: ResultList<T>,+ fieldsToConvert: string[] = [ 'createdAt' ],+ format?: DateFormat+ ): ResultList<T> {+ return this.applyToResultListData(result, this.convertDateToHuman, [ fieldsToConvert, format ])}- convertDateToHuman (target: any, fieldsToConvert: string[]) {+ convertDateToHuman (target: any, fieldsToConvert: string[], format?: DateFormat) {fieldsToConvert.forEach(field => {- target[field] = dateToHuman(target[field])+ target[field] = dateToHuman(this.localeId, new Date(target[field]), format)})return targetdiff --git a/client/src/app/helpers/utils/date.ts b/client/src/app/helpers/utils/date.tsindex 012b959ea2..75363cc819 100644--- a/client/src/app/helpers/utils/date.ts+++ b/client/src/app/helpers/utils/date.ts@@ -1,8 +1,29 @@import { DatePipe } from '@angular/common'-const datePipe = new DatePipe('en')-function dateToHuman (date: string) {- return datePipe.transform(date, 'medium')+let datePipe: DatePipe+let intl: Intl.DateTimeFormat++type DateFormat = 'medium' | 'precise'++function dateToHuman (localeId: string, date: Date, format: 'medium' | 'precise' = 'medium') {+ if (!datePipe) {+ datePipe = new DatePipe(localeId)+ }++ if (!intl) {+ intl = new Intl.DateTimeFormat(localeId, {+ hour: 'numeric',+ minute: 'numeric',+ second: 'numeric',+ year: '2-digit',+ month: 'numeric',+ day: 'numeric',+ fractionalSecondDigits: 3+ })+ }++ if (format === 'medium') return datePipe.transform(date, format)+ if (format === 'precise') return intl.format(date)}function durationToString (duration: number) {@@ -20,6 +41,8 @@ function durationToString (duration: number) {}export {+ DateFormat,+durationToString,dateToHuman}diff --git a/client/tsconfig.json b/client/tsconfig.jsonindex 7a0584d5c1..2345ca289b 100644--- a/client/tsconfig.json+++ b/client/tsconfig.json@@ -20,7 +20,7 @@"node_modules/@types"],"lib": [- "ES2020.Intl",+ "ES2021.Intl","es2018","es2017","es2016",