switch to gin, add basic server redering to login
This commit is contained in:
@@ -17,7 +17,5 @@ var Modules_fs embed.FS
|
||||
var Scripts_fs embed.FS
|
||||
|
||||
//go:embed html/*
|
||||
var HTML embed.FS
|
||||
|
||||
//go:embed templates/*
|
||||
var Templates embed.FS
|
||||
|
@@ -12,14 +12,14 @@
|
||||
</header>
|
||||
<main class="flex" style="justify-content: center; align-items: center;">
|
||||
<div class="w3-container w3-card w3-margin w3-padding" style="height: fit-content;">
|
||||
<h2 class="w3-center">{{.Organization}} Login</h2>
|
||||
<h2 class="w3-center">{{.global.Organization}} Login</h2>
|
||||
<form>
|
||||
<label for="username"><b>Username</b></label>
|
||||
<input class="w3-input w3-border" id="username" name="username" type="text" autocomplete="username">
|
||||
<label for="password"><b>Password</b></label>
|
||||
<input class="w3-input w3-border" id="password" name="password" type="password" autocomplete="current-password">
|
||||
<label for="realm">Realm</label>
|
||||
<select class="w3-select w3-border" id="realm" name="realm"></select>
|
||||
{{template "select" .realms}}
|
||||
<div class="w3-center">
|
||||
<button class="w3-button w3-margin" id="submit" type="submit">LOGIN</button>
|
||||
</div>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { goToPage, requestPVE, setAppearance, requestAPI } from "./utils.js";
|
||||
import { goToPage, setAppearance, requestAPI } from "./utils.js";
|
||||
import { alert } from "./dialog.js";
|
||||
|
||||
window.addEventListener("DOMContentLoaded", init);
|
||||
@@ -7,14 +7,6 @@ async function init () {
|
||||
await deleteAllCookies();
|
||||
setAppearance();
|
||||
const formSubmitButton = document.querySelector("#submit");
|
||||
const realms = await requestPVE("/access/domains", "GET");
|
||||
const realmSelect = document.querySelector("#realm");
|
||||
realms.data.forEach((element) => {
|
||||
realmSelect.add(new Option(element.comment, element.realm));
|
||||
if ("default" in element && element.default === 1) {
|
||||
realmSelect.value = element.realm;
|
||||
}
|
||||
});
|
||||
formSubmitButton.addEventListener("click", async (e) => {
|
||||
e.preventDefault();
|
||||
const form = document.querySelector("form");
|
||||
|
@@ -1,13 +1,13 @@
|
||||
{{define "head"}}
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{{.Organization}} - dashboard</title>
|
||||
<title>{{.global.Organization}} - dashboard</title>
|
||||
<link rel="icon" href="images/favicon.svg" sizes="any" type="image/svg+xml">
|
||||
<link rel="stylesheet" href="modules/w3.css">
|
||||
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
|
||||
<script>
|
||||
window.PVE = "{{.PVE}}";
|
||||
window.API = "{{.API}}";
|
||||
window.PVE = "{{.global.PVE}}";
|
||||
window.API = "{{.global.API}}";
|
||||
</script>
|
||||
<link rel="stylesheet" href="css/style.css">
|
||||
<link rel="stylesheet" href="css/nav.css">
|
||||
@@ -15,16 +15,16 @@
|
||||
{{end}}
|
||||
|
||||
{{define "header"}}
|
||||
<h1>{{.Organization}}</h1>
|
||||
<h1>{{.global.Organization}}</h1>
|
||||
<label for="navtoggle">☰</label>
|
||||
<input type="checkbox" id="navtoggle">
|
||||
<nav id="navigation">
|
||||
{{if eq .Page "login"}}
|
||||
{{if eq .page "login"}}
|
||||
<a href="login.html" aria-current="page">Login</a>
|
||||
{{else}}
|
||||
<a href="index.html" {{if eq .Page "index"}} aria-current="page" {{end}}>Instances</a>
|
||||
<a href="account.html" {{if eq .Page "account"}} aria-current="page" {{end}}>Account</a>
|
||||
<a href="settings.html" {{if eq .Page "settings"}} aria-current="page" {{end}}>Settings</a>
|
||||
<a href="index.html" {{if eq .page "index"}} aria-current="page" {{end}}>Instances</a>
|
||||
<a href="account.html" {{if eq .page "account"}} aria-current="page" {{end}}>Account</a>
|
||||
<a href="settings.html" {{if eq .page "settings"}} aria-current="page" {{end}}>Settings</a>
|
||||
<a href="login.html">Logout</a>
|
||||
{{end}}
|
||||
</nav>
|
11
web/templates/select.tmpl
Normal file
11
web/templates/select.tmpl
Normal file
@@ -0,0 +1,11 @@
|
||||
{{define "select"}}
|
||||
<select class="w3-select w3-border" id="{{.ID}}" name="{{.Name}}">
|
||||
{{range .Options}}
|
||||
{{if .Selected}}
|
||||
<option value="{{.Value}}" selected>{{.Display}}</option>
|
||||
{{else}}
|
||||
<option value="{{.Value}}">{{.Display}}</option>
|
||||
{{end}}
|
||||
{{end}}
|
||||
</select>
|
||||
{{end}}
|
Reference in New Issue
Block a user