Fork me on GitHub
#portal
<
2023-09-19
>
practicalli-johnny16:09:27

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.

djblue17:09:11

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-johnny17:09:19

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
djblue18:09:04

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

djblue18:09:17

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

djblue18:09:46

{:$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-johnny19:09:40

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
Felipe20:09:39

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

djblue20:09:14

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?

Felipe20:09:47

the latter, app available without the normal runtime connection

djblue20:09:24

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

Felipe21:09:45

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

djblue21:09:26

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

Felipe21:09:25

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

djblue21:09:33

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

👍 1
Felipe21:09:59

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

Felipe23:09:08

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)))}]))

Felipe23:09:53

surprised you can set! the opener

awesome 1
djblue23:09:05

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

Felipe23:09:08

that would be great! thank you!

djblue23:09:17

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

Felipe00:09:37

can try tomorrow, sure!

awesome 1
Felipe22:09:31

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

djblue23:09:20

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?

djblue23:09:24

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 👌

djblue23:09:51

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

djblue23:09:06

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

Felipe00:09:11

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)

Felipe00:09:33

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

djblue00:09:43

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