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

@Component({
  selector: 'app-role-report',
  templateUrl: './role-report.component.html',
  styleUrls: ['./role-report.component.css']
})


export class RoleReportComponent implements OnInit {
  
  roleId: number;
  rolesList: any [];
  selectedAll: any;

  constructor(private route: ActivatedRoute, 
    private dashboardSer: DashboardService, 
    private userService: UserService,
    private spinner: NgxSpinnerService ) { 
      this.spinner.show();
    }

  ngOnInit() {
    
    this.userService.getUserDataProfile();
    
    this.route.params.subscribe(
      (params: Params) => {
        this.roleId = params['roleReportId'];
        this.dashboardSer.get_report_pages_inside_roles(this.roleId).subscribe(
          (responce) => {
            //console.log(responce);
            this.rolesList = responce['role'];
            console.log('role list', this.rolesList);
            this.spinner.hide();
          }, 
          (error) => {
            console.log(error);
          }
        );
      }
    )  
  };

  //print function
  onPrint() {
    window.print();
  }

}
