Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | 73x 73x 73x 73x 6x 6x 6x | import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { catchError, map, Observable } from 'rxjs';
import { mapPage, Page } from '../../model/page';
import { Profile, ProfilePageArgs } from '../../model/profile';
import { params } from '../../util/http';
import { ConfigService } from '../config.service';
import { LoginService } from '../login.service';
@Injectable({
providedIn: 'root'
})
export class ProfileService {
constructor(
private http: HttpClient,
private config: ConfigService,
private login: LoginService,
) { }
private get base() {
return this.config.api + '/api/v1/profile';
}
create(profile: Profile): Observable<void> {
return this.http.post<void>(this.base, profile).pipe(
catchError(err => this.login.handleHttpError(err)),
);
}
getProfile(tag: string): Observable<Profile> {
return this.http.get(this.base, {
params: params({ tag }),
}).pipe(
map(p => p as Profile),
catchError(err => this.login.handleHttpError(err)),
);
}
page(args: ProfilePageArgs): Observable<Page<Profile>> {
return this.http.get(`${this.base}/page`, {
params: params(args),
}).pipe(
map(mapPage(res => res as Profile)),
catchError(err => this.login.handleHttpError(err)),
);
}
changePassword(profile: Profile): Observable<void> {
return this.http.post<void>(`${this.base}/password`, profile).pipe(
catchError(err => this.login.handleHttpError(err)),
);
}
changeRole(profile: Profile): Observable<void> {
return this.http.post<void>(`${this.base}/role`, profile).pipe(
catchError(err => this.login.handleHttpError(err)),
);
}
activate(tag: string): Observable<void> {
return this.http.post<void>(`${this.base}/activate`, tag).pipe(
catchError(err => this.login.handleHttpError(err)),
);
}
deactivate(tag: string): Observable<void> {
return this.http.post<void>(`${this.base}/deactivate`, tag).pipe(
catchError(err => this.login.handleHttpError(err)),
);
}
delete(tag: string): Observable<void> {
return this.http.delete<void>(this.base, {
params: params({ tag }),
}).pipe(
catchError(err => this.login.handleHttpError(err)),
);
}
}
|