ScenesList.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <template>
  2. <div>
  3. Scenes list
  4. <v-card>
  5. <v-container
  6. fluid
  7. grid-list-md
  8. >
  9. <v-layout row wrap>
  10. <v-flex
  11. md3
  12. v-for="aScene in scenes"
  13. :key="aScene.name"
  14. >
  15. <v-card>
  16. <a
  17. :href="aScene.qualitiesLink"
  18. >
  19. <v-img
  20. :src="aScene.thumbLink"
  21. height="200px"
  22. />
  23. </a>
  24. <v-card-title primary-title>
  25. <div>
  26. <div class="headline">{{ aScene.name }}</div>
  27. </div>
  28. <v-spacer />
  29. </v-card-title>
  30. </v-card>
  31. </v-flex>
  32. </v-layout>
  33. </v-container>
  34. </v-card>
  35. </div>
  36. </template>
  37. <script>
  38. import { API_ROUTES } from '@/functions'
  39. import { mapGetters } from 'vuex'
  40. export default {
  41. name: 'ScenesList',
  42. data() {
  43. return {
  44. scenes: []
  45. }
  46. },
  47. computed: {
  48. ...mapGetters(['getHostURI'])
  49. },
  50. async mounted() {
  51. // define empyt scenes list
  52. this.scenes = []
  53. const scenesList = await fetch(`${this.getHostURI}${API_ROUTES.listScenes}`)
  54. .then(res => res.json())
  55. for (const aScene of scenesList.data) {
  56. const { data: thumb } = await fetch(`${this.getHostURI}${API_ROUTES.getImage(aScene, 'max')}`).then(res => res.json())
  57. let sceneObj = {
  58. name: thumb.sceneName,
  59. thumbLink: `${this.getHostURI}${thumb.link}`,
  60. qualitiesLink: `${this.getHostURI}${API_ROUTES.listSceneQualities(aScene)}`
  61. }
  62. this.scenes.push(sceneObj)
  63. }
  64. }
  65. }
  66. </script>