Skip to content

Commit

Permalink
saving for now
Browse files Browse the repository at this point in the history
  • Loading branch information
hughhhh committed Jul 22, 2021
1 parent 6ddfd66 commit c145800
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ import Button from 'src/components/Button';
import { OptionsType } from 'react-select/src/types';
import { AsyncSelect } from 'src/components/Select';
import rison from 'rison';
import { t, SupersetClient } from '@superset-ui/core';
import { t, SupersetClient, QueryFormData } from '@superset-ui/core';
import Chart, { Slice } from 'src/types/Chart';
import { Form, FormItem } from 'src/components/Form';
import { getClientErrorObject } from 'src/utils/getClientErrorObject';
import { buildV1ChartDataPayload } from '../../exploreUtils';

type PropertiesModalProps = {
slice: Slice;
Expand Down Expand Up @@ -70,7 +71,9 @@ export default function PropertiesModal({

const fetchChartData = useCallback(
async function fetchChartData() {
console.log(slice);
try {
console.log('fetching chart data!');
const response = await SupersetClient.get({
endpoint: `/api/v1/chart/${slice.slice_id}`,
});
Expand All @@ -81,6 +84,26 @@ export default function PropertiesModal({
label: `${owner.first_name} ${owner.last_name}`,
})),
);

if (chart.query_context === null) {
// Build query context
const queryContext = buildV1ChartDataPayload({
formData: slice.form_data as QueryFormData,
force: false,
resultFormat: 'json',
resultType: 'full',
});

console.log('queryContext', queryContext);

// Todo: Make PUT to update query context
// const response = await makeApi({
// method: 'PUT',
// endpoint: `/api/v1/chart/${}`,
// })(`q=${queryParams}`);
}

// set query_context if null
} catch (response) {
const clientError = await getClientErrorObject(response);
showError(clientError);
Expand Down
2 changes: 2 additions & 0 deletions superset-frontend/src/explore/exploreUtils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ export const exportChart = ({
ownState,
});
}

console.log('making POST for getting data');
postForm(url, payload);
};

Expand Down
5 changes: 4 additions & 1 deletion superset/charts/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def ensure_thumbnails_enabled(self) -> Optional[Response]:
"params",
"slice_name",
"viz_type",
"query_context",
]
show_select_columns = show_columns + ["table.id"]
list_columns = [
Expand Down Expand Up @@ -337,6 +338,9 @@ def put(self, pk: int) -> Response:
500:
$ref: '#/components/responses/500'
"""
logger.info("*" * 20)
logger.info("hit put endpoint!!")
logger.info("*" * 20)

if not request.is_json:
return self.response_400(message="Request is not JSON")
Expand All @@ -345,7 +349,6 @@ def put(self, pk: int) -> Response:
# This validates custom Schema with custom validations
except ValidationError as error:
return self.response_400(message=error.messages)

try:
changed_model = UpdateChartCommand(g.user, pk, item).run()
response = self.response(200, id=changed_model.id, result=item)
Expand Down

0 comments on commit c145800

Please sign in to comment.