import { ActivatedRoute, Params } from '@angular/router';
import { Component, OnInit } from '@angular/core';
import { RolesService } from '../../../shared/roles.service';
import { UserService } from '../../../shared/user.service';
import { NgxSpinnerService } from 'ngx-spinner';


@Component({
  selector: 'app-role-report2',
  templateUrl: './role-report2.component.html',
  styleUrls: ['./role-report2.component.css']
})
export class RoleReport2Component implements OnInit {

  roleId: number;
  reportData = [];
  constructor(private roleServise: RolesService, 
    private route: ActivatedRoute, 
    private userService: UserService,
    private spinner: NgxSpinnerService) { 
      this.spinner.show();
    }

  ngOnInit() {
    this.userService.getUserDataProfile();
    this.route.params.subscribe(
      (params:Params) => {
        this.roleId = params['userRoleReportId'];
        this.roleServise.get_report_users_inside_roles(this.roleId).subscribe(
          (repsonce) => {
            //console.log(repsonce);
            this.reportData.push(repsonce['role']);
            console.log(this.reportData);
            this.spinner.hide();
          }, 
          (error) => {
            console.log(error);
          }
        )
      }
    );
  };

  onPrint() {
    window.print();
  }

}
