Skip to content

Commit

Permalink
✨ submit URL api
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidZhang73 committed Feb 27, 2022
1 parent 2bcc289 commit 4bc8fc0
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</a>
<router-link
class="vertical-middle"
:to="'annotation'"
:to="'/'"
>
ANU CVML Video Annotation Tool
</router-link>
Expand Down
32 changes: 18 additions & 14 deletions src/hooks/annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,25 +86,29 @@ export const useAnnotation = () => {
submitLoading.value = false
if (res.ok) {
console.log('Success', res)
res.text().then(text => {
copyToClipboard(text).then(() => {
utils.notify('Success (Already copied to clipboard): ' + text, 'positive')
}).catch((err) => {
console.log('Failed to copy to clipboard', err)
utils.notify('Failed to copy to clipboard: ' + err, 'negative')
}
)
res.json().then(data => {
const { message, clipboard } = data
if (message) {
utils.notify('Server: ' + text, 'positive')
}
if (clipboard) {
copyToClipboard(clipboard).then(() => {
utils.notify('Copied to clipboard: ' + clipboard, 'positive')
}).catch((err) => {
console.error('Failed to copy to clipboard', err)
utils.notify('Failed to copy to clipboard, please do it manually: ' + clipboard, 'negative', 10000)
}
)
}
})
} else {
console.log('Failed', res)
res.text().then(text => {
utils.notify('Failed: ' + text, 'warning')
})
console.error('Failed', res)
utils.notify(`Failed to submit: ${res.statusText} (${res.status})`, 'warning')
}
}).catch(err => {
submitLoading.value = false
console.log('Failed', err)
utils.notify('Failed: ' + err, 'negative')
console.error('Failed', err)
utils.notify('Failed to submit: ' + err, 'negative')
})
},
submitLoading
Expand Down
6 changes: 4 additions & 2 deletions src/libs/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ export default {
* Notify popup
* @param message
* @param color
* @param timeout
* @returns
*/
notify (message, color = 'positive') {
notify (message, color = 'positive', timeout=5000) {
return Notify.create({
message: message,
color: color,
position: 'bottom-right'
position: 'bottom-right',
timeout: timeout
})
},
/**
Expand Down
6 changes: 3 additions & 3 deletions src/pages/configuration/Configuration.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ const handleLoad = () => {
configurationStore.importConfig(JSON.parse(file))
utils.notify('Load successfully!', 'positive')
} catch (e) {
utils.notify(e.toString(), 'negative')
throw e
console.error(e)
utils.notify(`Could not load config: ${e}`, 'negative')
}
})
})
}
const handleSave = () => { // TODO
const handleSave = () => {
utils.prompt(
'Save',
'Enter configuration filename for saving',
Expand Down

0 comments on commit 4bc8fc0

Please sign in to comment.