mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-12-25 21:09:05 +01:00
templates for the login page
This commit is contained in:
parent
84c5cd47f6
commit
960b0245b2
10
templates/404.html
Normal file
10
templates/404.html
Normal file
@ -0,0 +1,10 @@
|
||||
{{template "base.html" .}}
|
||||
{{define "content"}}
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="alert alert-error" role="alert">
|
||||
404: Not found
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
24
templates/base.html
Normal file
24
templates/base.html
Normal file
@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset='utf-8'>
|
||||
<meta name='viewport' content='width=device-width,initial-scale=1'>
|
||||
<title>{{.Title}}</title>
|
||||
|
||||
<link rel='icon' type='image/png' href='/favicon.png'>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/css/bootstrap.min.css" integrity="sha384-F3w7mX95PdgyTmZZMECAngseQB83DfGTowi0iMjiWaeVhAn4FJkqJByhZMI3AhiU" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.4.1/font/bootstrap-icons.css">
|
||||
<link rel='stylesheet' href='/global.css'>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
{{block "content" .}}
|
||||
Whoops, you should not see this...
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
48
templates/login.html
Normal file
48
templates/login.html
Normal file
@ -0,0 +1,48 @@
|
||||
{{template "base.html" .}}
|
||||
{{define "content"}}
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h1>
|
||||
ClusterCockpit Login
|
||||
</h1>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
{{if .Login.Error}}
|
||||
<div class="alert alert-warning" role="alert">
|
||||
{{.Login.Error}}
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
{{if .Login.Info}}
|
||||
<div class="alert alert-success" role="alert">
|
||||
{{.Login.Info}}
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<form method="post" action="/login">
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="username">Username</label>
|
||||
<input class="form-control" type="text" id="username" name="username">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="password">Password</label>
|
||||
<input class="form-control" type="password" id="password" name="password">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Login</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<br/>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<form method="post" action="/logout">
|
||||
<button type="submit" class="btn btn-primary">Logout</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
29
templates/templates.go
Normal file
29
templates/templates.go
Normal file
@ -0,0 +1,29 @@
|
||||
package templates
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
var templates *template.Template
|
||||
|
||||
type Page struct {
|
||||
Title string
|
||||
Login *LoginPage
|
||||
}
|
||||
|
||||
type LoginPage struct {
|
||||
Error string
|
||||
Info string
|
||||
}
|
||||
|
||||
func init() {
|
||||
templates = template.Must(template.ParseGlob("./templates/*.html"))
|
||||
}
|
||||
|
||||
func Render(rw http.ResponseWriter, r *http.Request, name string, page *Page) {
|
||||
if err := templates.ExecuteTemplate(rw, name, page); err != nil {
|
||||
log.Printf("template error: %s\n", err.Error())
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user