dbnet-io / dbnet

dbNet is a web-based database client using Go as a backend, and React as front-end
https://docs.dbnet.io
GNU Affero General Public License v3.0
15 stars 1 forks source link

Frontend #10

Closed gedw99 closed 1 year ago

gedw99 commented 1 year ago

The Web GUI is OK, and i saw your tried out the fancy tauri rust / wasm approach. Now its React, like everything.

I use GIOUI which is golang that compiles to wasm, or desktop or mobile. its pretty good for these types of Use cases and so wanted to give it a try.

SO for GIOUI, I just need a golang types and some http transprt to do RPC. I dont even need REST or OPENAPI, cause its golang called golang.

--

The other way is good old HTMX with golang and go templates. Its pretty damn fast and easy. Then there is alos no API needed, because its just html being injected into the DOM over web sockets or SSE.

Hope i am not rubbing oyu up the wrong way for discussing these options..

flarco commented 1 year ago

@gedw99 not at all, it's great to hear another point of view. I settled on React because there are tons of libraries, resources and options. And I like typescript for ease of refactoring. I use Prime React for this, cause I am bad at Styling and GUI design. Adding advanced features while keeping a good UX on the UI is hard :).

For Golang stuff, I've recently started using Wails and really like it. It does all the auto-typing conversion as well into JS, server side function calling, similar to GIOUI. I will probably port dbnet over to that at some point, but it needs to be able to build as server only as well.

Thanks for sharing your thoughts! I welcome them.

gedw99 commented 1 year ago

Us devs are always arguing over which is better ...

I used wails too. Still prefer GIOUI or HTMX any day of the week :)

I might whip up a GIOUI GUI. Its very quick. Is there shared golang types i can use and a transport ?

gedw99 commented 1 year ago

maybe https://github.com/flarco/dbio/tree/main/iop ?

seems to have the bits i need.

flarco commented 1 year ago

Curious why prefer GIOUI?

What do you mean by shared golang type? like the structs?

Also not understanding a transport? If you look at https://github.com/dbnet-io/dbnet/blob/master/server/server.go, this is where the endpoint comes from. Which uses https://github.com/dbrest-io/dbREST.

gedw99 commented 1 year ago

why GIOUI ? thats a really hard one to justify... Its so subjective.

after 15 years of the crazy abstractions over HTML and AJAX, we have React etc etc etc. Its why HTMX has become so popular and really good. HTMX is crazy simple.

GIOUI is the exact opposite and does not care if its a browser, TV, mobile or desktop. It just wants a GPU canvas and off it goes.

So they are kind of the polar opposite BUT the common thing with both is i am just calling golang ! sure with htmx there is a slight abstraction, but not much.

you can go run . this: https://github.com/gioui/gio-example/tree/main/component

if your on linux you might need some extra bits. I am on mac. https://gioui.org/doc/install

Its very easy to extend from here to build very complex apps.


HTMX is also my fav.

this one is pretty nice: https://github.com/joerdav/go-htmx-examples

gedw99 commented 1 year ago

Or this one !

https://github.com/emad-elsaid/debugger

its a Golang debugger gui written in golang to debug Golang. It uses standard GIOUI.

Its a bit slow because of what it has to do but the layout possibilities are nice.

gedw99 commented 1 year ago

What do you mean by shared golang type? like the structs?

Also not understanding a transport? If you look at https://github.com/dbnet-io/dbnet/blob/master/server/server.go, this is where the endpoint comes from. Which uses https://github.com/dbrest-io/dbREST.

I am not sure yet. Yes i just need the types. I guess your transport is just HTTP, no push over websockets or SSE ?

I might just use NATS for the transport and router even. That's eliminates a ton of layers and gives you global Load balancing, security, etc in one hit. Most devs utterly hate this :)

flarco commented 1 year ago

Correct, no push. I had started with websockets, but it was a bit crappy. The backend has a timeout and returns status 202 when the query isn't done (see here for backend logic).

See https://github.com/dbnet-io/dbnet/blob/master/frontend/src/state/dbnet.ts#L417-L440 for frontend logic, which is responsible for sending a new request.

I suggest you check out the following for backend abstraction, it has a cleaner code-base and none of the frontend stuff:

dbREST is just the api part of dbNet. You could just call those functions by providing a fabricated echo.Context.

flarco commented 1 year ago

Thanks for all the links. I like htmlx's simplicity alot. My gripe is that I would have to create all the html components myself (or grab from various places), and it would not be appealing to the eye (at least my eye :). Also I like typescript's typed nature, and IDE powered features. I'll def turn to htmlx for simpler projects. I also like GIOUI's simplicity, cool stuff.

Let me know how this NATS stuff goes (have not used that one before), I'm eager to see how this turns out. My goal for all this stuff was (is) to provide a mechanism to easily query databases of all kinds, as well as move data into/out of databases, hence the separation into 3 tools:

image

screenshot from https://github.com/flarco

gedw99 commented 1 year ago

sure will let you know. At least your not pisssed off :)

I am a bit of a oldie and seen all the fads... so i admit my own bias.

I have gotten a GIO gui going with github.com/flarco/dbio. Early days... Will let you know and put it on github. Feel fee to copy it etc if you want. If you like it then we can work on it together with your other packages.

GIO now does deep links and Url Scheme BTW. So you can compile for web or desktop and if the user has desktop it will open desktop and if not it will open in the browser.

It also has webviews and other goodies: https://github.com/gioui-plugins/gio-plugins this is why i dont use WAILS btw. GIo can bypass the Electron cruft. Maybe i am missing a trick but its pretty nice to use without the abstractions.

About "creating all the html components yourself" - i totally get ya. With you get all the material design stuff for free with gio. If you want a sexy one you can often find it and then just "go get " it.

gedw99 commented 1 year ago

And about NATS, https://github.com/k3s-io/kine is a good starter.

It can embed nats or use external one.

embedding is pretty cool. you can even do it for your servers as a Leaf Node and so if the network goes down it keeps pumping to any local "microservices" and then catches up when the network is back.