src/app/shared/widgets/imarket/list/imarketlist.service.ts
Widget inputs |
Widget outputs |
Properties |
|
Methods |
constructor(authHttp: HttpClient, _progressbarService: ProgressbarService)
|
|||||||||
Parameters :
|
getActions | ||||
getActions(inputurl: )
|
||||
Parameters :
Returns :
Observable<any>
|
getAttributeValues | ||||
getAttributeValues(inputurl: )
|
||||
Parameters :
Returns :
Observable<any>
|
Public getInputLink |
getInputLink()
|
Returns :
Observable<String>
|
getTemplatedFilteredResults | ||||||||||||
getTemplatedFilteredResults(inputurl: , showProgressBar: boolean)
|
||||||||||||
Parameters :
Returns :
Observable<ResultResource>
|
getTemplatedFilteredResultsIndex | ||||||
getTemplatedFilteredResultsIndex(id: , inputurl: )
|
||||||
Parameters :
Returns :
Observable<ResultResource>
|
Public setInputLink | ||||
setInputLink(data: )
|
||||
Parameters :
Returns :
void
|
Public _progressbarService |
_progressbarService:
|
Type : ProgressbarService
|
Public authHttp |
authHttp:
|
Type : HttpClient
|
Private inputLinkEvent |
inputLinkEvent:
|
Default value : new Subject<String>()
|
Private inputLinkEventObservable |
inputLinkEventObservable:
|
Default value : this.inputLinkEvent.asObservable()
|
Public results |
results:
|
Type : Result[]
|
import { map, distinctUntilChanged, debounceTime, tap } from "rxjs/operators";
import { Injectable } from "@angular/core";
import { HttpClient } from "@angular/common/http";
import { Observable, Subject } from "rxjs";
import { Resource, Link, MultiSelectAction } from "../../../components/hal/hal";
import { Result, ResultResource } from "../../interfaces/list.interfaces";
import { ProgressbarService } from "../../../components/progressbar/progressbar.service";
declare var $;
export interface mpValuesResource {
total?: number;
count?: number;
_embedded?: {
values: availableValues[];
};
_links?: {
custom: Link;
};
}
export interface availableValues {
key: string;
value?: string;
}
@Injectable()
export class IMarketListService {
public results: Result[];
private inputLinkEvent = new Subject<String>();
private inputLinkEventObservable = this.inputLinkEvent.asObservable();
constructor(
public authHttp: HttpClient,
public _progressbarService: ProgressbarService
) {}
getTemplatedFilteredResults(
inputurl,
showProgressBar: boolean = true
): Observable<ResultResource> {
if (showProgressBar) {
this._progressbarService.addRequest();
}
return this.authHttp.get(inputurl, {}).pipe(
debounceTime(400),
distinctUntilChanged(),
tap(
(res) => {
if (showProgressBar) {
this._progressbarService.requestFinished();
}
return res;
},
(err) => {
if (showProgressBar) {
this._progressbarService.requestFinished();
}
}
),
map((res) => {
return <ResultResource>res;
})
);
}
getTemplatedFilteredResultsIndex(id, inputurl): Observable<ResultResource> {
return this.authHttp.get(inputurl, {}).pipe(
debounceTime(400),
distinctUntilChanged(),
map((res) => {
let results = <ResultResource>res;
results["id"] = id;
return results;
})
);
}
getActions(inputurl): Observable<any> {
return this.authHttp.get(inputurl, {}).pipe(
debounceTime(400),
distinctUntilChanged(),
map((res) => <ResultResource>res)
);
}
public getInputLink(): Observable<String> {
return this.inputLinkEventObservable;
}
public setInputLink(data) {
this.inputLinkEvent.next(data);
}
getAttributeValues(inputurl): Observable<any> {
return this.authHttp.get(inputurl, {}).pipe(
debounceTime(400),
distinctUntilChanged(),
map((res) => <any>res)
);
}
}