diff --git a/src/clj/pmagnus/elprice/web/routes/ui.clj b/src/clj/pmagnus/elprice/web/routes/ui.clj index 3b11dd0..6b4c449 100644 --- a/src/clj/pmagnus/elprice/web/routes/ui.clj +++ b/src/clj/pmagnus/elprice/web/routes/ui.clj @@ -100,21 +100,15 @@ (price-table title prices)]])) (defn home [query-fn request] + (prices/fetch-and-save! query-fn) (page {:lang "en"} - [:h1 {:class "text-2xl font-bold text-gray-900"} + [:h1 {:class "text-2xl font-bold text-gray-900 cursor-pointer hover:text-blue-600 transition-colors" + :hx-post "/prices/fetch" + :hx-target "#price-panel" + :hx-swap "innerHTML"} "Electricity Prices"] [:p {:class "mt-1 text-sm text-gray-500"} "Day-ahead spot prices for DK1 (øre/kWh)"] - [:button {:class "mt-4 rounded-lg bg-blue-600 px-4 py-2 text-white font-medium - active:bg-blue-700 transition-colors" - :hx-post "/prices/fetch" - :hx-target "#price-panel" - :hx-swap "innerHTML" - :hx-indicator "#fetch-spinner"} - "Refresh Prices"] - [:span {:id "fetch-spinner" - :class "ml-2 htmx-indicator text-sm text-gray-400"} - "Loading..."] [:div {:id "price-panel"} (price-content :today (prices/get-today-prices query-fn))]))