diff options
author | David Barksdale <amatus@amatus.name> | 2014-08-14 20:52:58 -0500 |
---|---|---|
committer | David Barksdale <amatus@amatus.name> | 2014-08-14 21:29:02 -0500 |
commit | ad7af88c9e029f47a25cf6544d852985001db8be (patch) | |
tree | a2ae4d1825962915db42e9e5c1890a706b3df07f /src/hl/index.cljs.hl | |
parent | c9c7a100b7b19a63c5269b29165e27e0c108292c (diff) |
Add a table with transport connection states
And automatically load hostlist.
Diffstat (limited to 'src/hl/index.cljs.hl')
-rw-r--r-- | src/hl/index.cljs.hl | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/src/hl/index.cljs.hl b/src/hl/index.cljs.hl index 869678b..66edd7e 100644 --- a/src/hl/index.cljs.hl +++ b/src/hl/index.cljs.hl @@ -15,15 +15,24 @@ ;; along with this program. If not, see <http://www.gnu.org/licenses/>. (page "index.html" - (:use [gnunet-web.hostlist :only (fetch-and-process!)] + (:use [amatus.code :only (base32-crockford)] + [gnunet-web.hostlist :only (fetch-and-process!)] [gnunet-web.service :only (start-worker)] - [gnunet-web.transport :only (monitor-peers)])) + [gnunet-web.transport :only (addr->string monitor-peers + state->string)])) (set! *print-fn* #(.log js/console %)) (def topology-worker (start-worker "topology" "js/gnunet-daemon-topology.js")) (def fs-worker (start-worker "fs" "js/gnunet-service-fs.js")) -(monitor-peers (fn [_])) + +(defc peers {}) +(monitor-peers (fn [message] + (swap! peers assoc (:peer message) + {:state (:state message) + :address (:address message) + :plugin (:plugin message)}))) +(fetch-and-process!) (defelem ui-button [attr kids] @@ -31,10 +40,32 @@ (html (head - (link :rel "stylesheet" :type "text/css" :href "css/main.css") (link :rel "stylesheet" :type "text/css" :href "css/semantic.min.css") (script :src "js/semantic.min.js")) (body - (ui-button :click fetch-and-process! "Fetch hostlist"))) + (table :class "ui table segment" + (thead + (tr + (th :text "Peer ID") + (th :text "State") + (th :text "Transport") + (th :text "Address"))) + (tbody + (loop-tpl :bindings [[peer info] peers] + (tr + (td :width "25%" + :text (cell= + (apply str + (concat + (take 4 (base32-crockford peer)) + "\u2026"))) + :title (cell= (base32-crockford peer))) + (td :width "25%" + :text (cell= (state->string (:state info)))) + (td :width "25%" + :text (cell= (:plugin info))) + (td :width "25%" + :text (cell= (addr->string (:address info)))))))) + (div :class "ui active inline loader"))) ;; vim: set expandtab ts=2 sw=2 filetype=clojure : |