Skip to content
Snippets Groups Projects
Commit 6d832f64 authored by Lewis Liu's avatar Lewis Liu
Browse files

Refactored out separate render container function

parent 3312abb1
Branches
Tags
No related merge requests found
......@@ -396,8 +396,10 @@
(number-field? col-2)) :bar
:else :table)))
(defn- render-pulse-card-container
[card content]
(defn render-pulse-card
"Render a single CARD for a `Pulse`. RESULT is the QP results."
[card {:keys [data error]}]
[:a {:href (card-href card)
:target "_blank"
:style (style section-style
......@@ -417,34 +419,26 @@
[:img {:style (style {:width :16px})
:width 16
:src (render-image-with-filename "frontend_client/app/img/external_link.png")}])]]]])
content])
(defn render-pulse-card
"Render a single CARD for a `Pulse`. RESULT is the QP results."
[card {:keys [data error]}]
(try
(when error
(throw (Exception. (str "Card has errors: " error))))
(let [content (case (detect-pulse-card-type card data)
:empty (render:empty card data)
:scalar (render:scalar card data)
:sparkline (render:sparkline card data)
:bar (render:bar card data)
:table (render:table card data)
[:div {:style (style font-style
{:color "#F9D45C"
:font-weight 700})}
"We were unable to display this card." [:br] "Please view this card in Metabase."])]
(render-pulse-card-container card content))
(case (detect-pulse-card-type card data)
:empty (render:empty card data)
:scalar (render:scalar card data)
:sparkline (render:sparkline card data)
:bar (render:bar card data)
:table (render:table card data)
[:div {:style (style font-style
{:color "#F9D45C"
:font-weight 700})}
"We were unable to display this card." [:br] "Please view this card in Metabase."])
(catch Throwable e
(log/warn "Pulse card render error:" e)
(let [content [:div {:style (style font-style
{:color "#EF8C8C"
:font-weight 700
:padding :16px})}
"An error occurred while displaying this card."]]
(render-pulse-card-container card content)))))
[:div {:style (style font-style
{:color "#EF8C8C"
:font-weight 700
:padding :16px})}
"An error occurred while displaying this card."]))])
(defn render-pulse-section
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment