From 721d1e8d6b48da7e60b35874d602975ed21bccab Mon Sep 17 00:00:00 2001 From: Christian Ditaputratama Date: Mon, 4 Nov 2024 16:36:22 +0700 Subject: [PATCH] feat: Added modal --- bun.lockb | Bin 46093 -> 47163 bytes internal/handler/response.go | 42 +++ internal/handler/routes.go | 1 + internal/handler/views/layout.templ | 24 ++ internal/handler/views/layout_templ.go | 52 +++- internal/handler/views/remote_nodes.templ | 20 +- internal/handler/views/remote_nodes_templ.go | 263 +++++++++++-------- internal/handler/views/src/css/main.css | 17 ++ internal/handler/views/src/js/main.js | 2 + package.json | 2 + tailwind.config.js | 6 +- 11 files changed, 319 insertions(+), 110 deletions(-) diff --git a/bun.lockb b/bun.lockb index 997b7580c52afa4252f18b0a77a594dd6b53e315..cbfeff8f34c7f2f7c0f3508162b962ff87209a43 100755 GIT binary patch delta 7260 zcmeHLdsr1mmhWn~cpKy;C^lCGM1`vZcm;BO(rSoC4eAJrXfzVM!WHE0GvK|bfEZEZ zN!(=O_=tI-NrVvBQAvDd@|tASBs(T?bi!uM1~m_NGh-g3ncwN|Ys|!NcK_OM|Csu| zU!OjYI#qS*R8@C1elUjoLM?1r0L)54xUVT;mVfQ z=a){~cTmzx?L)aS9;L=$etc%*HAs@YnL?7HK-)k=Kntp>TvY{<u69`(GUs~o~C`lH!^FUDPswyj4=8`mvB*lPF z2W7(qP;R&=zp89`sU)ooFdUupH}vK1MJu`C*TF}^?i$|N{t74$pwp!8s-(h_viqe~ zR-@io$l3p2!O!EKoiqiF7!Hr<{>uCUSCu5)0KzkcbB@$^Q)>Jft*LP2rjwa5m4^oMpK@Hq~KO2g0jD{y$$;aP>$ARlYR_6 z#_RFcs74}HfO3OR!hoqO+Hmj^C|CR+9C@$UjE?-hpX=x)clc9KwCOGBD@ic*W`n9| z$(z{EP-M_?zZg$>rK`kU>XLqqT;p*SRWDhQTvk~)*__3~SYw{5TqUl8YDt;{p2xWm zd|`gID;0L!jBkCs9%rQAK~Rp%K2V-#5D6jkmd6{jg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8%Nq1imFqEos#QRn{oAuJMOEyPoCEH8O4a2O_Uy{ z639I_vJ;2q21Hk7^3u(6V7b*h5x1~(vMyde8A*Zl@uDqh^=gvm#+8C#HGJYF z+EK*#Iz<_Q-E`vh87Ep4uhAv3c6>Dxsit0Sm1=I!wCjfpEnh!7Iz&83d+Vc&!!6}3 zzBs6B_xqbK#z%i1*AJu3JT z*S-9S<&%Hi&4hu4JJVbK+R!lC_Go0EdBMgJemZl(b6MN(QI~=b#HdHCnJsRGC4O29 no=>oMdQW&ro73mxznD&EH + } @@ -65,3 +66,26 @@ templ BaseLayout(m Meta, cmp templ.Component) { templ BlankLayout(cmp templ.Component) { @cmp } + +templ ModalLayout(title string, cmp templ.Component) { +
+ +
+} diff --git a/internal/handler/views/layout_templ.go b/internal/handler/views/layout_templ.go index 09acf1e..bd2f70c 100644 --- a/internal/handler/views/layout_templ.go +++ b/internal/handler/views/layout_templ.go @@ -231,7 +231,7 @@ func base(m Meta) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(", source code licensed under BSD-3-Clause license.

") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(", source code licensed under BSD-3-Clause license.

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -315,4 +315,54 @@ func BlankLayout(cmp templ.Component) templ.Component { }) } +func ModalLayout(title string, cmp templ.Component) templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var18 := templ.GetChildren(ctx) + if templ_7745c5c3_Var18 == nil { + templ_7745c5c3_Var18 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var19 string + templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(title) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/handler/views/layout.templ`, Line: 74, Col: 33} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cmp.Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return templ_7745c5c3_Err + }) +} + var _ = templruntime.GeneratedTemplate diff --git a/internal/handler/views/remote_nodes.templ b/internal/handler/views/remote_nodes.templ index 58bf516..4d52f67 100644 --- a/internal/handler/views/remote_nodes.templ +++ b/internal/handler/views/remote_nodes.templ @@ -194,7 +194,7 @@ templ TableNodes(data monero.Nodes, countries []monero.Countries, q monero.Query for _, row := range data.Items { - @cellHostPort(row.IPAddresses, row.Hostname, row.Port, row.IsTor, row.IPv6Only) + @cellHostPort(row.ID, row.Port, row.Hostname, row.IPAddresses, row.IsTor, row.IPv6Only) @cellNettype(row.Nettype, row.Height) @@ -225,10 +225,22 @@ templ TableNodes(data monero.Nodes, countries []monero.Countries, q monero.Query } -templ cellHostPort(ips, hostname string, port uint, isTor, ipv6Only bool) { +templ Node(data monero.Node) { +

{ fmt.Sprintf("%s:%d", data.Hostname, data.Port) }

+} + +templ cellHostPort(id, port uint, hostname, ips string, isTor, ipv6Only bool) { if isTor { - -
diff --git a/internal/handler/views/remote_nodes_templ.go b/internal/handler/views/remote_nodes_templ.go index 3f1bf5d..bed4525 100644 --- a/internal/handler/views/remote_nodes_templ.go +++ b/internal/handler/views/remote_nodes_templ.go @@ -433,7 +433,7 @@ func TableNodes(data monero.Nodes, countries []monero.Countries, q monero.QueryN if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = cellHostPort(row.IPAddresses, row.Hostname, row.Port, row.IsTor, row.IPv6Only).Render(ctx, templ_7745c5c3_Buffer) + templ_7745c5c3_Err = cellHostPort(row.ID, row.Port, row.Hostname, row.IPAddresses, row.IsTor, row.IPv6Only).Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -541,7 +541,7 @@ func TableNodes(data monero.Nodes, countries []monero.Countries, q monero.QueryN }) } -func cellHostPort(ips, hostname string, port uint, isTor, ipv6Only bool) templ.Component { +func Node(data monero.Node) templ.Component { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { @@ -562,17 +562,72 @@ func cellHostPort(ips, hostname string, port uint, isTor, ipv6Only bool) templ.C templ_7745c5c3_Var22 = templ.NopComponent } ctx = templ.ClearChildren(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var23 string + templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%s:%d", data.Hostname, data.Port)) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/handler/views/remote_nodes.templ`, Line: 229, Col: 52} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return templ_7745c5c3_Err + }) +} + +func cellHostPort(id, port uint, hostname, ips string, isTor, ipv6Only bool) templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var24 := templ.GetChildren(ctx) + if templ_7745c5c3_Var24 == nil { + templ_7745c5c3_Var24 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) if isTor { - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("