import {Injectable} from '@angular/core'; /** * @author Harsha A.N.S * * @description: Responsible to store the data of filters wrt name of filter. * */ @Injectable({ providedIn: 'root', }) export class FiltersDataService { public data: any[]; constructor() { this.data = new Array(); } /** * @returns object which contains all filters data. * */ public getAllData(): any { return this.data; } /** * @input filterName: name of the filter, datum: it's respective data. * */ public setData(filterName: any, datum: any): void { this.data[filterName] = datum; } /** * @input filterName: name of the filter. * * @returns empty object if not found else returns paires data to the filterName * */ public getData(filterName: string) { try { return this.data[filterName]; } catch (err) { console.warn(filterName + ' no data'); } return {}; } // public loadData(URL: string): Promise { // const filterPromises = []; // // let filtersConfig = this.loginService.filtersConfig; // const filtersConfig = []; // for (const config of filtersConfig) { // filterPromises.push( // this.apiService.getDataOf(URL, [{'name': 'hiddenActionType', 'value': config.filterActionString}]) // .then(data => { // this.setData(config.filterName, data); // this.logger.log(config.filterName, data); // })); // } // return new Promise((resolve, reject) => { // Promise.all(filterPromises).then(value => { // resolve(true); // } // ); // }); // } }