Skip to content

Kavita is a fast, feature rich, cross platform reading server. Built with the goal of being a full solution for all your reading needs. Setup your own server and share your reading collection with your friends and family.

UI Stat issue (#410)

Joseph Milazzoc2d84ed0eb08
diff --git a/UI/Web/src/app/_services/stats.service.ts b/UI/Web/src/app/_services/stats.service.ts
index 1c9d19133..37afc1d15 100644
--- a/UI/Web/src/app/_services/stats.service.ts
+++ b/UI/Web/src/app/_services/stats.service.ts
@@ -18,12 +18,11 @@ export class StatsService {
constructor(private httpClient: HttpClient, private navService: NavService) { }
- public async sendClientInfo() {
- const data = await this.getInfo();
- this.httpClient.post(this.baseUrl + 'stats/client-info', data);
+ public sendClientInfo(data: ClientInfo) {
+ return this.httpClient.post(this.baseUrl + 'stats/client-info', data);
}
- private async getInfo(): Promise<ClientInfo> {
+ public async getInfo(): Promise<ClientInfo> {
const screenResolution = `${window.screen.width} x ${window.screen.height}`;
const browser = Bowser.getParser(window.navigator.userAgent);
diff --git a/UI/Web/src/app/app.component.ts b/UI/Web/src/app/app.component.ts
index 3e9952e6e..bdec0812f 100644
--- a/UI/Web/src/app/app.component.ts
+++ b/UI/Web/src/app/app.component.ts
@@ -1,6 +1,7 @@
import { Component, OnInit } from '@angular/core';
import { AccountService } from './_services/account.service';
import { NavService } from './_services/nav.service';
+import { StatsService } from './_services/stats.service';
@Component({
selector: 'app-root',
@@ -9,10 +10,14 @@ import { NavService } from './_services/nav.service';
})
export class AppComponent implements OnInit {
- constructor(private accountService: AccountService, public navService: NavService) { }
+ constructor(private accountService: AccountService, public navService: NavService, private statsService: StatsService) { }
ngOnInit(): void {
this.setCurrentUser();
+
+ this.statsService.getInfo().then(data => {
+ this.statsService.sendClientInfo(data).subscribe(() => {/* No Operation */});
+ });
}
diff --git a/UI/Web/src/app/home/home.component.ts b/UI/Web/src/app/home/home.component.ts
index a33a7358e..ff9c4f354 100644
--- a/UI/Web/src/app/home/home.component.ts
+++ b/UI/Web/src/app/home/home.component.ts
@@ -4,7 +4,6 @@ import { Router } from '@angular/router';
import { take } from 'rxjs/operators';
import { MemberService } from '../_services/member.service';
import { AccountService } from '../_services/account.service';
-import { StatsService } from '../_services/stats.service';
@Component({
selector: 'app-home',
@@ -20,7 +19,7 @@ export class HomeComponent implements OnInit {
password: new FormControl('', [Validators.required])
});
- constructor(public accountService: AccountService, private memberService: MemberService, private router: Router, private statsService: StatsService) {
+ constructor(public accountService: AccountService, private memberService: MemberService, private router: Router) {
}
ngOnInit(): void {
@@ -33,9 +32,6 @@ export class HomeComponent implements OnInit {
}
this.accountService.currentUser$.pipe(take(1)).subscribe(user => {
-
- this.statsService.sendClientInfo();
-
if (user) {
this.router.navigateByUrl('/library');
} else {