* Fixed a case where when setting up initial rates for scrobbling, Kavita would log a user without a token set had no rate. * Migrated the whole app to use just the directive instead of whole transloco module. * Migrated the whole app to use just the directive instead of whole transloco module. Fixed prod mode breaking localization & fixed broken minification for language files. * Time Ago pipe will now show Never if there is a null date. Changed the wording of Last Added To -> Last Item Added for volume/series info screen. * Fixed Tachiyomi DTOs and bumped sonar to use Java 17 * One more GA thing * GA junk * Bump versions by dotnet-bump-version. * Weblate Changes (#2189) * Added translation using Weblate (Turkish) * Translated using Weblate (Thai) Currently translated at 100.0% (158 of 158 strings) Translation: Kavita/backend Translate-URL: https://hosted.weblate.org/projects/kavita/backend/th/ * Translated using Weblate (Thai) Currently translated at 15.2% (218 of 1426 strings) Translation: Kavita/ui Translate-URL: https://hosted.weblate.org/projects/kavita/ui/th/ * Translated using Weblate (Turkish) Currently translated at 7.7% (110 of 1426 strings) Translation: Kavita/ui Translate-URL: https://hosted.weblate.org/projects/kavita/ui/tr/ * Translated using Weblate (Portuguese) Currently translated at 17.5% (250 of 1426 strings) Translation: Kavita/ui Translate-URL: https://hosted.weblate.org/projects/kavita/ui/pt/ * Translated using Weblate (Russian) Currently translated at 1.2% (2 of 158 strings) Translation: Kavita/backend Translate-URL: https://hosted.weblate.org/projects/kavita/backend/ru/ * Translated using Weblate (Russian) Currently translated at 4.9% (71 of 1426 strings) Translation: Kavita/ui Translate-URL: https://hosted.weblate.org/projects/kavita/ui/ru/ * Translated using Weblate (Italian) Currently translated at 6.7% (96 of 1426 strings) Translation: Kavita/ui Translate-URL: https://hosted.weblate.org/projects/kavita/ui/it/ * Translated using Weblate (Turkish) Currently translated at 8.8% (14 of 158 strings) Translation: Kavita/backend Translate-URL: https://hosted.weblate.org/projects/kavita/backend/tr/ --------- Co-authored-by: akoray420 <akoray420@gmail.com> Co-authored-by: AlienHack <the4got10@windowslive.com> Co-authored-by: Duarte Silva <smallflake@protonmail.com> Co-authored-by: Blezz Rot <markus.jenya04@yandex.ru> Co-authored-by: Tomas Battistini <tomas.battistini@gmail.com> --------- Co-authored-by: Weblate (bot) <hosted@weblate.org> Co-authored-by: akoray420 <akoray420@gmail.com> Co-authored-by: AlienHack <the4got10@windowslive.com> Co-authored-by: Duarte Silva <smallflake@protonmail.com> Co-authored-by: Blezz Rot <markus.jenya04@yandex.ru> Co-authored-by: Tomas Battistini <tomas.battistini@gmail.com>
81 lines
3.3 KiB
TypeScript
81 lines
3.3 KiB
TypeScript
import {
|
|
ChangeDetectionStrategy,
|
|
ChangeDetectorRef,
|
|
Component,
|
|
DestroyRef,
|
|
inject,
|
|
OnInit
|
|
} from '@angular/core';
|
|
import { map, Observable, shareReplay } from 'rxjs';
|
|
import { FilterUtilitiesService } from 'src/app/shared/_services/filter-utilities.service';
|
|
import { UserReadStatistics } from 'src/app/statistics/_models/user-read-statistics';
|
|
import { StatisticsService } from 'src/app/_services/statistics.service';
|
|
import { ReadHistoryEvent } from '../../_models/read-history-event';
|
|
import { MemberService } from 'src/app/_services/member.service';
|
|
import { AccountService } from 'src/app/_services/account.service';
|
|
import { PieDataItem } from '../../_models/pie-data-item';
|
|
import { LibraryService } from 'src/app/_services/library.service';
|
|
import { PercentPipe, NgIf, AsyncPipe } from '@angular/common';
|
|
import {takeUntilDestroyed} from "@angular/core/rxjs-interop";
|
|
import { StatListComponent } from '../stat-list/stat-list.component';
|
|
import { ReadingActivityComponent } from '../reading-activity/reading-activity.component';
|
|
import { UserStatsInfoCardsComponent } from '../user-stats-info-cards/user-stats-info-cards.component';
|
|
import {TranslocoModule} from "@ngneat/transloco";
|
|
|
|
@Component({
|
|
selector: 'app-user-stats',
|
|
templateUrl: './user-stats.component.html',
|
|
styleUrls: ['./user-stats.component.scss'],
|
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
standalone: true,
|
|
imports: [
|
|
NgIf,
|
|
UserStatsInfoCardsComponent,
|
|
ReadingActivityComponent,
|
|
StatListComponent,
|
|
AsyncPipe,
|
|
TranslocoModule,
|
|
],
|
|
})
|
|
export class UserStatsComponent implements OnInit {
|
|
|
|
userId: number | undefined = undefined;
|
|
userStats$!: Observable<UserReadStatistics>;
|
|
readSeries$!: Observable<ReadHistoryEvent[]>;
|
|
isAdmin$: Observable<boolean>;
|
|
percentageRead$!: Observable<PieDataItem[]>;
|
|
private readonly destroyRef = inject(DestroyRef);
|
|
|
|
constructor(private readonly cdRef: ChangeDetectorRef, private statService: StatisticsService,
|
|
private filterService: FilterUtilitiesService, private accountService: AccountService, private memberService: MemberService,
|
|
private libraryService: LibraryService) {
|
|
this.isAdmin$ = this.accountService.currentUser$.pipe(takeUntilDestroyed(this.destroyRef), map(u => {
|
|
if (!u) return false;
|
|
return this.accountService.hasAdminRole(u);
|
|
}));
|
|
|
|
}
|
|
|
|
ngOnInit(): void {
|
|
const filter = this.filterService.createSeriesFilter();
|
|
filter.readStatus = {read: true, notRead: false, inProgress: true};
|
|
this.memberService.getMember().subscribe(me => {
|
|
this.userId = me.id;
|
|
this.cdRef.markForCheck();
|
|
|
|
this.userStats$ = this.statService.getUserStatistics(this.userId).pipe(takeUntilDestroyed(this.destroyRef), shareReplay());
|
|
this.readSeries$ = this.statService.getReadingHistory(this.userId).pipe(
|
|
takeUntilDestroyed(this.destroyRef),
|
|
);
|
|
|
|
const pipe = new PercentPipe('en-US');
|
|
this.libraryService.getLibraryNames().subscribe(names => {
|
|
this.percentageRead$ = this.userStats$.pipe(takeUntilDestroyed(this.destroyRef), map(d => d.percentReadPerLibrary.map(l => {
|
|
return {name: names[l.count], value: parseFloat((pipe.transform(l.value, '1.1-1') || '0').replace('%', ''))};
|
|
}).sort((a: PieDataItem, b: PieDataItem) => b.value - a.value)));
|
|
})
|
|
|
|
});
|
|
}
|
|
|
|
}
|