Skip to content
Snippets Groups Projects
Commit 41d59bf1 authored by Simon Belak's avatar Simon Belak
Browse files

use /api/dataset endpoint for transient cards

parent c6f54528
No related branches found
No related tags found
No related merge requests found
......@@ -43,6 +43,7 @@ import {
PublicApi,
EmbedApi,
AutoApi,
MetabaseApi,
} from "metabase/services";
import { getDashboard, getDashboardComplete } from "./selectors";
......@@ -467,6 +468,10 @@ export const fetchCardData = createThunkAction(FETCH_CARD_DATA, function(
...getParametersBySlug(dashboard.parameters, parameterValues),
}),
);
} else if (dashboardType === "auto") {
result = await fetchDataOrError(
MetabaseApi.dataset(card.dataset_query),
);
} else {
result = await fetchDataOrError(
CardApi.query({ cardId: card.id, parameters: datasetQuery.parameters }),
......
......@@ -35,7 +35,8 @@
:sizeY height
:card left
:series [right]
:visualization_settings {}})
:visualization_settings {}
:id (gensym)})
(let [width (/ populate/grid-width 2)]
(-> dashboard
(update :ordered_cards conj {:col 0
......@@ -43,13 +44,15 @@
:sizeX width
:sizeY height
:card left
:visualization_settings {}})
:visualization_settings {}
:id (gensym)})
(update :ordered_cards conj {:col width
:row row
:sizeX width
:sizeY height
:card right
:visualization_settings {}}))))
:visualization_settings {}
:id (gensym)}))))
(+ row height)])
(def ^:private ^Long title-height 2)
......
......@@ -50,12 +50,13 @@
:result_metadata (card.api/result-metadata-for-query query)
:collection_id (-> automagic-collection deref :id)}
card/populate-query-fields)]
(update dashboard :ordered_cards conj {:col y
:row x
:sizeX width
:sizeY height
:card card
:visualization_settings {}})))
(update dashboard :ordered_cards conj {:col y
:row x
:sizeX width
:sizeY height
:card card
:visualization_settings {}
:id (gensym)})))
(defn add-text-card
"Add a text card to dashboard `dashboard` at position [`x`, `y`]."
......@@ -71,7 +72,8 @@
:row x
:sizeX width
:sizeY height
:card nil}))
:card nil
:id (gensym)}))
(def ^:private ^Long max-cards 9)
......
......@@ -236,7 +236,7 @@
(doseq [dashcard dashcards]
(let [card (db/insert! 'Card (:card dashcard))
dashcard (-> dashcard
(dissoc :card)
(dissoc :card :id)
(update :parameter_mappings
(partial map #(assoc % :card_id (:id card)))))]
(events/publish-event! :card-create card)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment