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

Skip to content
Snippets Groups Projects
peer-reviewing.component.ts 1.34 KiB
Newer Older
import { Component, OnInit } from '@angular/core';
import { UserManagementService } from 'app/admin/user-management/service/user-management.service';
import { User } from 'app/admin/user-management/user-management.model';
import { Account } from 'app/core/auth/account.model';
import { AccountService } from 'app/core/auth/account.service';

@Component({
  selector: 'jhi-peer-reviewing',
  templateUrl: './peer-reviewing.component.html',
  styleUrls: ['./peer-reviewing.component.scss'],
})
export class PeerReviewingComponent implements OnInit {
  isChecked = false;
  currentAccount: Account | null = null;
  user: User | null = null;
  constructor(private userService: UserManagementService, private accountService: AccountService) {}

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

  getUserFromLogin(): void {
    if (this.currentAccount != null && this.currentAccount.login != null) {
      this.userService.find(this.currentAccount?.login).subscribe(val => (this.user = val));
    }
  }

  setReviewerStatusForLogin(): void {
    if (this.user != null && this.currentAccount != null && this.user.login == this.currentAccount.login) {
      this.user.reviewingEnabled = !this.user.reviewingEnabled;
      this.userService.update(this.user).subscribe();
    }
  }
}