diff options
Diffstat (limited to '_www/environment')
| -rw-r--r-- | _www/environment/index.html | 76 |
1 files changed, 36 insertions, 40 deletions
diff --git a/_www/environment/index.html b/_www/environment/index.html index 3c439ae..af5a7be 100644 --- a/_www/environment/index.html +++ b/_www/environment/index.html @@ -208,7 +208,7 @@ <div class="section-bottom"> <div> - <button onclick="handleSave()">Save</button> + <button onclick="EnvironmentUpdate()">Save</button> </div> </div> </div> @@ -218,32 +218,13 @@ <script> let resc = null - async function getEnvironment() { - const res = await resc.getEnvironment() - if (res.code != 200) { + async function EnvironmentUpdate() { + let res = await resc.EnvironmentUpdate() + if (res.code !== 200) { notifError(res.message) return } - - const env = res.data - - // Set all input values using env data. - document.getElementById("FileResolvConf").value = env.FileResolvConf - document.getElementById("Debug").value = env.Debug - - renderNameservers() - - document.getElementById("ListenAddress").value = env.ListenAddress - document.getElementById("HTTPPort").value = env.HTTPPort - document.getElementById("TLSPort").value = env.TLSPort - document.getElementById("TLSCertFile").value = env.TLSCertFile - document.getElementById("TLSPrivateKey").value = env.TLSPrivateKey - - document.getElementById("TLSAllowInsecure").checked = env.TLSAllowInsecure - document.getElementById("DoHBehindProxy").checked = env.DoHBehindProxy - - document.getElementById("PruneDelay").value = env.PruneDelay - document.getElementById("PruneThreshold").value = env.PruneThreshold + notifInfo("Environment has been saved!") } function handleAddNameserver() { @@ -251,16 +232,6 @@ renderNameservers() } - async function handleSave() { - console.log("handleSave: ", resc.env) - let res = await resc.updateEnvironment() - if (res.code !== 200) { - notifError(res.message) - return - } - notifInfo("Environment has been saved!") - } - function onDeleteNameserver(x) { resc.env.NameServers.splice(x, 1) renderNameservers() @@ -275,9 +246,34 @@ resc.env.NameServers[x] = newv } - function onLoad() { + async function onLoad() { resc = new Rescached("") - getEnvironment() + + const res = await resc.Environment() + if (res.code != 200) { + notifError(res.message) + return + } + + const env = res.data + + // Set all input values using env data. + document.getElementById("FileResolvConf").value = env.FileResolvConf + document.getElementById("Debug").value = env.Debug + + renderNameservers() + + document.getElementById("ListenAddress").value = env.ListenAddress + document.getElementById("HTTPPort").value = env.HTTPPort + document.getElementById("TLSPort").value = env.TLSPort + document.getElementById("TLSCertFile").value = env.TLSCertFile + document.getElementById("TLSPrivateKey").value = env.TLSPrivateKey + + document.getElementById("TLSAllowInsecure").checked = env.TLSAllowInsecure + document.getElementById("DoHBehindProxy").checked = env.DoHBehindProxy + + document.getElementById("PruneDelay").value = env.PruneDelay + document.getElementById("PruneThreshold").value = env.PruneThreshold } function renderNameservers() { @@ -295,10 +291,10 @@ let el = document.createElement("div") el.classList.add("input-deletable") el.innerHTML = ` - <input value="${ns}" oninput="onInputNameserver(${x}, this.value)"> - <button onclick="onDeleteNameserver(${x})"> - Delete - </button>` + <input value="${ns}" oninput="onInputNameserver(${x}, this.value)"> + <button onclick="onDeleteNameserver(${x})"> + Delete + </button>` listNS.appendChild(el) } } |
