Kavita/UI/Web/src/app/statistics/_components/user-stats-info-cards/user-stats-info-cards.component.ts
Joe Milazzo f64f232e51
Angular 15 (#1764)
* Updated ngx-virtual-scroller

* Removed the karma test config as it's breaking migration

* Reverted to pre angular 15

* Upgraded packages and reverted target to ES6 for older devices

* It's broken. Need to also find the safari version for old Ipads

* Fixes some code in default pipe and many updates to packages. Removed support for old iOS versions as it restricted Kavita from using newer features. Build still broken.

* More progress in getting build working on Angular 15. Removed polyfills.ts for new angular config

* Remove all.css for icons and use scss instead

* Removed stuff that isn't needed

* Migrated extended linting to eslint, ran on project and updated issues. Removed a duplicate component that did nothing. Fixed a few places where lifecycle hooks werent being called as interface wasn't implemented.

* App builds correctly. Source maps are still needed.

* Fixed source maps and removed more testing stuff. I will re-add later in another release when I figure out how to properly tackle dependencies on backend.

* Reverted back to old source map definition
2023-01-30 06:27:52 -08:00

42 lines
1.8 KiB
TypeScript

import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { CompactNumberPipe } from 'src/app/pipe/compact-number.pipe';
import { StatisticsService } from 'src/app/_services/statistics.service';
import { GenericListModalComponent } from '../_modals/generic-list-modal/generic-list-modal.component';
@Component({
selector: 'app-user-stats-info-cards',
templateUrl: './user-stats-info-cards.component.html',
styleUrls: ['./user-stats-info-cards.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class UserStatsInfoCardsComponent {
@Input() totalPagesRead: number = 0;
@Input() totalWordsRead: number = 0;
@Input() timeSpentReading: number = 0;
@Input() chaptersRead: number = 0;
@Input() lastActive: string = '';
@Input() avgHoursPerWeekSpentReading: number = 0;
constructor(private statsService: StatisticsService, private modalService: NgbModal) { }
openPageByYearList() {
const numberPipe = new CompactNumberPipe();
this.statsService.getPagesPerYear().subscribe(yearCounts => {
const ref = this.modalService.open(GenericListModalComponent, { scrollable: true });
ref.componentInstance.items = yearCounts.map(t => `${t.name}: ${numberPipe.transform(t.value)} pages`);
ref.componentInstance.title = 'Pages Read By Year';
});
}
openWordByYearList() {
const numberPipe = new CompactNumberPipe();
this.statsService.getWordsPerYear().subscribe(yearCounts => {
const ref = this.modalService.open(GenericListModalComponent, { scrollable: true });
ref.componentInstance.items = yearCounts.map(t => `${t.name}: ${numberPipe.transform(t.value)} pages`);
ref.componentInstance.title = 'Words Read By Year';
});
}
}