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 2020/11/25 02:07:46 UTC
[incubator-superset] 02/03: update network calls to pull data from
dataset
This is an automated email from the ASF dual-hosted git repository.
hugh pushed a commit to branch so-1119
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
commit 3b7dd043f4ace793452f4e6436dd1518abd91d16
Author: hughhhh <hu...@gmail.com>
AuthorDate: Tue Nov 24 18:02:44 2020 -0800
update network calls to pull data from dataset
---
.../src/datasource/ChangeDatasourceModal.tsx | 82 +++++++---------------
1 file changed, 25 insertions(+), 57 deletions(-)
diff --git a/superset-frontend/src/datasource/ChangeDatasourceModal.tsx b/superset-frontend/src/datasource/ChangeDatasourceModal.tsx
index 2c7a032..55b8598 100644
--- a/superset-frontend/src/datasource/ChangeDatasourceModal.tsx
+++ b/superset-frontend/src/datasource/ChangeDatasourceModal.tsx
@@ -69,7 +69,7 @@ const ChangeDatasourceModal: FunctionComponent<ChangeDatasourceModalProps> = ({
const selectDatasource = (datasource: any) => {
console.log(datasource)
SupersetClient.get({
- endpoint: `/datasource/get/${datasource.type}/${datasource.id}`,
+ endpoint: `/datasource/get/table/${datasource.id}`,
})
.then(({ json }) => {
console.log(json)
@@ -94,64 +94,32 @@ const ChangeDatasourceModal: FunctionComponent<ChangeDatasourceModalProps> = ({
searchRef.current.focus();
}
if (!datasources) {
-
- // SupersetClient.get({
- // endpoint: '/api/v1/dataset/',
- // }).then(({ json }) => {
- // console.log(json);
- // const data = json.result.map((ds: any) => ({
- // rawName: ds.table_name,
- // connection: ds.database.database_name,
- // schema: ds.schema,
- // name: (
- // <a
- // href="#"
- // onClick={() => selectDatasource(ds)}
- // className="datasource-link"
- // >
- // {ds.table_name}
- // </a>
- // ),
- // type: ds.kind,
- // }));
- // setLoading(false);
- // setDatasources(data);
- // }).catch(response => {
- // setLoading(false);
- // getClientErrorObject(response).then(({ error }: any) => {
- // addDangerToast(error.error || error.statusText || error);
- // });
- // });
-
SupersetClient.get({
- endpoint: '/superset/datasources/',
- })
- .then(({ json }) => {
- const data = json.map((ds: any) => ({
- rawName: ds.name,
- connection: ds.connection,
- schema: ds.schema,
- name: (
- <a
- href="#"
- onClick={() => selectDatasource(ds)}
- className="datasource-link"
- >
- {ds.name}
- </a>
- ),
- type: ds.type,
- }));
- setLoading(false);
- setDatasources(data);
- })
- .catch(response => {
- setLoading(false);
- getClientErrorObject(response).then(({ error }: any) => {
- addDangerToast(error.error || error.statusText || error);
- });
+ endpoint: '/api/v1/dataset/',
+ }).then(({ json }) => {
+ const data = json.result.map((ds: any) => ({
+ rawName: ds.table_name,
+ connection: ds.database.database_name,
+ schema: ds.schema,
+ name: (
+ <a
+ href="#"
+ onClick={() => selectDatasource(ds)}
+ className="datasource-link"
+ >
+ {ds.table_name}
+ </a>
+ ),
+ type: ds.kind,
+ }));
+ setLoading(false);
+ setDatasources(data);
+ }).catch(response => {
+ setLoading(false);
+ getClientErrorObject(response).then(({ error }: any) => {
+ addDangerToast(error.error || error.statusText || error);
});
- }
+ });
};
if (show) {