diff --git a/public/spinner.gif b/public/spinner.gif
new file mode 100644
index 0000000..316fc4b
Binary files /dev/null and b/public/spinner.gif differ
diff --git a/src/App.js b/src/App.js
index 707f5e6..3bd122e 100644
--- a/src/App.js
+++ b/src/App.js
@@ -370,48 +370,17 @@ function PopupWindow(p) {
}
-
-function EditBackendBox(p) {
- useEffect(()=>{
- var timer1 = setTimeout(()=>{document.getElementById("editBox").focus()},100)
- return () => {
- clearTimeout(timer1);
- };
- })
- return {
- if (e.key==="Enter") {p.setEdit(false);p.setUpdate(true)}
- else if (e.key==="Escape") {p.setEdit(false)}
- }} maxLength={p.maxlength?p.maxlength:20} onBlur={()=>{p.setEdit(false);p.setUpdate(true)}} value={p.value} onChange={(f)=>{f.currentTarget.value.length>0?p.setName(f.currentTarget.value):p.setName(p.originalName)}}>
-
-}
-
-function EditableBackendBox(p) {
- const [update,setUpdate] = useState(false)
- const [edit,setEdit] = useState(false)
- const [value,setValue] = useState(p.children)
- const [originalValue,setOriginalValue] = useState(p.children)
-
- useEffect(()=>{
- if (p.callback&&update) {
- p.callback(value)
- .then(()=>{
- setUpdate(false)
- setOriginalValue(value)
- })
- .catch(()=>{
- setUpdate(false)
- setValue(originalValue)
- })
- }
- },[update,originalValue,p,value])
-
- return <>
-
{setEdit(true)}}>
- {edit?
-
- :<>{value}>}
-
- >
+function InputBox(p) {
+ const [value,setValue] = useState(p.value)
+ const [failed,setFailed] = useState(false)
+ const [sending,setSending] = useState(false)
+ return {setValue(f.currentTarget.value)}} onBlur={(f)=>{
+ setSending(true)
+ setFailed(false)
+ p.callback(f.currentTarget.value)
+ .then(()=>{setFailed(false)})
+ .catch(()=>{setFailed(true)})
+ .then(()=>{setSending(false)})}} value={value}/>
}
function TableEditor(p) {
@@ -431,6 +400,7 @@ function TableEditor(p) {
const [update,setUpdate] = useState(false)
const [submitVals,setSubmitVal] = useReducer(updateVals,initialVals)
const [report,setReport] = useState("")
+ const [loading,setLoading] = useState(false)
function SubmitBoxes() {
axios.post(BACKEND_URL+p.path,submitVals)
@@ -448,43 +418,49 @@ function TableEditor(p) {
useEffect(()=>{
if (update) {
+ setLoading(true)
axios.get(BACKEND_URL+p.path)
.then((data)=>{
var cols = data.data.fields
var rows = data.data.rows
- setFields(cols.filter((col)=>col.name!=="id").map((col)=>col.name))
+ setFields(cols.filter((col)=>col.name!=="id"))
setData(rows)
})
.catch((err)=>{
setReport(JSON.stringify(err))
})
+ .then(()=>{
+ setLoading(false)
+ })
setUpdate(false)
}
},[update,p.path])
return <>
+ {!loading?
- {JSON.stringify(report)}
+ {JSON.stringify(fields)}
|
- {fields.map((field,i)=>{field} | )}
+ {fields.map((field,i)=>{field.name} | )}
{data.map((dat)=>
- {axios.delete(BACKEND_URL+p.path,{data:{id:dat.id}}).then(()=>{setUpdate(true)}).catch((err)=>{alert(err.response.data)})}}/> | {fields.map((col,i)=>{
+ {axios.delete(BACKEND_URL+p.path,{data:{id:dat.id}}).then(()=>{setUpdate(true)}).catch((err)=>{alert(err.response.data)})}}/> | {fields.map((col,i)=>
+ {
return axios.patch(BACKEND_URL+p.path,{
- [col]:value,
+ [col.name]:value,
id:dat.id
})
- }}>{String(dat[col])} | )} |
)}
- { | {fields.map((col,i)=>{{setSubmitVal({field:col,value:f.currentTarget.value});SubmitBoxes();document.getElementById("submitField0").focus()}:(f)=>{setSubmitVal({field:col,value:f.currentTarget.value})}}/>} | )}
}
+ }} value={String(dat[col.name])}/>)})}
+ { | {fields.map((col,i)=>{{setSubmitVal({field:col.name,value:f.currentTarget.value});SubmitBoxes();document.getElementById("submitField0").focus()}:(f)=>{setSubmitVal({field:col.name,value:f.currentTarget.value})}}/>} | )}
}
-
+ :
}
>
}
diff --git a/src/style.css b/src/style.css
index 6f6081c..6ab4950 100644
--- a/src/style.css
+++ b/src/style.css
@@ -892,4 +892,10 @@ button{
.modalCloseButton:hover{
color:rgba(200,0,0,1);
cursor:pointer;
+}
+.failedInput{
+ border: 1px solid rgba(200,0,0,1);
+}
+.submitting{
+ border: 1px solid rgba(0,150,200,1);
}
\ No newline at end of file