Skip to content
This repository has been archived by the owner on Mar 31, 2021. It is now read-only.

Commit

Permalink
Remove JSON formatter for csv and txt responses from the sql plugin; …
Browse files Browse the repository at this point in the history
…added asynchronous method for download functionality (#50)
  • Loading branch information
chloe-zh authored May 2, 2020
1 parent 249df1c commit 315b8f5
Show file tree
Hide file tree
Showing 4 changed files with 258 additions and 32 deletions.
28 changes: 18 additions & 10 deletions public/components/QueryResults/QueryResultsBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,34 +175,42 @@ class QueryResultsBody extends React.Component<QueryResultsBodyProps, QueryResul
if (!this.props.queryResultsJSON) {
this.props.getJson(this.props.queries);
}
const jsonObject = JSON.parse(this.props.queryResultsJSON);
const data = JSON.stringify(jsonObject, undefined, 4);
onDownloadFile(data, "json", this.props.selectedTabName + ".json");
setTimeout(() => {
const jsonObject = JSON.parse(this.props.queryResultsJSON);
const data = JSON.stringify(jsonObject, undefined, 4);
onDownloadFile(data, "json", this.props.selectedTabName + ".json");
}, 2000);
};

onDownloadJDBC = (): void => {
if (!this.props.queryResultsJDBC) {
this.props.getJdbc(this.props.queries);
}
const jsonObject = JSON.parse(this.props.queryResultsJDBC);
const data = JSON.stringify(jsonObject, undefined, 4);
onDownloadFile(data, "json", this.props.selectedTabName + ".json");
setTimeout(() => {
const jsonObject = JSON.parse(this.props.queryResultsJDBC);
const data = JSON.stringify(jsonObject, undefined, 4);
onDownloadFile(data, "json", this.props.selectedTabName + ".json");
}, 2000);
};

onDownloadCSV = (): void => {
if (!this.props.queryResultsCSV) {
this.props.getCsv(this.props.queries);
}
const data = this.props.queryResultsCSV;
onDownloadFile(data, "csv", this.props.selectedTabName + ".csv");
setTimeout(() => {
const data = this.props.queryResultsCSV;
onDownloadFile(data, "csv", this.props.selectedTabName + ".csv");
}, 2000);
};

onDownloadText = (): void => {
if (!this.props.queryResultsTEXT) {
this.props.getText(this.props.queries);
}
const data = this.props.queryResultsTEXT;
onDownloadFile(data, "plain", this.props.selectedTabName + ".txt");
setTimeout(() => {
const data = this.props.queryResultsTEXT;
onDownloadFile(data, "plain", this.props.selectedTabName + ".txt");
}, 2000);
};

// Actions for Downloads Button
Expand Down
Loading

0 comments on commit 315b8f5

Please sign in to comment.