diff --git a/src/views/builder/BuilderView/ColorCoded/ExtensionDomain.js b/src/views/builder/BuilderView/ColorCoded/ExtensionDomain.js index f2c109e2..07e08fd9 100644 --- a/src/views/builder/BuilderView/ColorCoded/ExtensionDomain.js +++ b/src/views/builder/BuilderView/ColorCoded/ExtensionDomain.js @@ -1,113 +1,153 @@ // src/views/builder/BuilderView/ColorCoded/ExtensionDomain.js -import React, { useState } from 'react'; -import { - Card, - CardActionArea, - CardContent, - TextField, - Typography, -} from '@material-ui/core'; +import React from 'react'; +import { withStyles, Typography } from '@material-ui/core'; +import Table from '@material-ui/core/Table'; +import TableBody from '@material-ui/core/TableBody'; +import TableCell from '@material-ui/core/TableCell'; +import TableHead from '@material-ui/core/TableHead'; +import TableRow from '@material-ui/core/TableRow'; import HelpIcon from '@material-ui/icons/Help'; import Button from '@material-ui/core/Button'; -import PropTypes from 'prop-types'; -import Extension from 'src/components/Extension'; +import TextField from '@material-ui/core/TextField'; +import Card from '@material-ui/core/Card'; +import Linker from './components/Linker'; + +// Cell styling +const StyledCell = withStyles({ + root: { + color: 'black' + }, + bordered: { + border: '1px solid black' + } +})(TableCell); // Pass an object and whether its keys are properties. export default function ExtensionDomain({ items }) { - const [newSchema, setNewSchema] = useState(); + const classes = withStyles(); + + const setInput = (value, i) => { + const holder = items.exd; + holder[i] = JSON.parse(value); + items.setExd(holder); + console.log('working?', items.exd[i]); + }; const addRows = () => { - fetch(newSchema) - .then((response) => response.json()) - .then((jsonData) => { - console.log(jsonData); - if (!items.exd) { - const holder = []; - holder.push({ - extension_schema: newSchema - }); - items.setExd(holder); - } else { - const holder = items.exd; - holder.push({ - extension_schema: newSchema - }); - items.setExd(holder); - } - }) - .catch((error) => { - console.log(`ERROR: ${error}`); - alert(`Fetch schema from '${newSchema}' FAILED: ${error}`); + console.log('add Rows', items); + if (!items.exd) { + const holder = []; + holder.push({ + extension_schema: '' }); - setNewSchema(''); + items.setExd(holder); + } else { + const holder = items.exd; + holder.push({ + extension_schema: '' + }) + items.setExd(holder); + } + items.setRerender(items.rerender + 1); }; - const removeRows = (index) => { - items.setExd(items.exd.filter(((o, i) => index !== i))); + const removeRows = (which) => { + const holder = items.exd; + holder.splice(which, 1); + items.setExd(holder); + items.setRerender(items.rerender + 1); }; - - const link = 'https://docs.biocomputeobject.org/extension-domain/'; + // useEffect(() => { + // if (!items.exd) { + // console.log('No Extension'); + // } else { + // for (let extensionIndex = 0; extensionIndex < items.exd.length; extensionIndex++) { + // const schemaURL = items.exd[extensionIndex].extension_schema; + // console.log('Extension schema', schema); + // fetch(schemaURL) + // .then((response) => response.json()) + // .then((jsonData) => { + // schemaList.push(jsonData); + // console.log(jsonData); + // }) + // .catch((error) => { + // // handle your errors here + // console.error(error); + // }); + // } + // setSchema(schemaList); + // } + // }, [items.exd]); return ( - - window.open(link)}> - - - Extension Domain   - - - - - - - - Top add an extension enter a valid URL for the extension schema - below and hit the 'ADD EXTENSION' button. - - setNewSchema(e.target.value)} - value={newSchema} - /> - - - - { (!items.exd) - ? ( - - ) - : (items.exd.map((item, index) => { - return ( - - - - - ); - }) - )} - + + + + + + + + + + {(!items.exd) + ? ({console.log('no items.exd')}) + : ( + items.exd.map((item, index) => { + return ( + + + + + Extension Schema + + + + + + + + + setInput(e.target.value, index)} + variant="outlined" + /> + + + + + + + ); + }) + )} + + + + + + + +
); -} - -ExtensionDomain.propTypes = { - items: PropTypes.object.isRequired, -}; +} \ No newline at end of file diff --git a/src/views/builder/BuilderView/ColorCoded/ExtensionDomain_beta.js b/src/views/builder/BuilderView/ColorCoded/ExtensionDomain_beta.js new file mode 100644 index 00000000..f2c109e2 --- /dev/null +++ b/src/views/builder/BuilderView/ColorCoded/ExtensionDomain_beta.js @@ -0,0 +1,113 @@ +// src/views/builder/BuilderView/ColorCoded/ExtensionDomain.js +import React, { useState } from 'react'; +import { + Card, + CardActionArea, + CardContent, + TextField, + Typography, +} from '@material-ui/core'; +import HelpIcon from '@material-ui/icons/Help'; +import Button from '@material-ui/core/Button'; +import PropTypes from 'prop-types'; +import Extension from 'src/components/Extension'; + +// Pass an object and whether its keys are properties. +export default function ExtensionDomain({ items }) { + const [newSchema, setNewSchema] = useState(); + + const addRows = () => { + fetch(newSchema) + .then((response) => response.json()) + .then((jsonData) => { + console.log(jsonData); + if (!items.exd) { + const holder = []; + holder.push({ + extension_schema: newSchema + }); + items.setExd(holder); + } else { + const holder = items.exd; + holder.push({ + extension_schema: newSchema + }); + items.setExd(holder); + } + }) + .catch((error) => { + console.log(`ERROR: ${error}`); + alert(`Fetch schema from '${newSchema}' FAILED: ${error}`); + }); + setNewSchema(''); + }; + + const removeRows = (index) => { + items.setExd(items.exd.filter(((o, i) => index !== i))); + }; + + const link = 'https://docs.biocomputeobject.org/extension-domain/'; + + return ( + + window.open(link)}> + + + Extension Domain   + + + + + + + + Top add an extension enter a valid URL for the extension schema + below and hit the 'ADD EXTENSION' button. + + setNewSchema(e.target.value)} + value={newSchema} + /> + + + + { (!items.exd) + ? ( + + ) + : (items.exd.map((item, index) => { + return ( + + + + + ); + }) + )} + + ); +} + +ExtensionDomain.propTypes = { + items: PropTypes.object.isRequired, +};