use HTTPExecuteHTMLTemplate and HTTPExecuteHTMLFragmentTemplate
tronnet/workflows: Static Analysis -- Golang / static-go (push) Successful in 26s
tronnet/workflows: Static Analysis -- Golang / static-go (push) Successful in 26s
This commit is contained in:
1 parent
4743bcf756
commit
b32a391022
7 files changed
+15
-127
No files matched your search
+1
-11
@@ -1,7 +1,6 @@
|
|||||||
package routes
|
package routes
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
paas "proxmoxaas-common-lib"
|
paas "proxmoxaas-common-lib"
|
||||||
@@ -55,21 +54,12 @@ func HandleGETAccount(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "text/html")
|
paas.HTTPExecuteHTMLTemplate(w, common.TMPL, "html/account.html", map[string]any{
|
||||||
body := bytes.Buffer{}
|
|
||||||
err = common.TMPL.ExecuteTemplate(&body, "html/account.html", map[string]any{
|
|
||||||
"global": common.Global,
|
"global": common.Global,
|
||||||
"page": "account",
|
"page": "account",
|
||||||
"user": user,
|
"user": user,
|
||||||
"pools": pools,
|
"pools": pools,
|
||||||
})
|
})
|
||||||
if err != nil {
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
w.Write(body.Bytes())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
http.Redirect(w, r, "/login", http.StatusFound) // if user is not authed, redirect user to login page
|
http.Redirect(w, r, "/login", http.StatusFound) // if user is not authed, redirect user to login page
|
||||||
return
|
return
|
||||||
|
|||||||
+2
-21
@@ -1,7 +1,6 @@
|
|||||||
package routes
|
package routes
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
paas "proxmoxaas-common-lib"
|
paas "proxmoxaas-common-lib"
|
||||||
@@ -41,21 +40,12 @@ func HandleGETBackups(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "text/html")
|
paas.HTTPExecuteHTMLTemplate(w, common.TMPL, "html/backups.html", map[string]any{
|
||||||
body := bytes.Buffer{}
|
|
||||||
err = common.TMPL.ExecuteTemplate(&body, "html/index.html", map[string]any{
|
|
||||||
"global": common.Global,
|
"global": common.Global,
|
||||||
"page": "backups",
|
"page": "backups",
|
||||||
"backups": backups,
|
"backups": backups,
|
||||||
"config": config,
|
"config": config,
|
||||||
})
|
})
|
||||||
if err != nil {
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
w.Write(body.Bytes())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
http.Redirect(w, r, "/login", http.StatusFound)
|
http.Redirect(w, r, "/login", http.StatusFound)
|
||||||
return
|
return
|
||||||
@@ -77,18 +67,9 @@ func HandleGETBackupsFragment(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "text/plain")
|
paas.HTTPExecuteHTMLFragmentTemplate(w, common.TMPL, "html/backups-backups.go.tmpl", map[string]any{
|
||||||
body := bytes.Buffer{}
|
|
||||||
err = common.TMPL.ExecuteTemplate(&body, "html/backups-backups.go.tmpl", map[string]any{
|
|
||||||
"backups": backups,
|
"backups": backups,
|
||||||
})
|
})
|
||||||
if err != nil {
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
w.Write(body.Bytes())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
} else { // return 401
|
} else { // return 401
|
||||||
w.WriteHeader(http.StatusUnauthorized)
|
w.WriteHeader(http.StatusUnauthorized)
|
||||||
return
|
return
|
||||||
|
|||||||
+5
-51
@@ -1,7 +1,6 @@
|
|||||||
package routes
|
package routes
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
paas "proxmoxaas-common-lib"
|
paas "proxmoxaas-common-lib"
|
||||||
@@ -59,20 +58,11 @@ func HandleGETConfig(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "text/html")
|
paas.HTTPExecuteHTMLTemplate(w, common.TMPL, "html/config.html", map[string]any{
|
||||||
body := bytes.Buffer{}
|
|
||||||
err = common.TMPL.ExecuteTemplate(&body, "html/config.html", map[string]any{
|
|
||||||
"global": common.Global,
|
"global": common.Global,
|
||||||
"page": "config",
|
"page": "config",
|
||||||
"config": config,
|
"config": config,
|
||||||
})
|
})
|
||||||
if err != nil {
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
w.Write(body.Bytes())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
http.Redirect(w, r, "/login", http.StatusFound)
|
http.Redirect(w, r, "/login", http.StatusFound)
|
||||||
return
|
return
|
||||||
@@ -94,18 +84,9 @@ func HandleGETConfigVolumesFragment(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "text/plain")
|
paas.HTTPExecuteHTMLFragmentTemplate(w, common.TMPL, "html/config-volumes.go.tmpl", map[string]any{
|
||||||
body := bytes.Buffer{}
|
|
||||||
err = common.TMPL.ExecuteTemplate(&body, "html/config-volumes.go.tmpl", map[string]any{
|
|
||||||
"config": config,
|
"config": config,
|
||||||
})
|
})
|
||||||
if err != nil {
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
w.Write(body.Bytes())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
w.WriteHeader(http.StatusUnauthorized)
|
w.WriteHeader(http.StatusUnauthorized)
|
||||||
return
|
return
|
||||||
@@ -127,18 +108,9 @@ func HandleGETConfigNetsFragment(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "text/plain")
|
paas.HTTPExecuteHTMLFragmentTemplate(w, common.TMPL, "html/config-nets.go.tmpl", map[string]any{
|
||||||
body := bytes.Buffer{}
|
|
||||||
err = common.TMPL.ExecuteTemplate(&body, "html/config-nets.go.tmpl", map[string]any{
|
|
||||||
"config": config,
|
"config": config,
|
||||||
})
|
})
|
||||||
if err != nil {
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
w.Write(body.Bytes())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
} else { // return 401
|
} else { // return 401
|
||||||
w.WriteHeader(http.StatusUnauthorized)
|
w.WriteHeader(http.StatusUnauthorized)
|
||||||
return
|
return
|
||||||
@@ -160,18 +132,9 @@ func HandleGETConfigDevicesFragment(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "text/plain")
|
paas.HTTPExecuteHTMLFragmentTemplate(w, common.TMPL, "html/config-devices.go.tmpl", map[string]any{
|
||||||
body := bytes.Buffer{}
|
|
||||||
err = common.TMPL.ExecuteTemplate(&body, "html/config-devices.go.tmpl", map[string]any{
|
|
||||||
"config": config,
|
"config": config,
|
||||||
})
|
})
|
||||||
if err != nil {
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
w.Write(body.Bytes())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
} else { // return 401
|
} else { // return 401
|
||||||
w.WriteHeader(http.StatusUnauthorized)
|
w.WriteHeader(http.StatusUnauthorized)
|
||||||
return
|
return
|
||||||
@@ -193,18 +156,9 @@ func HandleGETConfigBootFragment(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "text/plain")
|
paas.HTTPExecuteHTMLFragmentTemplate(w, common.TMPL, "html/config-boot.go.tmpl", map[string]any{
|
||||||
body := bytes.Buffer{}
|
|
||||||
err = common.TMPL.ExecuteTemplate(&body, "html/config-boot.go.tmpl", map[string]any{
|
|
||||||
"config": config,
|
"config": config,
|
||||||
})
|
})
|
||||||
if err != nil {
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
w.Write(body.Bytes())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
} else { // return 401
|
} else { // return 401
|
||||||
w.WriteHeader(http.StatusUnauthorized)
|
w.WriteHeader(http.StatusUnauthorized)
|
||||||
return
|
return
|
||||||
|
|||||||
+2
-21
@@ -1,7 +1,6 @@
|
|||||||
package routes
|
package routes
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
paas "proxmoxaas-common-lib"
|
paas "proxmoxaas-common-lib"
|
||||||
@@ -59,16 +58,7 @@ func HandleGETIndex(w http.ResponseWriter, r *http.Request) {
|
|||||||
"instances": instances,
|
"instances": instances,
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "text/html")
|
paas.HTTPExecuteHTMLTemplate(w, common.TMPL, "html/index.html", page)
|
||||||
body := bytes.Buffer{}
|
|
||||||
err = common.TMPL.ExecuteTemplate(&body, "html/index.html", page)
|
|
||||||
if err != nil {
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
w.Write(body.Bytes())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
} else { // return index without populating
|
} else { // return index without populating
|
||||||
http.Redirect(w, r, "/login", http.StatusFound)
|
http.Redirect(w, r, "/login", http.StatusFound)
|
||||||
return
|
return
|
||||||
@@ -84,18 +74,9 @@ func HandleGETInstancesFragment(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "text/plain")
|
paas.HTTPExecuteHTMLFragmentTemplate(w, common.TMPL, "html/index-instances.go.tmpl", map[string]any{
|
||||||
body := bytes.Buffer{}
|
|
||||||
err = common.TMPL.ExecuteTemplate(&body, "html/index-instances.go.tmpl", map[string]any{
|
|
||||||
"instances": instances,
|
"instances": instances,
|
||||||
})
|
})
|
||||||
if err != nil {
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
w.Write(body.Bytes())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
} else { // return 401
|
} else { // return 401
|
||||||
w.WriteHeader(http.StatusUnauthorized)
|
w.WriteHeader(http.StatusUnauthorized)
|
||||||
return
|
return
|
||||||
|
|||||||
+2
-11
@@ -1,9 +1,9 @@
|
|||||||
package routes
|
package routes
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
paas "proxmoxaas-common-lib"
|
||||||
"proxmoxaas-dashboard/app/common"
|
"proxmoxaas-dashboard/app/common"
|
||||||
|
|
||||||
"github.com/go-viper/mapstructure/v2"
|
"github.com/go-viper/mapstructure/v2"
|
||||||
@@ -61,18 +61,9 @@ func HandleGETLogin(w http.ResponseWriter, r *http.Request) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "text/html")
|
paas.HTTPExecuteHTMLTemplate(w, common.TMPL, "html/login.html", map[string]any{
|
||||||
body := bytes.Buffer{}
|
|
||||||
err = common.TMPL.ExecuteTemplate(&body, "html/login.html", map[string]any{
|
|
||||||
"global": common.Global,
|
"global": common.Global,
|
||||||
"page": "login",
|
"page": "login",
|
||||||
"realms": sel,
|
"realms": sel,
|
||||||
})
|
})
|
||||||
if err != nil {
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
w.Write(body.Bytes())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+2
-11
@@ -1,8 +1,8 @@
|
|||||||
package routes
|
package routes
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
paas "proxmoxaas-common-lib"
|
||||||
"proxmoxaas-dashboard/app/common"
|
"proxmoxaas-dashboard/app/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -15,19 +15,10 @@ func HandleGETSettings(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "text/html")
|
paas.HTTPExecuteHTMLTemplate(w, common.TMPL, "html/settings.html", map[string]any{
|
||||||
body := bytes.Buffer{}
|
|
||||||
err = common.TMPL.ExecuteTemplate(&body, "html/settings.html", map[string]any{
|
|
||||||
"global": common.Global,
|
"global": common.Global,
|
||||||
"page": "settings",
|
"page": "settings",
|
||||||
})
|
})
|
||||||
if err != nil {
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
w.Write(body.Bytes())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
http.Redirect(w, r, "/login", http.StatusFound)
|
http.Redirect(w, r, "/login", http.StatusFound)
|
||||||
return
|
return
|
||||||
|
|||||||
+1
-1
Submodule proxmoxaas-common-lib updated: 8284ffbc43...01c1f0389a.
Reference in new issue
Block a user