Skip to content
Snippets Groups Projects
Commit 73b0405e authored by zshan2's avatar zshan2
Browse files

small fixing

parent d8e2853e
No related branches found
No related tags found
No related merge requests found
...@@ -49,6 +49,36 @@ function App() { ...@@ -49,6 +49,36 @@ function App() {
const axios = require('axios').default; const axios = require('axios').default;
var center = {display: 'flex', justifyContent: 'center', alignItems: 'center'} var center = {display: 'flex', justifyContent: 'center', alignItems: 'center'}
/** Function used to hide the input form */
function hideForm() {
setFormState('hide')
}
/** Function used to show bookData input form */
function changeFormStateBook() {
setRenderState(false)
if (formState === 'hide') {
setFormState('showBook')
} else {
setFormState('hide')
}
}
/** Function used to show authorData input form */
function changeFormStateAuthor() {
setRenderState(false)
if (formState === 'hide') {
setFormState('showAuthor')
} else {
setFormState('hide')
}
}
/** Function used to set Dialog visible, which is called when a response is received */
function showDialog() {
setDialogState(true)
}
/** Function used in GET Requests */ /** Function used in GET Requests */
function get() { function get() {
axios.get('http://127.0.0.1:5000/api/' + queryStr) axios.get('http://127.0.0.1:5000/api/' + queryStr)
...@@ -58,9 +88,9 @@ function App() { ...@@ -58,9 +88,9 @@ function App() {
showDialog() showDialog()
document.getElementById('dialog').value = response.status + ":\n" + response.statusText document.getElementById('dialog').value = response.status + ":\n" + response.statusText
if (queryStr.includes('book')) { if (queryStr.includes('book')) {
setDataState(response.data['books'][0]) setDataState(response.data['books'])
} else { } else {
setDataState(response.data['authors'][0]) setDataState(response.data['authors'])
} }
setRenderState(true) setRenderState(true)
}) })
...@@ -108,36 +138,6 @@ function App() { ...@@ -108,36 +138,6 @@ function App() {
setDataState(authorData) setDataState(authorData)
return authorData return authorData
} }
/** Function used to hide the input form */
function hideForm() {
setFormState('hide')
}
/** Function used to show bookData input form */
function changeFormStateBook() {
setRenderState(false)
if (formState === 'hide') {
setFormState('showBook')
} else {
setFormState('hide')
}
}
/** Function used to show authorData input form */
function changeFormStateAuthor() {
setRenderState(false)
if (formState === 'hide') {
setFormState('showAuthor')
} else {
setFormState('hide')
}
}
/** Function used to set Dialog visible, which is called when a response is received */
function showDialog() {
setDialogState(true)
}
/** Function used in PUT requests */ /** Function used in PUT requests */
function put() { function put() {
......
...@@ -3,18 +3,35 @@ import MUIDataTable from "mui-datatables"; ...@@ -3,18 +3,35 @@ import MUIDataTable from "mui-datatables";
/** MUI dataTable component, used for rendering received response */ /** MUI dataTable component, used for rendering received response */
const ElementDisplay = (props) => { const ElementDisplay = (props) => {
var fields = Object.keys(props.data) var list = props.data
var values = Object.values(props.data) if (list.length <= 0) {
console.log(Object.values(props.data)) return (
console.log(Object.keys(props.data)) <MUIDataTable
title={"Data Table"}
data={[]}
columns={['Fields', 'Values']}
options={{}}
/>
)
}
var fields = Object.keys(list[0])
var values = []
for (var key in list){
if (list.hasOwnProperty(key)) {
values.push(Object.values(list[key]))
}
}
console.log(fields)
console.log(values)
console.log(list)
const columns = fields const columns = fields
const data = [values] const data = values
const options = { const options = {
'responsive':'vertical' 'responsive':'vertical'
} }
return ( return (
<MUIDataTable <MUIDataTable
title={"GET Data"} title={"Data Table"}
data={data} data={data}
columns={columns} columns={columns}
options={options} options={options}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment