123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- import { ReportService } from './../../shared/report.service';
- import { AuthServiceService } from './../../shared/auth-service.service';
- import { HttpClient } from '@angular/common/http';
- import { UserService } from './../../shared/user.service';
- import { ActivatedRoute, Params, Router } from '@angular/router';
- import { ToastrService } from 'ngx-toastr';
- import { NgxSpinnerService } from 'ngx-spinner';
- import { Component, OnInit } from '@angular/core';
- @Component({
- selector: 'app-report-list',
- templateUrl: './report-list.component.html',
- styleUrls: ['./report-list.component.css']
- })
- export class ReportListComponent implements OnInit {
- constructor(private route: ActivatedRoute,
- private userSer: UserService,
- private router: Router,
- public authSer: AuthServiceService,
- private toastr: ToastrService,
- private reportService:ReportService,
- private spinner: NgxSpinnerService,
- private http: HttpClient) { }
- reportType: string;
- permissionsTable:boolean = false;
- pagesTable:boolean = false;
- name:string = '';
- usersList = [];
- rolesList= [];
- roleValue:number;
- serviceId: number;
- userLoginId:number;
-
- typeRoleReport:string //to determine the type 0f report of role
- ngOnInit() {
- this.userSer.getUserDataProfile();
- //show / hide notification search in header
- this.authSer.notificationLogin = true;
- this.authSer.showSearchHeader = false;
- this.authSer.showHeaderLogin = false;
- this.authSer.showHeaderDashBoard = true;
- this.authSer.showDashboardHeader = true;
- this.authSer.internalHeader = false;
- this.route.parent.params.subscribe(
- (params:Params) => {
- this.userLoginId = params['userID'];
- this.serviceId = params['serviceID'];
- }
- );
- this.route.params.subscribe(
- (params: Params) => {
- this.reportType = params['reportName'];
- if(this.reportType == 'reportPermissions') {
- //this.permissionsTable = true;
- } else if(this.reportType == 'reportPages') {
- this.typeRoleReport = 'reportPages';
- this.spinner.show();
- this.pagesTable = true;
- this.http.get(this.authSer.pathApi + '/roles_list').subscribe(
- (responce) => {
- console.log(responce);
- this.rolesList = responce['roles'];
- console.log(this.rolesList);
- this.spinner.hide();
- }
- )
- } else if(this.reportType == "reportUsers") {
- this.spinner.show();
- this.typeRoleReport = 'reportUsers';
- this.pagesTable = true;
- this.http.get(this.authSer.pathApi + '/roles_list').subscribe(
- (responce) => {
- console.log(responce);
- this.rolesList = responce['roles'];
- console.log(this.rolesList);
- this.spinner.hide();
- }
- );
- }
- }
- );
-
- }
- onSearchName() {
- this.spinner.show();
- console.log(this.name);
- this.http.get(this.authSer.pathApi + '/find_user/' + this.name).subscribe(
- (responce) => {
- console.log('reprt data ', responce);
- if(responce['user'] == null) {
- this.toastr.warning('لا يوجد مستخدمين بهذا الاسم');
- } else {
- this.usersList = responce['user'];
- this.permissionsTable = true;
- console.log(this.usersList);
- }
- this.spinner.hide();
- },
- (error) => {
- console.log(error);
- }
- );
- };
- onGetRoles(roleVal) {
- console.log(roleVal);
- this.roleValue = roleVal;
- }
- //on get user report
- onGetReport(user_id) {
- console.log(user_id);
- this.router.navigate(['service/' + this.userLoginId + '/' + this.serviceId + '/userreport/' + user_id]);
- }
- getRoleReport() {
- if(this.typeRoleReport == 'reportPages') {
- this.router.navigate(['service/' + this.userLoginId + '/' + this.serviceId + '/roleReport/' + this.roleValue]);
- } else if(this.typeRoleReport == 'reportUsers') {
- this.router.navigate(['service/' + this.userLoginId + '/' + this.serviceId + '/userInRoleReport/' + this.roleValue]);
- }
- }
- }
|