Commit a7344a91 authored by christianrhansen's avatar christianrhansen

getting annotations

parent c6e677f9
......@@ -4,11 +4,66 @@
| Annotations Table
br
| {{ $route.params.id }}
br
| // {{ annotations }}
</template>
<script>
import constants from 'mbjs-data-models/src/constants'
import parseURI from 'mbjs-data-models/src/lib/parse-uri'
import { DateTime } from 'luxon'
export default {
name: 'AnnotationsTable'
name: 'AnnotationsTable',
data () {
return {
annotations: undefined,
video: undefined,
timeline: undefined,
metadata: undefined
}
},
async mounted () {
if (this.$route.params.id) {
this.$q.loading.show()
await this.getVideo()
await this.getAnnotations()
this.$q.loading.hide()
}
},
methods: {
async getVideo () {
this.video = await this.$store.dispatch('annotations/get', this.$route.params.id)
this.timeline = await this.$store.dispatch('maps/get', parseURI(this.video.target.id).uuid)
if (this.video) {
this.metadata = await this.$store.dispatch('metadata/get', this.video)
}
},
async getAnnotations () {
const
_this = this,
query = {
'target.id': this.timeline.id,
'target.type': constants.MAP_TYPE_TIMELINE,
'target.selector.value': { $gte: this.video.target.selector.value },
'body.type': { $in: ['TextualBody', 'VocabularyEntry'] }
}
if (this.metadata.duration) {
const start = DateTime.fromISO(this.video.target.selector.value, { setZone: true })
query['target.selector.value']['$lte'] = start.plus(this.metadata.duration * 1000).toISO()
}
const results = await this.$store.dispatch('annotations/find', query)
for (let item of results.items) {
if (item.body.type === 'VocabularyEntry') {
const entry = await this.$vocabularies.getEntry(item.body.source.id)
item.body.value = entry.value
}
}
if (results && Array.isArray(results.items)) {
_this.annotations = results.items.sort(this.$sort.onRef)
}
}
}
}
</script>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment