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

Merge branch 'automagic-dashboards-frontend' of github.com:metabase/metabase...

Merge branch 'automagic-dashboards-frontend' of github.com:metabase/metabase into automagic-dashboards-stage1
parents 6874fed6 fce8f354
No related branches found
No related tags found
No related merge requests found
......@@ -32,7 +32,7 @@ import { parseHashOptions } from "metabase/lib/browser";
const mapStateToProps = (state, props) => {
return {
dashboardId: props.params.dashboardId,
dashboardId: props.dashboardId || props.params.dashboardId,
isAdmin: getUserIsAdmin(state, props),
isEditing: getIsEditing(state, props),
......
......@@ -42,6 +42,7 @@ import {
RevisionApi,
PublicApi,
EmbedApi,
AutoApi,
} from "metabase/services";
import { getDashboard, getDashboardComplete } from "./selectors";
......@@ -108,6 +109,8 @@ function getDashboardType(id) {
return "public";
} else if (Utils.isJWT(id)) {
return "embed";
} else if (/\/auto\/dashboard/.test(id)) {
return "auto";
} else {
return "normal";
}
......@@ -513,6 +516,17 @@ export const fetchDashboard = createThunkAction(FETCH_DASHBOARD, function(
dashboard_id: dashId,
})),
};
} else if (dashboardType === "auto") {
const [type, id] = dashId.split("/").slice(3);
result = await AutoApi.dashboard({ type, id });
result = {
...result,
id: dashId,
ordered_cards: result.ordered_cards.map(dc => ({
...dc,
dashboard_id: dashId,
})),
};
} else {
result = await DashboardApi.get({ dashId: dashId });
}
......
......@@ -5,7 +5,7 @@ import MetabaseSettings from "metabase/lib/settings";
const PARENTS = MetabaseSettings.get("types");
/// Basically exactly the same as Clojure's isa?
/// Recurses through the type hierarchy until it can give you an anser.
/// Recurses through the type hierarchy until it can give you an answer.
/// isa(TYPE.BigInteger, TYPE.Number) -> true
/// isa(TYPE.Text, TYPE.Boolean) -> false
export function isa(child, ancestor) {
......
......@@ -224,6 +224,13 @@ export const getRoutes = store => (
<ModalRoute path="history" modal={DashboardHistoryModal} />
</Route>
<Route
path="/auto/:type/:subtype/:id"
component={props => (
<DashboardApp {...props} dashboardId={props.location.pathname} />
)}
/>
{/* QUERY BUILDER */}
<Route path="/question">
<IndexRoute component={QueryBuilder} />
......
......@@ -84,6 +84,10 @@ export const EmbedApi = {
),
};
export const AutoApi = {
dashboard: GET("/api/automagic-dashboards/:type/:id"),
};
export const EmailApi = {
updateSettings: PUT("/api/email"),
sendTest: POST("/api/email/test"),
......
......@@ -20,12 +20,13 @@
:db_id id
:visibility_type nil)
(remove (some-fn magic/link-table? magic/list-like-table?))
(keep magic/automagic-dashboard)))
(keep magic/automagic-dashboard)
first))
(api/defendpoint GET "/table/:id"
"Return an automagic dashboard for table with id `ìd`."
[id]
(magic/automagic-dashboard (Table id)))
(first (magic/automagic-dashboard (Table id))))
(api/defendpoint GET "/analize/metric/:id"
"Return an automagic dashboard analyzing metric with id `id`."
......
......@@ -22,30 +22,34 @@
(defn- clone-card
[card]
(-> card
(dissoc :height :position :id)
(assoc :creator_id api/*current-user-id*
:collection_id (-> populate/automagic-collection deref :id))
(dissoc :height :position :id)))
:collection_id (-> populate/automagic-collection deref :id))))
(defn- place-row
[dashboard row height left right]
[(if (-> left :display (#{:bar :line}))
(update dashboard :orderd_cards conj {:col 0
:row row
:sizeX populate/grid-width
:sizeY height
:series [right]})
(update dashboard :orderd_cards conj {:col 0
:row row
:sizeX populate/grid-width
:sizeY height
:card left
:series [right]
:visualization_settings {}})
(let [width (/ populate/grid-width 2)]
(-> dashboard
(update :ordered_cards conj {:col 0
:row row
:sizeX width
:sizeY height
:card left})
(update :ordered_cards conj {:col width
:row row
:sizeX width
:sizeY height
:card right}))))
(update :ordered_cards conj {:col 0
:row row
:sizeX width
:sizeY height
:card left
:visualization_settings {}})
(update :ordered_cards conj {:col width
:row row
:sizeX width
:sizeY height
:card right
:visualization_settings {}}))))
(+ row height)])
(def ^:private ^Long title-height 2)
......
......@@ -50,12 +50,12 @@
: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})))
(update dashboard :ordered_cards conj {:col y
:row x
:sizeX width
:sizeY height
:card card
:visualization_settings {}})))
(defn add-text-card
"Add a text card to dashboard `dashboard` at position [`x`, `y`]."
......
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