Project

General

Profile

« Previous | Next » 

Revision 56889

View differences:

piwik.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 { PiwikInfo } from '../domain/typeScriptClasses';
9 9
import { Observable } from 'rxjs';
10
import {URLParameter} from '../domain/url-parameter';
11
import {PiwikInfoPage} from '../domain/page-content';
10 12

  
11 13
const headerOptions = {
12 14
  headers : new HttpHeaders().set('Content-Type', 'application/json')
......
50 52
    return this.httpClient.get<PiwikInfo>(url, headerOptions);
51 53
  }
52 54

  
53
  getPiwikSitesForRepos(): Observable<PiwikInfo[]> {
55
  getPiwikSitesForRepos(urlParams: URLParameter[]): Observable<PiwikInfoPage> {
54 56
    const url = `${this.apiUrl}getPiwikSitesForRepos`;
55 57
    console.log(`knocking on: ${url}`);
58
    let params = new HttpParams();
59
    for (const urlParameter of urlParams) {
60
      for (const value of urlParameter.value) {
61
        params = params.append(urlParameter.key, value);
62
      }
63
    }
56 64

  
57
    return this.httpClient.get<PiwikInfo[]>(url, headerOptions);
65
    return this.httpClient.get<PiwikInfoPage>(url, {params, withCredentials: true});
58 66
  }
59 67

  
60

  
61 68
  markPiwikSiteAsValidated (repositoryId: string) {
62 69
    const url = `${this.apiUrl}markPiwikSiteAsValidated/${repositoryId}`;
63 70
    console.log(`knocking on: ${url}`);

Also available in: Unified diff