|
|
@@ -1,5 +1,7 @@
|
|
|
(ns frontend.db.rtc.debug-ui
|
|
|
"Debug UI for rtc module"
|
|
|
+ (:require-macros
|
|
|
+ [frontend.db.rtc.macro :refer [with-sub-data-from-ws get-req-id get-result-ch]])
|
|
|
(:require [frontend.ui :as ui]
|
|
|
[rum.core :as rum]
|
|
|
[frontend.db.rtc.core :as rtc-core]
|
|
|
@@ -57,6 +59,8 @@
|
|
|
(rum/local nil ::ops)
|
|
|
(rum/local nil ::ws-state)
|
|
|
(rum/local nil ::download-graph-to-repo)
|
|
|
+ (rum/local nil ::remote-graphs)
|
|
|
+ (rum/local nil ::graph-uuid-to-download)
|
|
|
[state]
|
|
|
(let [s (rum/react debug-state)
|
|
|
rtc-state (and s (rum/react (:*rtc-state s)))]
|
|
|
@@ -66,7 +70,14 @@
|
|
|
(let [repo (state/get-current-repo)
|
|
|
{:keys [local-tx ops]}
|
|
|
(<! (p->c (op/<get-ops&local-tx repo)))
|
|
|
- graph-uuid (<! (p->c (op/<get-graph-uuid repo)))]
|
|
|
+ graph-uuid (<! (p->c (op/<get-graph-uuid repo)))
|
|
|
+ graph-list (when (= :open rtc-state)
|
|
|
+ (with-sub-data-from-ws s
|
|
|
+ (<! (ws/<send! s {:req-id (get-req-id)
|
|
|
+ :action "list-graphs"
|
|
|
+ :graph-uuid "placeholder"}))
|
|
|
+ (:graphs (<! (get-result-ch)))))]
|
|
|
+ (reset! (::remote-graphs state) (map :graph-uuid graph-list))
|
|
|
(reset! (::local-tx state) local-tx)
|
|
|
(reset! (::ops state) (count ops))
|
|
|
(reset! (::graph-uuid state) graph-uuid)
|
|
|
@@ -77,7 +88,8 @@
|
|
|
:rtc-state rtc-state
|
|
|
:ws (and s (ws/get-state @(:*ws s)))
|
|
|
:local-tx @(::local-tx state)
|
|
|
- :pending-ops @(::ops state)}
|
|
|
+ :pending-ops @(::ops state)
|
|
|
+ :remote-graphs @(::remote-graphs state)}
|
|
|
(fipp/pprint {:width 20})
|
|
|
with-out-str)]
|
|
|
(if (or (nil? s)
|
|
|
@@ -87,17 +99,24 @@
|
|
|
|
|
|
[:div.my-2
|
|
|
[:div.my-2 (ui/button (str "send pending ops")
|
|
|
- {:on-click (fn [] (push-pending-ops))})]
|
|
|
+ {:on-click (fn [] (push-pending-ops))})]
|
|
|
[:div (ui/button "stop" {:on-click (fn [] (<stop))})]])
|
|
|
[:hr]
|
|
|
[:div.flex
|
|
|
+ ;; [:select
|
|
|
+ ;; {:on-change (fn [e]
|
|
|
+ ;; (let [value (util/evalue e)]
|
|
|
+ ;; (reset! (::graph-uuid-to-download state) value)))}
|
|
|
+ ;; (for [graph-uuid @(::remote-graphs state)]
|
|
|
+ ;; [:option {:key graph-uuid :value graph-uuid} graph-uuid])]
|
|
|
(ui/button (str "download graph to")
|
|
|
{:class "mr-2"
|
|
|
:on-click (fn []
|
|
|
(go
|
|
|
(when-let [repo @(::download-graph-to-repo state)]
|
|
|
- (<! (<download-graph repo debug-graph-uuid))
|
|
|
- (notification/show! "download graph successfully"))))})
|
|
|
+ (when-let [graph-uuid @(::graph-uuid-to-download state)]
|
|
|
+ (<! (<download-graph repo graph-uuid))
|
|
|
+ (notification/show! "download graph successfully")))))})
|
|
|
(ui/ls-textarea {:on-change (fn [e] (reset! (::download-graph-to-repo state) (util/evalue e)))})]
|
|
|
[:div.flex.my-2
|
|
|
(ui/button (str "upload graph") {:on-click (fn []
|