From 70c5fca3db4a8fd4f0cbbb48857b6b3b1781ce2e Mon Sep 17 00:00:00 2001 From: RAZAFIMAHEFA Aina Date: Sun, 19 Apr 2020 17:45:37 +0200 Subject: [PATCH 01/48] Update shadow-cljs configuration --- shadow-cljs.edn | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/shadow-cljs.edn b/shadow-cljs.edn index 9d48028..1b2201b 100644 --- a/shadow-cljs.edn +++ b/shadow-cljs.edn @@ -3,6 +3,10 @@ :builds {:dashboard {:target :browser - :output-dir "public/assets/app/js" - :asset-path "/assets/app/js" - :modules {:main {:entries [dashboard.core]}}}}} \ No newline at end of file + :output-dir "resources/public/assets/js" + :asset-path "/assets/js" + :modules {:dashboard {:init-fn dashboard.core/init}} + :devtools {:http-root "resources/public" + :http-handler shadow.http.push-state/handle + :http-port 8000 + :after-load dashboard.core/start}}}} \ No newline at end of file From fb97f632023da4147736c69cc8faa3078652a9b6 Mon Sep 17 00:00:00 2001 From: RAZAFIMAHEFA Aina Date: Sun, 19 Apr 2020 17:47:57 +0200 Subject: [PATCH 02/48] Implement app entrypoint in index.html --- resources/public/index.html | 8 +++----- src/dashboard/core.cljs | 19 ++++++++++++++++++- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/resources/public/index.html b/resources/public/index.html index 12081cd..a62e235 100644 --- a/resources/public/index.html +++ b/resources/public/index.html @@ -5,12 +5,10 @@ + -
-

Figwheel template

-

Checkout your developer console.

-
- +
If you see this then there must be an issue with the react rendering in dashboard.core/init
+ diff --git a/src/dashboard/core.cljs b/src/dashboard/core.cljs index e13e23f..1926810 100644 --- a/src/dashboard/core.cljs +++ b/src/dashboard/core.cljs @@ -1,5 +1,6 @@ (ns dashboard.core - (:require )) + (:require [reagent.core :as r] + [reagent.dom :as rdom])) (enable-console-print!) @@ -9,6 +10,22 @@ (defonce app-state (atom {:text "Hello world!"})) +(defn dashboard-app + "The dashboard component" + [] + [:div.container + [:h1.title "And we are good to go!!!"]]) + +(defn start + "Mounts the application root component in the DOM." + [] + (rdom/render [dashboard-app] (js/document.getElementById "app"))) + +(defn ^:export init + "Dashboard entrypoint which is called only once when `index.html` loads. + It must be exported so it is available even in :advanced release builds." + [] + (start)) (defn on-js-reload [] ;; optionally touch your app-state to force rerendering depending on From 28373a9ea88d3aab186bd9faae4e289b5d99e918 Mon Sep 17 00:00:00 2001 From: RAZAFIMAHEFA Aina Date: Sat, 25 Apr 2020 17:11:18 +0200 Subject: [PATCH 03/48] Add logging library --- project.clj | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/project.clj b/project.clj index 97e7741..ab66b60 100644 --- a/project.clj +++ b/project.clj @@ -7,10 +7,18 @@ :min-lein-version "2.9.1" :dependencies [[org.clojure/clojure "1.10.0"] - [org.clojure/clojurescript "1.10.520"] + + ;; clojurescript and tooling + [org.clojure/clojurescript "1.10.520" :scope "provided"] [binaryage/devtools "1.0.0"] [thheller/shadow-cljs "2.8.94"] + + ;; react [reagent "0.10.0"] + + ;; logging + [com.taoensso/timbre "4.10.0"] + ;; These has to be explicitly specified as lein does not ;; properly manage dependency version conflicts : ;; https://github.com/thheller/shadow-cljs/issues/488#issuecomment-486732296 From 1f451bae57c74a7b8b562f4a0ec82eb9447248a5 Mon Sep 17 00:00:00 2001 From: RAZAFIMAHEFA Aina Date: Sat, 25 Apr 2020 17:20:32 +0200 Subject: [PATCH 04/48] Add npm deps for bulma, bloomer and a few utils --- package.json | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 package.json diff --git a/package.json b/package.json new file mode 100644 index 0000000..3ae1901 --- /dev/null +++ b/package.json @@ -0,0 +1,29 @@ +{ + "name": "dashboard", + "version": "1.0.0", + "description": "The new (as of 2020) CLJS frontend dashboard for Yetibot", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/kaffein/dashboard.git" + }, + "keywords": [], + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/kaffein/dashboard/issues" + }, + "homepage": "https://github.com/kaffein/dashboard#readme", + "dependencies": { + "bloomer": "^0.6.5", + "bulma": "^0.8.2", + "bulma-checkradio": "^1.1.1", + "create-react-class": "^15.6.3", + "react": "^16.13.1", + "react-dom": "^16.13.1", + "react-router-dom": "^5.1.2" + } +} From a6b16cc5484412b57b4507cea9939d23be05a52f Mon Sep 17 00:00:00 2001 From: RAZAFIMAHEFA Aina Date: Sat, 25 Apr 2020 17:21:16 +0200 Subject: [PATCH 05/48] Implement top nav bar --- src/dashboard/components/search.cljs | 21 +++++++++++++++++++ src/dashboard/core.cljs | 31 ++++++++++++++++++++++++---- 2 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 src/dashboard/components/search.cljs diff --git a/src/dashboard/components/search.cljs b/src/dashboard/components/search.cljs new file mode 100644 index 0000000..6f4b9a4 --- /dev/null +++ b/src/dashboard/components/search.cljs @@ -0,0 +1,21 @@ +(ns dashboard.components.search + (:require [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" :as bloomer])) + +(defn search + "Search component skeleton" + [] + [:> bloomer/Control {:is-expanded true + :has-icons "left"} + [:input {:type :text + :value "" + :placeholder "Search history" + :iscolor "light" + :on-change (fn [e] + (info "changed this to stuff"))}] + [:> bloomer/Icon {:is-size "small" + :is-align "left" + :class "fa fa-search"}]]) \ No newline at end of file diff --git a/src/dashboard/core.cljs b/src/dashboard/core.cljs index 1926810..e35e646 100644 --- a/src/dashboard/core.cljs +++ b/src/dashboard/core.cljs @@ -1,6 +1,13 @@ (ns dashboard.core - (:require [reagent.core :as r] - [reagent.dom :as rdom])) + (:require [reagent.core :as r] + [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" :as bloomer] + ["react-router-dom" :as router] + [dashboard.components.search :refer [search]])) (enable-console-print!) @@ -13,8 +20,24 @@ (defn dashboard-app "The dashboard component" [] - [:div.container - [:h1.title "And we are good to go!!!"]]) + [:div "testing this"] + [:> router/BrowserRouter + [:div + [:> bloomer/Navbar {:class "is-white is-fixed-top"} + [:> bloomer/Container + [:> bloomer/NavbarStart + [:> bloomer/NavbarBrand + [:> bloomer/NavbarItem + [:> router/NavLink {:to "/"} + [:img {:style {:width 120 + :height 28} + :class "yetibot-logo" + :alt "Yetibot" + :src "https://yetibot.com/img/yetibot_lambda_blue_with_grey.svg"}]]]]] + [:> bloomer/NavbarEnd + [:> bloomer/NavbarItem + [:> bloomer/Field + [search]]]]]]]]) (defn start "Mounts the application root component in the DOM." From f1f44d73c60e4bf02b1d8f859e12bfc610509ffa Mon Sep 17 00:00:00 2001 From: RAZAFIMAHEFA Aina Date: Sat, 25 Apr 2020 18:09:17 +0200 Subject: [PATCH 06/48] Implement left pane menu UI --- src/dashboard/core.cljs | 93 ++++++++++++++++++++++++++++++++++------- 1 file changed, 77 insertions(+), 16 deletions(-) diff --git a/src/dashboard/core.cljs b/src/dashboard/core.cljs index e35e646..6df30b3 100644 --- a/src/dashboard/core.cljs +++ b/src/dashboard/core.cljs @@ -17,27 +17,88 @@ (defonce app-state (atom {:text "Hello world!"})) +(defn nav-bar + "Top nav bar" + [] + [:> bloomer/Navbar {:class "is-white is-fixed-top"} + [:> bloomer/Container + [:> bloomer/NavbarStart + [:> bloomer/NavbarBrand + [:> bloomer/NavbarItem + [:> router/NavLink {:to "/"} + [:img {:style {:width 120 + :height 28} + :class "yetibot-logo" + :alt "Yetibot" + :src "https://yetibot.com/img/yetibot_lambda_blue_with_grey.svg"}]]]]] + [:> bloomer/NavbarEnd + [:> bloomer/NavbarItem + [:> bloomer/Field + [search]]]]]]) + +(defn content-body + "Content body" + [] + [:> bloomer/Container {:id "content/body"} + [:div {:class "columns"} + [:div {:class "column is-2"} + [:> bloomer/Menu + ;; yetibot + [:> bloomer/MenuLabel "Yetibot"] + [:> bloomer/MenuList + [:li + [:> router/NavLink {:exact true + :to "/"} "Dashboard"]] + [:li + [:> router/NavLink {:to "/history"} "History"]] + [:li + [:> router/NavLink {:to "/users"} "Users"]] + [:li + [:> router/NavLink {:to "/adapters"} "Adapters"]] + [:li + [:> router/NavLink {:to "/aliases"} "Aliases"]] + [:li + [:> router/NavLink {:to "/observers"} "Observers"]] + [:li + [:> router/NavLink {:to "/cron"} "Cron tasks"]] + [:li + [:> router/NavLink {:to "/repl"} "REPL"]]] + + ;; links + [:> bloomer/MenuLabel "Links"] + [:> bloomer/MenuList + [:li + [:a {:href "https://yetibot.com"} + [:> bloomer/Icon {:is-size "small" + :is-align "left" + :class "fa fa-external-link-alt"}] + "Yetibot.com"]] + [:li + [:a {:href "https://github.com/yetibot/yetibot"} + [:> bloomer/Icon {:is-size "small" + :is-align "left" + :class "fa fa-external-link-alt"}] + "Github"]] + [:li + [:a {:href "https://yetibot.com/archives"} + [:> bloomer/Icon {:is-size "small" + :is-align "left" + :class "fa fa-external-link-alt"}] + "Blog"]] + [:li + [:a {:href "https://yetibot.com/user-guide"} + [:> bloomer/Icon {:is-size "small" + :is-align "left" + :class "fa fa-external-link-alt"}] + "Docs"]]]]]]]) + (defn dashboard-app "The dashboard component" [] - [:div "testing this"] [:> router/BrowserRouter [:div - [:> bloomer/Navbar {:class "is-white is-fixed-top"} - [:> bloomer/Container - [:> bloomer/NavbarStart - [:> bloomer/NavbarBrand - [:> bloomer/NavbarItem - [:> router/NavLink {:to "/"} - [:img {:style {:width 120 - :height 28} - :class "yetibot-logo" - :alt "Yetibot" - :src "https://yetibot.com/img/yetibot_lambda_blue_with_grey.svg"}]]]]] - [:> bloomer/NavbarEnd - [:> bloomer/NavbarItem - [:> bloomer/Field - [search]]]]]]]]) + [nav-bar] + [content-body]]]) (defn start "Mounts the application root component in the DOM." From 36811c6997b250bbe086c926aa58c37129e8c16b Mon Sep 17 00:00:00 2001 From: RAZAFIMAHEFA Aina Date: Sun, 26 Apr 2020 11:33:12 +0200 Subject: [PATCH 07/48] Make code less verbose when referring to external components --- src/dashboard/core.cljs | 72 +++++++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 32 deletions(-) diff --git a/src/dashboard/core.cljs b/src/dashboard/core.cljs index 6df30b3..54c20c7 100644 --- a/src/dashboard/core.cljs +++ b/src/dashboard/core.cljs @@ -2,11 +2,12 @@ (:require [reagent.core :as r] [reagent.dom :as rdom] [taoensso.timbre :as log - :refer-macros [log trace debug info warn error fatal report + :refer-macros [log trace debug info warn error fatal report logf tracef debugf infof warnf errorf fatalf reportf spy get-env]] - ["bloomer" :as bloomer] - ["react-router-dom" :as router] + ["bloomer" :refer (Navbar Container NavbarStart NavbarBrand NavbarItem + Icon MenuList MenuLabel Menu Field NavbarEnd)] + ["react-router-dom" :refer (Route NavLink) :rename {BrowserRouter Router}] [dashboard.components.search :refer [search]])) (enable-console-print!) @@ -20,85 +21,92 @@ (defn nav-bar "Top nav bar" [] - [:> bloomer/Navbar {:class "is-white is-fixed-top"} - [:> bloomer/Container - [:> bloomer/NavbarStart - [:> bloomer/NavbarBrand - [:> bloomer/NavbarItem - [:> router/NavLink {:to "/"} + [:> Navbar {:class "is-white is-fixed-top"} + [:> Container + [:> NavbarStart + [:> NavbarBrand + [:> NavbarItem + [:> NavLink {:to "/"} [:img {:style {:width 120 :height 28} :class "yetibot-logo" :alt "Yetibot" :src "https://yetibot.com/img/yetibot_lambda_blue_with_grey.svg"}]]]]] - [:> bloomer/NavbarEnd - [:> bloomer/NavbarItem - [:> bloomer/Field + [:> NavbarEnd + [:> NavbarItem + [:> Field [search]]]]]]) (defn content-body "Content body" [] - [:> bloomer/Container {:id "content/body"} + [:> Container {:id "content/body"} [:div {:class "columns"} [:div {:class "column is-2"} - [:> bloomer/Menu + [:> Menu ;; yetibot - [:> bloomer/MenuLabel "Yetibot"] - [:> bloomer/MenuList + [:> MenuLabel "Yetibot"] + [:> MenuList [:li - [:> router/NavLink {:exact true + [:> NavLink {:exact true :to "/"} "Dashboard"]] [:li - [:> router/NavLink {:to "/history"} "History"]] + [:> NavLink {:to "/history"} "History"]] [:li - [:> router/NavLink {:to "/users"} "Users"]] + [:> NavLink {:to "/users"} "Users"]] [:li - [:> router/NavLink {:to "/adapters"} "Adapters"]] + [:> NavLink {:to "/adapters"} "Adapters"]] [:li - [:> router/NavLink {:to "/aliases"} "Aliases"]] + [:> NavLink {:to "/aliases"} "Aliases"]] [:li - [:> router/NavLink {:to "/observers"} "Observers"]] + [:> NavLink {:to "/observers"} "Observers"]] [:li - [:> router/NavLink {:to "/cron"} "Cron tasks"]] + [:> NavLink {:to "/cron"} "Cron tasks"]] [:li - [:> router/NavLink {:to "/repl"} "REPL"]]] + [:> NavLink {:to "/repl"} "REPL"]]] ;; links - [:> bloomer/MenuLabel "Links"] - [:> bloomer/MenuList + [:> MenuLabel "Links"] + [:> MenuList [:li [:a {:href "https://yetibot.com"} - [:> bloomer/Icon {:is-size "small" + [:> Icon {:is-size "small" :is-align "left" :class "fa fa-external-link-alt"}] "Yetibot.com"]] [:li [:a {:href "https://github.com/yetibot/yetibot"} - [:> bloomer/Icon {:is-size "small" + [:> Icon {:is-size "small" :is-align "left" :class "fa fa-external-link-alt"}] "Github"]] [:li [:a {:href "https://yetibot.com/archives"} - [:> bloomer/Icon {:is-size "small" + [:> Icon {:is-size "small" :is-align "left" :class "fa fa-external-link-alt"}] "Blog"]] [:li [:a {:href "https://yetibot.com/user-guide"} - [:> bloomer/Icon {:is-size "small" + [:> Icon {:is-size "small" :is-align "left" :class "fa fa-external-link-alt"}] "Docs"]]]]]]]) +(defn content-container + [] + [:> Container {:id "content-container" + :class "column is-10"} + [:> Router]]) + (defn dashboard-app "The dashboard component" [] - [:> router/BrowserRouter + [:> Router [:div [nav-bar] - [content-body]]]) + [content-body] + [content-container]]]) (defn start "Mounts the application root component in the DOM." From 50fcb0abf99c81ade6bbcdaa0cec81f30653a44c Mon Sep 17 00:00:00 2001 From: RAZAFIMAHEFA Aina Date: Sun, 26 Apr 2020 11:45:37 +0200 Subject: [PATCH 08/48] Implement content container with no components --- src/dashboard/core.cljs | 127 ++++++++++++++++++++++------------------ 1 file changed, 69 insertions(+), 58 deletions(-) diff --git a/src/dashboard/core.cljs b/src/dashboard/core.cljs index 54c20c7..b406610 100644 --- a/src/dashboard/core.cljs +++ b/src/dashboard/core.cljs @@ -37,67 +37,79 @@ [:> Field [search]]]]]]) -(defn content-body - "Content body" +(defn menu [] - [:> Container {:id "content/body"} - [:div {:class "columns"} - [:div {:class "column is-2"} - [:> Menu - ;; yetibot - [:> MenuLabel "Yetibot"] - [:> MenuList - [:li - [:> NavLink {:exact true - :to "/"} "Dashboard"]] - [:li - [:> NavLink {:to "/history"} "History"]] - [:li - [:> NavLink {:to "/users"} "Users"]] - [:li - [:> NavLink {:to "/adapters"} "Adapters"]] - [:li - [:> NavLink {:to "/aliases"} "Aliases"]] - [:li - [:> NavLink {:to "/observers"} "Observers"]] - [:li - [:> NavLink {:to "/cron"} "Cron tasks"]] - [:li - [:> NavLink {:to "/repl"} "REPL"]]] + [:div {:class "column is-2"} + [:> Menu + ;; yetibot + [:> MenuLabel "Yetibot"] + [:> MenuList + [:li + [:> NavLink {:exact true + :to "/"} "Dashboard"]] + [:li + [:> NavLink {:to "/history"} "History"]] + [:li + [:> NavLink {:to "/users"} "Users"]] + [:li + [:> NavLink {:to "/adapters"} "Adapters"]] + [:li + [:> NavLink {:to "/aliases"} "Aliases"]] + [:li + [:> NavLink {:to "/observers"} "Observers"]] + [:li + [:> NavLink {:to "/cron"} "Cron tasks"]] + [:li + [:> NavLink {:to "/repl"} "REPL"]]] - ;; links - [:> MenuLabel "Links"] - [:> MenuList - [:li - [:a {:href "https://yetibot.com"} - [:> Icon {:is-size "small" - :is-align "left" - :class "fa fa-external-link-alt"}] - "Yetibot.com"]] - [:li - [:a {:href "https://github.com/yetibot/yetibot"} - [:> Icon {:is-size "small" - :is-align "left" - :class "fa fa-external-link-alt"}] - "Github"]] - [:li - [:a {:href "https://yetibot.com/archives"} - [:> Icon {:is-size "small" - :is-align "left" - :class "fa fa-external-link-alt"}] - "Blog"]] - [:li - [:a {:href "https://yetibot.com/user-guide"} - [:> Icon {:is-size "small" - :is-align "left" - :class "fa fa-external-link-alt"}] - "Docs"]]]]]]]) + ;; links + [:> MenuLabel "Links"] + [:> MenuList + [:li + [:a {:href "https://yetibot.com"} + [:> Icon {:is-size "small" + :is-align "left" + :class "fa fa-external-link-alt"}] + "Yetibot.com"]] + [:li + [:a {:href "https://github.com/yetibot/yetibot"} + [:> Icon {:is-size "small" + :is-align "left" + :class "fa fa-external-link-alt"}] + "Github"]] + [:li + [:a {:href "https://yetibot.com/archives"} + [:> Icon {:is-size "small" + :is-align "left" + :class "fa fa-external-link-alt"}] + "Blog"]] + [:li + [:a {:href "https://yetibot.com/user-guide"} + [:> Icon {:is-size "small" + :is-align "left" + :class "fa fa-external-link-alt"}] + "Docs"]]]]]) (defn content-container [] - [:> Container {:id "content-container" - :class "column is-10"} - [:> Router]]) + [:div#content-container.column.is-10 + [:> Route {:path "/" :exact true}] + [:> Route {:path "/adapters"}] + [:> Route {:path "/history"}] + [:> Route {:path "/users"}] + [:> Route {:path "/user/:id"}] + [:> Route {:path "/aliases"}] + [:> Route {:path "/observers"}] + [:> Route {:path "/cron"}] + [:> Route {:path "/repl"}]]) + +(defn content-body + "Content body" + [] + [:> Container {:id "content/body"} + [:div.columns + [menu] + [content-container]]]) (defn dashboard-app "The dashboard component" @@ -105,8 +117,7 @@ [:> Router [:div [nav-bar] - [content-body] - [content-container]]]) + [content-body]]]) (defn start "Mounts the application root component in the DOM." From be38525f9ddc8ac0f944a53c6e33828f2e1f59dd Mon Sep 17 00:00:00 2001 From: RAZAFIMAHEFA Aina Date: Fri, 5 Jun 2020 18:59:37 +0200 Subject: [PATCH 09/48] Add re-frame and re-graph dependencies --- project.clj | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/project.clj b/project.clj index ab66b60..ebe9650 100644 --- a/project.clj +++ b/project.clj @@ -15,10 +15,15 @@ ;; react [reagent "0.10.0"] + [re-frame "0.12.0"] ;; logging [com.taoensso/timbre "4.10.0"] + ;; graphql + [re-graph "0.1.12"] + [district0x/graphql-query "1.0.5"] + ;; These has to be explicitly specified as lein does not ;; properly manage dependency version conflicts : ;; https://github.com/thheller/shadow-cljs/issues/488#issuecomment-486732296 From 4ab94c30442aa00e26686781c84d9ad30bc9dcf9 Mon Sep 17 00:00:00 2001 From: RAZAFIMAHEFA Aina Date: Fri, 5 Jun 2020 19:02:38 +0200 Subject: [PATCH 10/48] Add re-frame-10x tooling and configuration --- project.clj | 1 + shadow-cljs.edn | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/project.clj b/project.clj index ebe9650..72dfa59 100644 --- a/project.clj +++ b/project.clj @@ -11,6 +11,7 @@ ;; clojurescript and tooling [org.clojure/clojurescript "1.10.520" :scope "provided"] [binaryage/devtools "1.0.0"] + [day8.re-frame/re-frame-10x "0.6.5"] [thheller/shadow-cljs "2.8.94"] ;; react diff --git a/shadow-cljs.edn b/shadow-cljs.edn index 1b2201b..5867451 100644 --- a/shadow-cljs.edn +++ b/shadow-cljs.edn @@ -5,8 +5,12 @@ {:dashboard {:target :browser :output-dir "resources/public/assets/js" :asset-path "/assets/js" + :dev {:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true + "day8.re_frame.tracing.trace_enabled_QMARK_" true}} :modules {:dashboard {:init-fn dashboard.core/init}} :devtools {:http-root "resources/public" :http-handler shadow.http.push-state/handle :http-port 8000 - :after-load dashboard.core/start}}}} \ No newline at end of file + :after-load dashboard.core/start + :preloads [devtools.preload + day8.re-frame-10x.preload]}}}} From 85899c0006d3a6962bbdc724b344b907d6fda123 Mon Sep 17 00:00:00 2001 From: RAZAFIMAHEFA Aina Date: Fri, 5 Jun 2020 19:07:22 +0200 Subject: [PATCH 11/48] WIP: Initiate graphql setup and configuration with re-graph --- src/dashboard/components/dashboard.cljs | 24 ++++++++++++ src/dashboard/core.cljs | 17 ++++++--- src/dashboard/events/init.cljs | 50 +++++++++++++++++++++++++ src/dashboard/graphql/queries.cljs | 17 +++++++++ 4 files changed, 103 insertions(+), 5 deletions(-) create mode 100644 src/dashboard/components/dashboard.cljs create mode 100644 src/dashboard/events/init.cljs create mode 100644 src/dashboard/graphql/queries.cljs diff --git a/src/dashboard/components/dashboard.cljs b/src/dashboard/components/dashboard.cljs new file mode 100644 index 0000000..445cf3f --- /dev/null +++ b/src/dashboard/components/dashboard.cljs @@ -0,0 +1,24 @@ +(ns dashboard.components.dashboard + (:require [reagent.core :as r] + [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]])) + +(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"]]]]]]) \ No newline at end of file diff --git a/src/dashboard/core.cljs b/src/dashboard/core.cljs index b406610..2c82dd8 100644 --- a/src/dashboard/core.cljs +++ b/src/dashboard/core.cljs @@ -1,6 +1,7 @@ (ns dashboard.core (:require [reagent.core :as r] [reagent.dom :as rdom] + [re-frame.core :as rf] [taoensso.timbre :as log :refer-macros [log trace debug info warn error fatal report logf tracef debugf infof warnf errorf fatalf reportf @@ -8,7 +9,9 @@ ["bloomer" :refer (Navbar Container NavbarStart NavbarBrand NavbarItem Icon MenuList MenuLabel Menu Field NavbarEnd)] ["react-router-dom" :refer (Route NavLink) :rename {BrowserRouter Router}] - [dashboard.components.search :refer [search]])) + [dashboard.components.search :refer [search]] + [dashboard.components.dashboard :refer [dashboard]] + [dashboard.events.init :as init])) (enable-console-print!) @@ -18,6 +21,9 @@ (defonce app-state (atom {:text "Hello world!"})) +;; Imported components +(def Dashboard (r/reactify-component dashboard)) + (defn nav-bar "Top nav bar" [] @@ -93,7 +99,7 @@ (defn content-container [] [:div#content-container.column.is-10 - [:> Route {:path "/" :exact true}] + [:> Route {:path "/" :exact true :component Dashboard}] [:> Route {:path "/adapters"}] [:> Route {:path "/history"}] [:> Route {:path "/users"}] @@ -120,14 +126,15 @@ [content-body]]]) (defn start - "Mounts the application root component in the DOM." - [] - (rdom/render [dashboard-app] (js/document.getElementById "app"))) + "Mounts the application root component in the DOM." + [] + (rdom/render [dashboard-app] (js/document.getElementById "app"))) (defn ^:export init "Dashboard entrypoint which is called only once when `index.html` loads. It must be exported so it is available even in :advanced release builds." [] + (rf/dispatch-sync [::init/init]) (start)) (defn on-js-reload [] diff --git a/src/dashboard/events/init.cljs b/src/dashboard/events/init.cljs new file mode 100644 index 0000000..8f6c469 --- /dev/null +++ b/src/dashboard/events/init.cljs @@ -0,0 +1,50 @@ +(ns dashboard.events.init + (:require [re-frame.core :as rf] + [re-graph.core :as re-graph] + [dashboard.graphql.queries :as queries] + [taoensso.timbre :as log])) + +;-------------------------------------------------------------- +; Initialization +;-------------------------------------------------------------- +(rf/reg-event-fx + ::init + (fn [{:keys [db]} _] + {:dispatch [::init-re-graph]})) + +;-------------------------------------------------------------- +; Re-graph initialization +;-------------------------------------------------------------- +(rf/reg-event-fx + ::init-re-graph + (fn [_ _] + {:dispatch [::re-graph/init + {:http + {:url "https://public.yetibot.com/graphql"}}]})) + +;-------------------------------------------------------------- +; Dashboard +;-------------------------------------------------------------- +(rf/reg-event-db + :dashboard/stats + (fn [_ [_ timezone-offset-hours]] + {:dispatch [::re-graph/query + queries/stats + {:timezone_offset_hours timezone-offset-hours} + [:dashboard/on-stats]]})) + +(rf/reg-event-db + :dashboard/on-stats + (fn [db [_ {:keys [data errors] :as payload}]] + (if errors + {:dispatch [::on-error :dashboard/stats payload]} + {:db (assoc db :dashboard/stats data)}))) + +;-------------------------------------------------------------- +; Generic error-handling +;-------------------------------------------------------------- +(rf/reg-event-db + ::on-error + (fn [db [{:keys [event-id & parameters]}]] + {:db (assoc db :error/event-id event-id + :error/parameters parameters)})) diff --git a/src/dashboard/graphql/queries.cljs b/src/dashboard/graphql/queries.cljs new file mode 100644 index 0000000..50e93b2 --- /dev/null +++ b/src/dashboard/graphql/queries.cljs @@ -0,0 +1,17 @@ +(ns dashboard.graphql.queries) + +(def stats + "query stats($timezone_offset_hours: Int!) { + stats(timezone_offset_hours: $timezone_offset_hours) { + uptime + adapter_count + user_count + command_count_today + command_count + history_count + history_count_today + alias_count + observer_count + cron_count + } + }") From f275bb29cccc5f7e3760db33431a3f584af3d07f Mon Sep 17 00:00:00 2001 From: RAZAFIMAHEFA Aina Date: Fri, 5 Jun 2020 19:43:07 +0200 Subject: [PATCH 12/48] Move tooling to :dev dependencies --- project.clj | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/project.clj b/project.clj index 72dfa59..7865efc 100644 --- a/project.clj +++ b/project.clj @@ -10,8 +10,6 @@ ;; clojurescript and tooling [org.clojure/clojurescript "1.10.520" :scope "provided"] - [binaryage/devtools "1.0.0"] - [day8.re-frame/re-frame-10x "0.6.5"] [thheller/shadow-cljs "2.8.94"] ;; react @@ -33,4 +31,7 @@ :source-paths ["src"] - :profiles {:dev {}}) + :profiles {:dev + {:dependencies [[binaryage/devtools "1.0.0"] + [day8.re-frame/re-frame-10x "0.6.5"] + [day8.re-frame/tracing "0.5.5"]]}}) From ca89ad4bbf768d8aa1b5276d3b483b19380a3925 Mon Sep 17 00:00:00 2001 From: RAZAFIMAHEFA Aina Date: Mon, 8 Jun 2020 19:41:20 +0200 Subject: [PATCH 13/48] Upgrade re-graph lib --- project.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project.clj b/project.clj index 7865efc..1d6de93 100644 --- a/project.clj +++ b/project.clj @@ -20,7 +20,7 @@ [com.taoensso/timbre "4.10.0"] ;; graphql - [re-graph "0.1.12"] + [re-graph "0.1.13" :exclusions [re-graph.hato]] [district0x/graphql-query "1.0.5"] ;; These has to be explicitly specified as lein does not From c062247f95c9970a129c95bcdb251ec0aaaee469 Mon Sep 17 00:00:00 2001 From: RAZAFIMAHEFA Aina Date: Mon, 8 Jun 2020 19:42:49 +0200 Subject: [PATCH 14/48] Refactor code for dashboard statistics fetching --- src/dashboard/events/init.cljs | 39 +++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/src/dashboard/events/init.cljs b/src/dashboard/events/init.cljs index 8f6c469..d8a6d6d 100644 --- a/src/dashboard/events/init.cljs +++ b/src/dashboard/events/init.cljs @@ -2,7 +2,8 @@ (:require [re-frame.core :as rf] [re-graph.core :as re-graph] [dashboard.graphql.queries :as queries] - [taoensso.timbre :as log])) + [taoensso.timbre :as log] + [day8.re-frame.tracing :refer-macros [fn-traced]])) ;-------------------------------------------------------------- ; Initialization @@ -17,28 +18,36 @@ ;-------------------------------------------------------------- (rf/reg-event-fx ::init-re-graph - (fn [_ _] - {:dispatch [::re-graph/init - {:http - {:url "https://public.yetibot.com/graphql"}}]})) + (fn-traced [_ _] + {:dispatch [::re-graph/init + {:http + {:url "https://public.yetibot.com/graphql"} + :ws + {:url nil}}]})) ;-------------------------------------------------------------- ; Dashboard ;-------------------------------------------------------------- -(rf/reg-event-db - :dashboard/stats - (fn [_ [_ timezone-offset-hours]] +(declare on-stats) + +(rf/reg-event-fx + :dashboard.stats/fetch + (fn-traced [_ [_ timezone-offset-hours]] {:dispatch [::re-graph/query queries/stats - {:timezone_offset_hours timezone-offset-hours} - [:dashboard/on-stats]]})) + {:timezone-offset-hours timezone-offset-hours} + on-stats]})) + +(defn on-stats + [{:keys [data errors]}] + (if errors + (rf/dispatch [::on-error :dashboard/error (str "An error occured while fetching statistics data" errors)]) + (rf/dispatch [:dashboard.stats/store data]))) (rf/reg-event-db - :dashboard/on-stats - (fn [db [_ {:keys [data errors] :as payload}]] - (if errors - {:dispatch [::on-error :dashboard/stats payload]} - {:db (assoc db :dashboard/stats data)}))) + :dashboard.stats/store + (fn-traced [db [_ data]] + (assoc db :dashboard/stats data))) ;-------------------------------------------------------------- ; Generic error-handling From f3148a2906176a65117ebdd1cd021539c30996f7 Mon Sep 17 00:00:00 2001 From: RAZAFIMAHEFA Aina Date: Tue, 9 Jun 2020 16:12:33 +0200 Subject: [PATCH 15/48] Add transit-cljs lib as a dependency for json encoding/decoding --- project.clj | 3 +++ 1 file changed, 3 insertions(+) diff --git a/project.clj b/project.clj index 1d6de93..d5d2ae2 100644 --- a/project.clj +++ b/project.clj @@ -23,6 +23,9 @@ [re-graph "0.1.13" :exclusions [re-graph.hato]] [district0x/graphql-query "1.0.5"] + ;; json encoder/decoder + [com.cognitect/transit-cljs "0.8.264"] + ;; These has to be explicitly specified as lein does not ;; properly manage dependency version conflicts : ;; https://github.com/thheller/shadow-cljs/issues/488#issuecomment-486732296 From f8676b735f19a09b7ba3db55587cadd147721772 Mon Sep 17 00:00:00 2001 From: RAZAFIMAHEFA Aina Date: Tue, 9 Jun 2020 18:41:04 +0200 Subject: [PATCH 16/48] Provide an explicit impl parameter for CORS Access-Control-Allow-Credentials --- src/dashboard/events/init.cljs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/dashboard/events/init.cljs b/src/dashboard/events/init.cljs index d8a6d6d..097194c 100644 --- a/src/dashboard/events/init.cljs +++ b/src/dashboard/events/init.cljs @@ -5,6 +5,7 @@ [taoensso.timbre :as log] [day8.re-frame.tracing :refer-macros [fn-traced]])) +(def ^:const graphql-endpoint "https://public.yetibot.com/graphql") ;-------------------------------------------------------------- ; Initialization ;-------------------------------------------------------------- @@ -21,7 +22,8 @@ (fn-traced [_ _] {:dispatch [::re-graph/init {:http - {:url "https://public.yetibot.com/graphql"} + {:url graphql-endpoint + :impl {:with-credentials? false}} :ws {:url nil}}]})) From 7344da8906a0a361e7a2f7b1a1435d72f9e0a97b Mon Sep 17 00:00:00 2001 From: RAZAFIMAHEFA Aina Date: Tue, 9 Jun 2020 18:47:18 +0200 Subject: [PATCH 17/48] Refactor code to use re-frame (instead of plain vanilla cljs) for re-graph --- src/dashboard/events/init.cljs | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/dashboard/events/init.cljs b/src/dashboard/events/init.cljs index 097194c..a37907e 100644 --- a/src/dashboard/events/init.cljs +++ b/src/dashboard/events/init.cljs @@ -3,9 +3,13 @@ [re-graph.core :as re-graph] [dashboard.graphql.queries :as queries] [taoensso.timbre :as log] + [cognitect.transit :as t] + [clojure.walk] [day8.re-frame.tracing :refer-macros [fn-traced]])) (def ^:const graphql-endpoint "https://public.yetibot.com/graphql") +(def json-reader (t/reader :json)) + ;-------------------------------------------------------------- ; Initialization ;-------------------------------------------------------------- @@ -19,7 +23,7 @@ ;-------------------------------------------------------------- (rf/reg-event-fx ::init-re-graph - (fn-traced [_ _] + (fn [_ _] {:dispatch [::re-graph/init {:http {:url graphql-endpoint @@ -30,26 +34,23 @@ ;-------------------------------------------------------------- ; Dashboard ;-------------------------------------------------------------- -(declare on-stats) - (rf/reg-event-fx :dashboard.stats/fetch - (fn-traced [_ [_ timezone-offset-hours]] + (fn [_ [_ timezone-offset-hours]] {:dispatch [::re-graph/query queries/stats - {:timezone-offset-hours timezone-offset-hours} - on-stats]})) - -(defn on-stats - [{:keys [data errors]}] - (if errors - (rf/dispatch [::on-error :dashboard/error (str "An error occured while fetching statistics data" errors)]) - (rf/dispatch [:dashboard.stats/store data]))) + {:timezone_offset_hours timezone-offset-hours} + [:dashboard.stats/store]]})) -(rf/reg-event-db +(rf/reg-event-fx :dashboard.stats/store - (fn-traced [db [_ data]] - (assoc db :dashboard/stats data))) + (fn [{:keys [db]} [_ payload]] + (let [data (-> (t/read json-reader payload) + (clojure.walk/keywordize-keys) + (get-in [:data :stats]))] + (if (nil? data) + {:dispatch [::on-error :dashboard/error (str "An error occured while fetching statistics data")]} + {:db (assoc db :dashboard/stats data)})))) ;-------------------------------------------------------------- ; Generic error-handling From 928ebc962e5cae23172c0989f9fff5f40c289ded Mon Sep 17 00:00:00 2001 From: RAZAFIMAHEFA Aina Date: Tue, 9 Jun 2020 22:40:29 +0200 Subject: [PATCH 18/48] Kebab-case incoming data to be more Clojure(script)-compliant --- project.clj | 3 ++- src/dashboard/events/init.cljs | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/project.clj b/project.clj index d5d2ae2..d91729b 100644 --- a/project.clj +++ b/project.clj @@ -23,8 +23,9 @@ [re-graph "0.1.13" :exclusions [re-graph.hato]] [district0x/graphql-query "1.0.5"] - ;; json encoder/decoder + ;; utils [com.cognitect/transit-cljs "0.8.264"] + [camel-snake-kebab "0.4.1"] ;; These has to be explicitly specified as lein does not ;; properly manage dependency version conflicts : diff --git a/src/dashboard/events/init.cljs b/src/dashboard/events/init.cljs index a37907e..364155a 100644 --- a/src/dashboard/events/init.cljs +++ b/src/dashboard/events/init.cljs @@ -1,6 +1,8 @@ (ns dashboard.events.init (:require [re-frame.core :as rf] [re-graph.core :as re-graph] + [camel-snake-kebab.core :as csk] + [camel-snake-kebab.extras :as cske] [dashboard.graphql.queries :as queries] [taoensso.timbre :as log] [cognitect.transit :as t] @@ -8,8 +10,11 @@ [day8.re-frame.tracing :refer-macros [fn-traced]])) (def ^:const graphql-endpoint "https://public.yetibot.com/graphql") + (def json-reader (t/reader :json)) +(def kebab-case-keywords (partial cske/transform-keys csk/->kebab-case-keyword)) + ;-------------------------------------------------------------- ; Initialization ;-------------------------------------------------------------- @@ -47,6 +52,7 @@ (fn [{:keys [db]} [_ payload]] (let [data (-> (t/read json-reader payload) (clojure.walk/keywordize-keys) + kebab-case-keywords (get-in [:data :stats]))] (if (nil? data) {:dispatch [::on-error :dashboard/error (str "An error occured while fetching statistics data")]} From 1aea3fcec9477d6b54ac7a94f20f1b3f2f8fa1a3 Mon Sep 17 00:00:00 2001 From: RAZAFIMAHEFA Aina Date: Tue, 9 Jun 2020 23:35:40 +0200 Subject: [PATCH 19/48] Add subscriptions for dashboard.stats --- src/dashboard/subs/dashboard.cljs | 47 +++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/dashboard/subs/dashboard.cljs diff --git a/src/dashboard/subs/dashboard.cljs b/src/dashboard/subs/dashboard.cljs new file mode 100644 index 0000000..02e6687 --- /dev/null +++ b/src/dashboard/subs/dashboard.cljs @@ -0,0 +1,47 @@ +(ns dashboard.subs.dashboard + (:require [re-frame.core :as rf])) + +(rf/reg-sub + :dashboard.stats/adapter-count + (fn [db _] + (get-in db [:dashboard/stats :adapter-count]))) + +(rf/reg-sub + :dashboard.stats/command-count + (fn [db _] + (get-in db [:dashboard/stats :command-count]))) + +(rf/reg-sub + :dashboard.stats/command-count-today + (fn [db _] + (get-in db [:dashboard/stats :command-count-today]))) + +(rf/reg-sub + :dashboard.stats/user-count + (fn [db _] + (get-in db [:dashboard/stats :user-count]))) + +(rf/reg-sub + :dashboard.stats/history-count + (fn [db _] + (get-in db [:dashboard/stats :history-count]))) + +(rf/reg-sub + :dashboard.stats/history-count-today + (fn [db _] + (get-in db [:dashboard/stats :history-count-today]))) + +(rf/reg-sub + :dashboard.stats/alias-count + (fn [db _] + (get-in db [:dashboard/stats :alias-count]))) + +(rf/reg-sub + :dashboard.stats/observer-count + (fn [db _] + (get-in db [:dashboard/stats :observer-count]))) + +(rf/reg-sub + :dashboard.stats/cron-count + (fn [db _] + (get-in db [:dashboard/stats :cron-count]))) From 91da7060c86d913340ed4e85f7b19d21abf227be Mon Sep 17 00:00:00 2001 From: RAZAFIMAHEFA Aina Date: Tue, 9 Jun 2020 23:36:12 +0200 Subject: [PATCH 20/48] WIP Implement components for dashboard Add subscription for stats.uptime Complete functional implementation for the dashboard UI --- src/dashboard/components/dashboard.cljs | 53 +++++++++++++++++++------ src/dashboard/subs/dashboard.cljs | 5 +++ 2 files changed, 46 insertions(+), 12 deletions(-) diff --git a/src/dashboard/components/dashboard.cljs b/src/dashboard/components/dashboard.cljs index 445cf3f..382c69d 100644 --- a/src/dashboard/components/dashboard.cljs +++ b/src/dashboard/components/dashboard.cljs @@ -1,5 +1,6 @@ (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 @@ -7,18 +8,46 @@ 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 stat-display + [label value] + [:> Tile {:is-child "true" :class "box"} + [:> Title @value] + [:> Subtitle label]]) + +(defn expandable-stat-display + [label value path] + [:> NavLink {:class "tile is-parent is-4" :to path} + [stat-display label value]]) (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"]]]]]]) \ No newline at end of file + (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]) + user-count (rf/subscribe [:dashboard.stats/user-count]) + history-count (rf/subscribe [:dashboard.stats/history-count]) + history-count-today (rf/subscribe [:dashboard.stats/history-count-today]) + alias-count (rf/subscribe [:dashboard.stats/alias-count]) + observer-count (rf/subscribe [:dashboard.stats/observer-count]) + cront-count (rf/subscribe [:dashboard.stats/cron-count]) + uptime (rf/subscribe [:dashboard.stats/uptime])] + [:div + [:> Hero {:is-bold "true" :is-color "info" :is-size "small"} + [:> HeroBody + [:> Title "Dashboard"] + [:> Subtitle (str "Uptime " @uptime)]]] + [:div.tiles + [:> Tile {:is-ancestor "true" :has-text-align "centered"} + [expandable-stat-display "Adapters" adapter-count "/adapters"] + [expandable-stat-display "Commands" command-count "/history?co=1"] + [stat-display "Commands today" command-count-today] + [expandable-stat-display "User" user-count "/users"] + [expandable-stat-display "History items" history-count "/history"] + [stat-display "History items today" history-count-today] + [expandable-stat-display "Aliases" alias-count "/aliases"] + [expandable-stat-display "Observers" observer-count "/observers"] + [expandable-stat-display "Cron tasks" cront-count "/cron"]]]])) diff --git a/src/dashboard/subs/dashboard.cljs b/src/dashboard/subs/dashboard.cljs index 02e6687..67753d8 100644 --- a/src/dashboard/subs/dashboard.cljs +++ b/src/dashboard/subs/dashboard.cljs @@ -1,6 +1,11 @@ (ns dashboard.subs.dashboard (:require [re-frame.core :as rf])) +(rf/reg-sub + :dashboard.stats/uptime + (fn [db _] + (get-in db [:dashboard/stats :uptime]))) + (rf/reg-sub :dashboard.stats/adapter-count (fn [db _] From bcdeac278dba2612e57c29cbc60488c652789051 Mon Sep 17 00:00:00 2001 From: RAZAFIMAHEFA Aina Date: Wed, 10 Jun 2020 14:51:46 +0200 Subject: [PATCH 21/48] Refactor dashboard stat metrics display component --- src/dashboard/components/dashboard.cljs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/dashboard/components/dashboard.cljs b/src/dashboard/components/dashboard.cljs index 382c69d..8fcd64e 100644 --- a/src/dashboard/components/dashboard.cljs +++ b/src/dashboard/components/dashboard.cljs @@ -11,7 +11,7 @@ [dashboard.components.search :refer [search]] [dashboard.subs.dashboard])) -(defn stat-display +(defn display [label value] [:> Tile {:is-child "true" :class "box"} [:> Title @value] @@ -20,7 +20,12 @@ (defn expandable-stat-display [label value path] [:> NavLink {:class "tile is-parent is-4" :to path} - [stat-display label value]]) + [display label value]]) + +(defn stat-display + [label value] + [:> Tile {:is-size 4 :is-parent "true"} + [display label value]]) (defn dashboard [] From f478b07288921cdac68034ab8e4aa407c466342c Mon Sep 17 00:00:00 2001 From: RAZAFIMAHEFA Aina Date: Wed, 10 Jun 2020 16:36:14 +0200 Subject: [PATCH 22/48] Fix UI component id --- src/dashboard/core.cljs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dashboard/core.cljs b/src/dashboard/core.cljs index 2c82dd8..083a106 100644 --- a/src/dashboard/core.cljs +++ b/src/dashboard/core.cljs @@ -112,7 +112,7 @@ (defn content-body "Content body" [] - [:> Container {:id "content/body"} + [:> Container {:id "content-body"} [:div.columns [menu] [content-container]]]) From 02530927a6287d373f308b4ac12189949e390930 Mon Sep 17 00:00:00 2001 From: RAZAFIMAHEFA Aina Date: Wed, 10 Jun 2020 16:36:53 +0200 Subject: [PATCH 23/48] Fix menu nested markup --- src/dashboard/core.cljs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/dashboard/core.cljs b/src/dashboard/core.cljs index 083a106..8eee305 100644 --- a/src/dashboard/core.cljs +++ b/src/dashboard/core.cljs @@ -114,7 +114,8 @@ [] [:> Container {:id "content-body"} [:div.columns - [menu] + [:div {:class "column is-2"} + [menu]] [content-container]]]) (defn dashboard-app From bdd36b941129e3b22e7a3cb8f87e66d01c7abe4c Mon Sep 17 00:00:00 2001 From: RAZAFIMAHEFA Aina Date: Wed, 10 Jun 2020 17:22:02 +0200 Subject: [PATCH 24/48] Refactor content-body --- src/dashboard/core.cljs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/dashboard/core.cljs b/src/dashboard/core.cljs index 8eee305..511ff0d 100644 --- a/src/dashboard/core.cljs +++ b/src/dashboard/core.cljs @@ -96,9 +96,9 @@ :class "fa fa-external-link-alt"}] "Docs"]]]]]) -(defn content-container +(defn routes [] - [:div#content-container.column.is-10 + [:<> [:> Route {:path "/" :exact true :component Dashboard}] [:> Route {:path "/adapters"}] [:> Route {:path "/history"}] @@ -114,9 +114,10 @@ [] [:> Container {:id "content-body"} [:div.columns - [:div {:class "column is-2"} + [:div.column.is-2 [menu]] - [content-container]]]) + [:div#content-container.column.is-10 + [routes]]]]) (defn dashboard-app "The dashboard component" From dea7e6a50e39539ccf5f211a8083af611abda7fa Mon Sep 17 00:00:00 2001 From: RAZAFIMAHEFA Aina Date: Wed, 10 Jun 2020 18:08:09 +0200 Subject: [PATCH 25/48] Refactor menu component --- src/dashboard/core.cljs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dashboard/core.cljs b/src/dashboard/core.cljs index 511ff0d..81edc43 100644 --- a/src/dashboard/core.cljs +++ b/src/dashboard/core.cljs @@ -45,7 +45,7 @@ (defn menu [] - [:div {:class "column is-2"} + [:div.column [:> Menu ;; yetibot [:> MenuLabel "Yetibot"] @@ -116,7 +116,7 @@ [:div.columns [:div.column.is-2 [menu]] - [:div#content-container.column.is-10 + [:div#content-container.column [routes]]]]) (defn dashboard-app From 1a6b4158218f00954a5b072cbec7ca8f0192b32d Mon Sep 17 00:00:00 2001 From: RAZAFIMAHEFA Aina Date: Tue, 14 Jul 2020 11:38:55 +0200 Subject: [PATCH 26/48] Update dependencies version to avoid conflicts Since we are using leiningen to manage dependencies, we have to make sure to include/align the versions of the dependencies with those pulled by shadow-cljs, especially those involving closure-compiler. Instead, if we opt to use shadow-cljs at some point, all the issues related to dependencies is solved by the tool and we would not have to deal with those as explained here by Thomas Heller : https://clojurians-log.clojureverse.org/shadow-cljs/2020-01-06 --- project.clj | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/project.clj b/project.clj index d91729b..26d20a9 100644 --- a/project.clj +++ b/project.clj @@ -6,12 +6,12 @@ :min-lein-version "2.9.1" - :dependencies [[org.clojure/clojure "1.10.0"] + :dependencies [[org.clojure/clojure "1.10.1"] ;; clojurescript and tooling - [org.clojure/clojurescript "1.10.520" :scope "provided"] + [org.clojure/clojurescript "1.10.597" :scope "provided"] [thheller/shadow-cljs "2.8.94"] - + ;; react [reagent "0.10.0"] [re-frame "0.12.0"] @@ -30,8 +30,8 @@ ;; These has to be explicitly specified as lein does not ;; properly manage dependency version conflicts : ;; https://github.com/thheller/shadow-cljs/issues/488#issuecomment-486732296 - [com.google.javascript/closure-compiler-unshaded "v20190325"] - [org.clojure/google-closure-library "0.0-20190213-2033d5d9"]] + [com.google.javascript/closure-compiler-unshaded "v20191027"] + [org.clojure/google-closure-library "0.0-20191016-6ae1f72f"]] :source-paths ["src"] From 13ed910e9b9ff048ec147ddb7d4f12ea59a4848f Mon Sep 17 00:00:00 2001 From: RAZAFIMAHEFA Aina Date: Tue, 14 Jul 2020 11:45:28 +0200 Subject: [PATCH 27/48] Add leiningen aliases to encapsulate shadow-cljs-related commands Since our main build tool is leiningen, we added a few aliases to allow it to interact with shadow-cljs. * lein watch : starts a new shadow-cljs watch process * lein compile : simply compiles the project * lein release : compiles the project for a production (minified js for each module) * lein cljs-repl : starts a clojurescript repl within the context of the app --- project.clj | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/project.clj b/project.clj index 26d20a9..34d5cf5 100644 --- a/project.clj +++ b/project.clj @@ -33,8 +33,20 @@ [com.google.javascript/closure-compiler-unshaded "v20191027"] [org.clojure/google-closure-library "0.0-20191016-6ae1f72f"]] + :plugins [[lein-shell "0.5.0"]] + :source-paths ["src"] + :aliases {"compile" ["do" + ["shell" "npm" "install"] + ["run" "-m" "shadow.cljs.devtools.cli" "compile" ":dashboard"]] + "watch" ["do" + ["run" "-m" "shadow.cljs.devtools.cli" "watch" ":dashboard"]] + "cljs-repl" ["do" + ["run" "-m" "shadow.cljs.devtools.cli" "cljs-repl" ":dashboard"]] + "release" ["do" + ["run" "-m" "shadow.cljs.devtools.cli" "release" ":dashboard"]]} + :profiles {:dev {:dependencies [[binaryage/devtools "1.0.0"] [day8.re-frame/re-frame-10x "0.6.5"] From a19778a23828ad7b9833206d3bc5f71b0498a987 Mon Sep 17 00:00:00 2001 From: RAZAFIMAHEFA Aina Date: Tue, 14 Jul 2020 16:27:21 +0200 Subject: [PATCH 28/48] Rename aliases to avoid shadowing leiningen default commands --- project.clj | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/project.clj b/project.clj index 34d5cf5..388c9d9 100644 --- a/project.clj +++ b/project.clj @@ -37,15 +37,15 @@ :source-paths ["src"] - :aliases {"compile" ["do" - ["shell" "npm" "install"] - ["run" "-m" "shadow.cljs.devtools.cli" "compile" ":dashboard"]] + :aliases {"compile-cljs" ["do" + ["shell" "npm" "install"] + ["run" "-m" "shadow.cljs.devtools.cli" "compile" ":dashboard"]] "watch" ["do" ["run" "-m" "shadow.cljs.devtools.cli" "watch" ":dashboard"]] "cljs-repl" ["do" ["run" "-m" "shadow.cljs.devtools.cli" "cljs-repl" ":dashboard"]] - "release" ["do" - ["run" "-m" "shadow.cljs.devtools.cli" "release" ":dashboard"]]} + "release-cljs" ["do" + ["run" "-m" "shadow.cljs.devtools.cli" "release" ":dashboard"]]} :profiles {:dev {:dependencies [[binaryage/devtools "1.0.0"] From e0e91618219412254fbed4cd047173fa1368acf2 Mon Sep 17 00:00:00 2001 From: RAZAFIMAHEFA Aina Date: Tue, 14 Jul 2020 16:37:09 +0200 Subject: [PATCH 29/48] Update the README file Some new instructions were added regarding the use of leiningen as an entrypoint for managing shadow-cljs and the whole front-end building process --- README.md | 122 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 117 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 1c14f9d..208477c 100644 --- a/README.md +++ b/README.md @@ -8,13 +8,120 @@ The new (as of 2020) CLJS frontend dashboard for Yetibot We chose `shadow-cljs` as our main build tool for the project. `shadow-cljs` is easy to use and configure and comes with a very good integration with the other tools that we already use on the other sub-projects under `Yetibot`, for e.g `Leiningen`. -See the `shadow-cljs` _user-guide_ on how to install it. +See the [`shadow-cljs` _user-guide_](https://shadow-cljs.github.io/docs/UsersGuide.html "Shadow-cljs user guide") on how to install it. ## Leiningen -`Leiningen` is the Clojure build tool that `Yetibot` uses. For `dashboard`, `shadow-cljs` delegates the _dependency management_ to `leiningen`. +`Leiningen` is the Clojure build tool that `Yetibot` uses. For `dashboard`, `shadow-cljs` delegates the _dependency management_ and _build entrypoint_ to `leiningen`. Using this tool is the easiest way to get started with the project. + +See the [`Leiningen` _installation docs_](https://leiningen.org/#install "Leiningen installation instructions") on how to install it. + + +# Development workflow using Leiningen (the easy way) + +## Running a watch process + +To start a `watch` process, which will monitor changes and automatically recompile the `dashboard` code base, run the following command from the termimal: + +`$ lein watch` + +a `watch` will implicitly start a _server process_ which will be re-used by all commands sent by the `shadow-cljs CLI`, instead of starting a new JVM. + +```shell script +added 43 packages from 380 contributors and audited 44 packages in 0.988s +found 0 vulnerabilities + +[:dashboard] Compiling ... +[:dashboard] Build completed. (562 files, 0 compiled, 0 warnings, 5,46s) +shadow-cljs - HTTP server available at http://localhost:8000 +shadow-cljs - server version: 2.8.94 running at http://localhost:9630 +shadow-cljs - nREPL server started on port 34945 +shadow-cljs - watching build :dashboard +[:dashboard] Configuring build. +[:dashboard] Compiling ... +[:dashboard] Build completed. (582 files, 1 compiled, 0 warnings, 5,49s) + +``` + +## Compiling the project + +To `compile` the project, run the following command : + +`$ lein compile-cljs` + + +```shell script +audited 44 packages in 0.6s +found 0 vulnerabilities + +[:dashboard] Compiling ... +[:dashboard] Build completed. (562 files, 0 compiled, 0 warnings, 5,45s) + +``` + +## Releasing for production + +When ready for a deployment in `production`, run the following command : + +`$ lein release-cljs` + +This phase will produce a `minified` version of the code for each module thanks to the `Google Closure Compiler`. + +```shell script +[:dashboard] Compiling ... +[:dashboard] Build completed. (562 files, 0 compiled, 0 warnings, 5,45s) +[:dashboard] Compiling ... +[:dashboard] Build completed. (223 files, 0 compiled, 0 warnings, 17,65s) + +``` + +## Starting a CLJS REPL + +To start a `cljs repl`, run the following command : + +`$ lein cljs-repl` + +The output of the command should indicate the address at which to access the application. + +```shell script +audited 44 packages in 0.548s +found 0 vulnerabilities +[:dashboard] Compiling ... +[:dashboard] Build completed. (562 files, 0 compiled, 0 warnings, 5,65s) +[2020-07-13 18:08:13.196 - WARNING] TCP Port 9630 in use. +[2020-07-13 18:08:14.207 - WARNING] TCP Port 8000 in use. +shadow-cljs - HTTP server available at http://localhost:8001 +shadow-cljs - server version: 2.8.94 running at http://localhost:9631 +shadow-cljs - nREPL server started on port 35103 + +``` +you can then open your browser at the address exposed by the `shadow-cljs HTTP server` (here, `http://localhost:8001`). + +To make sure that the `cljs repl` is correctly connected to your JS runtime (here the _browser_), you can try to open a popup by `eval`-ing the following form to the repl : + +```shell script +$ cljs.user=> (js/alert "Hey Yeti!!") +nil +``` + +a popup should be displayed in the browser tab/window containing the application. + +Otherwise an explicit error is displayed in the `repl` if the JS runtime has not loaded our Clojurescript compiled code. + +```shell script +cljs.user=> (js/alert "Hey Yeti!!") +No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code. +``` + +At this point, simply opening the browser at the correct address should solve the issue. + +--- +**NOTE** + +Depending on your workflow, it is also possible to use `shadow-cljs` directly via its `CLI` or programmatically through its `api` as detailed below. + +--- -See the `Leiningen` Installation docs to install it. # Development workflow using the shadow-cljs CLI @@ -75,7 +182,12 @@ cljs.user=> We also provide a `dev.clj` namespace in `dev/dev.clj` which allows for a more Clojure-_friendly_ workflow during development. This namespace contains a few utility functions for _programmatically_ interacting with `shadow-cljs` through its Clojure API. -The first step is to `eval` those functions in your REPL. + +The first step is to start a regular `Clojure repl` from your terminal (or using your IDE) using : + +`$ lein repl` + +and then `eval` the content of the `dev.clj` in the newly-started REPL : ```clojure ... @@ -156,4 +268,4 @@ shadow-cljs - nREPL server started on port 42915 [:dashboard] Compiling ... [:dashboard] Build completed. (59 files, 0 compiled, 0 warnings, 0,58s) => :done -``` +``` \ No newline at end of file From a17cb7fd2bf195daa7eef609e26f3dc059d4a814 Mon Sep 17 00:00:00 2001 From: RAZAFIMAHEFA Aina Date: Fri, 24 Jul 2020 13:38:53 +0200 Subject: [PATCH 30/48] Refactor component with init code as re-agent 2nd component form --- src/dashboard/components/dashboard.cljs | 29 +++++++++++++------------ 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/dashboard/components/dashboard.cljs b/src/dashboard/components/dashboard.cljs index 8fcd64e..3604bd9 100644 --- a/src/dashboard/components/dashboard.cljs +++ b/src/dashboard/components/dashboard.cljs @@ -40,19 +40,20 @@ observer-count (rf/subscribe [:dashboard.stats/observer-count]) cront-count (rf/subscribe [:dashboard.stats/cron-count]) uptime (rf/subscribe [:dashboard.stats/uptime])] - [:div - [:> Hero {:is-bold "true" :is-color "info" :is-size "small"} - [:> HeroBody + (fn [] + [:div + [:> Hero {:is-bold "true" :is-color "info" :is-size "small"} + [:> HeroBody [:> Title "Dashboard"] [:> Subtitle (str "Uptime " @uptime)]]] - [:div.tiles - [:> Tile {:is-ancestor "true" :has-text-align "centered"} - [expandable-stat-display "Adapters" adapter-count "/adapters"] - [expandable-stat-display "Commands" command-count "/history?co=1"] - [stat-display "Commands today" command-count-today] - [expandable-stat-display "User" user-count "/users"] - [expandable-stat-display "History items" history-count "/history"] - [stat-display "History items today" history-count-today] - [expandable-stat-display "Aliases" alias-count "/aliases"] - [expandable-stat-display "Observers" observer-count "/observers"] - [expandable-stat-display "Cron tasks" cront-count "/cron"]]]])) + [:div.tiles + [:> Tile {:is-ancestor "true" :has-text-align "centered"} + [expandable-stat-display "Adapters" adapter-count "/adapters"] + [expandable-stat-display "Commands" command-count "/history?co=1"] + [stat-display "Commands today" command-count-today] + [expandable-stat-display "User" user-count "/users"] + [expandable-stat-display "History items" history-count "/history"] + [stat-display "History items today" history-count-today] + [expandable-stat-display "Aliases" alias-count "/aliases"] + [expandable-stat-display "Observers" observer-count "/observers"] + [expandable-stat-display "Cron tasks" cront-count "/cron"]]]]))) From 65bc46ee26e20d4e5429dcfbb2b1b1458499f567 Mon Sep 17 00:00:00 2001 From: RAZAFIMAHEFA Aina Date: Fri, 24 Jul 2020 14:09:05 +0200 Subject: [PATCH 31/48] Format code --- src/dashboard/events/init.cljs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/dashboard/events/init.cljs b/src/dashboard/events/init.cljs index 364155a..72ac597 100644 --- a/src/dashboard/events/init.cljs +++ b/src/dashboard/events/init.cljs @@ -29,12 +29,11 @@ (rf/reg-event-fx ::init-re-graph (fn [_ _] - {:dispatch [::re-graph/init - {:http - {:url graphql-endpoint - :impl {:with-credentials? false}} - :ws - {:url nil}}]})) + {:dispatch [::re-graph/init {:http + {:url graphql-endpoint + :impl {:with-credentials? false}} + :ws + {:url nil}}]})) ;-------------------------------------------------------------- ; Dashboard From 8517f6766630dd075c13547c83896022a835b8c3 Mon Sep 17 00:00:00 2001 From: RAZAFIMAHEFA Aina Date: Fri, 11 Sep 2020 15:25:24 +0200 Subject: [PATCH 32/48] WIP --- src/dashboard/components/history.cljs | 19 +++++++++++++++ src/dashboard/core.cljs | 7 ++++-- src/dashboard/events/init.cljs | 29 ++++++++++++++++++++++- src/dashboard/graphql/queries.cljs | 33 +++++++++++++++++++++++++++ 4 files changed, 85 insertions(+), 3 deletions(-) create mode 100644 src/dashboard/components/history.cljs diff --git a/src/dashboard/components/history.cljs b/src/dashboard/components/history.cljs new file mode 100644 index 0000000..ba344de --- /dev/null +++ b/src/dashboard/components/history.cljs @@ -0,0 +1,19 @@ +(ns dashboard.components.history + (:require [reagent.core :as r] + [re-frame.core :as rf] + ["bloomer" :refer (Tile Hero HeroBody Title Subtitle Notification)] + ["react-router-dom" :refer (NavLink)])) + +(defn history + [] + (let [_ (rf/dispatch [:dashboard.history/fetch 480])] + (fn [] + [:div + [:> Hero {:is-bold "true" :is-color "info" :is-size "small"} + [:> HeroBody + [:> Title "History"] + [:> Subtitle (str "Total items")]]] + [:div.tiles + [:> Tile {:is-ancestor "true" :has-text-align "centered"} + ]]]))) + diff --git a/src/dashboard/core.cljs b/src/dashboard/core.cljs index 81edc43..4d6c7a0 100644 --- a/src/dashboard/core.cljs +++ b/src/dashboard/core.cljs @@ -11,6 +11,7 @@ ["react-router-dom" :refer (Route NavLink) :rename {BrowserRouter Router}] [dashboard.components.search :refer [search]] [dashboard.components.dashboard :refer [dashboard]] + [dashboard.components.history :refer [history]] [dashboard.events.init :as init])) (enable-console-print!) @@ -23,6 +24,7 @@ ;; Imported components (def Dashboard (r/reactify-component dashboard)) +(def History (r/reactify-component history)) (defn nav-bar "Top nav bar" @@ -54,7 +56,8 @@ [:> NavLink {:exact true :to "/"} "Dashboard"]] [:li - [:> NavLink {:to "/history"} "History"]] + [:> NavLink {:exact true + :to "/history"} "History"]] [:li [:> NavLink {:to "/users"} "Users"]] [:li @@ -101,7 +104,7 @@ [:<> [:> Route {:path "/" :exact true :component Dashboard}] [:> Route {:path "/adapters"}] - [:> Route {:path "/history"}] + [:> Route {:path "/history" :exact true :component History}] [:> Route {:path "/users"}] [:> Route {:path "/user/:id"}] [:> Route {:path "/aliases"}] diff --git a/src/dashboard/events/init.cljs b/src/dashboard/events/init.cljs index 72ac597..9efe630 100644 --- a/src/dashboard/events/init.cljs +++ b/src/dashboard/events/init.cljs @@ -9,7 +9,8 @@ [clojure.walk] [day8.re-frame.tracing :refer-macros [fn-traced]])) -(def ^:const graphql-endpoint "https://public.yetibot.com/graphql") +#_(def ^:const graphql-endpoint "https://public.yetibot.com/graphql") +(def ^:const graphql-endpoint "http://localhost:3003/graphql") (def json-reader (t/reader :json)) @@ -57,6 +58,32 @@ {:dispatch [::on-error :dashboard/error (str "An error occured while fetching statistics data")]} {:db (assoc db :dashboard/stats data)})))) +;-------------------------------------------------------------- +; History +;-------------------------------------------------------------- +(rf/reg-event-fx + :dashboard.history/fetch + (fn [_ [_ timezone-offset-hours]] + {:dispatch [::re-graph/query + queries/history + {:commands_only true + :yetibot_only true + :search_query "" + :timezone_offset_hours timezone-offset-hours} + [:dashboard.history/store]]})) + +(rf/reg-event-fx + :dashboard.history/store + (fn [{:keys [db]} [_ payload]] + (println payload) + (let [data (-> (t/read json-reader payload) + (clojure.walk/keywordize-keys) + kebab-case-keywords + (get-in [:data]))] + (if (nil? data) + {:dispatch [::on-error :dashboard/error (str "An error occured while fetching statistics data")]} + {:db (assoc db :dashboard/stats data)})))) + ;-------------------------------------------------------------- ; Generic error-handling ;-------------------------------------------------------------- diff --git a/src/dashboard/graphql/queries.cljs b/src/dashboard/graphql/queries.cljs index 50e93b2..df62c6c 100644 --- a/src/dashboard/graphql/queries.cljs +++ b/src/dashboard/graphql/queries.cljs @@ -15,3 +15,36 @@ cron_count } }") + +(def history + "query history($timezone_offset_hours: Int!, $yetibot_only: Boolean!, $commands_only: Boolean!, $search_query: String) { + stats(timezone_offset_hours: $timezone_offset_hours) { + history_count + } + + history(limit: 30, offset: 0, + commands_only: $commands_only, + yetibot_only: $yetibot_only, + search_query: $search_query + ) { + id + chat_source_adapter + chat_source_room + command + correlation_id + created_at + user_name + is_command + is_yetibot + body + user_id + user_name + } + }") + +(def history-item + "query history_item($history_id: String!) { + history_item(id: $history_id) { + id + } + }") From 42ebc300f010eb054af14df8818ba6c2f4d12732 Mon Sep 17 00:00:00 2001 From: RAZAFIMAHEFA Aina Date: Fri, 4 Dec 2020 20:40:41 +0100 Subject: [PATCH 33/48] Refactor project.clj : update lein dependencies --- project.clj | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/project.clj b/project.clj index 388c9d9..a720e91 100644 --- a/project.clj +++ b/project.clj @@ -9,12 +9,16 @@ :dependencies [[org.clojure/clojure "1.10.1"] ;; clojurescript and tooling - [org.clojure/clojurescript "1.10.597" :scope "provided"] + [org.clojure/clojurescript "1.10.597" :scope "provided" + :exclusions [com.google.javascript/closure-compiler-unshaded + org.clojure/google-closure-library + org.clojure/google-closure-library-third-party]] [thheller/shadow-cljs "2.8.94"] ;; react [reagent "0.10.0"] - [re-frame "0.12.0"] + [re-frame "1.1.2"] + [day8.re-frame/tracing "0.6.0"] ;; logging [com.taoensso/timbre "4.10.0"] @@ -25,13 +29,8 @@ ;; utils [com.cognitect/transit-cljs "0.8.264"] - [camel-snake-kebab "0.4.1"] + [camel-snake-kebab "0.4.1"]] - ;; These has to be explicitly specified as lein does not - ;; properly manage dependency version conflicts : - ;; https://github.com/thheller/shadow-cljs/issues/488#issuecomment-486732296 - [com.google.javascript/closure-compiler-unshaded "v20191027"] - [org.clojure/google-closure-library "0.0-20191016-6ae1f72f"]] :plugins [[lein-shell "0.5.0"]] From b906b4bab51a2a8f12b5703f8306629e4505d251 Mon Sep 17 00:00:00 2001 From: RAZAFIMAHEFA Aina Date: Fri, 4 Dec 2020 20:44:12 +0100 Subject: [PATCH 34/48] Refactor project.clj : add lein-shadow plugin (for shadow-cljs) --- project.clj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/project.clj b/project.clj index a720e91..8ea7d4f 100644 --- a/project.clj +++ b/project.clj @@ -32,7 +32,8 @@ [camel-snake-kebab "0.4.1"]] - :plugins [[lein-shell "0.5.0"]] + :plugins [[lein-shadow "0.3.1"] + [lein-shell "0.5.0"]] :source-paths ["src"] From ccce4388a85b6a91189d140e43df9db075489540 Mon Sep 17 00:00:00 2001 From: RAZAFIMAHEFA Aina Date: Fri, 4 Dec 2020 20:47:35 +0100 Subject: [PATCH 35/48] Refactor project.clj : add npm deps (managed by lein-shadow) --- project.clj | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/project.clj b/project.clj index 8ea7d4f..5ec0f31 100644 --- a/project.clj +++ b/project.clj @@ -31,6 +31,16 @@ [com.cognitect/transit-cljs "0.8.264"] [camel-snake-kebab "0.4.1"]] + :npm-deps [[react "16.13.1"] + ["bloomer" "0.6.5"] + ["bulma" "0.8.2"] + ["bulma-checkradio" "1.1.1"] + ["create-react-class" "15.6.3"] + ["highlight.js" "9.18.1"] + ["react" "16.13.1"] + ["react-dom" "16.13.1"] + ["react-highlight.js" "1.0.7"] + ["react-router-dom" "5.1.2"]] :plugins [[lein-shadow "0.3.1"] [lein-shell "0.5.0"]] From 459f4f2b29e6ad342812c51288edc3fb0549cfe6 Mon Sep 17 00:00:00 2001 From: RAZAFIMAHEFA Aina Date: Fri, 4 Dec 2020 20:55:10 +0100 Subject: [PATCH 36/48] Move shadow-cljs config to project.clj --- project.clj | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/project.clj b/project.clj index 5ec0f31..0d70148 100644 --- a/project.clj +++ b/project.clj @@ -47,15 +47,36 @@ :source-paths ["src"] - :aliases {"compile-cljs" ["do" - ["shell" "npm" "install"] - ["run" "-m" "shadow.cljs.devtools.cli" "compile" ":dashboard"]] - "watch" ["do" - ["run" "-m" "shadow.cljs.devtools.cli" "watch" ":dashboard"]] - "cljs-repl" ["do" - ["run" "-m" "shadow.cljs.devtools.cli" "cljs-repl" ":dashboard"]] - "release-cljs" ["do" - ["run" "-m" "shadow.cljs.devtools.cli" "release" ":dashboard"]]} + :clean-targets ^{:protect false} ["resources/public/js/compiled" "target"] + + :shadow-cljs {:nrepl {:port 8777} + + :builds {:dashboard {:target :browser + :output-dir "resources/public/js/compiled" + :asset-path "/js/compiled" + :modules {:app {:init-fn dashboard.core/init + :preloads [devtools.preload + day8.re-frame-10x.preload]}} + :dev {:compiler-options {:closure-defines {re-frame.trace.trace-enabled? true + day8.re-frame.tracing.trace-enabled? true}}} + :release {:build-options + {:ns-aliases + {day8.re-frame.tracing day8.re-frame.tracing-stubs}}} + + :devtools {:http-root "resources/public" + :http-port 8280}}}} + + :aliases {"cljs-repl" [["with-profile" "dev" "do" + ["shadow" "cljs-repl" "dashboard"]]] + + "watch" ["with-profile" "dev" "do" + ["shadow" "watch" "dashboard"]] + + "compile-cljs" ["with-profile" "dev" "do" + ["shadow" "compile" "dashboard"]] + + "release-cljs" ["with-profile" "prod" "do" + ["shadow" "release" "dashboard"]]} :profiles {:dev {:dependencies [[binaryage/devtools "1.0.0"] From 04c8873481fe794cb95943bdecedcb2112ab3435 Mon Sep 17 00:00:00 2001 From: RAZAFIMAHEFA Aina Date: Fri, 4 Dec 2020 20:56:00 +0100 Subject: [PATCH 37/48] Update profile config and deps --- project.clj | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/project.clj b/project.clj index 0d70148..e8ca200 100644 --- a/project.clj +++ b/project.clj @@ -79,6 +79,8 @@ ["shadow" "release" "dashboard"]]} :profiles {:dev - {:dependencies [[binaryage/devtools "1.0.0"] - [day8.re-frame/re-frame-10x "0.6.5"] - [day8.re-frame/tracing "0.5.5"]]}}) + {:dependencies [[binaryage/devtools "1.0.2"] + [day8.re-frame/re-frame-10x "0.7.0"]] + :source-paths ["dev"]} + + :prod {}}) From 1029d43faadd71f4b49bd322ceb9b02aa78a653b Mon Sep 17 00:00:00 2001 From: RAZAFIMAHEFA Aina Date: Fri, 4 Dec 2020 20:56:40 +0100 Subject: [PATCH 38/48] Remove shadow.cljs.edn from project Since lein-shadow plugin now generates shadow-cljs.edn from the configuration entry in project.clj, this file is not needed anymore --- shadow-cljs.edn | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 shadow-cljs.edn diff --git a/shadow-cljs.edn b/shadow-cljs.edn deleted file mode 100644 index 5867451..0000000 --- a/shadow-cljs.edn +++ /dev/null @@ -1,16 +0,0 @@ -;; shadow-cljs configuration -{:lein true - - :builds - {:dashboard {:target :browser - :output-dir "resources/public/assets/js" - :asset-path "/assets/js" - :dev {:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true - "day8.re_frame.tracing.trace_enabled_QMARK_" true}} - :modules {:dashboard {:init-fn dashboard.core/init}} - :devtools {:http-root "resources/public" - :http-handler shadow.http.push-state/handle - :http-port 8000 - :after-load dashboard.core/start - :preloads [devtools.preload - day8.re-frame-10x.preload]}}}} From 0b7591db97749ec8c0d1f303a071d232155d9038 Mon Sep 17 00:00:00 2001 From: RAZAFIMAHEFA Aina Date: Fri, 5 Feb 2021 21:44:49 +0100 Subject: [PATCH 39/48] Remove leiningen from the build pipeline To ease development, leiningen has been removed. Shadow-cljs provides a very efficient and lightweight way during development. Leiningen will eventually be added (if needed) at the end to comply with the other Yetibot projects which already use it. --- project.clj | 86 ------------------------------------- resources/public/index.html | 2 +- shadow-cljs.edn | 46 ++++++++++++++++++++ 3 files changed, 47 insertions(+), 87 deletions(-) delete mode 100644 project.clj create mode 100644 shadow-cljs.edn diff --git a/project.clj b/project.clj deleted file mode 100644 index e8ca200..0000000 --- a/project.clj +++ /dev/null @@ -1,86 +0,0 @@ -(defproject dashboard "0.1.0-SNAPSHOT" - :description "FIXME: write this!" - :url "http://example.com/FIXME" - :license {:name "Eclipse Public License" - :url "http://www.eclipse.org/legal/epl-v10.html"} - - :min-lein-version "2.9.1" - - :dependencies [[org.clojure/clojure "1.10.1"] - - ;; clojurescript and tooling - [org.clojure/clojurescript "1.10.597" :scope "provided" - :exclusions [com.google.javascript/closure-compiler-unshaded - org.clojure/google-closure-library - org.clojure/google-closure-library-third-party]] - [thheller/shadow-cljs "2.8.94"] - - ;; react - [reagent "0.10.0"] - [re-frame "1.1.2"] - [day8.re-frame/tracing "0.6.0"] - - ;; logging - [com.taoensso/timbre "4.10.0"] - - ;; graphql - [re-graph "0.1.13" :exclusions [re-graph.hato]] - [district0x/graphql-query "1.0.5"] - - ;; utils - [com.cognitect/transit-cljs "0.8.264"] - [camel-snake-kebab "0.4.1"]] - - :npm-deps [[react "16.13.1"] - ["bloomer" "0.6.5"] - ["bulma" "0.8.2"] - ["bulma-checkradio" "1.1.1"] - ["create-react-class" "15.6.3"] - ["highlight.js" "9.18.1"] - ["react" "16.13.1"] - ["react-dom" "16.13.1"] - ["react-highlight.js" "1.0.7"] - ["react-router-dom" "5.1.2"]] - - :plugins [[lein-shadow "0.3.1"] - [lein-shell "0.5.0"]] - - :source-paths ["src"] - - :clean-targets ^{:protect false} ["resources/public/js/compiled" "target"] - - :shadow-cljs {:nrepl {:port 8777} - - :builds {:dashboard {:target :browser - :output-dir "resources/public/js/compiled" - :asset-path "/js/compiled" - :modules {:app {:init-fn dashboard.core/init - :preloads [devtools.preload - day8.re-frame-10x.preload]}} - :dev {:compiler-options {:closure-defines {re-frame.trace.trace-enabled? true - day8.re-frame.tracing.trace-enabled? true}}} - :release {:build-options - {:ns-aliases - {day8.re-frame.tracing day8.re-frame.tracing-stubs}}} - - :devtools {:http-root "resources/public" - :http-port 8280}}}} - - :aliases {"cljs-repl" [["with-profile" "dev" "do" - ["shadow" "cljs-repl" "dashboard"]]] - - "watch" ["with-profile" "dev" "do" - ["shadow" "watch" "dashboard"]] - - "compile-cljs" ["with-profile" "dev" "do" - ["shadow" "compile" "dashboard"]] - - "release-cljs" ["with-profile" "prod" "do" - ["shadow" "release" "dashboard"]]} - - :profiles {:dev - {:dependencies [[binaryage/devtools "1.0.2"] - [day8.re-frame/re-frame-10x "0.7.0"]] - :source-paths ["dev"]} - - :prod {}}) diff --git a/resources/public/index.html b/resources/public/index.html index a62e235..38705fb 100644 --- a/resources/public/index.html +++ b/resources/public/index.html @@ -9,6 +9,6 @@
If you see this then there must be an issue with the react rendering in dashboard.core/init
- + diff --git a/shadow-cljs.edn b/shadow-cljs.edn new file mode 100644 index 0000000..628dce7 --- /dev/null +++ b/shadow-cljs.edn @@ -0,0 +1,46 @@ +{:source-paths ["dev" "src"] + + :dependencies [;; react + [reagent "1.0.0"] + [re-frame "1.1.2"] + + ;; graphql + [re-graph/re-graph "0.1.15" :exclusions [re-graph.hato]] + [district0x/graphql-query "1.0.6"] + + ;; utils + [camel-snake-kebab/camel-snake-kebab "0.4.2"] + [com.cognitect/transit-cljs "0.8.264"] + + ;; logging + [com.taoensso/timbre "5.1.1"] + + ;; Tooling + [day8.re-frame/re-frame-10x "0.7.0"] + [day8.re-frame/tracing "0.6.0"] + [binaryage/devtools "1.0.2"]] + + :nrepl {:port 8777} + + :builds + {:dashboard + {:target :browser + + ;; compiled assets output location configuration + :output-dir "resources/public/js" + :output-to "resources/public/js/dashboard.js" + :asset-path "public/js" + + ;; module entry point configuration + :modules {:dashboard {:init-fn dashboard.core/init}} + + ;; Trace-enabling for re-frame-10x tooling + :dev {:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true + "day8.re_frame.tracing.trace_enabled_QMARK_" true}} + + :compiler-options {:shadow-keywords true} + + :devtools {:http-root "resources/public" + :http-port 3000 + :preloads [devtools.preload + day8.re-frame-10x.preload]}}}} From de83c60bfb3baa5dfc0d0bbd339af286bca3a69b Mon Sep 17 00:00:00 2001 From: RAZAFIMAHEFA Aina Date: Fri, 5 Feb 2021 21:49:40 +0100 Subject: [PATCH 40/48] Upgrade npm deps --- package.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/package.json b/package.json index 3ae1901..b0b7335 100644 --- a/package.json +++ b/package.json @@ -22,8 +22,10 @@ "bulma": "^0.8.2", "bulma-checkradio": "^1.1.1", "create-react-class": "^15.6.3", + "highlight.js": "9.18.1", "react": "^16.13.1", "react-dom": "^16.13.1", + "react-highlight.js": "1.0.7", "react-router-dom": "^5.1.2" } } From e500a26de08eac1d54085ae43f3f06bc0165e3a4 Mon Sep 17 00:00:00 2001 From: RAZAFIMAHEFA Aina Date: Fri, 5 Feb 2021 21:50:59 +0100 Subject: [PATCH 41/48] Update .gitignore following the reverting to a pure shadow-cljs build setup --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index cdd1de3..559ea61 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -/resources/public/js/compiled/** +/resources/public/js/** figwheel_server.log pom.xml *jar From 1f3421be6f82e0bbd9820f1ecef6d1a91cbd257f Mon Sep 17 00:00:00 2001 From: RAZAFIMAHEFA Aina Date: Tue, 2 Mar 2021 18:40:15 +0100 Subject: [PATCH 42/48] Update documentation : shadow-cljs is used for building the project --- README.md | 248 +++++++++--------------------------------------------- 1 file changed, 41 insertions(+), 207 deletions(-) diff --git a/README.md b/README.md index 208477c..39ed9c5 100644 --- a/README.md +++ b/README.md @@ -10,128 +10,44 @@ We chose `shadow-cljs` as our main build tool for the project. `shadow-cljs` is See the [`shadow-cljs` _user-guide_](https://shadow-cljs.github.io/docs/UsersGuide.html "Shadow-cljs user guide") on how to install it. -## Leiningen - -`Leiningen` is the Clojure build tool that `Yetibot` uses. For `dashboard`, `shadow-cljs` delegates the _dependency management_ and _build entrypoint_ to `leiningen`. Using this tool is the easiest way to get started with the project. +# Development workflow using the shadow-cljs CLI -See the [`Leiningen` _installation docs_](https://leiningen.org/#install "Leiningen installation instructions") on how to install it. +There are two (2) main steps to get into the development workflow : +* Starting the `shadow-cljs` server which will be (re)used by any process to interact with the app. +* Starting a `watch` process which will, as its name suggests, watch and push any changes in the project code to the runtime (_hot reload_). -# Development workflow using Leiningen (the easy way) +> Starting a `watch` process actually starts a server process _automatically_ (step 2). +> +> When the _server_ is launched via the _watch_ process, the _server_ will have to be killed if the _watch_ has to be restarted. +> When launched separately, the `watch` process can be killed and restarted without restarting the _server_ and the `watch` will just reuse the existing server process. -## Running a watch process +## Starting the `shadow-cljs` server -To start a `watch` process, which will monitor changes and automatically recompile the `dashboard` code base, run the following command from the termimal: +To start the server, just type in : -`$ lein watch` +`$ shadow-cljs start` -a `watch` will implicitly start a _server process_ which will be re-used by all commands sent by the `shadow-cljs CLI`, instead of starting a new JVM. +It will then spin up a new jvm process for the server and the following output should be displayed on the console. ```shell script -added 43 packages from 380 contributors and audited 44 packages in 0.988s -found 0 vulnerabilities - -[:dashboard] Compiling ... -[:dashboard] Build completed. (562 files, 0 compiled, 0 warnings, 5,46s) -shadow-cljs - HTTP server available at http://localhost:8000 -shadow-cljs - server version: 2.8.94 running at http://localhost:9630 -shadow-cljs - nREPL server started on port 34945 -shadow-cljs - watching build :dashboard -[:dashboard] Configuring build. -[:dashboard] Compiling ... -[:dashboard] Build completed. (582 files, 1 compiled, 0 warnings, 5,49s) - +shadow-cljs - config: /home/kaffein/Projects/dashboard/shadow-cljs.edn +shadow-cljs - updating dependencies +shadow-cljs - dependencies updated +shadow-cljs - server starting ........................................................................ +ready! ``` -## Compiling the project - -To `compile` the project, run the following command : - -`$ lein compile-cljs` +> As part of the spinning-up process, the server process will also expose an _nrepl_ server via TCP. +> It can be used to manage the `shadow-cljs` process or interact with the application in its runtime. +## Running a `watch` process -```shell script -audited 44 packages in 0.6s -found 0 vulnerabilities - -[:dashboard] Compiling ... -[:dashboard] Build completed. (562 files, 0 compiled, 0 warnings, 5,45s) - -``` +To start a `watch` process which will monitor changes and automatically recompile the `dashboard` code base, run the following incantation from your terminal: -## Releasing for production +`$ shadow-cljs watch dashboard` -When ready for a deployment in `production`, run the following command : - -`$ lein release-cljs` - -This phase will produce a `minified` version of the code for each module thanks to the `Google Closure Compiler`. - -```shell script -[:dashboard] Compiling ... -[:dashboard] Build completed. (562 files, 0 compiled, 0 warnings, 5,45s) -[:dashboard] Compiling ... -[:dashboard] Build completed. (223 files, 0 compiled, 0 warnings, 17,65s) - -``` - -## Starting a CLJS REPL - -To start a `cljs repl`, run the following command : - -`$ lein cljs-repl` - -The output of the command should indicate the address at which to access the application. - -```shell script -audited 44 packages in 0.548s -found 0 vulnerabilities -[:dashboard] Compiling ... -[:dashboard] Build completed. (562 files, 0 compiled, 0 warnings, 5,65s) -[2020-07-13 18:08:13.196 - WARNING] TCP Port 9630 in use. -[2020-07-13 18:08:14.207 - WARNING] TCP Port 8000 in use. -shadow-cljs - HTTP server available at http://localhost:8001 -shadow-cljs - server version: 2.8.94 running at http://localhost:9631 -shadow-cljs - nREPL server started on port 35103 - -``` -you can then open your browser at the address exposed by the `shadow-cljs HTTP server` (here, `http://localhost:8001`). - -To make sure that the `cljs repl` is correctly connected to your JS runtime (here the _browser_), you can try to open a popup by `eval`-ing the following form to the repl : - -```shell script -$ cljs.user=> (js/alert "Hey Yeti!!") -nil -``` - -a popup should be displayed in the browser tab/window containing the application. - -Otherwise an explicit error is displayed in the `repl` if the JS runtime has not loaded our Clojurescript compiled code. - -```shell script -cljs.user=> (js/alert "Hey Yeti!!") -No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code. -``` - -At this point, simply opening the browser at the correct address should solve the issue. - ---- -**NOTE** - -Depending on your workflow, it is also possible to use `shadow-cljs` directly via its `CLI` or programmatically through its `api` as detailed below. - ---- - - -# Development workflow using the shadow-cljs CLI - -## Running a watch process - -To start a `watch` process which will monitor changes and automatically recompile the `dashboard` code base, run the following from your terminal: - -`$ shadow-cljs watch :dashboard` - -a `watch` will implicitly start a _server process_ which will be re-used by all commands sent by the CLI, instead of starting a new JVM. +the output on the console should give something like this : ```shell script + react-dom@16.13.0 @@ -147,7 +63,7 @@ a `watch` will implicitly start a _server process_ which will be re-used by all [:dashboard] Build completed. (157 files, 156 compiled, 0 warnings, 35.04s) ``` -To stop the `watch` process, just type in CTRL-C from the CLI : +To stop the `watch` process, just `CTRL-C` at the command line : ```shell script ... @@ -158,114 +74,32 @@ To stop the `watch` process, just type in CTRL-C from the CLI : Ctrl^C ``` -## The REPL - -To start the `REPL`, run : - -`$ shadow-cljs browser-repl :dashboard` - -It will launch a browser providing the `runtime` used to evaluate the code entered in the `REPL` - -``` -+ react-dom@16.13.0 -+ react@16.13.0 -updated 2 packages and audited 36 packages in 1.479s -found 0 vulnerabilities - -[:browser-repl] Configuring build. -[:browser-repl] Compiling ... -[:browser-repl] Build completed. (157 files, 156 compiled, 0 warnings, 21.91s) -cljs.user=> -``` - -# Development workflow using the provided `dev.clj` namespace - -We also provide a `dev.clj` namespace in `dev/dev.clj` which allows for a more Clojure-_friendly_ workflow during development. -This namespace contains a few utility functions for _programmatically_ interacting with `shadow-cljs` through its Clojure API. +## Checking the _dev_ setup -The first step is to start a regular `Clojure repl` from your terminal (or using your IDE) using : +At this point, to check whether everything works as expected : -`$ lein repl` +* open the application at `http://localhost:3000/` in the browser +* `jack-in`/`connect` your editor to the nrepl process -and then `eval` the content of the `dev.clj` in the newly-started REPL : +Once at the `repl` prompt, type in : -```clojure +```shell script +To quit, type: :cljs/quit ... -(defn- compile-build - "Compiles a build `build-id` where `build-id` is a - keyword identifying a build. - This is equivalent to invoking : - $ shadow-cljs compile :build-id" - [build-id] - (shadow/compile build-id)) -=> nil -=> #'dev/start-server -=> #'dev/stop-server -=> #'dev/re-init-server -=> #'dev/watch-build -=> #'dev/compile-build - -``` - -You can then `watch` or `compile` a build, `start`, `stop` or `re-init` the `shadow-cljs` server by just calling those functions from within the REPL. - -## Starting the shadow-cljs server - -```clojure -;; starts a shadow-cljs server -(start-server) -avr. 13, 2020 1:08:25 PM org.xnio.Xnio -INFO: XNIO version 3.7.3.Final -avr. 13, 2020 1:08:25 PM org.xnio.nio.NioXnio -INFO: XNIO NIO Implementation Version 3.7.3.Final -avr. 13, 2020 1:08:25 PM org.jboss.threads.Version -INFO: JBoss Threads version 2.3.2.Final -shadow-cljs - server version: 2.8.94 running at http://localhost:9630 -shadow-cljs - nREPL server started on port 34619 -=> :shadow.cljs.devtools.server/started - -;; since a shadow-cljs server is already running -(start-server) -=> :shadow.cljs.devtools.server/already-running -``` - -## Shutting down the shadow-cljs server - -```clojure -;; stops the running shadow-cljs server -(stop-server) -shutting down ... -=> nil +cljs.user> (js/alert "test") ``` +a popup should appear from inside the application. -## Re-initializing the shadow-cljs server - -```clojure -;; re-initializes the running shadow-cljs server -(re-init-server) -shadow-cljs - server version: 2.8.94 running at http://localhost:9630 -shadow-cljs - nREPL server started on port 42915 -=> :shadow.cljs.devtools.server/started -``` +# Compile the project -## Watching a build +To compile the project once and exit : -```clojure -;; watches a build (e.g here :dashboard) -(watch-build :dashboard) -[:dashboard] Configuring build. -[:dashboard] Compiling ... -=> :watching -[:dashboard] Build completed. (157 files, 1 compiled, 0 warnings, 2,18s) -... -``` +`$ shadow-cljs compile :dashboard` -## Compiling a build +If everything goes right, you should have the following output on the console. -```clojure -;; compiles a build (e.g here :dashboard) -(compile-build :dashboard) -[:dashboard] Compiling ... -[:dashboard] Build completed. (59 files, 0 compiled, 0 warnings, 0,58s) -=> :done +```shell script + ... + [:dashboard] Compiling ... + [:dashboard] Build completed. (567 files, 1 compiled, 3 warnings, 1,96s) ``` \ No newline at end of file From 33cd60b01ba250fe6f964c5d06cb2829ea7f1a0f Mon Sep 17 00:00:00 2001 From: RAZAFIMAHEFA Aina Date: Tue, 2 Mar 2021 18:40:58 +0100 Subject: [PATCH 43/48] Add metadata on hot-reloading entrypoint --- src/dashboard/core.cljs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dashboard/core.cljs b/src/dashboard/core.cljs index 4d6c7a0..3698ef0 100644 --- a/src/dashboard/core.cljs +++ b/src/dashboard/core.cljs @@ -130,7 +130,7 @@ [nav-bar] [content-body]]]) -(defn start +(defn ^:dev/after-load start "Mounts the application root component in the DOM." [] (rdom/render [dashboard-app] (js/document.getElementById "app"))) From ee93524b538951cf00dbd1b2961ffbc4fc6bdaa6 Mon Sep 17 00:00:00 2001 From: Aina RAZAFIMAHEFA Date: Sun, 23 Oct 2022 23:53:06 +0200 Subject: [PATCH 44/48] Add shadow-cljs as dev deps --- package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package.json b/package.json index b0b7335..8337e2e 100644 --- a/package.json +++ b/package.json @@ -27,5 +27,8 @@ "react-dom": "^16.13.1", "react-highlight.js": "1.0.7", "react-router-dom": "^5.1.2" + }, + "devDependencies": { + "shadow-cljs": "^2.20.6" } } From 2385200f5541f5454184d5baa05b1a1a107c1791 Mon Sep 17 00:00:00 2001 From: Aina RAZAFIMAHEFA Date: Sun, 23 Oct 2022 23:53:44 +0200 Subject: [PATCH 45/48] Fix audit vulnerability issues --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 8337e2e..b834935 100644 --- a/package.json +++ b/package.json @@ -18,14 +18,14 @@ }, "homepage": "https://github.com/kaffein/dashboard#readme", "dependencies": { - "bloomer": "^0.6.5", + "bloomer": "^0.6.3", "bulma": "^0.8.2", "bulma-checkradio": "^1.1.1", "create-react-class": "^15.6.3", - "highlight.js": "9.18.1", + "highlight.js": "^11.6.0", "react": "^16.13.1", "react-dom": "^16.13.1", - "react-highlight.js": "1.0.7", + "react-highlight.js": "^1.0.0", "react-router-dom": "^5.1.2" }, "devDependencies": { From 856cbe67618795bcad9613345e3cf003ac20be92 Mon Sep 17 00:00:00 2001 From: Aina RAZAFIMAHEFA Date: Sun, 23 Oct 2022 23:55:06 +0200 Subject: [PATCH 46/48] Add entries to .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 559ea61..10e1a5a 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,5 @@ pom.xml .lein-plugins/ .repl .nrepl-port +node_modules/ +package-lock.json From c712ecfd1585b750ca25a5db258340d5de7553a7 Mon Sep 17 00:00:00 2001 From: Aina RAZAFIMAHEFA Date: Mon, 24 Oct 2022 00:18:15 +0200 Subject: [PATCH 47/48] Git ignore shadow-cljs compilation outputs --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 10e1a5a..1b949e8 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ pom.xml .nrepl-port node_modules/ package-lock.json +.shadow-cljs/ From 0cc09546c3396f97fd343c80b6dd08e7d96baab3 Mon Sep 17 00:00:00 2001 From: Aina RAZAFIMAHEFA Date: Mon, 24 Oct 2022 00:44:19 +0200 Subject: [PATCH 48/48] Bump dependencies version --- shadow-cljs.edn | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/shadow-cljs.edn b/shadow-cljs.edn index 628dce7..95cfdcf 100644 --- a/shadow-cljs.edn +++ b/shadow-cljs.edn @@ -1,11 +1,11 @@ {:source-paths ["dev" "src"] :dependencies [;; react - [reagent "1.0.0"] - [re-frame "1.1.2"] + [reagent "1.1.1"] + [re-frame "1.3.0"] ;; graphql - [re-graph/re-graph "0.1.15" :exclusions [re-graph.hato]] + [re-graph/re-graph "0.2.0" :exclusions [re-graph.hato]] [district0x/graphql-query "1.0.6"] ;; utils @@ -13,12 +13,12 @@ [com.cognitect/transit-cljs "0.8.264"] ;; logging - [com.taoensso/timbre "5.1.1"] + [com.taoensso/timbre "5.2.0"] ;; Tooling - [day8.re-frame/re-frame-10x "0.7.0"] - [day8.re-frame/tracing "0.6.0"] - [binaryage/devtools "1.0.2"]] + [day8.re-frame/re-frame-10x "1.5.0"] + [day8.re-frame/tracing "0.6.2"] + [binaryage/devtools "1.0.6"]] :nrepl {:port 8777}