1
0
mirror of https://github.com/amir20/dozzle.git synced 2025-12-26 15:16:27 +01:00
Files
dozzle/assets/stores/config.ts
Amir Raminfar a6ba94e03f Adds hostname config for setting UI parameter (#1983)
* Adds hostname config to setting a hostname in title

* Also updates title for hostname
2022-12-12 09:37:54 -08:00

32 lines
770 B
TypeScript

const text = document.querySelector("script#config__json")?.textContent || "{}";
interface Config {
version: string;
base: string;
authorizationNeeded: boolean | "false" | "true";
secured: boolean | "false" | "true";
maxLogs: number;
hostname: string;
}
const pageConfig = JSON.parse(text);
const config: Config = {
maxLogs: 600,
...pageConfig,
};
if (config.version == "{{ .Version }}") {
config.version = "master";
config.base = "";
config.authorizationNeeded = false;
config.secured = false;
config.hostname = "localhost";
} else {
config.version = config.version.replace(/^v/, "");
config.authorizationNeeded = config.authorizationNeeded === "true";
config.secured = config.secured === "true";
}
export default config as Config;