File
Index
Widget inputs
|
|
Widget outputs
|
|
Properties
|
|
Methods
|
|
Constructor
constructor(authHttp: HttpClient, _progressbarService: ProgressbarService)
|
|
Parameters :
Name |
Type |
Optional |
authHttp |
HttpClient
|
no
|
_progressbarService |
ProgressbarService
|
no
|
|
Methods
getCategories
|
getCategories(childUrl: string)
|
|
Parameters :
Name |
Type |
Optional |
childUrl |
string
|
no
|
|
getRootCategories
|
getRootCategories(url: )
|
|
|
Public
_progressbarService
|
_progressbarService: ProgressbarService
|
Type : ProgressbarService
|
|
import { tap, map } from "rxjs/operators";
import { Injectable } from "@angular/core";
import { Observable } from "rxjs";
import { HttpClient } from "@angular/common/http";
import { Category } from "./category";
import { Resource } from "../../../components/hal/hal";
import { ProgressbarService } from "../../../components/progressbar/progressbar.service";
import { Link } from "../../../components/hal/hal";
export interface CategoryResource {
_embedded: {
categories: Category[];
};
_links?: {
children: Link;
};
}
@Injectable()
export class CategoryService {
constructor(
public authHttp: HttpClient,
public _progressbarService: ProgressbarService
) {}
getRootCategories(url): Observable<CategoryResource> {
this._progressbarService.addRequest();
return this.authHttp.get(url).pipe(
map((res) => <any>res),
tap(
(data) => this._progressbarService.requestFinished(),
(err) => this._progressbarService.requestFinished()
)
);
}
getCategories(childUrl: string): Observable<CategoryResource> {
this._progressbarService.addRequest();
return this.authHttp.get(childUrl).pipe(
map((res) => <any>res),
tap(
(data) => this._progressbarService.requestFinished(),
(err) => this._progressbarService.requestFinished()
)
);
}
}