Configuration Service

The Configuration Service (CloudAppConfigService) provides capabilities to save and retrieve app-specific institution-wide configuration. The configuration is stored in Alma and can be accessed by the app for any user. The following methods are available:

The following methods are available:

get

This method is used to retrieve configuration for the application.

Interface

get(): Observable<any>

Parameters:

  • None

Example

import { CloudAppConfigService } from '@exlibris/exl-cloudapp-angular-lib';

export class MainComponent implements OnInit { 
  private config: any; 

  constructor( private configService: CloudAppConfigService ) { } 

  ngOnInit() { 
    this.configService.get().subscribe( config => this.config = config ); 
  } 
}

 

set

This method is used to set the configuration for the application.

Interface

set(value: any): Observable<WriteSettingsResponse>

Parameters:

  • Value: the data to be stored

Example

save() {
  this.configService.set(this.form.value).subscribe(response=>console.log('Saved'));
}

 

remove

This method is used to remove the configuration for the application.

Interface

remove(): Observable<WriteSettingsResponse>

Example

remove() {
  this.configService.remove().subscribe( () => console.log('removed') );
}

 

getAsFormGroup

This method is used to retrieve configuration for the application as a FormGroup which can be used in Reactive Forms.

Interface

getAsFormGroup(): Observable<FormGroup>

Example

import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
import { CloudAppConfigService } from '@exlibris/exl-cloudapp-angular-lib';

@Component({
  selector: 'app-config',
  templateUrl: './config.component.html',
  styleUrls: ['./config.component.scss']
})
export class ConfigComponent implements OnInit {
  form: FormGroup;

  constructor(
    private fb: FormBuilder,
    private configService: CloudAppConfigService
  ) { }

  ngOnInit() {
    this.configService.getAsFormGroup().subscribe( config => {
      if (Object.keys(config.value).length!=0) {
        this.form = config;
      }
    });   
  }
}