aboutsummaryrefslogtreecommitdiff
path: root/packages/demobank-ui/src/settings.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/demobank-ui/src/settings.ts')
-rw-r--r--packages/demobank-ui/src/settings.ts54
1 files changed, 31 insertions, 23 deletions
diff --git a/packages/demobank-ui/src/settings.ts b/packages/demobank-ui/src/settings.ts
index 3a60c48a5..67f926e7f 100644
--- a/packages/demobank-ui/src/settings.ts
+++ b/packages/demobank-ui/src/settings.ts
@@ -14,23 +14,32 @@
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-import { Codec, buildCodecForObject, codecForBoolean, codecForList, codecForString, codecOptional } from "@gnu-taler/taler-util";
+import { Codec, buildCodecForObject, codecForBoolean, codecForList, codecForMap, codecForString, codecOptional } from "@gnu-taler/taler-util";
export interface BankUiSettings {
- // location of the backend API
+ // Where libeufin backend is localted
+ // default: window.origin without "webui/"
backendBaseURL?: string;
- // where the user is going to be redirected after clicking the Taler icon
- iconLinkURL?: string;
- // show demo nav
- showDemoNav?: boolean;
- // links of the demo nav. Array of tuples that contains [name,url]
- demoSites?: Array<Array<string>>;
- // show a button "create random account"
+ // Shows a button "create random account" in the registration form
+ // Useful for testing
+ // default: false
allowRandomAccountCreation?: boolean;
- // every random account will have password "123"
+ // Create all random accounts with password "123"
+ // Useful for testing
+ // default: false
simplePasswordForRandomAccounts?: boolean;
- // bank name in the top
+ // Bank name shown in the header
+ // default: "Taler Bank"
bankName?: string;
+ // URL where the user is going to be redirected after
+ // clicking in Taler Logo
+ // default: home page
+ iconLinkURL?: string;
+ // Mapping for every link shown in the top navitation bar
+ // - key: link label, what the user will read
+ // - value: link target, where the user is going to be redirected
+ // default: empty list
+ topNavSites?: Record<string, string>;
}
/**
@@ -39,31 +48,30 @@ export interface BankUiSettings {
const defaultSettings: BankUiSettings = {
backendBaseURL: undefined,
iconLinkURL: undefined,
- bankName: "Taler TESTING Bank",
- showDemoNav: false,
- simplePasswordForRandomAccounts: true,
- allowRandomAccountCreation: true,
- demoSites: [
- ["Demo", "https://demo.taler.net/"],
- ],
+ bankName: "Taler Bank",
+ simplePasswordForRandomAccounts: false,
+ allowRandomAccountCreation: false,
+ topNavSites: {},
};
const codecForBankUISettings = (): Codec<BankUiSettings> =>
buildCodecForObject<BankUiSettings>()
- .property("allowRandomAccountCreation", codecOptional(codecForBoolean()))
.property("backendBaseURL", codecOptional(codecForString()))
+ .property("allowRandomAccountCreation", codecOptional(codecForBoolean()))
+ .property("simplePasswordForRandomAccounts", codecOptional(codecForBoolean()))
.property("bankName", codecOptional(codecForString()))
- .property("demoSites", codecOptional(codecForList(codecForList(codecForString()))))
.property("iconLinkURL", codecOptional(codecForString()))
- .property("showDemoNav", codecOptional(codecForBoolean()))
- .property("simplePasswordForRandomAccounts", codecOptional(codecForBoolean()))
+ .property("topNavSites", codecOptional(codecForMap(codecForString())))
.build("BankUiSettings");
export function fetchSettings(listener: (s: BankUiSettings) => void): void {
fetch("./settings.json")
.then(resp => resp.json())
.then(json => codecForBankUISettings().decode(json))
- .then(listener)
+ .then(result => listener({
+ ...defaultSettings,
+ ...result,
+ }))
.catch(e => {
console.log("failed to fetch settings", e)
listener(defaultSettings)