Fork me on GitHub
#portal
<
2022-10-29
>
Jakub Holý (HolyJak)17:10:57

Is it possible to run Portal on the JVM but with a web UI, so that the ui can be accessed remotely over http?

1
seancorfield17:10:18

Yes, as long as you have the port exposed/accessible.

Jakub Holý (HolyJak)17:10:13

Hm, I tried

((requiring-resolve 'portal.api/open) {:port 8989
                                         :value (atom (list {:workspaces [], :reports []}))})
which opens a new chrome window but I am not able to open http://localhost:8989 in ab rowser

seancorfield17:10:49

What URL does it open in Chrome?

Jakub Holý (HolyJak)17:10:14

it opens a chrome window w/o the address bar

seancorfield17:10:02

That could be its socket server...?

seancorfield17:10:53

You need start, not open. That's how you can control where the server runs etc, if I'm understanding the code correctly.

Jakub Holý (HolyJak)17:10:11

found it, it should have been :portal.launcher/port

Jakub Holý (HolyJak)17:10:30

though start looks like a valid option too, thank you!

seancorfield17:10:56

Ah, yes, I thought it also accepted the short options but you're right, it only accepts the long options.

seancorfield17:10:43

open will start and then open a browser. start will just start the server. You might need :portal.launcher/host "0.0.0.0" if you plan to access this remotely from another machine.

Jakub Holý (HolyJak)17:10:31

ah, then start looks much better. Thank you!

seancorfield17:10:56

Looking at the code again, I think it does accept the short option names -- it just renames the long ones to the short ones if present.

seancorfield17:10:08

Confirmed:

(~/clojure)-(!2034)-> clojure -M:portal:rebel
[Rebel readline] Type :repl/help for online help info
user=> (require '[portal.api :as p])
nil
user=> (p/open {:port 4321})
{:session-id #uuid "12fa92f9-4e7e-4cac-a5e2-1e45f474264d"}
user=>
And I can open a browser at http://localhost:4321 and get Portal (in addition to the window it already opened without an address bar).

Jakub Holý (HolyJak)17:10:57

right. Interesting it did not work for me at first...

Jakub Holý (HolyJak)17:10:06

I must have screwed up something

seancorfield17:10:48

And I just tested it with p/start as well -- works too (without opening its own browser window).

seancorfield17:10:56

Sounds like you're up and running now?

Jakub Holý (HolyJak)17:10:46

yes, I am, thanks a lot!

hiredman19:10:50

There was a bug in a recent version where this wouldn't work because the ui wasn't using the correct port when it tried to make websocket connections

Jakub Holý (HolyJak)20:10:48

How do I specify :predicate for a custom Command? I see that portal.ui.commands/register! takes it as opts but portal.api/register! does not and the former is cljs-only. Thank you! I see it just delegates to portal.runtime/register! which has the 2-arg variant but why is it not exposed by the api?

djblue22:10:48

I think the main reason is wanting to iron out the API before exposing it.

👍 1