-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreplication.go.html
More file actions
260 lines (251 loc) · 12.1 KB
/
Copy pathreplication.go.html
File metadata and controls
260 lines (251 loc) · 12.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
{{/* Copyright (c) ClaceIO, LLC */}}
{{/* SPDX-License-Identifier: Apache-2.0 */}}
{{/* Replication detail page (/replication): one row per prod app
replication target with the full entry detail, searchable by app
path. Linked from the overview replication tile.
HTMX partial: block repl_rows
*/}}
<!DOCTYPE html>
<html lang="en">
{{ template "head" . }}
<body class="min-h-screen bg-base-200">
<div class="drawer lg:drawer-open">
{{ template "drawer_toggle" }}
<div class="drawer-content">
<main class="p-4 lg:p-6 space-y-4 max-w-6xl">
<!-- Header -->
<div
class="page-header flex items-center gap-2 flex-wrap mb-2 md:mb-6">
{{ template "hamburger" . }}
<div>
{{ template "page_title" "OpenRun Replication" }}
<p class="page-desc text-sm text-base-content/70">
SQLite replication status
</p>
</div>
<div class="page-actions ml-auto flex items-center gap-2">
<label
class="input input-sm flex-1 min-w-0 sm:flex-none sm:w-48 sm:focus-within:w-60 transition-[width] duration-300 flex">
<kbd class="kbd kbd-xs hidden sm:inline-flex" aria-hidden="true"
>⌘K</kbd
>
<input
id="page-search"
type="search"
name="query"
aria-label="Filter by app"
value="{{ .Data.Query }}"
placeholder="Filter by app…"
hx-get="{{ .AppPath }}/replication"
hx-trigger="input changed delay:300ms, search"
hx-push-url="true"
hx-target="#repl-rows"
hx-swap="innerHTML"
hx-indicator="#page-progress" />
</label>
</div>
</div>
{{ template "page_progress" }}
<!-- Replication target rows -->
<div id="repl-rows" class="space-y-4">
{{ block "repl_rows" . }}
{{ template "flash_alerts" .Data }}
{{ if .Data.Rows }}
<div class="card bg-base-100 border border-base-300">
<div
class="px-4 py-2.5 border-b border-base-300 flex items-center gap-2 flex-wrap">
<h2 class="text-sm font-medium">Prod app replication</h2>
<span class="text-xs text-base-content/70"
>{{ .Data.Total }}
targets{{ if .Data.Unhealthy }}
·
<span class="text-error"
>{{ .Data.Unhealthy }} unhealthy</span
>
{{ end }}</span
>
</div>
<div class="overflow-x-auto">
<table class="table table-sm">
<thead>
<tr>
<th scope="col" class="w-8">
<span class="sr-only">Details</span>
</th>
<th scope="col">State</th>
<th scope="col">App</th>
<th scope="col" class="hidden sm:table-cell">
Last sync
</th>
<th scope="col" class="hidden md:table-cell">
Sidecar
</th>
<th scope="col" class="hidden md:table-cell">Size</th>
<th scope="col" class="hidden lg:table-cell">
Databases
</th>
<th scope="col">Replica target</th>
</tr>
</thead>
<tbody>
{{ range .Data.Rows }}
<tr class="group hover:bg-base-200/60">
<td class="w-8">
{{/* Drill-down into the litestream sidecar
container; empty when there is no separate
sidecar container (kubernetes, or the
container feature/permission is off)
*/}}
{{ if .container_id }}
<a
href="{{ $.AppPath }}/containers/detail?id={{ .container_id }}"
class="btn btn-xs btn-ghost btn-square tooltip tooltip-right"
data-tip="Expand: litestream sidecar container - stats and logs"
aria-label="View the litestream sidecar container for {{ .app_path }}">
{{ template "drilldown_icon" }}
</a>
{{ end }}
</td>
<td class="whitespace-nowrap">
{{ if .unhealthy }}
<span class="status status-error"></span>
<span
class="text-xs text-error"
{{ if .error }}title="{{ .error }}"{{ end }}
>{{ .state }}</span
>
{{ else if eq .state "syncing" }}
<span class="status status-warning"></span>
<span class="text-xs">{{ .state }}</span>
{{ else if eq .state "pending" }}
<span class="status"></span>
<span class="text-xs">{{ .state }}</span>
{{ else }}
<span class="status status-success"></span>
<span class="text-xs">{{ .state }}</span>
{{ end }}
</td>
<td>
{{/* break-all needs a min-width floor: table
auto-layout otherwise squeezes the column to
one-character slivers on mobile
*/}}
<span
class="font-mono text-xs font-medium break-all inline-block min-w-40 align-bottom"
>{{ .app_path }}<a
href="{{ $.AppPath }}/apps/detail?path={{ .app_path }}"
aria-label="View details for {{ .app_path }}"
class="inline-block text-primary text-xs opacity-0 -translate-x-1 group-hover:opacity-100 group-hover:translate-x-0.5 transition-all duration-200 ml-0.5"
><span aria-hidden="true">↗</span></a
></span
>
</td>
<td
class="text-xs text-base-content/70 hidden sm:table-cell whitespace-nowrap">
{{ if .last_sync }}
{{ template "time_ago" .last_sync }}
{{ else }}
never
{{ end }}
</td>
<td
class="text-xs hidden md:table-cell whitespace-nowrap {{ if eq .sidecar "down" }}
text-error
{{ else }}
text-base-content/70
{{ end }}">
{{ if .sidecar }}
{{ .sidecar }}
{{ else }}
<span
class="tooltip tooltip-right"
data-tip="the sidecar runs inside the app pod on kubernetes"
>-</span
>
{{ end }}
</td>
<td
class="text-xs text-base-content/70 hidden md:table-cell whitespace-nowrap tabular-nums">
{{ if .size }}
{{ .size }}
{{ else }}
-
{{ end }}
</td>
<td
class="text-xs text-base-content/70 hidden lg:table-cell">
{{ if .files }}
<ul>
{{ range .files }}
<li class="whitespace-nowrap">
<span class="font-mono">{{ .path }}</span>
<span class="tabular-nums"
>{{ .size }}</span
>
{{ if .last_sync }}
·
{{ template "time_ago" .last_sync }}
{{ end }}
</li>
{{ end }}
</ul>
{{ else }}
-
{{ end }}
</td>
<td>
<span
class="font-mono text-xs break-all inline-block min-w-40 max-w-80"
>{{ .target }}</span
>
{{ if .error }}
<div
class="text-xs text-error break-all min-w-40 max-w-80">
{{ .error }}
</div>
{{ end }}
</td>
</tr>
{{ end }}
</tbody>
</table>
</div>
</div>
{{ else if not .Data.FlashError }}
<div class="card bg-base-100 border border-base-300 py-10">
<div
class="flex flex-col items-center gap-2 text-center text-sm text-base-content/70">
{{ if .Data.Query }}
<span class="text-xl" aria-hidden="true">🔍</span>
<p>No prod apps match "{{ .Data.Query }}"</p>
<button
class="btn btn-xs btn-outline transition-transform duration-150 active:scale-95"
onclick="const s = document.getElementById('page-search'); if (s) s.value = ''"
hx-get="{{ .AppPath }}/replication"
hx-vals='{"query": ""}'
hx-target="#repl-rows"
hx-swap="innerHTML"
hx-push-url="true"
hx-indicator="#page-progress">
Clear search
</button>
{{ else }}
<span class="text-xl" aria-hidden="true">💾</span>
<p>No replicated sqlite bindings</p>
<p class="text-xs text-base-content/70">
Prod apps with a replicated sqlite binding report their
replica state here
</p>
{{ end }}
</div>
</div>
{{ end }}
{{ end }}
<!-- End of "repl_rows" block -->
</div>
</main>
</div>
{{ template "sidebar" . }}
</div>
</body>
</html>