diff --git a/app/app.go b/app/app.go
index 26bc5c9..15df015 100644
--- a/app/app.go
+++ b/app/app.go
@@ -26,14 +26,15 @@ func Run() {
html := common.MinifyStatic(m, web.Templates)
common.TMPL = common.LoadHTMLToGin(router, html)
- router.GET("/account.html", routes.HandleGETAccount)
+ router.GET("/account", routes.HandleGETAccount)
router.GET("/", routes.HandleGETIndex)
- router.GET("/index.html", routes.HandleGETIndex)
- router.GET("/config.html", routes.HandleGETConfig)
- router.GET("/login.html", routes.HandleGETLogin)
- router.GET("/settings.html", routes.HandleGETSettings)
+ router.GET("/index", routes.HandleGETIndex)
+ router.GET("/config", routes.HandleGETConfig)
+ router.GET("/login", routes.HandleGETLogin)
+ router.GET("/settings", routes.HandleGETSettings)
- router.GET("/instances_fragment", routes.HandleGETInstancesFragment)
+ router.GET("/index/instances", routes.HandleGETInstancesFragment)
+ router.GET("/config/volumes", routes.HandleGETConfigVolumesFragment)
log.Fatal(router.Run(fmt.Sprintf("0.0.0.0:%d", common.Global.Port)))
}
diff --git a/app/routes/account.go b/app/routes/account.go
index 05bf7cc..80ccc8e 100644
--- a/app/routes/account.go
+++ b/app/routes/account.go
@@ -149,7 +149,7 @@ func HandleGETAccount(c *gin.Context) {
"account": account,
})
} else {
- c.Redirect(http.StatusFound, "/login.html") // if user is not authed, redirect user to login page
+ c.Redirect(http.StatusFound, "/login") // if user is not authed, redirect user to login page
}
}
diff --git a/app/routes/index.go b/app/routes/index.go
index 246430f..2acdf85 100644
--- a/app/routes/index.go
+++ b/app/routes/index.go
@@ -84,7 +84,7 @@ func HandleGETIndex(c *gin.Context) {
"instances": instances,
})
} else { // return index without populating
- c.Redirect(http.StatusFound, "/login.html") // if user is not authed, redirect user to login page
+ c.Redirect(http.StatusFound, "/login") // if user is not authed, redirect user to login page
}
}
@@ -96,11 +96,11 @@ func HandleGETInstancesFragment(c *gin.Context) {
common.HandleNonFatalError(c, err)
}
c.Header("Content-Type", "text/plain")
- common.TMPL.ExecuteTemplate(c.Writer, "html/instances.frag", gin.H{
+ common.TMPL.ExecuteTemplate(c.Writer, "html/index-instances.frag", gin.H{
"instances": instances,
})
c.Status(http.StatusOK)
- } else { // return index without populating
+ } else { // return 401
c.Status(http.StatusUnauthorized)
}
diff --git a/app/routes/settings.go b/app/routes/settings.go
index 5659bf0..df5e17d 100644
--- a/app/routes/settings.go
+++ b/app/routes/settings.go
@@ -15,6 +15,6 @@ func HandleGETSettings(c *gin.Context) {
"page": "settings",
})
} else {
- c.Redirect(http.StatusFound, "/login.html")
+ c.Redirect(http.StatusFound, "/login")
}
}
diff --git a/web/html/instances.frag b/web/html/index-instances.frag
similarity index 100%
rename from web/html/instances.frag
rename to web/html/index-instances.frag
diff --git a/web/scripts/index.js b/web/scripts/index.js
index 3cf2f6d..d734946 100644
--- a/web/scripts/index.js
+++ b/web/scripts/index.js
@@ -1,4 +1,4 @@
-import { requestPVE, requestAPI, goToPage, setAppearance, getSearchSettings, goToURL, getInstancesFragment } from "./utils.js";
+import { requestPVE, requestAPI, goToPage, setAppearance, getSearchSettings, goToURL, requestDash } from "./utils.js";
import { alert, dialog } from "./dialog.js";
import { setupClientSync } from "./clientsync.js";
import wfaInit from "../modules/wfa.js";
@@ -179,7 +179,7 @@ class InstanceCard extends HTMLElement {
handleConfigButton () {
if (!this.actionLock && this.status === "stopped") { // if the action lock is false, and the node is stopped, then navigate to the config page with the node info in the search query
- goToPage("config.html", { node: this.node.name, type: this.type, vmid: this.vmid });
+ goToPage("config", { node: this.node.name, type: this.type, vmid: this.vmid });
}
}
@@ -240,6 +240,10 @@ async function init () {
setupClientSync(refreshInstances);
}
+async function getInstancesFragment () {
+ return await requestDash("/index/instances", "GET")
+}
+
async function refreshInstances () {
let instances = await getInstancesFragment();
if (instances.status !== 200) {
diff --git a/web/scripts/login.js b/web/scripts/login.js
index 0b3112d..764b031 100644
--- a/web/scripts/login.js
+++ b/web/scripts/login.js
@@ -16,7 +16,7 @@ async function init () {
const ticket = await requestTicket(formData.get("username"), formData.get("password"), formData.get("realm"));
if (ticket.status === 200) {
formSubmitButton.innerText = "LOGIN";
- goToPage("index.html");
+ goToPage("index");
}
else if (ticket.status === 401) {
alert("Authenticaton failed.");
diff --git a/web/scripts/utils.js b/web/scripts/utils.js
index 5254d26..38358ec 100644
--- a/web/scripts/utils.js
+++ b/web/scripts/utils.js
@@ -146,18 +146,21 @@ export async function requestAPI (path, method, body = null) {
return response;
}
-export async function getInstancesFragment () {
+export async function requestDash (path, method, body = null) {
+ const prms = new URLSearchParams(body);
const content = {
- method: "GET",
- mode: "cors",
+ method,
credentials: "include",
headers: {
"Content-Type": "application/x-www-form-urlencoded"
}
};
content.headers.CSRFPreventionToken = getCookie("CSRFPreventionToken");
+ if (body) {
+ content.body = prms.toString();
+ }
- const response = await request(`${window.DASH}/instances_fragment`, content);
+ const response = await request(`${window.DASH}${path}`, content);
return response;
}
@@ -351,6 +354,7 @@ export function isEmpty (obj) {
}
}
+/*
export function addResourceLine (resourceConfig, field, attributesOverride, labelPrefix = null) {
const iconHref = resourceConfig.icon;
const elementType = resourceConfig.element;
@@ -428,3 +432,4 @@ export function addResourceLine (resourceConfig, field, attributesOverride, labe
return { icon, label, element, unit };
}
+*/
diff --git a/web/templates/base.tmpl b/web/templates/base.tmpl
index 7539198..a708b40 100644
--- a/web/templates/base.tmpl
+++ b/web/templates/base.tmpl
@@ -21,12 +21,12 @@
{{end}}
\ No newline at end of file