Format message.tmpl

This commit is contained in:
Christoph Kluge 2023-06-23 09:42:31 +02:00
parent 1761754865
commit 3c26deda30
2 changed files with 36 additions and 5 deletions

View File

@ -304,7 +304,7 @@ func HandleSearchBar(rw http.ResponseWriter, r *http.Request, buildInfo web.Buil
} }
} }
default: default:
web.RenderTemplate(rw, r, "message.tmpl", &web.Page{Title: "Warning", MsgType: "alert-warning", Message: fmt.Sprintf("Unknown search term %s", strings.Trim(splitSearch[0], " ")), User: *user, Roles: availableRoles, Build: buildInfo}) web.RenderTemplate(rw, r, "message.tmpl", &web.Page{Title: "Warning", MsgType: "alert-warning", Message: fmt.Sprintf("Unknown search type: %s", strings.Trim(splitSearch[0], " ")), User: *user, Roles: availableRoles, Build: buildInfo})
} }
} else if len(splitSearch) == 1 { } else if len(splitSearch) == 1 {

View File

@ -1,11 +1,42 @@
{{define "content"}} {{define "content"}}
<div class="row"> <div class="row">
<div class="col"> <div class="col messageCol">
<h2>{{.Title}}</h2> <div class="alert messageCard {{.MsgType}}" role="alert">
<div class="alert {{.MsgType}}" role="alert"> {{if eq .MsgType "alert-info"}}
{{.Message}} <i class="bi-info-circle-fill messageIcon"></i>
<b>{{.Message}}</b>
{{else if eq .MsgType "alert-warning"}}
<i class="bi-question-circle-fill messageIcon"></i>
<b>{{.Message}}</b>
{{else if eq .MsgType "alert-danger"}}
<i class="bi-exclamation-circle-fill messageIcon"></i>
<b>{{.Message}}</b>
{{end}}
</div> </div>
</div> </div>
</div> </div>
{{end}} {{end}}
{{define "stylesheets"}}
<style>
.messageCol {
display: flex;
justify-content: center;
}
.messageCard {
display: flex;
justify-content: center;
align-items: center;
width: 50%;
padding-top: 2rem;
padding-bottom: 2rem;
}
.messageIcon {
font-size: 2rem;
margin-right:1rem;
}
</style>
{{end}}