annotated-media-view.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <div class="annotated-media-view">
  3. <div class="media">
  4. <annotated-image :data="currentMedia" :project="currentProject" :socket="socket"/>
  5. </div>
  6. <div class="control">
  7. <media-control :hasPrevious="hasPrevious" :hasNext="hasNext"
  8. @previous="previous" @next="next"/>
  9. </div>
  10. <div class="selector">
  11. <media-selector :project="currentProject"
  12. :current="currentMedia"
  13. :socket="socket"
  14. @click="current = $event"/>
  15. </div>
  16. </div>
  17. </template>
  18. <script>
  19. import MediaSelector from "@/components/media/media-selector";
  20. import AnnotatedImage from "@/components/media/annotated-image";
  21. import MediaControl from "@/components/media/media-control";
  22. export default {
  23. name: "annotated-media-view",
  24. components: {MediaControl, AnnotatedImage, MediaSelector},
  25. props: ['currentProject', 'socket'],
  26. data: function() {
  27. return {
  28. current: 0
  29. };
  30. },
  31. computed: {
  32. hasPrevious: function() {
  33. return this.current > 0;
  34. },
  35. hasNext: function() {
  36. return this.current < this.currentProject.data.length - 1;
  37. },
  38. currentMedia: function() {
  39. if (this.current < this.currentProject.data.length)
  40. return this.currentProject.data[this.current];
  41. else
  42. return false;
  43. }
  44. },
  45. methods: {
  46. previous: function() {
  47. if (this.hasPrevious)
  48. this.current -= 1;
  49. },
  50. next: function() {
  51. if (this.hasNext)
  52. this.current += 1;
  53. }
  54. }
  55. }
  56. </script>
  57. <style scoped>
  58. .annotated-media-view {
  59. display: flex;
  60. flex-direction: column;
  61. width: 100%;
  62. height: 100%;
  63. background-color: rgba(0, 0, 0, 0.3);
  64. }
  65. .media {
  66. flex-grow: 1;
  67. position: relative;
  68. }
  69. .annotated-image {
  70. position: absolute;
  71. top: 0;
  72. left: 0;
  73. right: 0;
  74. bottom: 0;
  75. display: flex;
  76. align-items: center;
  77. justify-content: center;
  78. }
  79. .control {
  80. background-color: rgba(0, 0, 0, 0.8);
  81. padding-top: 0.5rem;
  82. padding-bottom: 0.5rem;
  83. }
  84. .selector {
  85. overflow-x: auto;
  86. white-space: nowrap;
  87. background-color: rgba(0, 0, 0, 0.5);
  88. }
  89. </style>