Skip to content

Commit c37f20f

Browse files
committed
[Bug Fix] Correctly show only one chan when multi outs got to 1 in
1 parent 0a6766e commit c37f20f

2 files changed

Lines changed: 65 additions & 40 deletions

File tree

src/clojurescript/flow_monitor_ui/global.cljs

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,29 @@
4848
last-leader-line)))
4949

5050
(defn draw []
51+
(doall (for [root (:roots @global-state)]
52+
(do
53+
(let [chan-type @chan-representation
54+
proc (first root)
55+
in-expanded? (get @proc-card-state proc)]
56+
(doall (for [in (-> root second :ins)
57+
:when (and (-> in second :buffer) (-> in second :chan-obj))]
58+
(let [in-socket (str proc "-" (first in))
59+
in-socket-target (if in-expanded?
60+
in-socket
61+
(str in-socket "-collapsed"))
62+
in-chan (str in-socket "-in-chan")
63+
in-chan-el (when (= :meter chan-type) (.getElementById js/document in-chan))
64+
in-socket-el (.getElementById js/document in-socket-target)]
65+
(when (= :meter chan-type)
66+
(let [l1 (js/LeaderLine. in-chan-el in-socket-el (clj->js {:color "#52606D"
67+
:size 3
68+
:startSocket "bottom"
69+
:hide true
70+
:endSocket "top"
71+
:path "straight" #_"grid" #_"straight"}))]
72+
(.show l1 "draw")
73+
(swap! lines assoc (random-uuid) l1))))))))))
5174
(doall (for [proc (-> @global-state :data :conns)]
5275
(do
5376
(let [chan-type @chan-representation
@@ -68,18 +91,18 @@
6891
out-socket-el (.getElementById js/document out-socket-target)
6992
in-socket-el (.getElementById js/document in-socket-target)]
7093
(if (= :meter chan-type)
71-
(let [l1 (js/LeaderLine. out-socket-el out-chan-el (clj->js {:color "#52606D"
72-
:size 3
73-
:startSocket "bottom"
74-
:hide true
75-
:endSocket "top"
76-
:path "straight" #_ "grid" #_ "straight"}))
77-
l2 (js/LeaderLine. out-chan-el in-socket-el (clj->js {:color "#52606D"
94+
(let [l1 (js/LeaderLine. out-socket-el in-chan-el (clj->js {:color "#52606D"
7895
:size 3
7996
:startSocket "bottom"
8097
:hide true
8198
:endSocket "top"
82-
:path "grid" #_ "grid" #_ "straight"}))]
99+
:path "grid" #_ "grid" #_ "straight"}))
100+
l2 (js/LeaderLine. in-chan-el in-socket-el (clj->js {:color "#52606D"
101+
:size 3
102+
:startSocket "bottom"
103+
:hide true
104+
:endSocket "top"
105+
:path "straight" #_ "grid" #_ "straight"}))]
83106
(.show l1 "draw")
84107
(swap! lines assoc (random-uuid) l1)
85108
(.show l2 "draw")
@@ -92,12 +115,12 @@
92115
:hide true
93116
:endPlug (if product/FIREFOX "behind" "arrow1")
94117
:animOptions (clj->js {:duration 1000 :timing "ease"})
95-
:startLabel (js/LeaderLine.captionLabel "0/10" (clj->js {:color "#52606D" :outlineColor "#CBD2D9"}))
118+
; :startLabel (js/LeaderLine.captionLabel "0/10" (clj->js {:color "#52606D" :outlineColor "#CBD2D9"}))
96119
; TODO Conditional upon unique chan id
97-
#_ #_ :endLabel (js/LeaderLine.captionLabel "0/10"
98-
{:color "#52606D"
99-
:outlineColor "#CBD2D9"
100-
#_#_:offset [-20 0]})}))]
120+
:startLabel (js/LeaderLine.captionLabel "0/10"
121+
{:color "#52606D"
122+
:outlineColor "#CBD2D9"
123+
#_#_:offset [-20 0]})}))]
101124
(.show line "draw")
102125
;(set! (.-id line) (str in-socket "-" out-socket))
103126
(set-id-on-last-leader-line! (str out-socket "-svg"))

src/clojurescript/flow_monitor_ui/routes/index/view.cljs

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,27 @@
3737
{} data))
3838

3939
(defn assoc-ping-data [relationships ping]
40-
(reduce-kv (fn [res proc data]
41-
(-> res
42-
(assoc-in [proc :status] (:clojure.core.async.flow/status data))
43-
(assoc-in [proc :count] (:clojure.core.async.flow/count data))
44-
(assoc-in [proc :ins] (:clojure.core.async.flow/ins data))
45-
(assoc-in [proc :outs] (:clojure.core.async.flow/outs data))
46-
(assoc-in [proc :state] (:clojure.core.async.flow/state data))
47-
(assoc-in [proc :ins :in :put-count] (-> data :clojure.core.async.flow/ins :in :put-count))
48-
(assoc-in [proc :ins :in :take-count] (-> data :clojure.core.async.flow/ins :in :take-count))
49-
(assoc-in [proc :ins :in :buffer :type] (-> data :clojure.core.async.flow/ins :in :buffer :type))
50-
(assoc-in [proc :ins :in :buffer :count] (-> data :clojure.core.async.flow/ins :in :buffer :count))
51-
(assoc-in [proc :ins :in :buffer :capacity] (-> data :clojure.core.async.flow/ins :in :buffer :capacity))
52-
(assoc-in [proc :outs :out :put-count] (-> data :clojure.core.async.flow/outs :in :put-count))
53-
(assoc-in [proc :outs :out :take-count] (-> data :clojure.core.async.flow/outs :in :take-count))
54-
(assoc-in [proc :outs :out :buffer :type] (-> data :clojure.core.async.flow/outs :out :buffer :type))
55-
(assoc-in [proc :outs :out :buffer :count] (-> data :clojure.core.async.flow/outs :out :buffer :count))
56-
(assoc-in [proc :outs :out :buffer :capacity] (-> data :clojure.core.async.flow/outs :out :buffer :capacity))
57-
))
58-
relationships ping))
40+
(let [r+p (reduce-kv (fn [res proc data]
41+
(-> res
42+
(assoc-in [proc :status] (:clojure.core.async.flow/status data))
43+
(assoc-in [proc :count] (:clojure.core.async.flow/count data))
44+
(assoc-in [proc :ins] (:clojure.core.async.flow/ins data))
45+
(assoc-in [proc :outs] (:clojure.core.async.flow/outs data))
46+
(assoc-in [proc :state] (:clojure.core.async.flow/state data))
47+
(assoc-in [proc :ins :in :put-count] (-> data :clojure.core.async.flow/ins :in :put-count))
48+
(assoc-in [proc :ins :in :take-count] (-> data :clojure.core.async.flow/ins :in :take-count))
49+
(assoc-in [proc :ins :in :buffer :type] (-> data :clojure.core.async.flow/ins :in :buffer :type))
50+
(assoc-in [proc :ins :in :buffer :count] (-> data :clojure.core.async.flow/ins :in :buffer :count))
51+
(assoc-in [proc :ins :in :buffer :capacity] (-> data :clojure.core.async.flow/ins :in :buffer :capacity))
52+
(assoc-in [proc :outs :out :put-count] (-> data :clojure.core.async.flow/outs :in :put-count))
53+
(assoc-in [proc :outs :out :take-count] (-> data :clojure.core.async.flow/outs :in :take-count))
54+
(assoc-in [proc :outs :out :buffer :type] (-> data :clojure.core.async.flow/outs :out :buffer :type))
55+
(assoc-in [proc :outs :out :buffer :count] (-> data :clojure.core.async.flow/outs :out :buffer :count))
56+
(assoc-in [proc :outs :out :buffer :capacity] (-> data :clojure.core.async.flow/outs :out :buffer :capacity))
57+
)) relationships ping)
58+
roots (filter (fn [[_ v]] (empty? (:from v))) r+p)]
59+
(swap! global-state assoc :roots roots)
60+
r+p))
5961

6062
(defn flow-levels [relationships]
6163
(loop [result []
@@ -231,7 +233,7 @@
231233
(send-socket-data {:action :pause-proc :pid proc})
232234
(send-socket-data {:action :resume-proc :pid proc})))}
233235
[:img {:src (if paused? "assets/img/pause_icon_orange.svg" "assets/img/pause_icon_white.svg")}]]]
234-
(when (> since-last-updated 0) [:div.stale "Last Updated: " since-last-updated " seconds ago."])]))
236+
(when (> since-last-updated 10) [:div.stale "Last Updated: " since-last-updated " seconds ago."])]))
235237

236238
(defn buffer-usage-percentage [buffer-count buffer-capacity]
237239
(* 100 (/ (js/parseInt buffer-count) (js/parseInt buffer-capacity))))
@@ -305,12 +307,12 @@
305307
(update-arrows proc ins outs)
306308
[:div.card-container {:id (name proc)
307309
:class (when (= :line @chan-representation) "line-chan-style")}
308-
; TODO Conditional upon having a distinct channel id
309-
#_ [:div.meter-cards
310-
(doall (for [in ins
311-
:when (-> in second :buffer :type)]
312-
(let [in-name (first in)]
313-
^{:key in-name} [meter-card proc in])))]
310+
[:div.meter-cards.animate__animated.collapsible-meter
311+
{:class (if (= :meter @chan-representation) "animate__fadeInDown" "animate__fadeOutUp")}
312+
(doall (for [in ins
313+
:when (-> in second :buffer :type)]
314+
(let [in-name (first in)]
315+
^{:key in-name} [meter-card proc in])))]
314316
[:div.proc-card {:class (str (if expanded? "expanded" "collapsed"))}
315317
(if paused?
316318
[:div.dot-pattern.animate__animated.animate__fadeIn]
@@ -352,7 +354,7 @@
352354
(doall (for [[io-id buffer-stats] outs
353355
:when (-> buffer-stats :buffer :type)]
354356
^{:key (str proc "-" io-id)} [:div.output {:id (str proc "-" io-id "-collapsed")}]))]]]]
355-
[:div.output-cards.animate__animated.collapsible-meter
357+
#_ [:div.output-cards.animate__animated.collapsible-meter
356358
{:class (if (= :meter @chan-representation)
357359
"animate__fadeInDown"
358360
"animate__fadeOutUp")}

0 commit comments

Comments
 (0)