Various bug fixes (#3667)
This commit is contained in:
parent
a1d3aef39b
commit
1ad8a360cb
17 changed files with 73 additions and 32 deletions
|
@ -39,9 +39,8 @@ export class TimeAgoPipe implements PipeTransform, OnDestroy {
|
|||
constructor(private readonly changeDetectorRef: ChangeDetectorRef, private ngZone: NgZone,
|
||||
private translocoService: TranslocoService) {}
|
||||
|
||||
transform(value: string) {
|
||||
|
||||
if (value === '' || value === null || value === undefined || value.split('T')[0] === '0001-01-01') {
|
||||
transform(value: string | Date | null) {
|
||||
if (value === '' || value === null || value === undefined || (value instanceof String && value.split('T')[0] === '0001-01-01')) {
|
||||
return this.translocoService.translate('time-ago-pipe.never');
|
||||
}
|
||||
|
||||
|
|
24
UI/Web/src/app/_pipes/utc-to-locale-date.pipe.ts
Normal file
24
UI/Web/src/app/_pipes/utc-to-locale-date.pipe.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
import {DateTime} from "luxon";
|
||||
|
||||
@Pipe({
|
||||
name: 'utcToLocaleDate',
|
||||
standalone: true
|
||||
})
|
||||
/**
|
||||
* This is the same as the UtcToLocalTimePipe but returning a timezone aware DateTime object rather than a string.
|
||||
* Use this when the next operation needs a Date object (like the TimeAgoPipe)
|
||||
*/
|
||||
export class UtcToLocaleDatePipe implements PipeTransform {
|
||||
|
||||
transform(utcDate: string | undefined | null): Date | null {
|
||||
if (utcDate === '' || utcDate === null || utcDate === undefined || utcDate.split('T')[0] === '0001-01-01') {
|
||||
return null;
|
||||
}
|
||||
|
||||
const browserLanguage = navigator.language;
|
||||
const dateTime = DateTime.fromISO(utcDate, { zone: 'utc' }).toLocal().setLocale(browserLanguage);
|
||||
return dateTime.toJSDate()
|
||||
}
|
||||
|
||||
}
|
|
@ -535,7 +535,7 @@
|
|||
<div class="mb-3">
|
||||
<app-setting-item [title]="t('date-added-label')" [toggleOnViewClick]="false" [showEdit]="false">
|
||||
<ng-template #view>
|
||||
{{chapter.createdUtc | utcToLocalTime | translocoDate: {dateStyle: 'short', timeStyle: 'short' } | defaultDate}}
|
||||
{{chapter.createdUtc | utcToLocalTime:'short' | defaultDate}}
|
||||
</ng-template>
|
||||
</app-setting-item>
|
||||
</div>
|
||||
|
|
|
@ -197,7 +197,12 @@ export class EditChapterModalComponent implements OnInit {
|
|||
this.editForm.addControl('language', new FormControl(this.chapter.language, []));
|
||||
this.editForm.addControl('isbn', new FormControl(this.chapter.isbn, []));
|
||||
this.editForm.addControl('ageRating', new FormControl(this.chapter.ageRating, []));
|
||||
this.editForm.addControl('releaseDate', new FormControl(this.chapter.releaseDate, []));
|
||||
|
||||
if (this.chapter.releaseDate !== '0001-01-01T00:00:00') {
|
||||
this.editForm.addControl('releaseDate', new FormControl(this.chapter.releaseDate.substring(0, 10), []));
|
||||
} else {
|
||||
this.editForm.addControl('releaseDate', new FormControl('', []));
|
||||
}
|
||||
|
||||
|
||||
this.editForm.addControl('genres', new FormControl(this.chapter.genres, []));
|
||||
|
@ -261,7 +266,11 @@ export class EditChapterModalComponent implements OnInit {
|
|||
const model = this.editForm.value;
|
||||
const selectedIndex = this.editForm.get('coverImageIndex')?.value || 0;
|
||||
|
||||
this.chapter.releaseDate = model.releaseDate;
|
||||
if (model.releaseDate === '') {
|
||||
this.chapter.releaseDate = '0001-01-01T00:00:00';
|
||||
} else {
|
||||
this.chapter.releaseDate = model.releaseDate + 'T00:00:00';
|
||||
}
|
||||
this.chapter.ageRating = parseInt(model.ageRating + '', 10) as AgeRating;
|
||||
this.chapter.genres = model.genres;
|
||||
this.chapter.tags = model.tags;
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
<div class="mb-3">
|
||||
<app-setting-item [title]="t('date-added-label')" [toggleOnViewClick]="false" [showEdit]="false">
|
||||
<ng-template #view>
|
||||
{{volume.createdUtc | utcToLocalTime | translocoDate: {dateStyle: 'short', timeStyle: 'short' } | defaultDate}}
|
||||
{{volume.createdUtc | utcToLocalTime:'short' | defaultDate}}
|
||||
</ng-template>
|
||||
</app-setting-item>
|
||||
</div>
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<app-setting-item [title]="t('edit-collection-tags.last-sync-title')" [showEdit]="false" [canEdit]="false"
|
||||
[subtitle]="t('edit-collection-tags.last-sync-tooltip')">
|
||||
<ng-template #view>
|
||||
{{collection.lastSyncUtc | utcToLocalTime | date:'shortDate' | defaultDate}}
|
||||
{{collection.lastSyncUtc | utcToLocalTime:'shortDate' | defaultDate}}
|
||||
</ng-template>
|
||||
</app-setting-item>
|
||||
</div>
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
@if ((messageHub.onlineUsers$ | async)?.includes(member.username)) {
|
||||
{{t('online-now-tooltip')}}
|
||||
} @else {
|
||||
{{member.lastActiveUtc | utcToLocalTime | timeAgo | sentenceCase | defaultDate}}
|
||||
{{member.lastActiveUtc | utcToLocaleDate | timeAgo | sentenceCase | defaultDate}}
|
||||
}
|
||||
</span>
|
||||
</td>
|
||||
|
|
|
@ -23,6 +23,7 @@ import {LoadingComponent} from "../../shared/loading/loading.component";
|
|||
import {TimeAgoPipe} from "../../_pipes/time-ago.pipe";
|
||||
import {SentenceCasePipe} from "../../_pipes/sentence-case.pipe";
|
||||
import {DefaultModalOptions} from "../../_models/default-modal-options";
|
||||
import {UtcToLocaleDatePipe} from "../../_pipes/utc-to-locale-date.pipe";
|
||||
|
||||
@Component({
|
||||
selector: 'app-manage-users',
|
||||
|
@ -30,7 +31,7 @@ import {DefaultModalOptions} from "../../_models/default-modal-options";
|
|||
styleUrls: ['./manage-users.component.scss'],
|
||||
standalone: true,
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
imports: [NgbTooltip, TagBadgeComponent, AsyncPipe, TitleCasePipe, DatePipe, TranslocoModule, DefaultDatePipe, NgClass, DefaultValuePipe, ReadMoreComponent, UtcToLocalTimePipe, LoadingComponent, NgIf, TimeAgoPipe, SentenceCasePipe]
|
||||
imports: [NgbTooltip, TagBadgeComponent, AsyncPipe, TitleCasePipe, DatePipe, TranslocoModule, DefaultDatePipe, NgClass, DefaultValuePipe, ReadMoreComponent, UtcToLocalTimePipe, LoadingComponent, NgIf, TimeAgoPipe, SentenceCasePipe, UtcToLocaleDatePipe]
|
||||
})
|
||||
export class ManageUsersComponent implements OnInit {
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@
|
|||
<div class="row g-0 mb-2">
|
||||
<div class="col-md-6">
|
||||
<div>{{t('last-sync-title')}}</div>
|
||||
<div>{{tag.lastSyncUtc | utcToLocalTime | date:'shortDate' | defaultDate}}</div>
|
||||
<div>{{tag.lastSyncUtc | utcToLocalTime:'shortDate' | defaultDate}}</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div>{{t('source-url-title')}}</div>
|
||||
|
|
|
@ -589,7 +589,7 @@
|
|||
<div class="mb-3">
|
||||
<app-setting-item [title]="t('created-title')" [toggleOnViewClick]="false" [showEdit]="false">
|
||||
<ng-template #view>
|
||||
{{series.created | date:'shortDate'}}
|
||||
{{series.created | utcToLocalTime:'shortDate'}}
|
||||
</ng-template>
|
||||
</app-setting-item>
|
||||
</div>
|
||||
|
@ -665,7 +665,7 @@
|
|||
{{t('added-title')}} {{volume.createdUtc | utcToLocalTime | defaultDate}}
|
||||
</div>
|
||||
<div class="col">
|
||||
{{t('last-modified-title')}} {{volume.lastModifiedUtc | utcToLocalTime | translocoDate: {dateStyle: 'short' } | defaultDate}}
|
||||
{{t('last-modified-title')}} {{volume.lastModifiedUtc | utcToLocalTime:'short' | defaultDate}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
|
|
@ -74,10 +74,10 @@
|
|||
}
|
||||
</td>
|
||||
<td>
|
||||
{{progressEvents[idx].createdUtc | utcToLocalTime | date:'shortDate' | defaultDate}}
|
||||
{{progressEvents[idx].createdUtc | utcToLocalTime:'shortDate' | defaultDate}}
|
||||
</td>
|
||||
<td>
|
||||
{{progressEvents[idx].lastModifiedUtc | utcToLocalTime | date:'shortDate' | defaultDate}}
|
||||
{{progressEvents[idx].lastModifiedUtc | utcToLocalTime:'shortDate' | defaultDate}}
|
||||
</td>
|
||||
<!-- <td>-->
|
||||
<!-- @if(editMode[idx]) {-->
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue