src/app/data/cdb.service.ts
Service that requests data from the Configuration database to the IAS Webserver through HTTP Requests
Properties |
Methods |
constructor(httpClientService: HttpClientService)
|
||||||||
Defined in src/app/data/cdb.service.ts:25
|
||||||||
Instantiates the service
Parameters :
|
getBroadcastRate |
getBroadcastRate()
|
Defined in src/app/data/cdb.service.ts:58
|
Get refresh broadcast rate from IAS configuration data
Returns :
number
contains the 'broadcastRate' in seconds |
getBroadcastThreshold |
getBroadcastThreshold()
|
Defined in src/app/data/cdb.service.ts:72
|
Get refresh broadcast threshold from IAS configuration data
Returns :
number
contains the 'broadcastThreshold' in seconds |
getConfigurationData |
getConfigurationData()
|
Defined in src/app/data/cdb.service.ts:50
|
Get the ias configuration data from the IAS Webserver
Returns :
any
IAS configuration |
initialize |
initialize()
|
Defined in src/app/data/cdb.service.ts:39
|
Triggers request of general information to the IAS Webserver when the component is initializated
Returns :
any
|
iasConfiguration |
Defined in src/app/data/cdb.service.ts:20
|
Variable to store the ias configuration data |
Public iasDataAvailable |
Default value : new BehaviorSubject<any>(false)
|
Defined in src/app/data/cdb.service.ts:25
|
Notify changes on the service data |
iasUrl |
Default value : BackendUrls.CDB_IAS
|
Defined in src/app/data/cdb.service.ts:15
|
IAS Webserver URL for IAS configuration requests |
import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import { BackendUrls } from '../settings';
import { HttpClientService } from '../data/http-client.service';
/**
* Service that requests data from the Configuration database to the
* IAS Webserver through HTTP Requests
*/
@Injectable()
export class CdbService {
/** IAS Webserver URL for IAS configuration requests */
iasUrl = BackendUrls.CDB_IAS;
/**
* Variable to store the ias configuration data
*/
iasConfiguration;
/**
* Notify changes on the service data
*/
public iasDataAvailable = new BehaviorSubject<any>(false);
/**
* Instantiates the service
* @param {HttpClientService} httpClientService Service used to perform HTTP requests
*/
constructor(
private httpClientService: HttpClientService
) {}
/**
* Triggers request of general information to the IAS Webserver when
* the component is initializated
*/
initialize() {
return this.getConfigurationData().subscribe((res) => {
this.iasConfiguration = res;
this.iasDataAvailable.next(true);
});
}
/**
* Get the ias configuration data from the IAS Webserver
* @returns {json} IAS configuration
*/
getConfigurationData() {
return this.httpClientService.get(this.iasUrl);
}
/**
* Get refresh broadcast rate from IAS configuration data
* @returns {number} contains the 'broadcastRate' in seconds
*/
getBroadcastRate(): number {
let value;
try {
value = Number(this.iasConfiguration['broadcastRate']);
} catch (e) {
value = 10;
}
return value;
}
/**
* Get refresh broadcast threshold from IAS configuration data
* @returns {number} contains the 'broadcastThreshold' in seconds
*/
getBroadcastThreshold(): number {
let value;
try {
value = Number(this.iasConfiguration['broadcastThreshold']);
} catch (e) {
value = 11;
}
return value;
}
}