feat: add support for runtime server url changes (#1271)

Fixes: #786
Fixes: #1229
This commit is contained in:
Karan Takalkar
2020-11-19 12:03:12 +05:30
committed by GitHub
parent 5f90bc00bd
commit 8271eb00ac
14 changed files with 145 additions and 11 deletions
+33
View File
@@ -1,6 +1,9 @@
/** Angular Imports */
import { Injectable } from '@angular/core';
/** Environment Imports */
import { environment } from '../../environments/environment';
/**
* Settings Service
*/
@@ -27,6 +30,22 @@ export class SettingsService {
localStorage.setItem('mifosXLanguage', JSON.stringify(language));
}
/**
* Sets server URL setting throughout the app.
* @param {string} url URL
*/
setServer(url: string) {
localStorage.setItem('mifosXServerURL', JSON.stringify(url));
}
/**
* Sets server URL setting throughout the app.
* @param {string[]} list List of default servers
*/
setServers(list: string[]) {
localStorage.setItem('mifosXServers', JSON.stringify(list));
}
/**
* Returns date format setting.
*/
@@ -41,4 +60,18 @@ export class SettingsService {
return JSON.parse(localStorage.getItem('mifosXLanguage'));
}
/**
* Returns list of default server
*/
get servers() {
return JSON.parse(localStorage.getItem('mifosXServers'));
}
/**
* Returns server setting
*/
get server() {
return environment.baseApiUrl;
}
}