AreSameImagesReference.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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></template>
  9. <template v-slot:content>
  10. <v-flex xs12 sm6>
  11. <v-card dark color="primary">
  12. <v-card-text class="px-0">Image 1</v-card-text>
  13. <v-img v-if="image1 && image1.link" :src="image1.link">
  14. <template v-slot:placeholder>
  15. <v-layout fill-height align-center justify-center ma-0>
  16. <v-progress-circular indeterminate color="grey lighten-5" />
  17. </v-layout>
  18. </template>
  19. </v-img>
  20. </v-card>
  21. </v-flex>
  22. <v-flex sm6 xs12>
  23. <v-card dark color="primary">
  24. <v-card-text>Image 2</v-card-text>
  25. <v-img v-if="image2 && image2.link" :src="image2.link" @load="scrollToChoiceButtons">
  26. <template v-slot:placeholder>
  27. <v-layout fill-height align-center justify-center ma-0>
  28. <v-progress-circular indeterminate color="grey lighten-5" />
  29. </v-layout>
  30. </template>
  31. </v-img>
  32. </v-card>
  33. </v-flex>
  34. <!-- Experiment validation button -->
  35. <v-layout justify-center align-content-center>
  36. <div id="choice">
  37. <v-container grid-list-md text-xs-center fluid>
  38. <h2>Test {{ testCount }} / {{ maxTestCount }}</h2>
  39. <v-layout row wrap>
  40. <v-flex sm6 xs12>
  41. <v-btn @click="nextAction(false)" color="error" large>Images are NOT the same</v-btn>
  42. </v-flex>
  43. <v-flex sm6 xs12>
  44. <v-btn @click="nextAction(true)" color="success" large>Images are the same</v-btn>
  45. </v-flex>
  46. </v-layout>
  47. </v-container>
  48. </div>
  49. </v-layout>
  50. <!--/ Experiment validation button -->
  51. </template>
  52. </ExperimentBlock>
  53. </template>
  54. <script>
  55. import ExperimentBlock from '@/components/ExperimentBlock.vue'
  56. import ExperimentBaseAreSameImages from '@/mixins/ExperimentBaseAreSameImages'
  57. export default {
  58. name: 'AreSameImagesReference',
  59. components: {
  60. ExperimentBlock
  61. },
  62. mixins: [ExperimentBaseAreSameImages],
  63. data() {
  64. return {
  65. experimentName: 'AreSameImagesReference',
  66. referenceImagePosition: null
  67. }
  68. },
  69. async mounted() {
  70. // Load config for this scene to local state
  71. this.loadConfig()
  72. // Load progress from store into local state
  73. this.loadProgress()
  74. // Load scene data from the API
  75. await this.getQualitiesList()
  76. // Load a test if not already one loaded
  77. if (!this.image1 || !this.image1.link || !this.image2 || !this.image2.link) {
  78. const { image1, image2 } = await this.getReferenceTest()
  79. this.image1 = image1
  80. this.image2 = image2
  81. }
  82. this.saveProgress()
  83. },
  84. methods: {
  85. // generate next action and save data
  86. async nextAction(same) {
  87. let additionalData = {
  88. stepCounter: this.testCount,
  89. maxStepCount: this.maxTestCount
  90. }
  91. this.areTheSameAction(same, this.getReferenceTest, additionalData)
  92. }
  93. }
  94. }
  95. </script>