MatchExtractsWithReference.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. <template>
  2. <ExperimentBlock
  3. :run-expe="runExpe"
  4. :experiment-name="experimentName"
  5. :scene-name="sceneName"
  6. :loading-message="loadingMessage"
  7. :loading-error-message="loadingErrorMessage"
  8. >
  9. <template v-slot:header>
  10. <!-- Extract configuration -->
  11. <extract-configuration
  12. v-if="lockConfig === false"
  13. @setExtractConfig="setExtractConfig($event, $refs.configurator)"
  14. :loading-error-message="loadingErrorMessage"
  15. ref="configurator"
  16. />
  17. <!--/ Extract configuration -->
  18. </template>
  19. <template v-slot:content>
  20. <v-flex v-if="explanation === true || disableStart === true" xs12 sm12>
  21. <div style="margin-top:15%">
  22. <p v-if="disableStart === false && calibrationScene === true" style="font-size: 1.4em;">
  23. Vous allez voir des images, l'image de droite constitue toujours l'image de référence. Vous devez régler la qualité de l'image de gauche pour qu'elle soit la plus proche de l'image de droite.
  24. La première image est constitué de carré gris, c'est une partie de calibration. Si vous souhaitez régler votre écran (contraste, luminosité) vous pouvez le faire maintenant mais il vous est demandé de ne plus changer ce réglage au cours de l'expérience.
  25. Vous allez ensuite voir des scènes d'image de synthèse. Vous pouvez arrêter l'expérience quand vous souhaitez (ou faire une pause).
  26. </p>
  27. <p v-if="disableStart === true" style="margin-top:2%; color:orange; font-size: 1.4em;">
  28. <strong>Attention !</strong> L'expérience requiert un écran de taille minimal de <strong>1920 x 1080</strong>.
  29. <br />
  30. <br />
  31. Vous pouvez redimensionner la fenêtre de votre navigateur pour poursuivre l'expérience.
  32. </p>
  33. <p v-if="disableStart === false" style="margin-top:2%; color:#007acc; font-size: 1.4em;">
  34. <strong>La résolution de votre fenêtre de navigateur vous permet d'accéder à l'expérience</strong>.
  35. </p>
  36. <v-btn v-if="disableStart === true" @click="startExperiment" color="#007acc" large disabled>Poursuivre l'expérience</v-btn>
  37. <v-btn v-if="disableStart === false" @click="startExperiment" color="#007acc" large>Poursuivre l'expérience</v-btn>
  38. </div>
  39. </v-flex>
  40. <v-flex v-if="haveBreak === true" xs12 sm12>
  41. <div style="margin-top:15%">
  42. <p style="font-size: 1.4em;">
  43. Nous vous remercions d'avoir participé à cette expérience.
  44. Elle va nous permettre d'améliorer les calculs d'images. Si vous le souhaitez, vous pouvez revenir sur l'expérience via le <a :href="launcherURI" target="_blank">launcher</a> pour revoir de nouvelles images.
  45. </p>
  46. <v-btn @click="startExperiment" color="#007acc" large>Continuer l'expérience</v-btn>
  47. </div>
  48. <div style="margin-top:15%">
  49. <p style="font-size: 1.4em;">Si vous souhaitez être informé des résultats non nomminatifs de ces recherches vous pouvez, sans obligation, laisser votre adresse mail, elle ne sera utilisée que pour vous permettre d'accéder aux résultats de l'étude une fois analysés.</p>
  50. <v-text-field
  51. v-model="email"
  52. :rules="emailRules"
  53. label="Votre adresse email"
  54. required
  55. />
  56. <v-btn @click="finishExperiment" color="success" large disabled>Valider mon adresse</v-btn>
  57. </div>
  58. </v-flex>
  59. <v-flex v-if="runExpe === true" xs12 sm6 :style="{ 'max-width': maxWidth + 'px', 'min-width': maxWidth + 'px', 'margin-right': 20 + 'px' }">
  60. <v-card dark color="primary" :max-width="maxWidth" :min-width="maxWidth">
  61. <!-- <v-card-text class="px-0">Experiment image</v-card-text> -->
  62. <v-container class="pa-1">
  63. <template v-for="i in extractConfig.y">
  64. <v-layout row wrap :key="`row-${i}`">
  65. <v-flex
  66. v-for="(anExtract, index) in extracts.slice(extractConfig.x * (i - 1), (extractConfig.x * i))"
  67. :key="`extract-${i}-${extractConfig.x}-${extractConfig.y}-${index}-${anExtract.quality}`"
  68. class="pa-0"
  69. >
  70. <v-card flat tile class="d-flex height100">
  71. <div
  72. v-if="anExtract.loading"
  73. class="img-extract-loader"
  74. @click.right.prevent
  75. >
  76. <v-progress-circular
  77. :indeterminate="true"
  78. />
  79. </div>
  80. <v-img
  81. v-else
  82. :src="anExtract.link"
  83. @click.left.prevent="extractAction($event, anExtract)"
  84. @click.right.prevent="extractAction($event, anExtract)"
  85. class="cursor"
  86. :class="{ 'extract-hover-border': showHoverBorder === true }"
  87. @error="extractsRemovedFromServerFallback"
  88. >
  89. <template v-slot:placeholder>
  90. <v-layout fill-height align-center justify-center ma-0>
  91. <v-progress-circular indeterminate color="grey lighten-5" />
  92. </v-layout>
  93. </template>
  94. </v-img>
  95. </v-card>
  96. </v-flex>
  97. </v-layout>
  98. </template>
  99. </v-container>
  100. </v-card>
  101. </v-flex>
  102. <v-flex v-if="runExpe === true" sm6 xs12 :style="{ 'max-width': maxWidth + 'px', 'min-width': maxWidth + 'px' }">
  103. <v-card dark color="primary" :max-width="maxWidth" :min-width="maxWidth">
  104. <!-- <v-card-text>Reference image</v-card-text> -->
  105. <v-img v-if="referenceImage" :src="referenceImage" :max-height="maxHeight" :max-width="maxWidth" :min-width="maxWidth" />
  106. </v-card>
  107. </v-flex>
  108. <!-- Experiment validation button -->
  109. <v-layout v-if="runExpe === true" justify-end align-content-end>
  110. <v-text-field
  111. v-model="comment"
  112. label="Ajouter un commentaire ici"
  113. />
  114. <v-btn @click="userBreak" color="primary" large right>Arrêter ou faire une pause</v-btn>
  115. <v-btn @click="finishExperiment" color="success" large right>Valider & passer à l'image suivante</v-btn>
  116. </v-layout>
  117. <!--/ Experiment validation button -->
  118. </template>
  119. </ExperimentBlock>
  120. </template>
  121. <script>
  122. import { mapGetters } from 'vuex'
  123. import ExperimentBlock from '@/components/ExperimentBlock.vue'
  124. import ExperimentBaseExtracts from '@/mixins/ExperimentBaseExtracts'
  125. import ExtractConfiguration from '@/components/ExperimentsComponents/ExtractConfiguration.vue'
  126. import { NEWS as newsletter } from '@/../config.messagesId'
  127. export default {
  128. components: {
  129. ExperimentBlock,
  130. ExtractConfiguration
  131. },
  132. mixins: [ExperimentBaseExtracts],
  133. data() {
  134. return {
  135. referenceImage: null,
  136. maxWidth: null,
  137. maxHeight: null,
  138. launcherURI: null,
  139. explanation: false,
  140. haveBreak: false,
  141. calibrationScene: false,
  142. runExpe: false,
  143. disableStart: false,
  144. emailRules: [
  145. v => !!v || 'L\'adresse email est obligatoire',
  146. v => /.+@.+/.test(v) || 'L\'email doit être valide'
  147. ],
  148. email: ''
  149. }
  150. },
  151. computed: {
  152. ...mapGetters(['getHostURI'])
  153. },
  154. async mounted() {
  155. // Load config for this scene to local state
  156. this.loadConfig()
  157. // Load progress from store into local state
  158. this.loadProgress()
  159. this.launcherURI = this.getHostURI + '/launcher/'
  160. let reference = null
  161. // Load scene data from the API
  162. await Promise.all([
  163. this.getImage('max').then(res => (reference = res)),
  164. this.getQualitiesList()
  165. ])
  166. this.referenceImage = reference.link
  167. this.maxWidth = reference.metadata.width
  168. this.maxHeight = reference.metadata.height
  169. // Load the cached configuration in the configurator component
  170. if (this.lockConfig === false) this.$refs.configurator.setDefaultConfig(this.extractConfig)
  171. // Load extracts if none were cached
  172. // if (this.extracts.length === 0)
  173. await this.setExtractConfig(this.extractConfig, this.$refs.configurator)
  174. this.saveProgress()
  175. this.loadExperimentState()
  176. // check window size
  177. this.checkWindow()
  178. window.addEventListener('resize', this.checkWindow)
  179. },
  180. methods: {
  181. startExperiment() {
  182. this.explanation = false
  183. this.haveBreak = false
  184. this.runExpe = true
  185. },
  186. userBreak() {
  187. this.haveBreak = true
  188. this.explanation = false
  189. this.runExpe = false
  190. },
  191. loadExperimentState() {
  192. this.explanation = false
  193. this.haveBreak = false
  194. this.runExpe = false
  195. if (this.sceneName === '50_shades_of_grey') {
  196. this.explanation = true
  197. this.calibrationScene = true
  198. }
  199. else {
  200. this.runExpe = true
  201. }
  202. },
  203. checkWindow() {
  204. // check window screen size
  205. console.log(window.innerWidth, ' ', window.innerHeight)
  206. if (window.innerWidth < 1920 || window.innerHeight < 900) {
  207. this.disableStart = true
  208. this.explanation = true
  209. this.runExpe = false
  210. this.haveBreak = false
  211. }
  212. else {
  213. this.disableStart = false
  214. }
  215. },
  216. addNewsletter() {
  217. this.sendMessage({
  218. msgId: newsletter,
  219. msg: {
  220. experimentName: this.experimentName,
  221. sceneName: this.sceneName,
  222. userEmail: this.email
  223. }
  224. })
  225. }
  226. }
  227. }
  228. </script>