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/20 03:53:29 UTC

[incubator-superset] branch so-1119 created (now 07a3f03)

This is an automated email from the ASF dual-hosted git repository.

hugh pushed a change to branch so-1119
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git.


      at 07a3f03  update tableview with dataset endpoint

This branch includes the following new commits:

     new 07a3f03  update tableview with dataset endpoint

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[incubator-superset] 01/01: update tableview with dataset endpoint

Posted by hu...@apache.org.
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 07a3f03f29bbd4f643f1ff2de47521746e91375a
Author: hughhhh <hu...@gmail.com>
AuthorDate: Thu Nov 19 19:52:36 2020 -0800

    update tableview with dataset endpoint
---
 .../src/datasource/ChangeDatasourceModal.tsx       | 83 +++++++++++++++-------
 1 file changed, 56 insertions(+), 27 deletions(-)

diff --git a/superset-frontend/src/datasource/ChangeDatasourceModal.tsx b/superset-frontend/src/datasource/ChangeDatasourceModal.tsx
index 4f1597b..70486be 100644
--- a/superset-frontend/src/datasource/ChangeDatasourceModal.tsx
+++ b/superset-frontend/src/datasource/ChangeDatasourceModal.tsx
@@ -68,7 +68,7 @@ const ChangeDatasourceModal: FunctionComponent<ChangeDatasourceModalProps> = ({
   useEffect(() => {
     const selectDatasource = (datasource: any) => {
       SupersetClient.get({
-        endpoint: `/datasource/get/${datasource.type}/${datasource.id}`,
+        endpoint: `/datasource/get/${datasource.kind}/${datasource.id}`,
       })
         .then(({ json }) => {
           onDatasourceSave(json);
@@ -92,34 +92,63 @@ const ChangeDatasourceModal: FunctionComponent<ChangeDatasourceModalProps> = ({
         searchRef.current.focus();
       }
       if (!datasources) {
+
         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 }) => {
+          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);
+        //     });
+        //   });
       }
     };