Project

General

Profile

« Previous | Next » 

Revision 56635

View differences:

repository.service.ts
2 2
* Created by myrto on 12/05/2017
3 3
*/
4 4

  
5
import { HttpClient, HttpHeaders } from '@angular/common/http';
5
import {HttpClient, HttpHeaders, HttpParams} from '@angular/common/http';
6 6
import { Injectable } from '@angular/core';
7 7
import { environment } from '../../environments/environment';
8 8
import {
......
10 10
  Country, MetricsInfo,
11 11
  Repository,
12 12
  RepositoryInterface,
13
  RepositorySnippet,
13
  RepositorySnippet, RepositorySummaryInfo,
14 14
  Timezone,
15 15
  Typology
16 16
} from '../domain/typeScriptClasses';
17 17
import { Observable, of } from 'rxjs';
18 18
import { timezones } from '../domain/timezones';
19 19
import { typologies } from '../domain/typologies';
20
import {URLParameter} from '../domain/url-parameter';
20 21

  
21 22
const headerOptions = {
22 23
  headers : new HttpHeaders().set('Content-Type', 'application/json')
......
28 29
@Injectable ()
29 30
export class RepositoryService {
30 31
  private apiUrl = environment.API_ENDPOINT + '/repository/';
32
  private dashboardAPIUrl = environment.API_ENDPOINT + '/dashboard/';
31 33

  
32 34
  constructor(private httpClient: HttpClient) { }
33 35

  
......
156 158
    return this.httpClient.get<any>(url, headerOptions);
157 159
  }
158 160

  
161
  searchRegisteredRepositories(page, size, urlParams: URLParameter[]) {
162
    const url = `${this.apiUrl}searchRegisteredRepositories/${page}/${size}`;
163
    console.log(`knocking on: ${url}`);
164
    let params = new HttpParams();
165
    for (const urlParameter of urlParams) {
166
      for (const value of urlParameter.value) {
167
        params = params.append(urlParameter.key, value);
168
      }
169
    }
170

  
171
    return this.httpClient.get<RepositorySnippet[]>(url, {params, withCredentials: true});
172
  }
173

  
174
  getRepositoriesSummaryInfo(userEmail: string): Observable<RepositorySummaryInfo[]> {
175
    const url = `${this.dashboardAPIUrl}getRepositoriesSummary/${userEmail}/0/100`;
176
    console.log(`knocking on: ${url}`);
177
    return this.httpClient.get<RepositorySummaryInfo[]>(url, headerOptions);
178
  }
159 179
}

Also available in: Unified diff