mirror of
https://github.com/apache/superset.git
synced 2026-04-26 03:24:53 +00:00
feat: expand new chart data endpoint coverage (#9903)
* feat: implement new chart API for additional components * Fix python tests * Fix tests * Fix lint * fix camel case error in requestParams * lint * fix samples row limit * Add samples row limit to config * remove unnecessary code * lint * Address review comments
This commit is contained in:
@@ -41,7 +41,7 @@ import { SupersetClient } from '@superset-ui/connection';
|
||||
|
||||
import getClientErrorObject from '../../utils/getClientErrorObject';
|
||||
import CopyToClipboard from './../../components/CopyToClipboard';
|
||||
import { getExploreUrl } from '../exploreUtils';
|
||||
import { getChartDataRequest } from '../../chart/chartAction';
|
||||
|
||||
import Loading from '../../components/Loading';
|
||||
import ModalTrigger from './../../components/ModalTrigger';
|
||||
@@ -87,33 +87,29 @@ export class DisplayQueryButton extends React.PureComponent {
|
||||
this.openPropertiesModal = this.openPropertiesModal.bind(this);
|
||||
this.closePropertiesModal = this.closePropertiesModal.bind(this);
|
||||
}
|
||||
beforeOpen(endpointType) {
|
||||
beforeOpen(resultType) {
|
||||
this.setState({ isLoading: true });
|
||||
const url = getExploreUrl({
|
||||
formData: this.props.latestQueryFormData,
|
||||
endpointType,
|
||||
});
|
||||
SupersetClient.post({
|
||||
url,
|
||||
postPayload: { form_data: this.props.latestQueryFormData },
|
||||
})
|
||||
.then(({ json }) => {
|
||||
|
||||
getChartDataRequest(this.props.latestQueryFormData, 'json', resultType)
|
||||
.then(response => {
|
||||
// Currently displaying of only first query is supported
|
||||
const result = response.result[0];
|
||||
this.setState({
|
||||
language: json.language,
|
||||
query: json.query,
|
||||
data: json.data,
|
||||
language: result.language,
|
||||
query: result.query,
|
||||
data: result.data,
|
||||
isLoading: false,
|
||||
error: null,
|
||||
});
|
||||
})
|
||||
.catch(response =>
|
||||
.catch(response => {
|
||||
getClientErrorObject(response).then(({ error, statusText }) => {
|
||||
this.setState({
|
||||
error: error || statusText || t('Sorry, An error occurred'),
|
||||
isLoading: false,
|
||||
});
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
changeFilterText(event) {
|
||||
this.setState({ filterText: event.target.value });
|
||||
|
||||
@@ -48,7 +48,7 @@ export default function ExploreActionButtons({
|
||||
'disabled disabledButton': !canDownload,
|
||||
});
|
||||
const doExportCSV = exportChart.bind(this, latestQueryFormData, 'csv');
|
||||
const doExportChart = exportChart.bind(this, latestQueryFormData, 'json');
|
||||
const doExportChart = exportChart.bind(this, latestQueryFormData, 'results');
|
||||
|
||||
return (
|
||||
<div className="btn-group results" role="group">
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
*/
|
||||
/* eslint camelcase: 0 */
|
||||
import URI from 'urijs';
|
||||
import { getChartMetadataRegistry } from '@superset-ui/chart';
|
||||
import { availableDomains } from '../utils/hostNamesConfig';
|
||||
import { SupersetClient } from '@superset-ui/connection';
|
||||
import { allowCrossDomain, availableDomains } from '../utils/hostNamesConfig';
|
||||
import { safeStringify } from '../utils/safeStringify';
|
||||
|
||||
const MAX_URL_LENGTH = 8000;
|
||||
@@ -67,7 +67,9 @@ export function getAnnotationJsonUrl(slice_id, form_data, isNative) {
|
||||
export function getURIDirectory(endpointType = 'base') {
|
||||
// Building the directory part of the URI
|
||||
if (
|
||||
['json', 'csv', 'query', 'results', 'samples'].indexOf(endpointType) >= 0
|
||||
['full', 'json', 'csv', 'query', 'results', 'samples'].includes(
|
||||
endpointType,
|
||||
)
|
||||
) {
|
||||
return '/superset/explore_json/';
|
||||
}
|
||||
@@ -107,11 +109,6 @@ export function getExploreLongUrl(
|
||||
return url;
|
||||
}
|
||||
|
||||
export function shouldUseLegacyApi(formData) {
|
||||
const { useLegacyApi } = getChartMetadataRegistry().get(formData.viz_type);
|
||||
return useLegacyApi || false;
|
||||
}
|
||||
|
||||
export function getExploreUrl({
|
||||
formData,
|
||||
endpointType = 'base',
|
||||
|
||||
Reference in New Issue
Block a user