1
1
(ns dashboard.components.dashboard
2
2
(:require [reagent.core :as r]
3
+ [re-frame.core :as rf]
3
4
[reagent.dom :as rdom]
4
5
[taoensso.timbre :as log
5
6
:refer-macros [log trace debug info warn error fatal report
6
7
logf tracef debugf infof warnf errorf fatalf reportf
7
8
spy get-env]]
8
9
[" bloomer" :refer (Tile Hero HeroBody Title Subtitle Notification)]
9
10
[" 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]]])
11
20
12
21
(defn dashboard
13
22
[]
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