mirror of
https://gitlab.com/MrFry/qmining-data-editor
synced 2025-04-01 20:24:01 +02:00
Button styling, better informing user about upload process
This commit is contained in:
parent
179aa6ebfa
commit
25b9f72093
2 changed files with 44 additions and 28 deletions
|
@ -22,6 +22,7 @@ const views = {
|
||||||
export default function Index (props) {
|
export default function Index (props) {
|
||||||
const [data, setData] = useState(null)
|
const [data, setData] = useState(null)
|
||||||
const [view, setView] = useState(views.welcome)
|
const [view, setView] = useState(views.welcome)
|
||||||
|
const [sending, setSending] = useState(false)
|
||||||
const [error, setError] = useState(null)
|
const [error, setError] = useState(null)
|
||||||
const [password, setPassword] = useState('')
|
const [password, setPassword] = useState('')
|
||||||
const [editedQuestions, setEditedQuestions] = useState({})
|
const [editedQuestions, setEditedQuestions] = useState({})
|
||||||
|
@ -109,6 +110,12 @@ export default function Index (props) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const SendDataToServer = async () => {
|
const SendDataToServer = async () => {
|
||||||
|
if (sending) {
|
||||||
|
alert('Adatok már feltöltés alatt, várd meg míg feltölti') // eslint-disable-line
|
||||||
|
return
|
||||||
|
}
|
||||||
|
setSending(true)
|
||||||
|
try {
|
||||||
const rawResponse = await fetch(constants.apiUrl + 'uploaddata', {
|
const rawResponse = await fetch(constants.apiUrl + 'uploaddata', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -125,6 +132,7 @@ export default function Index (props) {
|
||||||
})
|
})
|
||||||
rawResponse.json()
|
rawResponse.json()
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
|
setSending(false)
|
||||||
if (resp.status === 'ok') {
|
if (resp.status === 'ok') {
|
||||||
alert(`Sikeres feltöltés! thankx ${resp.user}!`) // eslint-disable-line
|
alert(`Sikeres feltöltés! thankx ${resp.user}!`) // eslint-disable-line
|
||||||
console.log('OK')
|
console.log('OK')
|
||||||
|
@ -138,9 +146,15 @@ export default function Index (props) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
|
setSending(false)
|
||||||
alert('Hiba feltöltés közben! (kliens oldalon)! Több adat konzolban') // eslint-disable-line
|
alert('Hiba feltöltés közben! (kliens oldalon)! Több adat konzolban') // eslint-disable-line
|
||||||
console.error('Error posting data', e)
|
console.error('Error posting data', e)
|
||||||
})
|
})
|
||||||
|
} catch (e) {
|
||||||
|
setSending(false)
|
||||||
|
alert('Hiba feltöltés közben! (kliens oldalon)! Több adat konzolban') // eslint-disable-line
|
||||||
|
console.error('Error posting data', e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const renderView = () => {
|
const renderView = () => {
|
||||||
|
@ -219,7 +233,7 @@ export default function Index (props) {
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Feltöltés
|
{sending ? 'Feltöltés ...' : 'Mentés'}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.viewButtonContainer}>
|
<div className={styles.viewButtonContainer}>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
.viewButtonContainer span {
|
.viewButtonContainer span {
|
||||||
|
cursor: pointer;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin: 5px;
|
margin: 5px;
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
|
@ -11,6 +12,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.optionsButtonContainer span {
|
.optionsButtonContainer span {
|
||||||
|
cursor: pointer;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin: 3px;
|
margin: 3px;
|
||||||
padding: 3px;
|
padding: 3px;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue