MatchExtractsWithReference.vue 4.2 KB

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