Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automagic dashboards #7048

Merged
merged 245 commits into from
Mar 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
245 commits
Select commit Hold shift + click to select a range
6e26853
Add example configuration YAML
sbelak Nov 22, 2017
e0cbdc1
Add more predicates
sbelak Nov 22, 2017
7a50c86
Automagic dashboards POC
sbelak Nov 29, 2017
3683b8f
Add provisional API endpoint
sbelak Nov 30, 2017
84d6dfb
Remove constraints that potentially touch the warehouse
sbelak Nov 30, 2017
85a5ab2
Add autolayout
sbelak Nov 30, 2017
3f9f16d
Add YAML frontend
sbelak Nov 30, 2017
f3ffe9f
Add permission checking
sbelak Nov 30, 2017
4b6f786
Support native queries
sbelak Nov 30, 2017
6764f26
Resolve FKs, mode cards
sbelak Dec 4, 2017
5e5f517
Docstrings, minor refactor
sbelak Dec 4, 2017
551ddcb
Ad limit scope to a table only to api
sbelak Dec 4, 2017
e2ee0d5
Always create a new dashboard
sbelak Dec 4, 2017
70104a0
Add tests
sbelak Dec 4, 2017
e89252f
Add typehints
sbelak Dec 4, 2017
3100849
Explicitly define dashboards
sbelak Dec 4, 2017
dbd5e4a
Add nested queries, maps
sbelak Dec 7, 2017
60fe522
Add metrics
sbelak Dec 7, 2017
9b7a9f5
Add row charts, limits, sorting
sbelak Dec 8, 2017
4e3a217
Create dashboards only if needed
sbelak Dec 11, 2017
68a2ee2
Automatically inject table names in native queries
sbelak Dec 12, 2017
8d698de
Use metadata types
sbelak Dec 15, 2017
86ceabc
some example yaml files
salsakran Dec 16, 2017
7eddd06
Add entities to public settings.
sbelak Dec 18, 2017
504be1f
Definition language v3
sbelak Dec 19, 2017
480fa9e
GA table progress
mazameli Dec 20, 2017
035836f
add GA table yaml
mazameli Dec 20, 2017
5e5a300
Primitive table classification
sbelak Dec 20, 2017
886dac0
Add limit and add all autogenerated cards to a collection
sbelak Dec 20, 2017
af11e3f
One heuristic per table
sbelak Dec 20, 2017
b4ec9c5
Add explicit links
sbelak Dec 20, 2017
66384c8
Support dimension references in metrics and filter definitions
sbelak Dec 20, 2017
9c1f11f
Merge branch 'automagic-dashboards-poc' of github.com:metabase/metaba…
sbelak Dec 20, 2017
206cc28
Yank 100 into max-score
sbelak Dec 20, 2017
0ea4b2a
Minor refactor
sbelak Dec 20, 2017
0e1ee62
Update example/test yamls
sbelak Dec 20, 2017
f62ce92
Fix null exception when no cards can be made
sbelak Dec 21, 2017
48ade18
Minor refactoring
sbelak Dec 21, 2017
c76c454
comment out GA things we can't do yet
mazameli Dec 21, 2017
870e5ea
naming
salsakran Dec 21, 2017
1b61dc4
Merge branch 'automagic-dashboards-poc' of github.com:metabase/metaba…
salsakran Dec 21, 2017
7f41d61
Minor refactor: defer transforming models to references
sbelak Dec 21, 2017
2d3f969
Merge branch 'automagic-dashboards-poc' of github.com:metabase/metaba…
sbelak Dec 21, 2017
9aa8829
Support GA engine, minor refactoring
sbelak Dec 22, 2017
e9ced54
Add GA yaml
sbelak Dec 22, 2017
89a1eae
Update additional examples
sbelak Dec 22, 2017
abcf575
Fix wrong indentation
sbelak Dec 22, 2017
e6a0753
Fix field name
sbelak Dec 22, 2017
ba6492c
change top page cards to tables
mazameli Dec 22, 2017
9c22dcf
Massive refactor
sbelak Dec 26, 2017
ea41f87
Merge branch 'automagic-dashboards-poc' of github.com:metabase/metaba…
sbelak Dec 26, 2017
b2442a8
Use with-defaults throughout
sbelak Dec 26, 2017
abc6957
Add command line entry point to validate heuristics
sbelak Dec 26, 2017
a9dda02
Work better with weird inputs
sbelak Dec 26, 2017
3caf2f4
Fix missing deps
sbelak Dec 26, 2017
3122362
Minor refactor
sbelak Dec 26, 2017
bc103fa
Add & fix tests; add missing docstrings; add logging; refactor
sbelak Dec 27, 2017
44cd7d9
Merge branch 'master' of github.com:metabase/metabase into automagic-…
sbelak Dec 27, 2017
0f46672
Fix test
sbelak Dec 27, 2017
c699bcd
Make Schemas private
sbelak Dec 27, 2017
c9dd71d
Fix name clash
sbelak Dec 27, 2017
3d2738e
Add docstring to max-score
sbelak Dec 27, 2017
508007b
Validate order_by references
sbelak Dec 27, 2017
2f93aa2
Test that all rules are valid
sbelak Dec 27, 2017
a08a3d5
doall -> dorun
sbelak Dec 27, 2017
3519f7f
Add order_by
sbelak Dec 27, 2017
986fa22
Remove ordering from GA
sbelak Dec 27, 2017
a91ce8b
Fill templates
sbelak Dec 27, 2017
6ffe20d
Fix rename
sbelak Dec 27, 2017
b9f6094
Fix filter-tables
sbelak Dec 27, 2017
6115067
Add support for native queries; more tests; more robustness
sbelak Dec 28, 2017
931d7d6
Disambiguate FKs, fullly qualified field references in native
sbelak Dec 28, 2017
70e62e2
Clean up created models after test.
sbelak Dec 28, 2017
6fa7d76
Simplify dashboard layout (since we always start anew)
sbelak Dec 28, 2017
178a941
Add names to Schema constraints
sbelak Dec 28, 2017
b006802
Add more field type classifiers
sbelak Dec 28, 2017
91b0d2f
Make count less ambigious
sbelak Dec 28, 2017
738ed71
more stringent income pattern
sbelak Dec 28, 2017
2d31161
Add EventTable type
sbelak Dec 29, 2017
6d3b48a
New and refreshed heuristics
sbelak Dec 30, 2017
85d2f98
Skip hidden tables, smarter type matching
sbelak Dec 30, 2017
1b417dd
Correctly handle multiple FKs pointing from-to the same table
sbelak Jan 2, 2018
dbb83cb
Change visualization so we don't get broken charts.
sbelak Jan 3, 2018
9b3ede9
Merge branch 'master' of github.com:metabase/metabase into automagic-…
sbelak Jan 3, 2018
8e8f129
Add aggregation to dimensions
sbelak Jan 4, 2018
73299f7
Fix dimension-form checker
sbelak Jan 4, 2018
7b2f950
revert raw type chenges
sbelak Jan 4, 2018
185a444
Add named predicate to dimension definitions
sbelak Jan 4, 2018
f2edc53
Rearrange ns
sbelak Jan 4, 2018
b9dc9b5
Merge branch 'master' of github.com:metabase/metabase into automagic-…
sbelak Jan 8, 2018
435243b
Don't generate dashboards for pure link tables
sbelak Jan 8, 2018
e5f96b6
Fix invalid date format for ga charts
sbelak Jan 9, 2018
4173e6b
Better handling of Druid tables
sbelak Jan 9, 2018
cfeeae5
Add map dimension binding support
sbelak Jan 9, 2018
ca7799c
Better key-like field elimination.
sbelak Jan 9, 2018
2ede38c
Make EventTable more robust
sbelak Jan 9, 2018
baf88e1
Fix table test (new table type)
sbelak Jan 9, 2018
8b0521d
Explain why & how we use SnakeYAML
sbelak Jan 10, 2018
94e893d
Layout control and auto-flow
sbelak Jan 11, 2018
4b11d0c
Switch to grid units everywhere
sbelak Jan 11, 2018
7039d67
Make linter happy
sbelak Jan 11, 2018
242156b
Remove old example yaml
sbelak Jan 11, 2018
ca3005b
Provisional grouping
sbelak Jan 11, 2018
4cd7b9c
Update users.yaml
salsakran Jan 13, 2018
a29c8fc
Update orders.yaml
salsakran Jan 13, 2018
e4139e9
Merge branch 'master' of github.com:metabase/metabase into automagic-…
sbelak Jan 16, 2018
75ccbd8
Move table types to own hieararchy.
sbelak Jan 16, 2018
3d26ebd
Merge branch 'automagic-dashboards-poc' of github.com:metabase/metaba…
sbelak Jan 16, 2018
0dbe592
Add documentation/example
sbelak Jan 16, 2018
dd006f3
Add more types, improve type detection heuristics
sbelak Jan 17, 2018
3de454d
Lift 1 table, 1 dashboard restriction
sbelak Jan 18, 2018
7d0d7a4
Add subtables for Transactions, fix some bugs
sbelak Jan 22, 2018
32ef13f
Fix toplevel type exclusion
sbelak Jan 23, 2018
58dfbb8
Merge branch 'master' of github.com:metabase/metabase into automagic-…
sbelak Jan 23, 2018
fe6aeba
Update UserTable.yaml
salsakran Jan 23, 2018
4e33f67
Correctly flow types thorugh FKs, add more time breakdowns
sbelak Jan 24, 2018
bf1cbf2
Fix GA worldmap, add count by time
sbelak Jan 24, 2018
82e2793
Add max_cardinality filter, retain ordering, add rowcount
sbelak Jan 24, 2018
ab9152e
Add more rowcounts, limit categories to 10 rows
sbelak Jan 24, 2018
c5aaac7
Add distinct count for FKs
sbelak Jan 24, 2018
d4624a0
Fix metric name
sbelak Jan 24, 2018
388c02e
Add correlation dashboard
sbelak Jan 24, 2018
28bbd83
Nips and tucks
sbelak Jan 25, 2018
ea0a82d
Merge branch 'master' of github.com:metabase/metabase into automagic-…
sbelak Jan 25, 2018
e415b1d
Skip single-field tables
sbelak Jan 25, 2018
e80a079
Use arg destructuring
sbelak Jan 25, 2018
2d1db76
Merge branch 'master' of github.com:metabase/metabase into automagic-…
sbelak Jan 25, 2018
3170872
Add grouping and visually space out groups
sbelak Jan 26, 2018
f19e856
Add 2 col comparision
sbelak Feb 1, 2018
056d8bc
Merge branch 'automagic-dashboards-grouping' of github.com:metabase/m…
sbelak Feb 1, 2018
9a72392
Hybrid dashboard
sbelak Feb 1, 2018
7e915e3
Add automagic filters
sbelak Feb 2, 2018
6fda93b
Build histograms from preaggregated data
sbelak Feb 3, 2018
b1b53db
minor refactor
sbelak Feb 5, 2018
c2ab32b
Ensure each field gets bind to only one dimension
sbelak Feb 6, 2018
c077298
Merge branch 'automagic-dashboards-poc' of github.com:metabase/metaba…
sbelak Feb 6, 2018
d0fb6cc
Merge branch 'automagic-dashboards-grouping' of github.com:metabase/m…
sbelak Feb 6, 2018
863584b
We don't need to remove duplicate bindings any more
sbelak Feb 6, 2018
5fbeb03
Treat field x aggregation pairs as distinct
sbelak Feb 6, 2018
266b4ee
Merge branch 'master' of github.com:metabase/metabase into automagic-…
sbelak Feb 6, 2018
b2f67ed
Merge branch 'automagic-dashboards-poc' of github.com:metabase/metaba…
sbelak Feb 6, 2018
f275513
Add analysis dashboard
sbelak Feb 7, 2018
ec42a2c
Remove interestingness stuff and focus on flow/grouping
sbelak Feb 7, 2018
fce8f35
Automatic dashboards frontend PoC
tlrobinson Feb 19, 2018
0806f82
Merge branch 'automagic-dashboards-poc' of github.com:metabase/metaba…
Mar 1, 2018
a60cc88
Merge branch 'master' of github.com:metabase/metabase into automagic-…
Mar 1, 2018
8291ff6
Merge branch 'automagic-analysis' of github.com:metabase/metabase int…
Mar 1, 2018
ac68b0a
Merge branch 'automagic-dashboards-comparison' of github.com:metabase…
Mar 1, 2018
50db36b
Make linter happy
Mar 1, 2018
e0a1e1f
Fix whitespace
Mar 1, 2018
e26018f
Add docstring
Mar 1, 2018
a6a2f37
Fix identation
Mar 1, 2018
da4e1b5
Merge branch 'master' of github.com:metabase/metabase into automagic-…
Mar 2, 2018
df5ef11
revert type changes
Mar 2, 2018
ed8af8c
Fix failing test
Mar 2, 2018
cd9bbb6
Merge branch 'automagic-filters' of github.com:metabase/metabase into…
Mar 2, 2018
fbaf0f3
add docstring
Mar 2, 2018
687848d
Build transient representations
Mar 5, 2018
71069de
Add dashboard saving
Mar 5, 2018
a87e2db
Fetch entire dashboard for comparison
Mar 5, 2018
c52d174
don't go into /special directory
Mar 5, 2018
c6ffd1d
Add transient endpoints
Mar 5, 2018
6874fed
fix rename
Mar 5, 2018
c6f5452
Merge branch 'automagic-dashboards-frontend' of github.com:metabase/m…
Mar 5, 2018
d3d8fae
init
kdoh Mar 5, 2018
2476a11
initial content for setup step
kdoh Mar 6, 2018
3ce9f0a
content and layout tweaks
kdoh Mar 6, 2018
28e3895
basic skeleton
kdoh Mar 6, 2018
2927b12
header cleanup
kdoh Mar 6, 2018
41d59bf
use /api/dataset endpoint for transient cards
Mar 6, 2018
1e9a787
clarify route logic comment-out
kdoh Mar 6, 2018
8cb6944
Minor refactor
Mar 6, 2018
f9aa709
Rename dashboard type from auto to transient
Mar 6, 2018
d39a75c
Remove ns prefix
Mar 6, 2018
92beb01
misc style cleanup
kdoh Mar 6, 2018
a85a5b5
Minor refactor
Mar 6, 2018
4652a8b
Add remaining comparison combinations
Mar 7, 2018
7ced989
add links in
salsakran Mar 7, 2018
a7459f4
add in+outs stage 1ish
salsakran Mar 8, 2018
b6c2c78
Merge remote-tracking branch 'origin/onboarding-exploration-fe' into …
tlrobinson Mar 8, 2018
6480ac1
Update automatic dashboards frontend
tlrobinson Mar 8, 2018
bd23322
Merge branch 'automagic-dashboards-stage1' of github.com:metabase/met…
tlrobinson Mar 8, 2018
1a5712c
GET -> POST for saving
salsakran Mar 8, 2018
6c36af9
clean up comments
salsakran Mar 8, 2018
82879c4
Auto dashboard saving
tlrobinson Mar 8, 2018
9a47cdd
Merge branch 'automagic-dashboards-stage1' of github.com:metabase/met…
tlrobinson Mar 8, 2018
4cb9aef
Add tophat api
Mar 8, 2018
f58bcea
Fix typo
tlrobinson Mar 8, 2018
3c6f29d
Wire up auto dashboard title and suggestions
tlrobinson Mar 8, 2018
5c93d36
Fix titles in recommended
Mar 8, 2018
51acb5e
Change related url to public
Mar 8, 2018
99fbcc2
change url endpoint to /auto/
Mar 8, 2018
3821ebe
Add endpoint for specific rule
Mar 8, 2018
3f0a2b6
fill out analysis endpoints
Mar 8, 2018
396c564
Cleanup auto dashboard suggestions
tlrobinson Mar 9, 2018
47fa4b7
Support arbitrary sub paths for auto dashboards
tlrobinson Mar 9, 2018
3d5b381
Reduce number of db hits
Mar 9, 2018
76a0a35
Merge branch 'automagic-dashboards-stage1' of github.com:metabase/met…
Mar 9, 2018
61be13f
Lift populate and call it only for the actual dashboard
Mar 9, 2018
8becdef
Add parameters to automatic dashboards. Not currently functional
tlrobinson Mar 9, 2018
36ca0c0
fix metrics autoD
Mar 12, 2018
52fb54b
Fix related titles
Mar 12, 2018
3651ed8
Merge branch 'automagic-dashboards-stage1' of github.com:metabase/met…
tlrobinson Mar 12, 2018
ddad790
Get parameters working on transient dashboards
tlrobinson Mar 12, 2018
9304d0b
Add support for segments and table-like questions
Mar 12, 2018
c6b0b5b
Merge branch 'automagic-dashboards-stage1' of github.com:metabase/met…
Mar 12, 2018
82d39b0
Fix typo (dashboard -> database)
Mar 12, 2018
ae1fd59
Add card ids
Mar 12, 2018
eebf66e
Add missing dep
Mar 12, 2018
a67062b
Properly handle filters for dashcards with series
Mar 12, 2018
0370bee
Revert adding ExploreStep to setup flow
tlrobinson Mar 13, 2018
5a4009c
Merge branch 'automagic-dashboards-stage1' of github.com:metabase/met…
tlrobinson Mar 13, 2018
fe09da6
Fix flow errors
tlrobinson Mar 13, 2018
fde2792
Add post-setup flow with auto dashboard suggestions
tlrobinson Mar 13, 2018
063786f
Update post-setup flow
tlrobinson Mar 13, 2018
3904717
comment out things that dont work
salsakran Mar 13, 2018
1592a53
Add cell analysis dashboard
Mar 13, 2018
2fa9834
Enable autoD for table-like cards & adhoc questions
Mar 13, 2018
df3ff3f
Fix generated filter clause if there is only one filter expression
Mar 13, 2018
f4937b7
Cap related
Mar 13, 2018
f4624f5
remove show more stuff + pass lint
salsakran Mar 14, 2018
b08c8bc
Merge branch 'automagic-dashboards-stage1' of github.com:metabase/met…
salsakran Mar 14, 2018
016f0e7
Add docstrings to IRootEntity protocol
Mar 14, 2018
ec53595
Merge branch 'automagic-dashboards-stage1' of github.com:metabase/met…
Mar 14, 2018
20b383f
use withBackground for automatic dash app
kdoh Mar 14, 2018
d3d8c5a
Make linter happy
Mar 14, 2018
37fcd56
Merge branch 'automagic-dashboards-stage1' of github.com:metabase/met…
Mar 14, 2018
9d5f363
make logging less chatty
Mar 14, 2018
726487a
Merge branch 'master' of github.com:metabase/metabase into automagic-…
Mar 14, 2018
65d63b2
Fix failing tests
Mar 14, 2018
030051b
make js pretty
Mar 14, 2018
bb837fc
change icon + fix tests
salsakran Mar 14, 2018
c3851e5
Merge branch 'automagic-dashboards-stage1' of github.com:metabase/met…
salsakran Mar 14, 2018
cfae6bd
add correct new test
salsakran Mar 14, 2018
65ff959
fix dupe props
salsakran Mar 14, 2018
3482e41
Fix group titles & reuse automagic-dashboard function for metrics
Mar 14, 2018
e10e2ec
Merge branch 'automagic-dashboards-stage1' of github.com:metabase/met…
Mar 14, 2018
01cb01e
Implement code review suggestions
Mar 14, 2018
8bb68b6
Implement code review changes part II
Mar 14, 2018
64a5f3c
styling and microcopy
mazameli Mar 14, 2018
116f278
merge
mazameli Mar 14, 2018
48702ed
fix unintended change to entitymenuitem
mazameli Mar 14, 2018
f442539
prettier
mazameli Mar 14, 2018
5419fad
Cache fKs for filters
Mar 15, 2018
58b391b
Fix broken links and broken test
Mar 15, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions frontend/interfaces/underscore.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ declare module "underscore" {

declare function debounce<T: any => any>(func: T): T;

declare function partition<T>(
array: T[],
pred: (val: T) => boolean,
): [T[], T[]];

// TODO: improve this
declare function chain<S>(obj: S): any;

Expand Down
68 changes: 68 additions & 0 deletions frontend/src/metabase/components/ExplorePane.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/* @flow */

import React from "react";
import { Link } from "react-router";

import Icon from "metabase/components/Icon";
import MetabotLogo from "metabase/components/MetabotLogo";

import { t } from "c-3po";

import type { Candidate } from "metabase/meta/types/Auto";

const DEFAULT_TITLE = t`Hi, Metabot here.`;
const DEFAULT_DESCRIPTION = "";

export const ExplorePane = ({
options,
// $FlowFixMe
title = DEFAULT_TITLE,
// $FlowFixMe
description = DEFAULT_DESCRIPTION,
}: {
options?: ?(Candidate[]),
title?: ?string,
description?: ?string,
}) => (
<div>
{title && (
<div className="flex align-center mb2">
<MetabotLogo className="mr2" />
<h3>
<span>{title}</span>
</h3>
</div>
)}
{description && (
<div className="mb4">
<span>{description}</span>
</div>
)}
{options && <ExploreList options={options} />}
</div>
);

export const ExploreList = ({ options }: { options: Candidate[] }) => (
<ol className="Grid Grid--1of2 Grid--gutters">
{options &&
options.map((option, index) => (
<li className="Grid-cell" key={index}>
<ExploreOption option={option} />
</li>
))}
</ol>
);

export const ExploreOption = ({ option }: { option: Candidate }) => (
<Link to={option.url} className="link flex align-center text-bold">
<div
className="bg-slate-almost-extra-light p2 flex align-center rounded mr1 justify-center text-gold"
style={{ width: 48, height: 48 }}
>
<Icon name="bolt" size={32} />
</div>
<span>{option.title}</span>
</Link>
);

export default ExplorePane;
11 changes: 11 additions & 0 deletions frontend/src/metabase/components/MetabotLogo.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from "react";
import cx from "classnames";

const MetabotLogo = ({ className }) => (
<div
style={{ width: 58, height: 40 }}
className={cx("bg-brand rounded", className)}
/>
);

export default MetabotLogo;
42 changes: 42 additions & 0 deletions frontend/src/metabase/components/Quotes.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* @flow */

import React, { Component } from "react";

type Props = {
period: number,
quotes: string[],
};
type State = {
count: number,
};

export default class Quotes extends Component {
props: Props;
state: State = {
count: 0,
};

_timer: ?number = null;

static defaultProps = {
quotes: [],
period: 1000,
};

componentWillMount() {
this._timer = setInterval(
() => this.setState({ count: this.state.count + 1 }),
this.props.period,
);
}
componentWillUnmount() {
if (this._timer != null) {
clearInterval(this._timer);
}
}
render() {
const { quotes } = this.props;
const { count } = this.state;
return <span>{quotes[count % quotes.length]}</span>;
}
}
135 changes: 135 additions & 0 deletions frontend/src/metabase/dashboard/containers/AutomaticDashboardApp.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
import React from "react";

import { connect } from "react-redux";
import { push } from "react-router-redux";
import { Link } from "react-router";
import { withBackground } from "metabase/hoc/Background";
import ActionButton from "metabase/components/ActionButton";
import Icon from "metabase/components/Icon";
import cxs from "cxs";

import { Dashboard } from "./Dashboard";
import DashboardData from "metabase/dashboard/hoc/DashboardData";
import Parameters from "metabase/parameters/components/Parameters";

import { DashboardApi } from "metabase/services";
import * as Urls from "metabase/lib/urls";

import { dissoc } from "icepick";

const suggestionClasses = cxs({
":hover h3": {
color: "#509ee3",
},
":hover .Icon": {
color: "#F9D45C",
},
});

const SuggestionsList = ({ suggestions }) => (
<ol className="px2">
{suggestions.map((s, i) => (
<li key={i} className={suggestionClasses}>
<Link
to={s.url}
className="bordered rounded bg-white shadowed mb2 p2 flex no-decoration"
>
<div
className="bg-slate-extra-light rounded flex align-center justify-center text-slate mr1 flex-no-shrink"
style={{ width: 48, height: 48 }}
>
<Icon name="bolt" className="Icon text-grey-1" size={22} />
</div>
<div>
<h3 className="m0 mb1 ml1">{s.title}</h3>
<p className="text-grey-4 ml1 mt0 mb0">{s.description}</p>
</div>
</Link>
</li>
))}
</ol>
);

const SuggestionsSidebar = ({ related }) => (
<div className="flex flex-column">
<div className="py2 text-centered my3">
<h3>More explorations</h3>
</div>
{Object.values(related).map(suggestions => (
<SuggestionsList suggestions={suggestions} />
))}
</div>
);

const getDashboardId = (state, { params: { splat } }) =>
`/auto/dashboard/${splat}`;

const mapStateToProps = (state, props) => ({
dashboardId: getDashboardId(state, props),
});

@connect(mapStateToProps, { push })
@DashboardData
class AutomaticDashboardApp extends React.Component {
save = async () => {
const { dashboard, push } = this.props;
// remove the transient id before trying to save
const newDashboard = await DashboardApi.save(dissoc(dashboard, "id"));
push(Urls.dashboard(newDashboard.id));
};

render() {
const {
dashboard,
parameters,
parameterValues,
setParameterValue,
location,
} = this.props;
return (
<div className="flex">
<div className="flex-full">
<div className="bg-white border-bottom py2">
<div className="wrapper flex align-center">
<Icon name="bolt" className="text-gold mr1" size={24} />
<h2>{dashboard && dashboard.name}</h2>
<ActionButton
className="ml-auto bg-green text-white"
borderless
actionFn={this.save}
>
Save this
</ActionButton>
</div>
</div>
<div className="px3 pb4">
{parameters &&
parameters.length > 0 && (
<div className="px1 pt1">
<Parameters
parameters={parameters.map(p => ({
...p,
value: parameterValues && parameterValues[p.id],
}))}
query={location.query}
setParameterValue={setParameterValue}
syncQueryString
isQB
/>
</div>
)}
<Dashboard {...this.props} />
</div>
</div>
{dashboard &&
dashboard.related && (
<div className="Layout-sidebar flex-no-shrink">
<SuggestionsSidebar related={dashboard.related} />
</div>
)}
</div>
);
}
}

export default withBackground("bg-slate-extra-light")(AutomaticDashboardApp);
60 changes: 60 additions & 0 deletions frontend/src/metabase/dashboard/containers/Dashboard.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/* @flow */

import React, { Component } from "react";
import cx from "classnames";

import LoadingAndErrorWrapper from "metabase/components/LoadingAndErrorWrapper";
import DashboardGrid from "metabase/dashboard/components/DashboardGrid";
import DashboardData from "metabase/dashboard/hoc/DashboardData";

import type { Dashboard as _Dashboard } from "metabase/meta/types/Dashboard";
import type { Parameter } from "metabase/meta/types/Parameter";

type Props = {
location?: { query: { [key: string]: string } },
dashboardId: string,

dashboard?: _Dashboard,
parameters: Parameter[],
parameterValues: { [key: string]: string },

initialize: () => void,
isFullscreen: boolean,
isNightMode: boolean,
fetchDashboard: (
dashId: string,
query?: { [key: string]: string },
) => Promise<void>,
fetchDashboardCardData: (options: {
reload: boolean,
clear: boolean,
}) => Promise<void>,
setParameterValue: (id: string, value: string) => void,
setErrorPage: (error: { status: number }) => void,
};

export class Dashboard extends Component {
props: Props;

render() {
const { dashboard } = this.props;

return (
<LoadingAndErrorWrapper
className={cx("Dashboard p1 flex-full")}
loading={!dashboard}
>
{() => (
<DashboardGrid
{...this.props}
className={"spread"}
// Don't allow clicking titles on public dashboards
navigateToNewCardFromDashboard={null}
/>
)}
</LoadingAndErrorWrapper>
);
}
}

export default DashboardData(Dashboard);
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Loading