From f3c6dd4ccdfad967686fa8f28de9c16015994606 Mon Sep 17 00:00:00 2001 From: srivastava9 Date: Thu, 26 Mar 2020 16:06:13 +0530 Subject: [PATCH 1/3] made ui for export to python button --- .../a/components/assets/BodyWidget.styles.js | 11 +++++- .../scenes/a/components/assets/BodyWidget.tsx | 6 +-- .../scenes/a/components/assets/Log.tsx | 38 ++++++++++++------- 3 files changed, 36 insertions(+), 19 deletions(-) diff --git a/tensormap-client/src/pages/dashboard/scenes/a/components/assets/BodyWidget.styles.js b/tensormap-client/src/pages/dashboard/scenes/a/components/assets/BodyWidget.styles.js index b3e86b5a..84bba70c 100644 --- a/tensormap-client/src/pages/dashboard/scenes/a/components/assets/BodyWidget.styles.js +++ b/tensormap-client/src/pages/dashboard/scenes/a/components/assets/BodyWidget.styles.js @@ -10,7 +10,7 @@ const styles = theme => ({ }, select: { display: "flex", - alignItems: "center", + alignItems: "center" }, red: { color: theme.palette.getContrastText(red[500]), @@ -35,7 +35,14 @@ const styles = theme => ({ button: { margin: theme.spacing(1) }, - + exportButton: { + height: "40px", + margin: theme.spacing(2) + }, + divStyle: { + display: "flex", + justifyContent: "space-between" + } }); export default styles; diff --git a/tensormap-client/src/pages/dashboard/scenes/a/components/assets/BodyWidget.tsx b/tensormap-client/src/pages/dashboard/scenes/a/components/assets/BodyWidget.tsx index 3313602f..46f4c3ff 100644 --- a/tensormap-client/src/pages/dashboard/scenes/a/components/assets/BodyWidget.tsx +++ b/tensormap-client/src/pages/dashboard/scenes/a/components/assets/BodyWidget.tsx @@ -23,8 +23,8 @@ import MenuItem from '@material-ui/core/MenuItem'; import Select from '@material-ui/core/Select'; import Avatar from '@material-ui/core/Avatar'; import {withStyles} from '@material-ui/core'; -import styles from './BodyWidget.styles' - +import styles from './BodyWidget.styles'; +//import FileSaver from 'file-saver'; import { baseURL } from '../../../../../../config'; import socketIOClient from "socket.io-client"; @@ -568,7 +568,7 @@ class BodyWidget extends React.Component { - + diff --git a/tensormap-client/src/pages/dashboard/scenes/a/components/assets/Log.tsx b/tensormap-client/src/pages/dashboard/scenes/a/components/assets/Log.tsx index 31dd1480..deec6721 100644 --- a/tensormap-client/src/pages/dashboard/scenes/a/components/assets/Log.tsx +++ b/tensormap-client/src/pages/dashboard/scenes/a/components/assets/Log.tsx @@ -1,17 +1,21 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import AppBar from '@material-ui/core/AppBar'; -import Tabs from '@material-ui/core/Tabs'; -import Tab from '@material-ui/core/Tab'; -import Typography from '@material-ui/core/Typography'; +import React from "react"; +import PropTypes from "prop-types"; +import AppBar from "@material-ui/core/AppBar"; +import Tabs from "@material-ui/core/Tabs"; +import Tab from "@material-ui/core/Tab"; +import Typography from "@material-ui/core/Typography"; +import { Button } from "@material-ui/core"; +import GetAppIcon from "@material-ui/icons/GetApp"; interface TabContainerProps { children?: React.ReactNode; } interface SimpleTabsProps { - code:string; - runtimeData:string; + exportStyle?: string | undefined; + divStyle?: string | undefined; + code: string; + runtimeData: string; } function TabContainer(props: TabContainerProps) { @@ -23,7 +27,7 @@ function TabContainer(props: TabContainerProps) { } TabContainer.propTypes = { - children: PropTypes.node.isRequired, + children: PropTypes.node.isRequired }; export default function SimpleTabs(props: SimpleTabsProps) { @@ -33,7 +37,7 @@ export default function SimpleTabs(props: SimpleTabsProps) { setValue(newValue); } - let newText = props.code.split('\n').map((item, i) => { + let newText = props.code.split("\n").map((item, i) => { return

{item}

; }); @@ -41,14 +45,20 @@ export default function SimpleTabs(props: SimpleTabsProps) {
- + {value === 0 && {props.runtimeData}} - {value === 1 && {newText} - } + {value === 1 && ( +
+ {newText} + +
+ )}
); @@ -56,5 +66,5 @@ export default function SimpleTabs(props: SimpleTabsProps) { SimpleTabs.propTypes = { code: PropTypes.string.isRequired, - runtimeData: PropTypes.string.isRequired, + runtimeData: PropTypes.string.isRequired }; From c72647b999c34c150ddf010874c538720b0bb112 Mon Sep 17 00:00:00 2001 From: srivastava9 Date: Thu, 26 Mar 2020 16:13:59 +0530 Subject: [PATCH 2/3] made functionality for exporting code to python using file-saver library --- tensormap-client/package.json | 3 +++ .../dashboard/scenes/a/components/assets/Log.tsx | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/tensormap-client/package.json b/tensormap-client/package.json index 87acd2c5..08843686 100644 --- a/tensormap-client/package.json +++ b/tensormap-client/package.json @@ -47,5 +47,8 @@ "last 1 firefox version", "last 1 safari version" ] + }, + "devDependencies": { + "@types/file-saver": "^2.0.1" } } diff --git a/tensormap-client/src/pages/dashboard/scenes/a/components/assets/Log.tsx b/tensormap-client/src/pages/dashboard/scenes/a/components/assets/Log.tsx index deec6721..6d62f226 100644 --- a/tensormap-client/src/pages/dashboard/scenes/a/components/assets/Log.tsx +++ b/tensormap-client/src/pages/dashboard/scenes/a/components/assets/Log.tsx @@ -5,7 +5,7 @@ import Tabs from "@material-ui/core/Tabs"; import Tab from "@material-ui/core/Tab"; import Typography from "@material-ui/core/Typography"; import { Button } from "@material-ui/core"; - +import Filesaver from "file-saver"; import GetAppIcon from "@material-ui/icons/GetApp"; interface TabContainerProps { children?: React.ReactNode; @@ -40,6 +40,10 @@ export default function SimpleTabs(props: SimpleTabsProps) { let newText = props.code.split("\n").map((item, i) => { return

{item}

; }); + function exportPython() { + var blob = new Blob([props.code], { type: "text/x-python;charset=utf-8" }); + Filesaver.saveAs(blob, "hello-world.py"); + } return (
@@ -54,7 +58,11 @@ export default function SimpleTabs(props: SimpleTabsProps) { {value === 1 && (
{newText} -
From 46729729c6719d97ac453a36324eb25ba52c0d7b Mon Sep 17 00:00:00 2001 From: srivastava9 Date: Fri, 27 Mar 2020 00:32:44 +0530 Subject: [PATCH 3/3] solved a warning and pr merge issue --- .../dashboard/scenes/a/components/assets/BodyWidget.styles.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensormap-client/src/pages/dashboard/scenes/a/components/assets/BodyWidget.styles.js b/tensormap-client/src/pages/dashboard/scenes/a/components/assets/BodyWidget.styles.js index 84bba70c..567dc8cf 100644 --- a/tensormap-client/src/pages/dashboard/scenes/a/components/assets/BodyWidget.styles.js +++ b/tensormap-client/src/pages/dashboard/scenes/a/components/assets/BodyWidget.styles.js @@ -1,6 +1,6 @@ import { Theme } from "@material-ui/core/styles"; import { red, grey, green, blue } from "@material-ui/core/colors"; -import { flexbox } from "@material-ui/system"; +//import { flexbox } from "@material-ui/system"; const styles = theme => ({ root: { display: "flex",