Skip to content

Commit

Permalink
💄 some tweaks and better fetch error message
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidZhang73 committed Feb 27, 2022
1 parent 63caf78 commit 769b92d
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 15 deletions.
12 changes: 5 additions & 7 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,11 @@ if (!annotation && video) {
}
if (!annotation && config) {
utils.readFile(config).then(res => {
try {
configurationStore.importConfig(JSON.parse(res))
utils.notify('Config loaded successfully!', 'positive')
} catch (e) {
utils.notify(e.toString(), 'negative')
throw e
}
configurationStore.importConfig(JSON.parse(res))
utils.notify('Config loaded successfully!', 'positive')
}).catch(err => {
console.error(err)
utils.notify(`Could not load config: ${config}: ${err}`, 'negative')
})
}
const mode_dict = {
Expand Down
4 changes: 2 additions & 2 deletions src/components/VideoLoaderV1.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ const handleSeeked = (event) => {
}
}
const handleError = (event) => {
console.log(event)
utils.notify(`Unable to load video: ${event.target.error.message}, please check the video path.`, 'negative')
console.error(event)
utils.notify(`Could not load video: ${annotationStore.video.src}: ${event.target.error.message}`, 'negative')
annotationStore.reset()
}
</script>
4 changes: 2 additions & 2 deletions src/components/VideoLoaderV2.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ onMounted(() => {
} else if (event.data.error) {
if (event.data.error.type === 'fetch') {
utils.notify(
`Unable to load video: ${event.data.error.statusText} (${event.data.error.status}), please check the video path.`,
`Could not load video: ${newValue}: ${event.data.error.statusText} (${event.data.error.status})`,
'negative')
}
console.log(event.data.error)
console.error(event.data.error)
annotationStore.isCaching = false
annotationStore.reset()
worker.terminate()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import utils from '~/libs/utils.js'
import { useAnnotationStore } from '~/store/annotation.js'
import { usePreferenceStore } from '~/store/preference.js'

export const useFrameIndicator = () => {
export const frameIndicator = () => {
const ALWAYS_SHOW = true // TODO: load from preferenceStore

const HEIGHT_UNIT = 16
Expand Down
1 change: 1 addition & 0 deletions src/libs/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export default {
readFile: (pathname) => {
return new Promise(function (resolve, reject) {
fetch(pathname).then(res => {
if (!res.ok) reject(`${pathname}: ${res.statusText} (${res.status})`)
return res.text()
}).then(text => {
resolve(text)
Expand Down
9 changes: 6 additions & 3 deletions src/pages/annotation/KeyframePanel.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<template>
<div class="row justify-evenly items-center q-pt-lg">
<div
class="row justify-evenly items-center q-pt-lg"
:class="{'q-pb-lg': q.screen.lt.md}"
>
<q-btn-group flat>
<q-btn
outline
Expand Down Expand Up @@ -80,7 +83,7 @@
<script setup>
import { useQuasar } from 'quasar'
import { computed, onMounted, onUnmounted, ref } from 'vue'
import { useFrameIndicator } from '~/hooks/useFrameIndicator.js'
import { frameIndicator } from '~/hooks/frameIndicator.js'
import utils from '~/libs/utils.js'
import KeyframeTable from '~/pages/annotation/components/KeyframeTable.vue'
import { useAnnotationStore } from '~/store/annotation.js'
Expand Down Expand Up @@ -323,7 +326,7 @@ const currentFrameRange = computed({
annotationStore.rightCurrentFrame = value.max
}
})
const { rangeStyle } = useFrameIndicator()
const { rangeStyle } = frameIndicator()
</script>

<style>
Expand Down

0 comments on commit 769b92d

Please sign in to comment.