66 lines
2.3 KiB
Plaintext
66 lines
2.3 KiB
Plaintext
package popup
|
|
|
|
import "strconv"
|
|
import "fmt"
|
|
import "git.haelnorr.com/h/golib/notify"
|
|
|
|
// ErrorModalWS displays a WebSocket-triggered error modal
|
|
// Matches design of error page (page.ErrorWithDetails)
|
|
templ ErrorModalWS(code int, stacktrace string, nt notify.Notification, id int) {
|
|
<div
|
|
id="error-modal-ws-container"
|
|
hx-swap-oob="morph:#error-modal-ws-container"
|
|
>
|
|
<!-- Fullscreen backdrop overlay -->
|
|
<div class="fixed inset-0 z-50 bg-crust/80 flex items-center justify-center p-4">
|
|
<!-- Modal card -->
|
|
<div class="bg-base rounded-lg shadow-xl max-w-2xl w-full max-h-[90vh] overflow-y-auto p-8 text-center">
|
|
<!-- Error code -->
|
|
<h1 class="text-9xl text-text">{ strconv.Itoa(code) }</h1>
|
|
<!-- Error title -->
|
|
<p class="text-2xl font-bold tracking-tight text-subtext1 sm:text-4xl">
|
|
{ nt.Title }
|
|
</p>
|
|
<!-- User message -->
|
|
<p class="mt-4 text-subtext0">{ nt.Message }</p>
|
|
<!-- Details dropdown -->
|
|
if stacktrace != "" {
|
|
<div class="mt-8 text-left">
|
|
<details class="bg-surface0 rounded-lg p-4 text-right">
|
|
<summary class="text-left cursor-pointer text-subtext1 font-semibold select-none hover:text-text">
|
|
Details
|
|
<span class="text-xs text-subtext0 ml-2">(click to expand)</span>
|
|
</summary>
|
|
<div class="text-left mt-4 relative">
|
|
<pre
|
|
id={ fmt.Sprintf("error-modal-ws-details-%d", id) }
|
|
class="text-xs text-subtext0 font-mono whitespace-pre-wrap break-all bg-mantle p-4 rounded overflow-x-auto max-h-96"
|
|
>{ stacktrace }</pre>
|
|
</div>
|
|
<button
|
|
onclick={ templ.JSFuncCall("copyToClipboard", fmt.Sprintf("error-modal-ws-details-%v", id), "copyButton") }
|
|
id="copyButton"
|
|
class="mt-2 bg-mauve text-crust px-3 py-1 rounded text-xs hover:bg-mauve/75 transition"
|
|
title="Copy to clipboard"
|
|
>
|
|
Copy
|
|
</button>
|
|
</details>
|
|
</div>
|
|
}
|
|
<!-- Close button -->
|
|
<div class="mt-6">
|
|
<button
|
|
onclick="document.getElementById('error-modal-ws-container').innerHTML = ''"
|
|
class="inline-block rounded-lg bg-mauve px-5 py-3 text-sm text-crust transition hover:bg-mauve/75"
|
|
>
|
|
Close Modal
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<script src="/static/js/copytoclipboard.js"></script>
|
|
</div>
|
|
}
|
|
|