File

src/app/shared/widgets/imarket/list/imarketlist.service.ts

Index

Widget inputs
Widget outputs
Properties
Methods

Constructor

constructor(authHttp: HttpClient, _progressbarService: ProgressbarService)
Parameters :
Name Type Optional
authHttp HttpClient no
_progressbarService ProgressbarService no

Methods

getActions
getActions(inputurl: )
Parameters :
Name Optional
inputurl no
Returns : Observable<any>
getAttributeValues
getAttributeValues(inputurl: )
Parameters :
Name Optional
inputurl no
Returns : Observable<any>
Public getInputLink
getInputLink()
Returns : Observable<String>
getTemplatedFilteredResults
getTemplatedFilteredResults(inputurl: , showProgressBar: boolean)
Parameters :
Name Type Optional Default value
inputurl no
showProgressBar boolean no true
getTemplatedFilteredResultsIndex
getTemplatedFilteredResultsIndex(id: , inputurl: )
Parameters :
Name Optional
id no
inputurl no
Public setInputLink
setInputLink(data: )
Parameters :
Name Optional
data no
Returns : void

Properties

Public _progressbarService
_progressbarService: ProgressbarService
Type : ProgressbarService
Public authHttp
authHttp: HttpClient
Type : HttpClient
Private inputLinkEvent
inputLinkEvent:
Default value : new Subject<String>()
Private inputLinkEventObservable
inputLinkEventObservable:
Default value : this.inputLinkEvent.asObservable()
Public results
results: Result[]
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)
    );
  }
}

results matching ""

    No results matching ""