import { Component, OnInit } from '@angular/core'; import { SelectItem } from 'primeng/api'; import { ISelectedFilter } from '../shared/core/ISelectedFilter'; import { StaffActivityService } from '../shared/service/staff-activity.service'; import { LoginHistoryService } from '../shared/service/login-history.service'; @Component({ selector: 'app-staff-review', templateUrl: './staff-review.component.html', styleUrls: ['./staff-review.component.css'] }) export class StaffReviewComponent implements OnInit { type = "SEL"; //list of filters bind to these vars dateRangeFilterList: SelectItem[] =[]; modulesFilterList: SelectItem[] =[]; personTypeFilterList: SelectItem[] =[]; //to get search value searchValue: string; //temporary var to keep currently selected filters list selectedFilterList: ISelectedFilter; constructor(private staffActivityService: StaffActivityService, private loginHistoryService: LoginHistoryService) { } ngOnInit() { //calling to get filters this.getDateRangeFilters(); this.getModuleListFilters(); this.getPerosonTypeFilters(); } //search box value access function for searching getSearchValue(value){ this.searchValue = value.target.value; this.bindFilter(this.selectedFilterList); } //this method call service for date range filters list getDateRangeFilters(){ this.staffActivityService.getDateRangeFilters().subscribe(f =>{ //filters list as a response from service this.dateRangeFilterList = f; }) } //this method call service for module filters list getModuleListFilters(){ this.staffActivityService.getModulesList().subscribe(f =>{ //filters list as a response from service this.modulesFilterList = f; }) } //this method call service for person type filters list getPerosonTypeFilters(){ this.loginHistoryService.getPersonTypeFilters().subscribe(f =>{ //filters list as a response from service this.personTypeFilterList = f; }) } bindFilter(value : ISelectedFilter){ //temporary filter list this.selectedFilterList = value; //clear existing filtered data before apply new data this.clearAllFilters(); } //this method clear all filters and reset data clearAllFilters(){ } }