portal

practicalli-johnny 2023-09-19T16:56:27.348449Z

Did pagination feature become part of Portal? No desperate need, mostly curious. I've used Cider Inspector to paginate through largish data science related data sets (e.g. covid19 statistics for the UK) and paging through 50 results at a time stopped Emacs grinding to a halt. I assume there is some limit to what portal can comfortably display without some performance issues with the browser its running in... maybe, or maybe not.. Thanks.

djblue 2023-09-19T17:02:11.153149Z

I think there are two distinct sub problems here, serialization and rendering. Serialization is done eagerly, so things like infinite seqs will break Portal, but it's generally fast enough that most values I work with don't cause issues. Rendering is done lazily and is realized as you scroll. Currently, there is no pagination support in Portal, but it would be relatively easy to add as part of rendering. Is there a particular issue / ux you were thinking of?

practicalli-johnny 2023-09-19T17:21:19.778999Z

Ah, good to know. I dont have a current issue, however, I did find paginating through results very useful when building a Covid dashboard project. It was useful to check through at least some of the data set to ensure values were being propigated as I when through several data transformations. e.g. raw data > clojure data > visualisation data structure. I remember using inspect tools to help understand the large geojson format (which seems to be far too interesting to easily deal with without a good tool). Next time I do a project around this size data I'll feedback on what works and any challenges around using Portal for this type of thing. Thank you.

👍 1
djblue 2023-09-19T18:22:04.763809Z

I'd be interested in what vega/vega-lite could do with geo json 🤔

djblue 2023-09-19T18:26:17.214189Z

I have an example in the docs around lat/lon in a csv so it does know about that.

djblue 2023-09-19T18:30:46.648319Z

{:$schema "",
 :data {:url ""},
 :projection {:type "albersUsa"},
 :mark "circle",
 :encoding
 {:longitude {:field "longitude", :type "quantitative"},
  :latitude {:field "latitude", :type "quantitative"},
  :size {:value 10}}, 
 :config {:view {:stroke "transparent"}}}
The data looks like ☝️

practicalli-johnny 2023-09-19T19:28:40.716909Z

One of the biggest challenges I had with visualising the data accurately was geographical boundaries in geojson being different to political boundaries the raw data was organised in. So this type of Portal visualisation would be incredibly helpful, thanks for providing the examples.

👍 1
Felipe 2023-09-19T20:21:39.673409Z

maybe related to the standalone Portal q, is there an easy way to embed Portal in an existing cljs application?

Felipe 2023-09-21T22:44:31.319549Z

this is what I've got so far. launcher iframe-url + setting the opener as a hack is probably not ideal, but not sure where to go from here https://github.com/djblue/portal/pull/195/files

djblue 2023-09-21T23:33:20.453539Z

Ohh, I think I was expecting Portal itself to own the iframe. Do you want to be able to place the iframe in a specific place in your app?

djblue 2023-09-21T23:34:24.365109Z

I mainly wouldn't want the downstream consumer to have to know about this type of stuff:

(-> x .-contentWindow .-window .-opener (set! js/window))
                     (reset! c/connection (-> x .-contentWindow))
I do like that you have an example though 👌

djblue 2023-09-21T23:35:51.108999Z

Perhaps the consumer could pass in the element to inject the iframe into? 🤔

djblue 2023-09-21T23:37:06.293259Z

(portal.web/open {:launcher :iframe :iframe-element el}) is kinda the api I had in mind

Felipe 2023-09-22T00:44:25.998289Z

not beautiful, but almost there 😄 https://github.com/djblue/portal/pull/195/commits/c2668a54d459208b16fff9c6d6651b7891d7b6ff

Felipe 2023-09-22T00:45:11.601079Z

not in launcher :iframe :iframe-element el format only due to laziness. going to bed now and can do this change tomorrow (or go ahead if you want, should be a simple change)

Felipe 2023-09-22T00:45:33.475789Z

the mutationobserver stuff is nasty but not really sure how to do it any other way

djblue 2023-09-22T00:46:43.647249Z

Awesome, will take another look in a bit, thanks! 🙏

djblue 2023-09-19T20:28:14.891359Z

What type of embedding are you thinking here? Like using the viewers in different contexts outside of the main portal app? Or having the app be available without the normal runtime connection?

Felipe 2023-09-19T20:41:47.853499Z

the latter, app available without the normal runtime connection

djblue 2023-09-19T20:48:24.736949Z

I think portal.web might be what you are looking for

Felipe 2023-09-19T21:16:45.939179Z

I was thinking more of something that could go into an existing window, but this works 😄 thanks!

djblue 2023-09-19T21:17:26.270379Z

I think gettin the same version of the app opened in an iframe might be doable 🤔

djblue 2023-09-19T21:18:24.093399Z

https://github.com/djblue/portal/blob/master/src/portal/runtime/web/launcher.cljs#L62-L66 is the current open code for portal.web

Felipe 2023-09-19T21:18:25.779569Z

yeah, I think I saw some Clerk POC that did this? or maybe not, since that had a clj part

djblue 2023-09-19T21:20:33.365539Z

FYI cmd|ctrl + shift + o will open the inspector

👍 1
Felipe 2023-09-19T21:48:59.565099Z

trying to put the blob url in an iframe gives me be8db697-dd3a-40a2-b8f6-148759936463:5050 WebSocket connection to '' failed: . anyway, the separate window seems good enough for my purpose

djblue 2023-09-19T21:52:36.892039Z

Ohh, it's probably related to https://github.com/djblue/portal/blob/master/src/portal/ui/rpc.cljs#L118

Felipe 2023-09-19T23:49:08.266469Z

hah!

(defn portal-iframe []
  (swap! rt/sessions assoc-in [(:session-id @c/session) :options] {})
  (swap! c/session rt/open-session)
  (let [url (str->src (index/html {:code-url code-url :platform "web"})
                      "text/html")]
    [:iframe {:src url
              :width "100%"
              :height 600
              :ref (fn [x]
                     (when x
                       (-> x .-contentWindow .-window .-opener (set! js/window))
                       (reset! c/connection (-> x .-contentWindow)))
                     (c/make-atom (:session-id @c/session)))}]))

Felipe 2023-09-19T23:49:53.178029Z

surprised you can set! the opener

1
djblue 2023-09-19T23:52:05.551989Z

I assume it's because they share the same host 🤔 I'm down to add support to portal.web for :launcher :iframe if you want.

Felipe 2023-09-19T23:57:08.942459Z

that would be great! thank you!

djblue 2023-09-19T23:59:17.771919Z

Did you want to take a crack at it with a PR?

Felipe 2023-09-20T00:06:37.339679Z

can try tomorrow, sure!

1