Newer
Older
import { Component, OnInit } from '@angular/core';
import { Injectable } from '@angular/core';
import { SearchService } from 'app/search/service/search-service';
import { HttpClient } from '@angular/common/http';
import { AccountService } from 'app/core/auth/account.service';
import { Account } from 'app/core/user/account.model';
import { Statistics } from 'app/shared/model/statistics.model';
@Component({
selector: 'jhi-achievements',
templateUrl: './achievements.component.html',
styleUrls: ['./achievements.component.scss'],
})
@Injectable({ providedIn: 'root' })
export class AchievementsComponent implements OnInit {
account!: Account;
statistics!: Statistics;
config = require('./achievements_config.json');
constructor(private accountService: AccountService, protected searchService: SearchService, private httpClient: HttpClient) {}
public getTotalNumberOfViews(): void {
// eslint-disable-next-line no-console
console.log('Searching statistics for the email: ' + this.account.email);
this.searchService.getStatisticsForUser().subscribe(
(data: Statistics) => {
if (data) {
this.statistics = data;
// eslint-disable-next-line no-console
console.log(

Eduard Frankford
committed
'Data: Number of Downloads: ' + data.downloads + ' Number of views: ' + data.views + ' for account ' + this.account.email
},
() => alert('Could not load statistics for User')
);
}
ngOnInit(): void {
this.accountService.identity().subscribe(account => {
if (account) {
this.account = account;
}
});
this.getTotalNumberOfViews();