1
|
import {HttpClient, HttpHeaders, HttpParams} from '@angular/common/http';
|
2
|
import { Injectable } from '@angular/core';
|
3
|
import { environment } from '../../environments/environment';
|
4
|
import {
|
5
|
AggregationDetails, BrokerSummary, CollectionMonitorSummary,
|
6
|
Country, MetricsInfo,
|
7
|
Repository,
|
8
|
RepositoryInterface,
|
9
|
RepositorySnippet, RepositorySummaryInfo,
|
10
|
Timezone,
|
11
|
Typology, UsageSummary
|
12
|
} from '../domain/typeScriptClasses';
|
13
|
import { Observable, of } from 'rxjs';
|
14
|
|
15
|
const headerOptions = {
|
16
|
headers : new HttpHeaders().set('Content-Type', 'application/json')
|
17
|
.set('Accept', 'application/json'),
|
18
|
withCredentials: true
|
19
|
};
|
20
|
|
21
|
|
22
|
@Injectable ()
|
23
|
export class DashboardService {
|
24
|
|
25
|
private dashboardAPIUrl = environment.API_ENDPOINT + '/dashboard/';
|
26
|
|
27
|
constructor(private httpClient: HttpClient) { }
|
28
|
|
29
|
getRepositoriesSummaryInfo(userEmail: string): Observable<RepositorySummaryInfo[]> {
|
30
|
const url = `${this.dashboardAPIUrl}getRepositoriesSummary/${userEmail}/0/100`;
|
31
|
console.log(`knocking on: ${url}`);
|
32
|
return this.httpClient.get<RepositorySummaryInfo[]>(url, headerOptions);
|
33
|
}
|
34
|
|
35
|
getCollectionMonitorSummary(id: string, items: number): Observable<CollectionMonitorSummary> {
|
36
|
const url = `${this.dashboardAPIUrl}collectionMonitorSummary/${id}?size=${items}`;
|
37
|
console.log(`knocking on: ${url}`);
|
38
|
return this.httpClient.get<CollectionMonitorSummary>(url, headerOptions);
|
39
|
}
|
40
|
|
41
|
getUsageSummary(repoId: string): Observable<UsageSummary> {
|
42
|
const url = `${this.dashboardAPIUrl}usageSummary/${repoId}`;
|
43
|
console.log(`knocking on: ${url}`);
|
44
|
return this.httpClient.get<UsageSummary>(url, headerOptions);
|
45
|
}
|
46
|
|
47
|
getBrokerSummary(repoName: string): Observable<BrokerSummary> {
|
48
|
const url = `${this.dashboardAPIUrl}brokerSummary/${encodeURIComponent(repoName)}`;
|
49
|
console.log(`knocking on: ${url}`);
|
50
|
return this.httpClient.get<BrokerSummary>(url, headerOptions);
|
51
|
}
|
52
|
}
|