You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by hu...@apache.org on 2021/07/23 11:43:17 UTC
[superset] 02/02: saving for now
This is an automated email from the ASF dual-hosted git repository.
hugh pushed a commit to branch hugh/update-put-query-context
in repository https://gitbox.apache.org/repos/asf/superset.git
commit c145800710b221cce9ab6f032e0af932e1b7bef1
Author: hughhhh <hu...@gmail.com>
AuthorDate: Thu Jul 22 14:15:25 2021 -0400
saving for now
---
.../explore/components/PropertiesModal/index.tsx | 25 +++++++++++++++++++++-
.../src/explore/exploreUtils/index.js | 2 ++
superset/charts/api.py | 5 ++++-
3 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/superset-frontend/src/explore/components/PropertiesModal/index.tsx b/superset-frontend/src/explore/components/PropertiesModal/index.tsx
index 0c46f6b..490e989 100644
--- a/superset-frontend/src/explore/components/PropertiesModal/index.tsx
+++ b/superset-frontend/src/explore/components/PropertiesModal/index.tsx
@@ -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;
@@ -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}`,
});
@@ -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);
diff --git a/superset-frontend/src/explore/exploreUtils/index.js b/superset-frontend/src/explore/exploreUtils/index.js
index ddcd95b..20fa4f2 100644
--- a/superset-frontend/src/explore/exploreUtils/index.js
+++ b/superset-frontend/src/explore/exploreUtils/index.js
@@ -303,6 +303,8 @@ export const exportChart = ({
ownState,
});
}
+
+ console.log('making POST for getting data');
postForm(url, payload);
};
diff --git a/superset/charts/api.py b/superset/charts/api.py
index 0d394cd..2f7f4c7 100644
--- a/superset/charts/api.py
+++ b/superset/charts/api.py
@@ -129,6 +129,7 @@ class ChartRestApi(BaseSupersetModelRestApi):
"params",
"slice_name",
"viz_type",
+ "query_context",
]
show_select_columns = show_columns + ["table.id"]
list_columns = [
@@ -337,6 +338,9 @@ class ChartRestApi(BaseSupersetModelRestApi):
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")
@@ -345,7 +349,6 @@ class ChartRestApi(BaseSupersetModelRestApi):
# 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)