mirror of
https://github.com/amir20/dozzle.git
synced 2025-12-26 23:21:41 +01:00
fix: cleans up config in template (#2273)
This commit is contained in:
@@ -3,11 +3,11 @@ const text = document.querySelector("script#config__json")?.textContent || "{}";
|
||||
interface Config {
|
||||
version: string;
|
||||
base: string;
|
||||
authorizationNeeded: boolean | "false" | "true";
|
||||
secured: boolean | "false" | "true";
|
||||
authorizationNeeded: boolean;
|
||||
secured: boolean;
|
||||
maxLogs: number;
|
||||
hostname: string;
|
||||
hosts: string[] | string;
|
||||
hosts: string[];
|
||||
}
|
||||
|
||||
const pageConfig = JSON.parse(text);
|
||||
@@ -17,22 +17,6 @@ const config: Config = {
|
||||
...pageConfig,
|
||||
};
|
||||
|
||||
if (config.version == "{{ .Version }}") {
|
||||
config.version = "master";
|
||||
config.base = "";
|
||||
config.authorizationNeeded = false;
|
||||
config.secured = false;
|
||||
config.hostname = "localhost";
|
||||
config.hosts = ["localhost", "64.225.88.189"];
|
||||
} else {
|
||||
config.version = config.version.replace(/^v/, "");
|
||||
config.authorizationNeeded = config.authorizationNeeded === "true";
|
||||
config.secured = config.secured === "true";
|
||||
config.hosts = (config.hosts as string).split(",");
|
||||
}
|
||||
config.version = config.version.replace(/^v/, "");
|
||||
|
||||
export default config as Omit<Config, "hosts" | "authorizationNeeded" | "secured"> & {
|
||||
hosts: string[];
|
||||
authorizationNeeded: boolean;
|
||||
secured: boolean;
|
||||
};
|
||||
export default config;
|
||||
|
||||
@@ -161,19 +161,19 @@ func (h *handler) executeTemplate(w http.ResponseWriter, req *http.Request) {
|
||||
}
|
||||
|
||||
config := struct {
|
||||
Base string `json:"base"`
|
||||
Version string `json:"version"`
|
||||
AuthorizationNeeded bool `json:"authorizationNeeded"`
|
||||
Secured bool `json:"secured"`
|
||||
Hostname string `json:"hostname"`
|
||||
Hosts string `json:"hosts"`
|
||||
Base string `json:"base"`
|
||||
Version string `json:"version"`
|
||||
AuthorizationNeeded bool `json:"authorizationNeeded"`
|
||||
Secured bool `json:"secured"`
|
||||
Hostname string `json:"hostname"`
|
||||
Hosts []string `json:"hosts"`
|
||||
}{
|
||||
path,
|
||||
h.config.Version,
|
||||
h.isAuthorizationNeeded(req),
|
||||
secured,
|
||||
h.config.Hostname,
|
||||
strings.Join(hosts, ","),
|
||||
hosts,
|
||||
}
|
||||
|
||||
data := map[string]interface{}{
|
||||
|
||||
Reference in New Issue
Block a user