Skip to content

Commit 92e82f2

Browse files
committed
feat: Add Header
1 parent 42bb031 commit 92e82f2

File tree

4 files changed

+52
-27
lines changed

4 files changed

+52
-27
lines changed

internal/config/config.go

+6
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ type UI struct {
3838
RefreshInterval time.Duration `yaml:"refresh"`
3939
Graphs Graphs `yaml:"graphs"`
4040
Theme string `yaml:"theme"`
41+
Header UIHeader `yaml:"header`
42+
}
43+
44+
type UIHeader struct {
45+
Enabled bool `yaml:"enabled"`
46+
Logo string `yaml:"logo"`
4147
}
4248

4349
type Metrics struct {

internal/resources/views/base.html

+34-19
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,37 @@
11
<!DOCTYPE html>
2-
<html lang="en" {{ if ne .Config.UI.Theme "auto" }}class="{{ .Config.UI.Theme }}"{{ end }}>
3-
<head>
4-
<meta charset="UTF-8">
5-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6-
<link rel="stylesheet" href="/static/tailwind.css?v={{ .Version }}" />
7-
<link rel="icon" type="image/png" href="/static/icon.png" />
8-
<title>{{ .Config.UI.PageTitle }}</title>
9-
</head>
10-
<body class="mx-auto min-h-dvh w-full md:w-3/4 p-6 md:p-8 lg:p-6 lg:w-1/2 flex flex-col justify-between bg-neutral-50 dark:bg-zinc-900">
11-
<div>
12-
{{ template "content" . }}
13-
</div>
2+
<html lang="en" {{ if ne .Config.UI.Theme "auto" }}class="{{ .Config.UI.Theme }}" {{ end }}>
143

15-
<div class="mt-6 text-center text-gray-400 dark:text-gray-200">
16-
Built with <a class="text-avocado-600 hover:text-avocado-500" href="https://github.com/henrywhitaker3/prompage">PromPage</a> |
17-
Checked {{ .Age }} ago
18-
</div>
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<link rel="stylesheet" href="/static/tailwind.css?v={{ .Version }}" />
8+
<link rel="icon" type="image/png" href="/static/icon.png" />
9+
<title>{{ .Config.UI.PageTitle }}</title>
10+
</head>
1911

20-
{{ template "scripts" . }}
21-
</body>
22-
</html>
12+
<body
13+
class="mx-auto min-h-dvh w-full md:w-3/4 p-6 md:p-8 lg:p-6 lg:w-1/2 flex flex-col justify-between bg-neutral-50 dark:bg-zinc-900">
14+
{{ if .Config.UI.Header.Enabled }}
15+
<div class="mb-4">
16+
<a class="flex flex-row items-center" href="/" title="{{ .Config.UI.PageTitle }}">
17+
{{ if ne .Config.UI.Header.Logo "" }}
18+
<img class="max-h-[100px]" src="{{ .Config.UI.Header.Logo }}" />
19+
{{ end }}
20+
<h1 class="text-4xl text-black dark:text-white">{{ .Config.UI.PageTitle }}</h1>
21+
</a>
22+
</div>
23+
{{ end }}
24+
<div>
25+
{{ template "content" . }}
26+
</div>
27+
28+
<div class="mt-6 text-center text-gray-400 dark:text-gray-200">
29+
Built with <a class="text-avocado-600 hover:text-avocado-500"
30+
href="https://github.com/henrywhitaker3/prompage">PromPage</a> |
31+
Checked {{ .Age }} ago
32+
</div>
33+
34+
{{ template "scripts" . }}
35+
</body>
36+
37+
</html>

internal/resources/views/service.html

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
{{- if not (eq .Graph "") }}
33
<div class="flex flex-col justify-between items-center">
44
<div class="w-full flex flex-col md:flex-row justify-center md:items-baseline items-center mb-6">
5-
<h1 class="text-xl font-bold md:inline-block md:mr-2 text-avocado-800 dark:text-avocado-100" >{{ .Result.Service.Name }}</h1>
6-
<span class="text-gray-500 dark:text-gray-300 text-sm">{{ $.Sprintf "%.2f" .Result.Uptime }}% over the last {{ $.PrettyDuration .Result.Service.Query.Range }}</span>
5+
<h1 class="text-xl font-bold md:inline-block md:mr-2 text-avocado-800 dark:text-avocado-100">{{
6+
.Result.Service.Name }}</h1>
7+
<span class="text-gray-500 dark:text-gray-300 text-sm">{{ $.Sprintf "%.2f" .Result.Uptime }}% over the last {{
8+
$.PrettyDuration .Result.Service.Query.Range }}</span>
79
</div>
810

911
<div class="h-64 md:h-96 w-full border border-gray-200 dark:border-none dark:bg-zinc-800 rounded-md shadow-md mb-6">
@@ -23,4 +25,4 @@ <h2 class="text-center text-avocado-800 dark:text-avocado-100">{{ $name }}</h2>
2325
{{- end }}
2426

2527
{{- define "scripts"}}
26-
{{- end }}
28+
{{- end }}

internal/resources/views/status.html

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
21
{{- define "content" }}
3-
<div class="flex flex-col justify-center items-center py-6 mb-6 w-full rounded-md shadow-md text-xl {{ .BannerClasses }}">
2+
<div
3+
class="flex flex-col justify-center items-center py-6 mb-6 w-full rounded-md shadow-md text-xl {{ .BannerClasses }}">
44
{{- if eq .Outage "None" }}
55
All Systems Operational
66
{{- else }}
@@ -19,8 +19,10 @@ <h2 class="text-xl mb-2 pl-1 text-avocado-800 dark:text-avocado-100">{{ .Name }}
1919
<a href="/{{ .Service.Name }}" class="block w-full">
2020
<div class="flex justify-between items-center w-full py-6 px-6 md:px-8 lg:px-12 border-b border-gray-200 dark:border-none">
2121
<div>
22-
<h3 class="text-lg font-bold md:inline-block md:mr-2 text-avocado-800 dark:text-avocado-100" >{{ .Service.Name }}</h3>
23-
<span class="text-gray-500 dark:text-gray-300 text-sm">{{ $.Sprintf "%.2f" .Uptime }}% over the last {{ $.PrettyDuration .Service.Query.Range }}</span>
22+
<h3 class="text-lg font-bold md:inline-block md:mr-2 text-avocado-800 dark:text-avocado-100">{{
23+
.Service.Name }}</h3>
24+
<span class="text-gray-500 dark:text-gray-300 text-sm">{{ $.Sprintf "%.2f" .Uptime }}% over the last
25+
{{ $.PrettyDuration .Service.Query.Range }}</span>
2426
</div>
2527
<div>
2628
{{- if not .Success }}
@@ -44,4 +46,4 @@ <h3 class="text-lg font-bold md:inline-block md:mr-2 text-avocado-800 dark:text-
4446
<script>
4547
setTimeout(() => { location.reload() }, {{ .Refresh }})
4648
</script>
47-
{{- end}}
49+
{{- end}}

0 commit comments

Comments
 (0)