2019-01-18 18:03:45 +01:00
|
|
|
import { HttpHeaders } from '@angular/common/http';
|
|
|
|
import { Injectable } from '@angular/core';
|
2023-12-05 21:36:00 +01:00
|
|
|
import { DashboardStatistics } from '@app/core/model/dashboard/dashboard-statistics';
|
|
|
|
import { RecentActivityItem } from '@app/core/model/dashboard/recent-activity-item';
|
|
|
|
import { RecentActivityItemLookup } from '@app/core/query/recent-activity-item-lookup.lookup';
|
|
|
|
import { Observable, throwError } from 'rxjs';
|
|
|
|
import { catchError } from 'rxjs/operators';
|
2020-03-26 17:44:12 +01:00
|
|
|
import { ConfigurationService } from '../configuration/configuration.service';
|
2023-12-05 21:36:00 +01:00
|
|
|
import { BaseHttpV2Service } from '../http/base-http-v2.service';
|
2024-01-04 17:09:09 +01:00
|
|
|
import { BaseHttpParams } from '@common/http/base-http-params';
|
|
|
|
import { InterceptorType } from '@common/http/interceptors/interceptor-type';
|
2019-01-18 18:03:45 +01:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class DashboardService {
|
|
|
|
|
2023-12-05 21:36:00 +01:00
|
|
|
private headers = new HttpHeaders();
|
2019-01-18 18:03:45 +01:00
|
|
|
|
2023-12-05 21:36:00 +01:00
|
|
|
constructor(
|
|
|
|
private http: BaseHttpV2Service,
|
|
|
|
private configurationService: ConfigurationService,
|
|
|
|
) {
|
2019-01-18 18:03:45 +01:00
|
|
|
}
|
|
|
|
|
2023-12-05 21:36:00 +01:00
|
|
|
private get apiBase(): string { return `${this.configurationService.server}dashboard`; }
|
2019-01-18 18:03:45 +01:00
|
|
|
|
2023-12-05 21:36:00 +01:00
|
|
|
getMyRecentActivityItems(q: RecentActivityItemLookup): Observable<RecentActivityItem[]> {
|
|
|
|
const url = `${this.apiBase}/mine/recent-activity`;
|
|
|
|
return this.http.post<RecentActivityItem[]>(url, q).pipe(catchError((error: any) => throwError(error)));
|
2019-01-18 18:03:45 +01:00
|
|
|
}
|
2020-06-30 15:59:06 +02:00
|
|
|
|
2023-12-05 21:36:00 +01:00
|
|
|
getMyDashboardStatistics(): Observable<DashboardStatistics> {
|
|
|
|
const url = `${this.apiBase}/mine/get-statistics`;
|
|
|
|
return this.http.get<DashboardStatistics>(url).pipe(catchError((error: any) => throwError(error)));
|
2020-06-30 15:59:06 +02:00
|
|
|
}
|
2020-07-10 15:52:35 +02:00
|
|
|
|
2023-12-05 21:36:00 +01:00
|
|
|
getPublicDashboardStatistics(): Observable<DashboardStatistics> {
|
|
|
|
const url = `${this.apiBase}/public/get-statistics`;
|
2024-01-04 17:09:09 +01:00
|
|
|
const params = new BaseHttpParams();
|
|
|
|
params.interceptorContext = {
|
|
|
|
excludedInterceptors: [InterceptorType.AuthToken]
|
|
|
|
};
|
|
|
|
return this.http.get<DashboardStatistics>(url, { params: params }).pipe(catchError((error: any) => throwError(error)));
|
2023-12-05 21:36:00 +01:00
|
|
|
}
|
2019-01-18 18:03:45 +01:00
|
|
|
}
|