2424 (update-in [from-proc :outs ] (fnil conj []) out-port)))
2525 {} data))
2626
27- (defn flow-levels [relationships]
28- (loop [result []
29- current-level (filter (fn [[_ v]] (empty? (:from v))) relationships)
27+ (defn flow-levels [relationships root]
28+ (let [orphans (filter (fn [[_ v]] (empty? (:from v))) relationships)
29+ user-roots (filter (fn [[k _]] (contains? (set root) k)) relationships)]
30+ (loop [result []
31+ current-level (if (empty? orphans) user-roots orphans)
3032 remaining (apply dissoc relationships (map first current-level))]
3133 (if (empty? current-level)
3234 result
3335 (let [next-level (select-keys remaining (mapcat (fn [[_ v]] (:to v)) current-level))]
3436 (recur (conj result (map (fn [[k v]] {k v}) current-level))
3537 next-level
36- (apply dissoc remaining (keys next-level)))))))
38+ (apply dissoc remaining (keys next-level))))))))
3739
3840(defn proc-card [proc]
3941 [:div.middle-section-one-container
6062 (for [proc row]
6163 (proc-el proc))])
6264
63- (defn chart [conns]
65+ (defn chart [conns root ]
6466 (let [relationships (flow-relationships conns)]
6567 [:div#chart
66- (for [[idx row] (map-indexed vector (flow-levels relationships))]
68+ (for [[idx row] (map-indexed vector (flow-levels relationships root ))]
6769 (proc-row idx row))]))
6870
6971(defn json-friendly [conn]
7981(defn connections-to-json [connections]
8082 (json/write-str (mapv json-friendly connections)))
8183
82- (defn template [{:keys [conns]}]
84+ (defn template [{:keys [conns]} root ]
8385 (str
8486 (h/html
8587 [:html
@@ -116,8 +118,8 @@ window.addEventListener('load', function() {
116118 drawConnections();});" )]
117119 [:style "html,\nbody {\n margin: 0;\n padding: 0;\n}\n\nbody {\n height: 100vh;\n width: 100vw;\n margin-top: 50px;\n background-color: #CBD2D9;\n}\n\n.row-3 {\n display: flex;\n flex-direction: row;\n justify-content: center;\n gap: 10px;\n align-items: center;\n}\n\n.card-container {\n display: flex;\n flex-direction: column;\n align-items: center;\n margin-bottom: 40px;\n min-width: 220px;\n}\n.card-container .proc-card {\n background: #F5F7FA;\n border-radius: 3px;\n width: 100%;\n display: inline-block;\n position: relative;\n transition: all 0.4s ease-in-out;\n will-change: height;\n margin-bottom: 55px;\n}\n.card-container .proc-card.expanded .expanded-view {\n max-height: 500px;\n opacity: 1;\n visibility: visible;\n}\n.card-container .proc-card .expanded-view {\n transition: all 0.4s ease-in-out;\n max-height: 0;\n opacity: 0;\n overflow: hidden;\n visibility: hidden;\n}\n.card-container .proc-card .expanded-view .header-labels {\n display: flex;\n justify-content: center;\n padding: 0 15px;\n}\n.card-container .proc-card .expanded-view .header-labels .header-label {\n font-size: 1.75em;\n font-weight: 500;\n color: #4a4a4a;\n text-align: center;\n width: 150px;\n}\n.card-container .proc-card .expanded-view .middle-section-one-container {\n box-sizing: border-box;\n background: #52606D;\n color: #E4E7EB;\n border-radius: 2px;\n position: relative;\n padding: 10px 0;\n width: calc(100% - 20px);\n margin: auto;\n}\n.card-container .proc-card .expanded-view .title-container {\n text-align: center;\n}\n.card-container .proc-card .expanded-view .title-container .title {\n font-size: 2.3em;\n font-weight: 600;\n margin: 0;\n color: white;\n}\n.card-container .proc-card .output-section {\n width: 100%;\n display: flex;\n flex-direction: column;\n align-items: center;\n box-sizing: border-box;\n}\n.card-container .proc-card .output-section .output-container {\n display: flex;\n flex-direction: row;\n gap: 15px;\n justify-content: center;\n align-items: center;\n width: calc(100% - 14px);\n margin: 0 7px;\n padding: 0 0;\n box-sizing: border-box;\n}\n.card-container .proc-card .output-section .output-container .output {\n flex: 1;\n min-width: 110px;\n padding: 0 8px;\n font-size: 1.75em;\n color: #4a4a4a;\n text-align: center;\n height: 40px;\n display: flex;\n justify-content: center;\n align-items: center;\n white-space: nowrap;\n}\n"]]
118120 [:body
119- (chart conns)]])))
121+ (chart conns root )]])))
120122
121- (defn graph [flow-config]
122- (tagged-literal 'flare/html {:html (template flow-config)
123+ (defn graph [flow-config & root ]
124+ (tagged-literal 'flare/html {:html (template flow-config ( first root) )
123125 :title " Flow Chart" }))
0 commit comments