Fineract backend settings with environment variables
This commit is contained in:
committed by
Arnold Gálovics
parent
1b72136411
commit
14ceb4f3fd
@@ -1,5 +1,7 @@
|
||||
/** Angular Imports */
|
||||
import { Injectable } from '@angular/core';
|
||||
import { AlertService } from 'app/core/alert/alert.service';
|
||||
import { Dates } from 'app/core/utils/dates';
|
||||
|
||||
/** Environment Imports */
|
||||
import { environment } from '../../environments/environment';
|
||||
@@ -12,7 +14,12 @@ import { environment } from '../../environments/environment';
|
||||
})
|
||||
export class SettingsService {
|
||||
|
||||
constructor() { }
|
||||
public static businessDateConfigName = 'enable_business_date';
|
||||
public static businessDateType = 'BUSINESS_DATE';
|
||||
public static cobDateType = 'COB_DATE';
|
||||
|
||||
constructor(private alertService: AlertService,
|
||||
private dateUtils: Dates) { }
|
||||
|
||||
/**
|
||||
* Sets date format setting throughout the app.
|
||||
@@ -42,7 +49,7 @@ export class SettingsService {
|
||||
* @param {string} url URL
|
||||
*/
|
||||
setServer(url: string) {
|
||||
localStorage.setItem('mifosXServerURL', JSON.stringify(url));
|
||||
localStorage.setItem('mifosXServerURL', url);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,7 +88,42 @@ export class SettingsService {
|
||||
* Returns server setting
|
||||
*/
|
||||
get server() {
|
||||
if (localStorage.getItem('mifosXServerURL')) {
|
||||
return localStorage.getItem('mifosXServerURL');
|
||||
}
|
||||
return environment.baseApiUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns server url with api path and version
|
||||
*/
|
||||
get serverUrl() {
|
||||
return this.server + environment.apiProvider + environment.apiVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate If the enable_business_date configuration is enabled or disabled.
|
||||
*/
|
||||
validateBusinessDateStatus(configurations: any) {
|
||||
configurations.some((config: any) => {
|
||||
if (config.name === SettingsService.businessDateConfigName) {
|
||||
return config.enabled;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Business Date or COB Date.
|
||||
*/
|
||||
getBusinessDates(businessDateData: any, dateType: string): void {
|
||||
businessDateData.some((data: any) => {
|
||||
if (data.type === dateType) {
|
||||
const dateVal = new Date(data.date);
|
||||
this.alertService.alert({ type: dateType + ' Set',
|
||||
message: this.dateUtils.formatDate(dateVal, this.dateFormat())});
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user