simplify front end routes,

simplify ssr fragment fetch methods
This commit is contained in:
2025-04-15 17:13:22 +00:00
parent 844cf4dfb9
commit 099f9c4e42
9 changed files with 33 additions and 23 deletions

View File

@@ -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)))
}

View File

@@ -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
}
}

View File

@@ -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)
}

View File

@@ -15,6 +15,6 @@ func HandleGETSettings(c *gin.Context) {
"page": "settings",
})
} else {
c.Redirect(http.StatusFound, "/login.html")
c.Redirect(http.StatusFound, "/login")
}
}