Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e082671f53 | |||
| ef28805042 |
@@ -15,6 +15,31 @@ document.body.addEventListener('htmx:responseError', function (evt) {
|
|||||||
banner.scrollIntoView({ behavior: 'instant', block: 'nearest' });
|
banner.scrollIntoView({ behavior: 'instant', block: 'nearest' });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Toggle visibility of a create-form panel. The button text alternates
|
||||||
|
// between the given labels. Used by admin pages (accounts, policies,
|
||||||
|
// pgcreds, SSO clients) to show/hide the inline create form.
|
||||||
|
//
|
||||||
|
// Usage: <button data-toggle-form="create-form"
|
||||||
|
// data-label-show="Add Item" data-label-hide="Cancel">
|
||||||
|
function toggleForm(btn) {
|
||||||
|
var id = btn.getAttribute('data-toggle-form');
|
||||||
|
var el = document.getElementById(id);
|
||||||
|
if (!el) { return; }
|
||||||
|
var show = el.hidden || el.style.display === 'none';
|
||||||
|
el.hidden = false;
|
||||||
|
el.style.display = show ? '' : 'none';
|
||||||
|
var labelShow = btn.getAttribute('data-label-show') || 'Create';
|
||||||
|
var labelHide = btn.getAttribute('data-label-hide') || 'Cancel';
|
||||||
|
btn.textContent = show ? labelHide : labelShow;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Auto-wire all toggle-form buttons on page load.
|
||||||
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
|
document.querySelectorAll('[data-toggle-form]').forEach(function (btn) {
|
||||||
|
btn.addEventListener('click', function () { toggleForm(btn); });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Clear the error banner whenever a successful HTMX swap completes so
|
// Clear the error banner whenever a successful HTMX swap completes so
|
||||||
// stale errors do not persist after the user corrects their input.
|
// stale errors do not persist after the user corrects their input.
|
||||||
document.body.addEventListener('htmx:afterSwap', function () {
|
document.body.addEventListener('htmx:afterSwap', function () {
|
||||||
|
|||||||
@@ -34,3 +34,8 @@ th { background: #e9ecef; }
|
|||||||
input, select { padding: 0.4rem; border: 1px solid #ced4da; border-radius: 4px; }
|
input, select { padding: 0.4rem; border: 1px solid #ced4da; border-radius: 4px; }
|
||||||
.clickable-row { cursor: pointer; }
|
.clickable-row { cursor: pointer; }
|
||||||
.clickable-row:hover { background: #e9ecef; }
|
.clickable-row:hover { background: #e9ecef; }
|
||||||
|
.flex-wrap { flex-wrap: wrap; }
|
||||||
|
.flex-1 { flex: 1; min-width: 200px; }
|
||||||
|
.flex-2 { flex: 2; min-width: 300px; }
|
||||||
|
.text-center { text-align: center; }
|
||||||
|
.p-2 { padding: 2rem; }
|
||||||
|
|||||||
@@ -6,22 +6,25 @@
|
|||||||
<h2>SSO Clients</h2>
|
<h2>SSO Clients</h2>
|
||||||
<p class="text-muted text-small">Registered applications that use MCIAS for single sign-on.</p>
|
<p class="text-muted text-small">Registered applications that use MCIAS for single sign-on.</p>
|
||||||
</div>
|
</div>
|
||||||
<button class="btn btn-primary" onclick="var f=document.getElementById('create-form');f.hidden=!f.hidden;this.textContent=f.hidden?'Add Client':'Cancel'">Add Client</button>
|
<button class="btn btn-primary"
|
||||||
|
data-toggle-form="create-form"
|
||||||
|
data-label-show="Add Client"
|
||||||
|
data-label-hide="Cancel">Add Client</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="create-form" class="card mt-2" hidden>
|
<div id="create-form" class="card mt-2" hidden>
|
||||||
<div class="card-title">Register SSO Client</div>
|
<div class="card-title">Register SSO Client</div>
|
||||||
<form hx-post="/sso-clients" hx-target="#sso-clients-tbody" hx-swap="afterbegin">
|
<form hx-post="/sso-clients" hx-target="#sso-clients-tbody" hx-swap="afterbegin">
|
||||||
<div class="d-flex gap-1" style="flex-wrap:wrap">
|
<div class="d-flex gap-1 flex-wrap">
|
||||||
<div class="form-group" style="flex:1;min-width:200px">
|
<div class="form-group flex-1">
|
||||||
<label class="form-label">Client ID / Service Name</label>
|
<label class="form-label">Client ID / Service Name</label>
|
||||||
<input class="form-control" type="text" name="client_id" required placeholder="e.g. mcr">
|
<input class="form-control" type="text" name="client_id" required placeholder="e.g. mcr">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group" style="flex:2;min-width:300px">
|
<div class="form-group flex-2">
|
||||||
<label class="form-label">Redirect URI</label>
|
<label class="form-label">Redirect URI</label>
|
||||||
<input class="form-control" type="url" name="redirect_uri" required placeholder="https://service.example.com/sso/callback">
|
<input class="form-control" type="url" name="redirect_uri" required placeholder="https://service.example.com/sso/callback">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group" style="flex:1;min-width:200px">
|
<div class="form-group flex-1">
|
||||||
<label class="form-label">Tags <span class="text-muted text-small">(comma-separated)</span></label>
|
<label class="form-label">Tags <span class="text-muted text-small">(comma-separated)</span></label>
|
||||||
<input class="form-control" type="text" name="tags" placeholder="env:prod,tier:web">
|
<input class="form-control" type="text" name="tags" placeholder="env:prod,tier:web">
|
||||||
</div>
|
</div>
|
||||||
@@ -49,6 +52,6 @@
|
|||||||
{{end}}
|
{{end}}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{{if not .Clients}}<p class="text-muted" style="text-align:center;padding:2rem">No SSO clients registered.</p>{{end}}
|
{{if eq (len .Clients) 0}}<p class="text-muted text-center p-2">No SSO clients registered.</p>{{end}}
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|||||||
Reference in New Issue
Block a user