This is the codeAbility Sharing Platform! Learn more about the codeAbility Sharing Platform.

Skip to content
Snippets Groups Projects
achievements.component.ts 1.19 KiB
Newer Older
import { Component, OnInit } from '@angular/core';
import { Injectable } from '@angular/core';
import { SearchService } from 'app/search/service/search-service';

import { AccountService } from 'app/core/auth/account.service';
import { Account } from 'app/core/user/account.model';

@Component({
  selector: 'jhi-achievements',
  templateUrl: './achievements.component.html',
  styleUrls: ['./achievements.component.scss'],
})
@Injectable({ providedIn: 'root' })
export class AchievementsComponent implements OnInit {
  account!: Account;

  constructor(private accountService: AccountService, protected searchService: SearchService) {}

  public getTotalNumberOfViews(): void {
    // eslint-disable-next-line no-console
    console.log('I have been called');
    this.searchService.getStatisticsForUser(this.account.login).subscribe(
      (data: number) => {
        // eslint-disable-next-line no-console
        console.log('Data: ' + data + ' for account ' + this.account.login);
      },
      () => alert('Could not load statistics for User')
    );
  }

  ngOnInit(): void {
    this.accountService.identity().subscribe(account => {
      if (account) {
        this.account = account;
      }
    });
  }
}