File

src/app/shared/widgets/portal/modules/module.service.ts

Index

Widget inputs
Widget outputs
Properties
Methods

Constructor

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

Methods

getModules
getModules()
postModule
postModule(inputurl: , body: )
Parameters :
Name Optional
inputurl no
body no
Returns : Observable<any>
updateModuleOrder
updateModuleOrder(ids: string[])
Parameters :
Name Type Optional
ids string[] no
Returns : Observable<any>

Properties

Public _progressbarService
_progressbarService: ProgressbarService
Type : ProgressbarService
Public authHttp
authHttp: HttpClient
Type : HttpClient
import { mergeMap, map, filter, tap } from "rxjs/operators";
import { Injectable } from "@angular/core";
import { Observable } from "rxjs";
import { AppdataStore } from "../../../components/appdata/appdata.store";
import { HttpClient } from "@angular/common/http";
import { Resource } from "../../../components/hal/hal";
import { ProgressbarService } from "../../../components/progressbar/progressbar.service";
import { Module } from "./module";

export interface ModuleResource extends Resource {
  _embedded: {
    modules: Module[];
  };
}

@Injectable()
export class ModuleService {
  constructor(
    public authHttp: HttpClient,
    private _appdata: AppdataStore,
    public _progressbarService: ProgressbarService
  ) {}

  getModules(): Observable<ModuleResource> {
    return <any>this._appdata.getAppdata().pipe(
      map((data) => {
        return data["portal"]._links["modules"].href;
      }),
      filter((uri) => uri !== undefined),
      mergeMap((uri) => {
        return this.authHttp.get(uri);
      }),
      map((res) => <ModuleResource>res)
    );
  }

  postModule(inputurl, body): Observable<any> {
    this._progressbarService.addRequest();

    return this.authHttp.post(inputurl, body).pipe(
      tap(
        (data) => this._progressbarService.requestFinished(),
        (err) => this._progressbarService.requestFinished()
      )
    );
  }

  updateModuleOrder(ids: string[]): Observable<any> {
    return <any>this._appdata.getAppdata().pipe(
      map((data) => {
        return data["portal"]._links["modules"].href;
      }),
      filter((uri) => uri !== undefined),
      mergeMap((uri) => {
        return this.authHttp.put(uri, ids);
      })
    );
  }
}

results matching ""

    No results matching ""