Fork me on GitHub
#portal
<
2022-10-18
>
wilkerlucio12:10:37

hello, is there a guide on how to use charts with Portal?

djblue20:10:53

I think portal has some higher level viewers that will map data to vega/vega-lite, but if you want custom stuff, you can use the vega/vega-lite viewer directly ๐Ÿ‘

djblue20:10:44

FYI for any who use portal.api/eval-str and have had issues with promises, you can do (portal.api/eval-str :all "(.resolve js/Promise 123)" {:await true}) with the latest release, https://github.com/djblue/portal/releases/tag/0.32.0

seancorfield21:10:00

@djblue Starting a new thread about the middleware so we don't keep spamming Max T about it... ๐Ÿงต

๐Ÿ˜… 1
seancorfield21:10:31

So I have this working nicely, locally. With :portal.nrepl/eval true in the metadata.

seancorfield21:10:58

What are the red yellow orange dots meant to be at the top of the stdio stuff?

djblue21:10:37

Just decoration that I plan on making the expand / collapse buttons in the future. It's suppose to look like a terminal ๐Ÿ˜†

seancorfield21:10:32

Ah, a Mac terminal.

djblue21:10:06

Yeah, the viewer will also correctly handle color escape codes ๐Ÿ‘Œ

djblue21:10:46

It supports three tags: :out, :err and :tap

seancorfield21:10:19

OK, took me a bit of messing about to get the results I wanted in the right order but...

awesome 1
seancorfield21:10:32

That's the result of my "run tests" hot key which invokes parts of clojure.test and then tap>'s the result (summary hash map). So now it is show the report card, then the standard output, then the actual value I tapped. That means that the most recent tapped value is still the most recent item in Portal, even if there is output or test results, and I can still use my various hotkeys to drive Portal's UI to expand parts of it or cycle through viewers, as before.

seancorfield21:10:23

What was the go to file/line hot key in Portal where you're on logging style line?

djblue21:10:59

goto-definition should be mapped to g + d

seancorfield21:10:51

Ah, yes, and it loads it in the portal window group. Thanks.

seancorfield21:10:31

So here's where I've ended up and this works very nicely:

(ns dev)

(defonce *v (atom nil))
(defonce was-tap (atom false))

(defn submit
  [v]
  (let [m (try (meta v) (catch Exception _))]
    (if (:portal.nrepl/eval m)
      (let [{:keys [stdio report level]} v]
        (when report
          ((requiring-resolve 'portal.api/submit) report))
        (when stdio
          ((requiring-resolve 'portal.api/submit) stdio))
        (when (= level :error)
          ((requiring-resolve 'portal.api/submit) v))
        (when @was-tap
          (reset! was-tap false)
          ((requiring-resolve 'portal.api/submit) @dev/*v)))
      (do
        (when @was-tap
          (reset! was-tap false)
          ((requiring-resolve 'portal.api/submit) @dev/*v))
        (reset! dev/*v v)
        (reset! was-tap true)))))
and the change to nrepl.clj is just this:
(with-meta {:portal.nrepl/eval true
                        :portal.viewer/for
                        {:code :portal.viewer/code
                         :time :portal.viewer/relative-time}
                        :portal.viewer/code {:language :clojure}})
            tap>)))
(add :portal.nrepl/eval true to metadata and use tap> instead of p/submit

djblue21:10:53

Nice! I think meta is safe without try catch :thinking_face:

seancorfield22:10:41

Yup, thanks. Will simplify.

๐Ÿ’ฏ 1
seancorfield22:10:49

Yeah, this is working really well for me... I get better feedback on "normal" evaluations via Calva and I still have my previous tap> workflow with hotkeys to drive navigation in Portal.

awesome 1
djblue22:10:36

The prepl and test report viewers could use some ux polish so if you think of anything, let me know. I still need to add filter failing for the test viewer

seancorfield22:10:54

I'm the wrong person to ask about UI/UX ๐Ÿ™‚ but if I run into anything and have suggestions, I'll let you know.

๐Ÿ™ 1