Merge Angular 16 Irish Monitor to develop #33
|
@ -21,7 +21,7 @@ import {Dates, StringUtils} from "../utils/string-utils.class";
|
|||
import {Params} from "@angular/router";
|
||||
import {StatisticsService} from "../monitor-admin/utils/services/statistics.service";
|
||||
import {SearchResearchResultsService} from "../services/searchResearchResults.service";
|
||||
import {CustomFilterService} from "../../shared/customFilter.service";
|
||||
import {CustomFilterService} from "../shared/customFilter.service";
|
||||
|
||||
@Directive()
|
||||
export abstract class MonitorIndicatorStakeholderBaseComponent extends IndicatorStakeholderBaseComponent implements OnInit {
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
import {Injectable} from "@angular/core";
|
||||
import {HttpClient} from "@angular/common/http";
|
||||
import {BehaviorSubject, from, Observable, Subscriber} from "rxjs";
|
||||
import {SearchCustomFilter} from "../searchPages/searchUtils/searchUtils.class";
|
||||
|
||||
|
||||
@Injectable({
|
||||
providedIn: "root"
|
||||
})
|
||||
export class CustomFilterService {
|
||||
|
||||
private customFilterSubject: BehaviorSubject<SearchCustomFilter[]> = null;
|
||||
private promise: Promise<void>;
|
||||
private sub;
|
||||
|
||||
constructor(private http: HttpClient) {
|
||||
this.customFilterSubject = new BehaviorSubject<SearchCustomFilter[]>(null);
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.clearSubscriptions();
|
||||
}
|
||||
|
||||
clearSubscriptions() {
|
||||
if (this.sub instanceof Subscriber) {
|
||||
this.sub.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
async getCustomFilterAsync() {
|
||||
if (this.promise) {
|
||||
await this.promise;
|
||||
this.promise = null;
|
||||
}
|
||||
this.clearSubscriptions();
|
||||
return this.customFilterSubject.getValue();
|
||||
}
|
||||
|
||||
|
||||
getCustomFilterAsObservable(): Observable<SearchCustomFilter[]> {
|
||||
return this.customFilterSubject.asObservable();
|
||||
}
|
||||
|
||||
setCustomFilter(customFilters: SearchCustomFilter[]) {
|
||||
this.customFilterSubject.next(customFilters);
|
||||
}
|
||||
/*
|
||||
static getDefaultFilters(){
|
||||
let defaultFilters = new Map<string, SearchCustomFilter[]>();
|
||||
defaultFilters.set("result",[new SearchCustomFilter("National", "country", "IE", "Irish National Monitor")]);
|
||||
defaultFilters.set("project",[new SearchCustomFilter("National", "country", "IE", "Irish National Monitor")]);
|
||||
defaultFilters.set("organization",[new SearchCustomFilter("National", "country", "IE", "Irish National Monitor")]);
|
||||
defaultFilters.set("datasource",[new SearchCustomFilter("National", "country", "IE", "Irish National Monitor")]);
|
||||
return defaultFilters;
|
||||
}*/
|
||||
}
|
Loading…
Reference in New Issue