Repository navigation
Expand file tree
/
Copy pathconfig.go.html
More file actions
202 lines (195 loc) · 9.97 KB
/
Copy pathconfig.go.html
File metadata and controls
202 lines (195 loc) · 9.97 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
{{/* Copyright (c) ClaceIO, LLC */}}
{{/* SPDX-License-Identifier: Apache-2.0 */}}
{{/* Configuration page (/config): overview of the config areas, one card per
sub page. RBAC has the staged-update workflow; the other sub pages
(authentication, remote management API, MCP API, git auth, secrets,
system settings, app builder) hold dynamic entries/settings which take
effect immediately on save and override the static openrun.toml values;
the RBAC card renders second, after Authentication. Ends with the config history with restore.
HTMX partial: block config_content
*/}}
{{ template "page_open" (dict "Ctx" . "Main" "max-w-6xl") }}
<div id="config-content" class="space-y-4">
{{ block "config_content" . }}
<!-- Header -->
<div
class="page-header flex items-center gap-2 flex-wrap mb-2 md:mb-6">
{{ template "hamburger" . }}
<div>
{{ template "page_title" "Configuration" }}
<p class="page-desc text-sm text-base-content/70">
Server configuration - changes are live immediately
</p>
</div>
</div>
{{ template "page_progress" }}
{{ if .Data.Error }}
{{ template "error_alert" .Data.Error }}
{{ else }}
{{ template "flash_alerts" .Data }}
<!-- Config areas -->
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<!-- Sub page cards -->
{{ range .Data.Pages }}
<div class="card bg-base-100 border border-base-300">
<div class="card-body p-4 gap-2">
<div class="flex items-center gap-2 flex-wrap">
<h2 class="text-sm font-medium">{{ .title }}</h2>
{{ if .has_entries }}
<span class="badge badge-ghost badge-sm"
>{{ template "count" (dict "N" .entry_count "One" "entry" "Many" "entries") }}</span
>
{{ end }}
{{ if .dynamic_count }}
<span
class="badge badge-soft badge-primary badge-sm tooltip tooltip-top"
data-tip="dynamic values overriding openrun.toml"
>{{ .dynamic_count }} dynamic</span
>
{{ end }}
<a
href="{{ $.AppPath }}/config/{{ .page }}"
class="btn btn-xs btn-outline ml-auto">
Manage
</a>
</div>
<p class="text-xs text-base-content/70">
{{ .desc }}
</p>
</div>
</div>
{{ if eq .page "auth" }}
{{/* RBAC follows Authentication (the order is the
CONFIG_PAGES order, RBAC is not one of them) */}}
{{ template "config_rbac_card" $ }}
{{ end }}
{{ end }}
</div>
<!-- Config history -->
<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">
<h2 class="text-sm font-medium">History</h2>
<span class="text-xs text-base-content/70"
>{{ len .Data.History }} config versions - restoring
creates a new version</span
>
</div>
{{ if .Data.History }}
<div class="overflow-x-auto">
<table class="table table-sm">
<thead>
<tr>
<th scope="col">Version</th>
<th scope="col" class="hidden sm:table-cell">By</th>
<th scope="col">When</th>
<th scope="col" class="text-right">Actions</th>
</tr>
</thead>
<tbody>
{{ range $i, $h := .Data.History }}
<tr
class="group hover:bg-base-200/60 {{ if eq $h.version_id $.Data.VersionId }}
bg-success/5
{{ end }}">
<td class="font-mono text-xs">
{{ trunc 16 $h.version_id }}…
{{ if eq $h.version_id $.Data.VersionId }}
<span
class="badge badge-success badge-xs badge-soft"
>live</span
>
{{ end }}
</td>
<td class="text-xs text-base-content/70 hidden sm:table-cell">
{{ if $h.user_id }}
{{ $h.user_id }}
{{ else }}
-
{{ end }}
</td>
<td class="text-xs text-base-content/70">
{{ template "time_ago" $h.update_time }}
</td>
<td class="text-right whitespace-nowrap">
<a
href="{{ $.AppPath }}/config/history?version={{ $h.version_id }}"
class="btn btn-xs btn-ghost tooltip tooltip-left"
data-tip="View this config snapshot as JSON">
view
</a>
{{ if ne $h.version_id $.Data.VersionId }}
<button
class="btn btn-xs btn-ghost text-primary"
{{ if index $.Data.Perms "config:update" }}
hx-post="{{ $.AppPath }}/config/action"
hx-vals='{"action": "restore",
"restore_version": "{{ $h.version_id }}"}'
hx-confirm="Restore the full configuration
(RBAC and dynamic entries) from this
snapshot? It is validated and written as a
new version." hx-target="#config-content"
hx-swap="innerHTML"
hx-disable="this"
hx-indicator="#page-progress"
{{ else }}
disabled data-tip="requires config:update"
{{ end }}>
restore
</button>
{{ end }}
</td>
</tr>
{{ end }}
</tbody>
</table>
</div>
{{ else }}
<p class="text-sm text-base-content/70 px-4 py-4">
No configuration changes recorded yet
</p>
{{ end }}
</div>
{{ end }}
{{ end }}
<!-- End of "config_content" block -->
</div>
{{ template "page_close" . }}
{{/* config_rbac_card: the RBAC summary card of the config index (RBAC has
the staged-update workflow, not a CONFIG_PAGES entry). Page-local define;
context is the page context */}}
{{ define "config_rbac_card" }}
<!-- RBAC summary card -->
<div class="card bg-base-100 border border-base-300">
<div class="card-body p-4 gap-2">
<div class="flex items-center gap-2 flex-wrap">
<h2 class="text-sm font-medium">RBAC</h2>
{{ if not .AppRBACEnabled }}
<span
class="badge badge-warning badge-sm badge-soft tooltip tooltip-top"
data-tip="security.unsafe_disable_rbac is set on this server: grants are not enforced"
>not enforced</span
>
{{ end }}
{{ if .Data.RBAC.has_staged }}
<span
class="badge badge-warning badge-sm badge-soft tooltip tooltip-top"
data-tip="staged changes by {{ .Data.RBAC.staged_by }} pending publish"
>pending</span
>
{{ end }}
<a
href="{{ .AppPath }}/config/rbac"
class="btn btn-xs btn-outline ml-auto">
Manage
</a>
</div>
<p class="text-xs text-base-content/70">
Role based access control - {{ template "count" (dict "N" .Data.RBAC.groups "One" "group") }},
{{ template "count" (dict "N" .Data.RBAC.roles "One" "role") }},
{{ template "count" (dict "N" .Data.RBAC.grants "One" "grant") }}. Always enforced; changes
are staged and go live on publish
</p>
</div>
</div>
{{ end }}