Revision 50432
Added by Myrto Koukouli about 6 years ago
repository.service.ts | ||
---|---|---|
11 | 11 |
|
12 | 12 |
import { Observable } from 'rxjs/Observable'; |
13 | 13 |
|
14 |
import { Country, PiwikInfo, Repository, RepositoryInterface, Timezone, Topic } from '../domain/typeScriptClasses';
|
|
14 |
import { Country, Repository, RepositoryInterface, Timezone, Topic } from '../domain/typeScriptClasses'; |
|
15 | 15 |
import 'rxjs/add/operator/map'; |
16 | 16 |
import { Http, Response } from '@angular/http'; |
17 |
import { AuthenticationService } from './authentication.service'; |
|
18 | 17 |
|
19 | 18 |
const httpOptions = { |
20 | 19 |
headers: new HttpHeaders().set('Content-Type', 'application/json') |
... | ... | |
78 | 77 |
.catch(this.handleError); |
79 | 78 |
} |
80 | 79 |
|
81 |
getPiwikInfo(id: string): Observable<PiwikInfo> { |
|
82 |
let url = `${this.apiUrl}/piwik/getPiwikSiteForRepo/${id}`; |
|
83 |
console.log(`knocking on: ${url}`); |
|
84 |
return this.http.get(url) |
|
85 |
.map( piwik => <PiwikInfo>piwik.json() ) |
|
86 |
.catch(this.handleError); |
|
87 |
} |
|
88 |
|
|
89 | 80 |
getTopicsForDataSource(name: string): Observable<Topic[]> { |
90 | 81 |
let url = `${this.apiUrl}/broker/getTopicsForDatasource/${name}`; |
91 | 82 |
console.log(`knocking on: ${url}`); |
... | ... | |
102 | 93 |
.catch(this.handleError); |
103 | 94 |
} |
104 | 95 |
|
105 |
getPiwikSitesForRepos(): Observable<PiwikInfo[]> { |
|
106 |
let url = `${this.apiUrl}/piwik/getPiwikSitesForRepos`; |
|
107 |
console.log(`knocking on: ${url}`); |
|
108 |
return this.http.get(url) |
|
109 |
.map( res => <PiwikInfo[]>res.json()) |
|
110 |
.catch(this.handleError); |
|
111 |
} |
|
112 |
|
|
113 | 96 |
private handleError(error: Response | any) { |
114 | 97 |
// In a real world app, we might use a remote logging infrastructure |
115 | 98 |
// We'd also dig deeper into the error to get a better message |
Also available in: Unified diff
reorganized services