Skip to content

Commit

Permalink
WIP Implement components for dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
kaffein committed Jun 9, 2020
1 parent 1aea3fc commit a7c5c14
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions src/dashboard/components/dashboard.cljs
Original file line number Diff line number Diff line change
@@ -1,24 +1,36 @@
(ns dashboard.components.dashboard
(:require [reagent.core :as r]
[re-frame.core :as rf]
[reagent.dom :as rdom]
[taoensso.timbre :as log
:refer-macros [log trace debug info warn error fatal report
logf tracef debugf infof warnf errorf fatalf reportf
spy get-env]]
["bloomer" :refer (Tile Hero HeroBody Title Subtitle Notification)]
["react-router-dom" :refer (NavLink)]
[dashboard.components.search :refer [search]]))
[dashboard.components.search :refer [search]]
[dashboard.subs.dashboard]))

(defn dashboard-stat-display
[label value path]
[:> NavLink {:class "tile is-parent is-4" :to path}
[:> Tile {:ischild "true" :class "box"}
[:> Title @value]
[:> Subtitle label]]])

(defn dashboard
[]
[:div
[:> Hero {:isbold "true" :iscolor "true" :issize "small"}
[:> HeroBody
[:> Title "Dashboard"]
[:> Subtitle "Uptime"]]]
[:div.tiles
[:> Tile {:isancestor "true" :hastextalign "centered"}
[:> NavLink {:class "tile is-parent is-4" :to "/adapters"}
[:> Tile {:ischild "true" :class "box"}
[:> Title "stats.adapter_count"]
[:> Subtitle "Adapters"]]]]]])
(let [_ (rf/dispatch [:dashboard.stats/fetch 120])
adapter-count (rf/subscribe [:dashboard.stats/adapter-count])
command-count (rf/subscribe [:dashboard.stats/command-count])
command-count-today (rf/subscribe [:dashboard.stats/command-count-today])]
[:div
[:> Hero {:isbold "true" :iscolor "true" :issize "small"}
[:> HeroBody
[:> Title "Dashboard"]
[:> Subtitle "Uptime"]]]
[:div.tiles
[:> Tile {:isancestor "true" :hastextalign "centered"}
[dashboard-stat-display "Adapters" adapter-count "/adapters"]
[dashboard-stat-display "Commands" command-count "/history?co=1"]
[dashboard-stat-display "Commands today" command-count-today "/"]]]]))

0 comments on commit a7c5c14

Please sign in to comment.