File

projects/cobbler-frontend/src/app/services/item-settings.service.ts

Index

Properties
Methods

Constructor

constructor(authO: UserService, cobblerApiService: CobblerApiService)
Parameters :
Name Type Optional
authO UserService No
cobblerApiService CobblerApiService No

Methods

getAll
getAll()
getitem
getitem(name: string)
Parameters :
Name Type Optional
name string No
Returns : Observable<any>

Properties

Public authO
Type : UserService
import { Injectable } from '@angular/core';
import { CobblerApiService } from 'cobbler-api';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { Settings } from 'cobbler-api';
import { UserService } from './user.service';

@Injectable({
  providedIn: 'root',
})
export class ItemSettingsService {
  constructor(
    public authO: UserService,
    private cobblerApiService: CobblerApiService,
  ) {
    // Nothing to see here
  }

  getAll(): Observable<Settings> {
    return this.cobblerApiService.get_settings(this.authO.token);
  }

  getitem(name: string): Observable<any> {
    return this.cobblerApiService.get_settings(this.authO.token).pipe(
      map<Settings, any>((data: Settings) => {
        if (name in data) {
          return data[name];
        }
        throw new Error('Requested name not found in the settings!');
      }),
    );
  }
}

results matching ""

    No results matching ""