index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <div>
  3. <v-container grid-list-md text-xs-center fluid>
  4. <v-layout row wrap>
  5. <v-flex xs12>
  6. <v-layout justify-start>
  7. <v-btn flat exact :to="`/experiments/${experimentName}`">
  8. <v-icon left>arrow_back</v-icon>
  9. Back to scene selection
  10. </v-btn>
  11. </v-layout>
  12. <h1>Experiment with reference - {{ sceneName }}</h1>
  13. <!-- Extract configuration -->
  14. <extract-configuration v-if="lockConfig === false" @setExtractConfig="setExtractConfig($event, $refs.configurator)" :loading-error-message="loadingErrorMessage" ref="configurator" />
  15. <!--/ Extract configuration -->
  16. </v-flex>
  17. <!-- Loading screen -->
  18. <loader v-if="loadingMessage" :message="loadingMessage" />
  19. <!--/ Loading screen -->
  20. <!-- Experiment -->
  21. <template v-else-if="!loadingErrorMessage">
  22. <v-flex xs12 sm6>
  23. <v-card dark color="primary">
  24. <v-card-text class="px-0">Experiment image</v-card-text>
  25. <v-container class="pa-1">
  26. <template v-for="i in extractConfig.y">
  27. <v-layout row wrap :key="`row-${i}`">
  28. <v-flex
  29. v-for="(anExtract, index) in extracts.slice(extractConfig.x * (i - 1), (extractConfig.x * i))"
  30. :key="`extract-${i}-${extractConfig.x}-${extractConfig.y}-${index}-${anExtract.quality}`"
  31. class="pa-0"
  32. >
  33. <v-card flat tile class="d-flex height100">
  34. <div
  35. v-if="anExtract.loading"
  36. class="img-extract-loader"
  37. @click.right.prevent
  38. >
  39. <v-progress-circular
  40. :indeterminate="true"
  41. />
  42. </div>
  43. <v-img
  44. v-else
  45. :src="anExtract.link"
  46. @click.left.prevent="extractAction($event, anExtract)"
  47. @click.right.prevent="extractAction($event, anExtract)"
  48. class="cursor"
  49. :class="{ 'extract-hover-border': showHoverBorder === true }"
  50. >
  51. <template v-slot:placeholder>
  52. <v-layout
  53. fill-height
  54. align-center
  55. justify-center
  56. ma-0
  57. >
  58. <v-progress-circular indeterminate color="grey lighten-5" />
  59. </v-layout>
  60. </template>
  61. </v-img>
  62. </v-card>
  63. </v-flex>
  64. </v-layout>
  65. </template>
  66. </v-container>
  67. </v-card>
  68. </v-flex>
  69. <v-flex sm6 xs12>
  70. <v-card dark color="primary">
  71. <v-card-text>Reference image</v-card-text>
  72. <v-img v-if="referenceImage" :src="referenceImage" />
  73. </v-card>
  74. </v-flex>
  75. <!-- Experiment validation button -->
  76. <v-layout justify-end align-content-end>
  77. <v-btn @click="finishExperiment" color="primary" large right>Finish experiment</v-btn>
  78. </v-layout>
  79. <!--/ Experiment validation button -->
  80. </template>
  81. <!--/ Experiment -->
  82. </v-layout>
  83. </v-container>
  84. </div>
  85. </template>
  86. <script>
  87. import ExperimentBaseExtracts from '@/mixins/ExperimentBaseExtracts'
  88. import Loader from '@/components/Loader.vue'
  89. import ExtractConfiguration from '@/components/ExperimentsComponents/ExtractConfiguration.vue'
  90. import experimentConfig from './config'
  91. export default {
  92. name: 'ExperimentWithReference',
  93. components: {
  94. Loader,
  95. ExtractConfiguration
  96. },
  97. mixins: [ExperimentBaseExtracts],
  98. data() {
  99. return {
  100. experimentName: 'ExperimentWithReference',
  101. referenceImage: null
  102. }
  103. },
  104. async mounted() {
  105. // Load config for this scene to local state
  106. await this.loadConfig(experimentConfig)
  107. // Load progress from store into local state
  108. this.loadProgress()
  109. // Load scene data from the API
  110. await Promise.all([
  111. this.getImage('max')
  112. .then(res => {
  113. this.referenceImage = this.getHostURI + res.link
  114. this.saveProgress()
  115. }),
  116. this.getQualitiesList()
  117. ])
  118. // Load the cached configuration in the configurator component
  119. if (this.lockConfig === false) this.$refs.configurator.setDefaultConfig(this.extractConfig)
  120. // Load extracts of none were cached
  121. if (this.extracts.length === 0) await this.setExtractConfig(this.extractConfig, this.$refs.configurator)
  122. this.saveProgress()
  123. },
  124. methods: {}
  125. }
  126. </script>