SelectExperimentScene.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <div>
  3. Select a scene for the experiment "{{ experimentName }}"
  4. <v-card>
  5. <v-container
  6. fluid
  7. grid-list-md
  8. >
  9. <v-layout row wrap>
  10. <v-flex
  11. v-for="aScene in scenes"
  12. :key="aScene.name"
  13. >
  14. <v-card>
  15. <v-img
  16. :src="aScene.thumbLink"
  17. height="200px"
  18. />
  19. <v-card-title primary-title>
  20. <div>
  21. <div class="headline">{{ aScene.name }}</div>
  22. </div>
  23. <v-card-actions>
  24. <v-chip v-if="aScene.progression === 'done'" color="green" text-color="white" small>
  25. <v-avatar class="green darken-4">
  26. <v-icon>check</v-icon>
  27. </v-avatar>
  28. <span>Validated</span>
  29. </v-chip>
  30. <v-chip v-else-if="aScene.progression === 'working'" color="orange" text-color="white" small>
  31. <v-avatar class="orange darken-4">
  32. <v-icon>edit</v-icon>
  33. </v-avatar>
  34. <span>Started but not validated</span>
  35. </v-chip>
  36. <v-chip v-else-if="aScene.progression === 'todo'" color="red" text-color="white" small>
  37. <v-avatar class="red darken-4">
  38. <v-icon>close</v-icon>
  39. </v-avatar>
  40. <span>Not started</span>
  41. </v-chip>
  42. </v-card-actions>
  43. <v-spacer />
  44. <v-card-actions>
  45. <v-btn flat round :to="aScene.experimentLink">Start experiment</v-btn>
  46. </v-card-actions>
  47. </v-card-title>
  48. </v-card>
  49. </v-flex>
  50. </v-layout>
  51. </v-container>
  52. </v-card>
  53. </div>
  54. </template>
  55. <script>
  56. import { mapState, mapGetters } from 'vuex'
  57. import { API_ROUTES } from '@/functions'
  58. export default {
  59. name: 'SelectExperimentScene',
  60. props: {
  61. experimentName: {
  62. type: String,
  63. required: true
  64. }
  65. },
  66. data() {
  67. return {
  68. scenes: []
  69. }
  70. },
  71. computed: {
  72. ...mapState(['scenesList', 'progression']),
  73. ...mapGetters(['getHostURI'])
  74. },
  75. async mounted() {
  76. for (const aScene of this.scenesList) {
  77. const { data: thumb } = await fetch(`${this.getHostURI}${API_ROUTES.getImage(aScene, 'max')}`)
  78. .then(res => res.json())
  79. let sceneObj = {}
  80. sceneObj = {
  81. name: thumb.sceneName,
  82. thumbLink: `${this.getHostURI}${thumb.link}`,
  83. experimentLink: `/experiments/${this.experimentName}/${thumb.sceneName}`
  84. }
  85. if (this.progression[this.experimentName] && this.progression[this.experimentName][thumb.sceneName]) {
  86. const obj = this.progression[this.experimentName][thumb.sceneName]
  87. if (obj.done)
  88. sceneObj.progression = 'done'
  89. else if (Object.entries(obj.data).length !== 0 && obj.constructor === Object)
  90. sceneObj.progression = 'working'
  91. else
  92. sceneObj.progression = 'todo'
  93. }
  94. this.scenes.push(sceneObj)
  95. }
  96. }
  97. }
  98. </script>