Skip to content

Commit a7c5c14

Browse files
committed
WIP Implement components for dashboard
1 parent 1aea3fc commit a7c5c14

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed
Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,36 @@
11
(ns dashboard.components.dashboard
22
(:require [reagent.core :as r]
3+
[re-frame.core :as rf]
34
[reagent.dom :as rdom]
45
[taoensso.timbre :as log
56
:refer-macros [log trace debug info warn error fatal report
67
logf tracef debugf infof warnf errorf fatalf reportf
78
spy get-env]]
89
["bloomer" :refer (Tile Hero HeroBody Title Subtitle Notification)]
910
["react-router-dom" :refer (NavLink)]
10-
[dashboard.components.search :refer [search]]))
11+
[dashboard.components.search :refer [search]]
12+
[dashboard.subs.dashboard]))
13+
14+
(defn dashboard-stat-display
15+
[label value path]
16+
[:> NavLink {:class "tile is-parent is-4" :to path}
17+
[:> Tile {:ischild "true" :class "box"}
18+
[:> Title @value]
19+
[:> Subtitle label]]])
1120

1221
(defn dashboard
1322
[]
14-
[:div
15-
[:> Hero {:isbold "true" :iscolor "true" :issize "small"}
16-
[:> HeroBody
17-
[:> Title "Dashboard"]
18-
[:> Subtitle "Uptime"]]]
19-
[:div.tiles
20-
[:> Tile {:isancestor "true" :hastextalign "centered"}
21-
[:> NavLink {:class "tile is-parent is-4" :to "/adapters"}
22-
[:> Tile {:ischild "true" :class "box"}
23-
[:> Title "stats.adapter_count"]
24-
[:> Subtitle "Adapters"]]]]]])
23+
(let [_ (rf/dispatch [:dashboard.stats/fetch 120])
24+
adapter-count (rf/subscribe [:dashboard.stats/adapter-count])
25+
command-count (rf/subscribe [:dashboard.stats/command-count])
26+
command-count-today (rf/subscribe [:dashboard.stats/command-count-today])]
27+
[:div
28+
[:> Hero {:isbold "true" :iscolor "true" :issize "small"}
29+
[:> HeroBody
30+
[:> Title "Dashboard"]
31+
[:> Subtitle "Uptime"]]]
32+
[:div.tiles
33+
[:> Tile {:isancestor "true" :hastextalign "centered"}
34+
[dashboard-stat-display "Adapters" adapter-count "/adapters"]
35+
[dashboard-stat-display "Commands" command-count "/history?co=1"]
36+
[dashboard-stat-display "Commands today" command-count-today "/"]]]]))

0 commit comments

Comments
 (0)