Skip to content

Commit

Permalink
[0.24 fixedMergeConflicts] [deck_multi] fixing issues with deck_multi (
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch authored and hughhhh committed Apr 11, 2018
1 parent ea621c7 commit f8e9ae9
Show file tree
Hide file tree
Showing 5 changed files with 9,664 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import Select from '../../../components/AsyncSelect';
import ControlHeader from '../ControlHeader';
import { t } from '../../../locales';

const propTypes = {
Expand All @@ -26,24 +27,27 @@ const defaultProps = {
placeholder: t('Select ...'),
};

const SelectAsyncControl = ({ value, onChange, dataEndpoint,
multi, mutator, placeholder, onAsyncErrorMessage }) => {
const SelectAsyncControl = (props) => {
const { value, onChange, dataEndpoint, multi, mutator, placeholder, onAsyncErrorMessage } = props;
const onSelectionChange = (options) => {
const optionValues = options.map(option => option.value);
onChange(optionValues);
};

return (
<Select
dataEndpoint={dataEndpoint}
onChange={onSelectionChange}
onAsyncError={errorMsg => notify.error(onAsyncErrorMessage + ': ' + errorMsg)}
mutator={mutator}
multi={multi}
value={value}
placeholder={placeholder}
valueRenderer={v => (<div>{v.label}</div>)}
/>
<div>
<ControlHeader {...props} />
<Select
dataEndpoint={dataEndpoint}
onChange={onSelectionChange}
onAsyncError={errorMsg => notify.error(onAsyncErrorMessage + ': ' + errorMsg)}
mutator={mutator}
multi={multi}
value={value}
placeholder={placeholder}
valueRenderer={v => (<div>{v.label}</div>)}
/>
</div>
);
};

Expand Down
2 changes: 1 addition & 1 deletion superset/assets/javascripts/explore/stores/controls.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1978,7 +1978,7 @@ export const controls = {
validators: [v.nonEmpty],
default: [],
description: t('Pick a set of deck.gl charts to layer on top of one another'),
dataEndpoint: '/sliceasync/api/read?_flt_0_viz_type=deck_',
dataEndpoint: '/sliceasync/api/read?_flt_0_viz_type=deck_&_flt_7_viz_type=deck_multi',
placeholder: t('Select charts'),
onAsyncErrorMessage: t('Error while fetching charts'),
mutator: (data) => {
Expand Down
7 changes: 4 additions & 3 deletions superset/assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
"d3-tip": "^0.6.7",
"datamaps": "^0.5.8",
"datatables.net-bs": "^1.10.15",
"deck.gl": "^5.0.1",
"deck.gl": "^5.1.4",
"deep-equal": "^1.0.1",
"distributions": "^1.0.0",
"dompurify": "^1.0.3",
"fastdom": "^1.0.6",
Expand All @@ -68,8 +69,8 @@
"jed": "^1.1.1",
"jquery": "3.1.1",
"lodash.throttle": "^4.1.1",
"luma.gl": "^5.0.1",
"mapbox-gl": "^0.43.0",
"luma.gl": "^5.1.4",
"mapbox-gl": "^0.44.2",
"mathjs": "^3.20.2",
"moment": "^2.20.1",
"mousetrap": "^1.6.1",
Expand Down
9 changes: 3 additions & 6 deletions superset/assets/visualizations/deckgl/multi.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,15 @@ import layerGenerators from './layers';


function deckMulti(slice, payload, setControlValue) {
if (!slice.subSlicesLayers) {
slice.subSlicesLayers = {}; // eslint-disable-line no-param-reassign
}
const subSlicesLayers = {};
const fd = slice.formData;
const render = () => {
const viewport = {
...fd.viewport,
width: slice.width(),
height: slice.height(),
};
const layers = Object.keys(slice.subSlicesLayers).map(k => slice.subSlicesLayers[k]);
const layers = Object.keys(subSlicesLayers).map(k => subSlicesLayers[k]);
ReactDOM.render(
<DeckGLContainer
mapboxApiAccessToken={payload.data.mapboxApiKey}
Expand Down Expand Up @@ -49,9 +47,8 @@ function deckMulti(slice, payload, setControlValue) {

const url = getExploreLongUrl(subsliceCopy.form_data, 'json');
$.get(url, (data) => {
// Late import to avoid circular deps
const layer = layerGenerators[subsliceCopy.form_data.viz_type](subsliceCopy.form_data, data);
slice.subSlicesLayers[subsliceCopy.slice_id] = layer; // eslint-disable-line no-param-reassign
subSlicesLayers[subsliceCopy.slice_id] = layer;
render();
});
});
Expand Down
Loading

0 comments on commit f8e9ae9

Please sign in to comment.