diff --git a/api/api.go b/api/api.go index 876f456..aa11513 100644 --- a/api/api.go +++ b/api/api.go @@ -57,15 +57,13 @@ func (a *API) ServeHTTP(w http.ResponseWriter, r *http.Request) { } func (a *API) index(w http.ResponseWriter, r *http.Request) { - // nolint:errcheck - if pusher, ok := w.(http.Pusher); ok { - pusher.Push("/assets/style.css", nil) - pusher.Push("/assets/htmx.min.js", nil) - pusher.Push("/assets/sse.js", nil) - pusher.Push("/assets/Inter-Regular.ttf", nil) - pusher.Push("/assets/Inter-Bold.ttf", nil) - pusher.Push("/assets/Inter-SemiBold.ttf", nil) + if r.Header.Get("Hx-Request") == "true" { + w.Header().Set("HX-Push-Url", r.URL.EscapedPath()) + a.table(w, r) + return } + + push(w) if err := templates.Index().Render(r.Context(), w); err != nil { slog.Error("failed to render index", slog.Any("err", err)) } @@ -87,15 +85,7 @@ func (a *API) txPage(w http.ResponseWriter, r *http.Request) { return } - // nolint:errcheck - if pusher, ok := w.(http.Pusher); ok { - pusher.Push("/assets/style.css", nil) - pusher.Push("/assets/htmx.min.js", nil) - pusher.Push("/assets/sse.js", nil) - pusher.Push("/assets/Inter-Regular.ttf", nil) - pusher.Push("/assets/Inter-Bold.ttf", nil) - pusher.Push("/assets/Inter-SemiBold.ttf", nil) - } + push(w) if err := templates.TxPage(txInfo).Render(r.Context(), w); err != nil { slog.Error("failed to render TxPage", slog.Any("err", err)) @@ -193,3 +183,15 @@ func SearchFilter(f string, since time.Time) Filter { func NoFilter(e model.Event) bool { return true } + +func push(w http.ResponseWriter) { + // nolint:errcheck + if pusher, ok := w.(http.Pusher); ok { + pusher.Push("/assets/style.css", nil) + pusher.Push("/assets/htmx.min.js", nil) + pusher.Push("/assets/sse.js", nil) + pusher.Push("/assets/Inter-Regular.ttf", nil) + pusher.Push("/assets/Inter-Bold.ttf", nil) + pusher.Push("/assets/Inter-SemiBold.ttf", nil) + } +} diff --git a/api/assets/style.css b/api/assets/style.css index bce9cff..d29b0b1 100644 --- a/api/assets/style.css +++ b/api/assets/style.css @@ -670,6 +670,20 @@ input:checked+.slider:before { margin: 10px; } +.tx-info-header>a { + float: right; + cursor: pointer; +} + +.tx-info-header svg { + width: 16px; + height: 16px; +} + +.tx-info-header svg path { + fill: #808080 +} + #tx-info-blocks { display: flex; flex-direction: row; @@ -857,8 +871,8 @@ body.dark .tx-log-row:nth-last-child(odd) { display: flex; margin-right: 10px; margin-left: auto; - min-width: 158px; - max-width: 158px; + min-width: 160px; + max-width: 160px; } .tx-log-timestamp span { diff --git a/api/templates/index.templ b/api/templates/index.templ index 7fc2bf8..e25bb5a 100644 --- a/api/templates/index.templ +++ b/api/templates/index.templ @@ -144,7 +144,14 @@ templ Tx(tx model.TxInfo) { templ TxInfo(tx model.TxInfo) {
-
Transaction Info
+
+ Transaction Info + + + + + +
diff --git a/api/templates/index_templ.go b/api/templates/index_templ.go index 45014c8..d1be074 100644 --- a/api/templates/index_templ.go +++ b/api/templates/index_templ.go @@ -507,14 +507,14 @@ func TxInfo(tx model.TxInfo) templ.Component { templ_7745c5c3_Var21 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
Transaction Info
") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
Transaction Info
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var22 string templ_7745c5c3_Var22, templ_7745c5c3_Err = templ.JoinStringErrs(tx.State.String()) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 150, Col: 51} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 157, Col: 51} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var22)) if templ_7745c5c3_Err != nil { @@ -527,7 +527,7 @@ func TxInfo(tx model.TxInfo) templ.Component { var templ_7745c5c3_Var23 string templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(formatDuration(tx.Duration)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 151, Col: 56} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 158, Col: 56} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23)) if templ_7745c5c3_Err != nil { @@ -584,7 +584,7 @@ func TxIDBlock(id, header string) templ.Component { var templ_7745c5c3_Var25 string templ_7745c5c3_Var25, templ_7745c5c3_Err = templ.JoinStringErrs(id) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 166, Col: 38} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 173, Col: 38} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var25)) if templ_7745c5c3_Err != nil { @@ -597,7 +597,7 @@ func TxIDBlock(id, header string) templ.Component { var templ_7745c5c3_Var26 string templ_7745c5c3_Var26, templ_7745c5c3_Err = templ.JoinStringErrs(header) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 168, Col: 44} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 175, Col: 44} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var26)) if templ_7745c5c3_Err != nil { @@ -702,7 +702,7 @@ func TxLogEvent(e model.TxLogEvent) templ.Component { var templ_7745c5c3_Var31 string templ_7745c5c3_Var31, templ_7745c5c3_Err = templ.JoinStringErrs(e.State.String()) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 196, Col: 79} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 203, Col: 79} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var31)) if templ_7745c5c3_Err != nil { @@ -715,7 +715,7 @@ func TxLogEvent(e model.TxLogEvent) templ.Component { var templ_7745c5c3_Var32 string templ_7745c5c3_Var32, templ_7745c5c3_Err = templ.JoinStringErrs(e.IDType) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 200, Col: 39} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 207, Col: 39} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var32)) if templ_7745c5c3_Err != nil { @@ -728,7 +728,7 @@ func TxLogEvent(e model.TxLogEvent) templ.Component { var templ_7745c5c3_Var33 string templ_7745c5c3_Var33, templ_7745c5c3_Err = templ.JoinStringErrs(e.IDType) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 202, Col: 43} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 209, Col: 43} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var33)) if templ_7745c5c3_Err != nil { @@ -741,7 +741,7 @@ func TxLogEvent(e model.TxLogEvent) templ.Component { var templ_7745c5c3_Var34 string templ_7745c5c3_Var34, templ_7745c5c3_Err = templ.JoinStringErrs(e.ID) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 203, Col: 16} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 210, Col: 16} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var34)) if templ_7745c5c3_Err != nil { @@ -754,7 +754,7 @@ func TxLogEvent(e model.TxLogEvent) templ.Component { var templ_7745c5c3_Var35 string templ_7745c5c3_Var35, templ_7745c5c3_Err = templ.JoinStringErrs(e.Timestamp.Format("03:04 PM, 02/01/06")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 209, Col: 52} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 216, Col: 52} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var35)) if templ_7745c5c3_Err != nil { @@ -839,7 +839,7 @@ func footer() templ.Component { var templ_7745c5c3_Var39 string templ_7745c5c3_Var39, templ_7745c5c3_Err = templ.JoinStringErrs(time.Now().Format("2006")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 296, Col: 61} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 303, Col: 61} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var39)) if templ_7745c5c3_Err != nil {