You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
2.0 KiB

2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <v-main>
  3. <v-container fluid>
  4. <v-row justify="center">
  5. <v-col cols="12" md="9">
  6. <audio controls :src="src" class="mt-2 mb-5" style="width: 100%">
  7. Your browser does not support the
  8. <code>audio</code> element.
  9. </audio>
  10. <seq2seq-box
  11. :text="currentDoc.text"
  12. :annotations="currentDoc.annotations"
  13. @delete:annotation="_deleteAnnotation"
  14. @update:annotation="_updateAnnotation"
  15. @create:annotation="_createAnnotation"
  16. />
  17. </v-col>
  18. <v-col cols="12" md="3">
  19. <list-metadata :metadata="currentDoc.meta" />
  20. </v-col>
  21. </v-row>
  22. </v-container>
  23. </v-main>
  24. </template>
  25. <script>
  26. import ListMetadata from '@/components/tasks/metadata/ListMetadata'
  27. import Seq2seqBox from '~/components/tasks/seq2seq/Seq2seqBox'
  28. export default {
  29. components: {
  30. Seq2seqBox,
  31. ListMetadata
  32. },
  33. layout: 'demo',
  34. data() {
  35. return {
  36. currentDoc: {
  37. id: 8,
  38. text: '',
  39. annotations: [
  40. {
  41. id: 17,
  42. text: 'Hi! Welcome to doccano!',
  43. user: 1,
  44. document: 8
  45. }
  46. ],
  47. meta: {
  48. url: 'https://github.com/doccano'
  49. },
  50. annotation_approver: null
  51. },
  52. src: require('~/assets/examples/speech_1.mp3').default
  53. }
  54. },
  55. methods: {
  56. _deleteAnnotation(annotationId) {
  57. this.currentDoc.annotations = this.currentDoc.annotations.filter(
  58. (item) => item.id !== annotationId
  59. )
  60. },
  61. _updateAnnotation(annotationId, text) {
  62. const index = this.currentDoc.annotations.findIndex((item) => item.id === annotationId)
  63. this.currentDoc.annotations[index].text = text
  64. },
  65. _createAnnotation(text) {
  66. const payload = {
  67. id: Math.floor(Math.random() * Math.floor(Number.MAX_SAFE_INTEGER)),
  68. text
  69. }
  70. this.currentDoc.annotations.push(payload)
  71. }
  72. }
  73. }
  74. </script>