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/16 18:49:09 UTC

[incubator-superset] branch hugh/SO-1117-modal updated (3170382 -> 74348a1)

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

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


    from 3170382  fix onclick reference
     new 268052c  working create datasource boiler
     new 74348a1  saving spot for callback on text input

The 2 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.


Summary of changes:
 .../src/SqlLab/components/ResultSet.tsx            | 36 +++++++++++++++++++++-
 .../src/SqlLab/components/SaveDatasetModal.tsx     |  4 +--
 2 files changed, 37 insertions(+), 3 deletions(-)


[incubator-superset] 02/02: saving spot for callback on text input

Posted by hu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hugh pushed a commit to branch hugh/SO-1117-modal
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git

commit 74348a1d707da48ce299f23c41a9eaef8958a87c
Author: hughhhh <hu...@gmail.com>
AuthorDate: Mon Nov 16 10:48:19 2020 -0800

    saving spot for callback on text input
---
 superset-frontend/src/SqlLab/components/ResultSet.tsx        | 10 +++++++---
 superset-frontend/src/SqlLab/components/SaveDatasetModal.tsx |  4 ++--
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/superset-frontend/src/SqlLab/components/ResultSet.tsx b/superset-frontend/src/SqlLab/components/ResultSet.tsx
index caed1d9..c8cf1f2 100644
--- a/superset-frontend/src/SqlLab/components/ResultSet.tsx
+++ b/superset-frontend/src/SqlLab/components/ResultSet.tsx
@@ -88,7 +88,8 @@ export default class ResultSet extends React.PureComponent<
       searchText: '',
       showExploreResultsButton: false,
       data: [],
-      showSaveDatasetModal: false
+      showSaveDatasetModal: false,
+      newSaveDatasetName: '',
     };
 
     this.changeSearch = this.changeSearch.bind(this);
@@ -203,6 +204,10 @@ export default class ResultSet extends React.PureComponent<
       });
   }
 
+  handleDatasetNameChange(e) {
+    console.log(e.target.value)
+  }
+
   handleHideSaveModal() {
     console.log('hiding the modal');
     this.setState({showSaveDatasetModal: false})
@@ -222,8 +227,7 @@ export default class ResultSet extends React.PureComponent<
             visible={showSaveDatasetModal}
             onOk={this.handleSaveInDataset}
             onCancel={this.handleHideSaveModal}
-            query={this.props.query}
-            createDatasource={this.props.actions.createDatasource}
+            handleDatasetNameChange={this.handleDatasetNameChange}
           />
           <div className="ResultSetButtons">
             {this.props.visualize &&
diff --git a/superset-frontend/src/SqlLab/components/SaveDatasetModal.tsx b/superset-frontend/src/SqlLab/components/SaveDatasetModal.tsx
index e052e25..c0dccc6 100644
--- a/superset-frontend/src/SqlLab/components/SaveDatasetModal.tsx
+++ b/superset-frontend/src/SqlLab/components/SaveDatasetModal.tsx
@@ -32,7 +32,7 @@ interface SaveDatasetModalProps = {
 }
 
 // eslint-disable-next-line no-empty-pattern
-export const SaveDatasetModal: FunctionComponent<> = ({visible, onOk, onCancel}) => {
+export const SaveDatasetModal: FunctionComponent<> = ({visible, onOk, onCancel, handleDatasetNameChange}) => {
   const [value, setValue] = useState('');
   const [options, setOptions] = useState([]);
   const [radioOption, setRadioOptions] = useState(1);
@@ -87,7 +87,7 @@ export const SaveDatasetModal: FunctionComponent<> = ({visible, onOk, onCancel})
         <Radio.Group onChange={onRadioChange} value={radioOption}>
           <Radio style={radioStyle} value={1}>
             Save as new dataset
-            <Input style={{ width: 200 }} defaultValue="my_new_dataset_A" />
+            <Input style={{ width: 200 }} defaultValue="my_new_dataset_A" onChange={handleDatasetNameChange} />
           </Radio>
           <Radio style={radioStyle} value={2}>
             Overwrite existing dataset


[incubator-superset] 01/02: working create datasource boiler

Posted by hu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hugh pushed a commit to branch hugh/SO-1117-modal
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git

commit 268052cddfdfe063bde8b436baf3161b299f3c43
Author: hughhhh <hu...@gmail.com>
AuthorDate: Mon Nov 16 10:20:33 2020 -0800

    working create datasource boiler
---
 .../src/SqlLab/components/ResultSet.tsx            | 30 ++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/superset-frontend/src/SqlLab/components/ResultSet.tsx b/superset-frontend/src/SqlLab/components/ResultSet.tsx
index c613a0f..caed1d9 100644
--- a/superset-frontend/src/SqlLab/components/ResultSet.tsx
+++ b/superset-frontend/src/SqlLab/components/ResultSet.tsx
@@ -173,6 +173,34 @@ export default class ResultSet extends React.PureComponent<
 
   handleSaveInDataset() {
     console.log('Saving dataset');
+    console.log(this.props.query);
+    console.log(this.props.actions.createDatasource);
+    const { schema, sql, dbId, templateParams } = this.props.query;
+
+    let selectedColumns;
+    if (
+      this.props.query &&
+      this.props.query.results &&
+      this.props.query.results.selected_columns
+    ) {
+      selectedColumns = this.props.query.results.selected_columns;
+    } else {
+      selectedColumns = []
+    }
+
+    this.props.actions.createDatasource({
+        schema,
+        sql,
+        dbId,
+        templateParams,
+        datasourceName: 'hmiles.test_dataset_2',
+        columns: selectedColumns,
+      }).then(data => {
+          console.log(data);
+      }).catch(error => {
+          console.log('an error occurred trying to create a datasource');
+          console.log(error);
+      });
   }
 
   handleHideSaveModal() {
@@ -194,6 +222,8 @@ export default class ResultSet extends React.PureComponent<
             visible={showSaveDatasetModal}
             onOk={this.handleSaveInDataset}
             onCancel={this.handleHideSaveModal}
+            query={this.props.query}
+            createDatasource={this.props.actions.createDatasource}
           />
           <div className="ResultSetButtons">
             {this.props.visualize &&