-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP Implement components for dashboard
- Loading branch information
Showing
1 changed file
with
24 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 "/"]]]])) |