Skip to content

Commit

Permalink
Merge pull request apache#16 from john-bodley/john-bodley-sync-apache…
Browse files Browse the repository at this point in the history
…-master

[sync] apache master
  • Loading branch information
john-bodley authored Mar 6, 2018
2 parents 19ea5f0 + 48430a1 commit d995649
Show file tree
Hide file tree
Showing 172 changed files with 3,197 additions and 1,370 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ app.db
*.sqllite
.vscode
.python-version
.tox

# Node.js, webpack artifacts
*.entry.js
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ the world know they are using Superset. Join our growing community!
- [Udemy](https://www.udemy.com/)
- [VIPKID](https://www.vipkid.com.cn/)
- [Yahoo!](https://yahoo.com/)
- [Zaihang](http://www.zaih.com/)
- [Zalando](https://www.zalando.com)


Expand Down
1 change: 1 addition & 0 deletions run_specific_test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env bash
echo $DB
rm -f .coverage
export PYTHONPATH=./
export SUPERSET_CONFIG=tests.superset_test_config
set -e
superset/bin/superset version -v
Expand Down
1 change: 1 addition & 0 deletions run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ rm ~/.superset/unittests.db
rm ~/.superset/celerydb.sqlite
rm ~/.superset/celery_results.sqlite
rm -f .coverage
export PYTHONPATH=./
export SUPERSET_CONFIG=tests.superset_test_config
set -e
superset/bin/superset db upgrade
Expand Down
6 changes: 6 additions & 0 deletions scripts/permissions_cleanup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from collections import defaultdict

from superset import sm
Expand Down
7 changes: 7 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import json
import os
import subprocess
Expand Down Expand Up @@ -81,6 +87,7 @@ def get_git_sha():
'thrift>=0.9.3',
'thrift-sasl>=0.2.1',
'unidecode>=0.04.21',
'unicodecsv==0.14.1',
'bleach==2.1.2',
],
extras_require={
Expand Down
1 change: 1 addition & 0 deletions superset/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
"""Package's main module!"""
from __future__ import absolute_import
from __future__ import division
Expand Down
9 changes: 6 additions & 3 deletions superset/assets/javascripts/addSlice/AddSliceContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ export default class AddSliceContainer extends React.PureComponent {
}

exploreUrl() {
const baseUrl = `/superset/explore/${this.state.datasourceType}/${this.state.datasourceId}`;
const formData = encodeURIComponent(JSON.stringify({ viz_type: this.state.visType }));
return `${baseUrl}?form_data=${formData}`;
const formData = encodeURIComponent(
JSON.stringify({
viz_type: this.state.visType,
datasource: this.state.datasourceValue,
}));
return `/superset/explore/?form_data=${formData}`;
}

gotoSlice() {
Expand Down
17 changes: 17 additions & 0 deletions superset/assets/javascripts/chart/Chart.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import ChartBody from './ChartBody';
import Loading from '../components/Loading';
import { Logger, LOG_ACTIONS_RENDER_EVENT } from '../logger';
import StackTraceMessage from '../components/StackTraceMessage';
import RefreshChartOverlay from '../components/RefreshChartOverlay';
import visMap from '../../visualizations/main';
import sandboxedEval from '../modules/sandbox';
import './chart.css';
Expand Down Expand Up @@ -36,11 +37,15 @@ const propTypes = {
queryResponse: PropTypes.object,
lastRendered: PropTypes.number,
triggerQuery: PropTypes.bool,
refreshOverlayVisible: PropTypes.bool,
errorMessage: PropTypes.node,
// dashboard callbacks
addFilter: PropTypes.func,
getFilters: PropTypes.func,
clearFilter: PropTypes.func,
removeFilter: PropTypes.func,
onQuery: PropTypes.func,
onDismissRefreshOverlay: PropTypes.func,
};

const defaultProps = {
Expand Down Expand Up @@ -214,12 +219,24 @@ class Chart extends React.PureComponent {
/>
}

{!isLoading &&
!this.props.chartAlert &&
this.props.refreshOverlayVisible &&
!this.props.errorMessage &&
<RefreshChartOverlay
height={this.height()}
width={this.width()}
onQuery={this.props.onQuery}
onDismiss={this.props.onDismissRefreshOverlay}
/>
}
{!isLoading && !this.props.chartAlert &&
<ChartBody
containerId={this.containerId}
vizType={this.props.vizType}
height={this.height}
width={this.width}
faded={this.props.refreshOverlayVisible && !this.props.errorMessage}
ref={(inner) => {
this.container = inner;
}}
Expand Down
3 changes: 2 additions & 1 deletion superset/assets/javascripts/chart/ChartBody.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const propTypes = {
vizType: PropTypes.string.isRequired,
height: PropTypes.func.isRequired,
width: PropTypes.func.isRequired,
faded: PropTypes.bool,
};

class ChartBody extends React.PureComponent {
Expand Down Expand Up @@ -42,7 +43,7 @@ class ChartBody extends React.PureComponent {
return (
<div
id={this.props.containerId}
className={`slice_container ${this.props.vizType}`}
className={`slice_container ${this.props.vizType}${this.props.faded ? ' faded' : ''}`}
ref={(el) => { this.el = el; }}
/>
);
Expand Down
42 changes: 42 additions & 0 deletions superset/assets/javascripts/components/RefreshChartOverlay.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import React from 'react';
import PropTypes from 'prop-types';
import Button from '../components/Button';
import { t } from '../locales';

const propTypes = {
height: PropTypes.number.isRequired,
width: PropTypes.number.isRequired,
onQuery: PropTypes.func,
onDismiss: PropTypes.func,
};

class RefreshChartOverlay extends React.PureComponent {
render() {
return (
<div
style={{ height: this.props.height, width: this.props.width }}
className="explore-chart-overlay"
>
<div>
<Button
className="refresh-overlay-btn"
onClick={this.props.onQuery}
bsStyle="primary"
>
{t('Run Query')}
</Button>
<Button
className="dismiss-overlay-btn"
onClick={this.props.onDismiss}
>
{t('Dismiss')}
</Button>
</div>
</div>
);
}
}

RefreshChartOverlay.propTypes = propTypes;

export default RefreshChartOverlay;
9 changes: 6 additions & 3 deletions superset/assets/javascripts/dashboard/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,16 @@ export function getInitialState(bootstrapData) {

dashboard.posDict = {};
dashboard.layout = [];
if (dashboard.position_json) {
if (Array.isArray(dashboard.position_json)) {
dashboard.position_json.forEach((position) => {
dashboard.posDict[position.slice_id] = position;
});
} else {
dashboard.position_json = [];
}
const lastRowId = Math.max.apply(null,
dashboard.position_json.map(pos => (pos.row + pos.size_y)));

const lastRowId = Math.max(0, Math.max.apply(null,
dashboard.position_json.map(pos => (pos.row + pos.size_y))));
let newSliceCounter = 0;
dashboard.slices.forEach((slice) => {
const sliceId = slice.slice_id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { Alert } from 'react-bootstrap';
import { Alert, Tab, Tabs } from 'react-bootstrap';
import visTypes, { sectionsToRender } from '../stores/visTypes';
import ControlPanelSection from './ControlPanelSection';
import ControlRow from './ControlRow';
Expand All @@ -26,6 +26,7 @@ class ControlPanelsContainer extends React.Component {
super(props);
this.removeAlert = this.removeAlert.bind(this);
this.getControlData = this.getControlData.bind(this);
this.renderControlPanelSection = this.renderControlPanelSection.bind(this);
}
getControlData(controlName) {
const control = this.props.controls[controlName];
Expand All @@ -49,8 +50,56 @@ class ControlPanelsContainer extends React.Component {
removeAlert() {
this.props.actions.removeControlPanelAlert();
}
render() {
renderControlPanelSection(section) {
const ctrls = this.props.controls;
const hasErrors = section.controlSetRows.some(rows => rows.some(s => (
ctrls[s] &&
ctrls[s].validationErrors &&
(ctrls[s].validationErrors.length > 0)
)));
return (
<ControlPanelSection
key={section.label}
label={section.label}
startExpanded={section.expanded}
hasErrors={hasErrors}
description={section.description}
>
{section.controlSetRows.map((controlSets, i) => (
<ControlRow
key={`controlsetrow-${i}`}
className="control-row"
controls={controlSets.map(controlName => (
controlName &&
ctrls[controlName] &&
<Control
name={controlName}
key={`control-${controlName}`}
value={this.props.form_data[controlName]}
validationErrors={ctrls[controlName].validationErrors}
actions={this.props.actions}
{...this.getControlData(controlName)}
/>
))}
/>
))}
</ControlPanelSection>
);
}
render() {
const allSectionsToRender = this.sectionsToRender();
const querySectionsToRender = [];
const displaySectionsToRender = [];
allSectionsToRender.forEach((section) => {
if (section.controlSetRows.some(rows => rows.some(
control => controls[control] && !controls[control].renderTrigger,
))) {
querySectionsToRender.push(section);
} else {
displaySectionsToRender.push(section);
}
});

return (
<div className="scrollbar-container">
<div className="scrollbar-content">
Expand All @@ -64,40 +113,16 @@ class ControlPanelsContainer extends React.Component {
/>
</Alert>
}
{this.sectionsToRender().map((section) => {
const hasErrors = section.controlSetRows.some(rows => rows.some(s => (
ctrls[s] &&
ctrls[s].validationErrors &&
(ctrls[s].validationErrors.length > 0)
)));
return (
<ControlPanelSection
key={section.label}
label={section.label}
startExpanded={section.expanded}
hasErrors={hasErrors}
description={section.description}
>
{section.controlSetRows.map((controlSets, i) => (
<ControlRow
key={`controlsetrow-${i}`}
className="control-row"
controls={controlSets.map(controlName => (
controlName &&
ctrls[controlName] &&
<Control
name={controlName}
key={`control-${controlName}`}
value={this.props.form_data[controlName]}
validationErrors={ctrls[controlName].validationErrors}
actions={this.props.actions}
{...this.getControlData(controlName)}
/>
))}
/>
))}
</ControlPanelSection>);
})}
<Tabs id="controlSections">
<Tab eventKey="query" title="Data">
{querySectionsToRender.map(this.renderControlPanelSection)}
</Tab>
{displaySectionsToRender.length > 0 &&
<Tab eventKey="display" title="Style">
{displaySectionsToRender.map(this.renderControlPanelSection)}
</Tab>
}
</Tabs>
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import ExploreChartHeader from './ExploreChartHeader';
const propTypes = {
actions: PropTypes.object.isRequired,
addHistory: PropTypes.func,
onQuery: PropTypes.func,
onDismissRefreshOverlay: PropTypes.func,
can_overwrite: PropTypes.bool.isRequired,
can_download: PropTypes.bool.isRequired,
datasource: PropTypes.object,
Expand All @@ -24,7 +26,9 @@ const propTypes = {
form_data: PropTypes.object,
standalone: PropTypes.bool,
timeout: PropTypes.number,
refreshOverlayVisible: PropTypes.bool,
chart: PropTypes.shape(chartPropType),
errorMessage: PropTypes.node,
};

class ExploreChartPanel extends React.PureComponent {
Expand All @@ -45,6 +49,10 @@ class ExploreChartPanel extends React.PureComponent {
setControlValue={this.props.actions.setControlValue}
timeout={this.props.timeout}
vizType={this.props.vizType}
refreshOverlayVisible={this.props.refreshOverlayVisible}
errorMessage={this.props.errorMessage}
onQuery={this.props.onQuery}
onDismissRefreshOverlay={this.props.onDismissRefreshOverlay}
/>
);
}
Expand Down
Loading

0 comments on commit d995649

Please sign in to comment.