Browse Source

Merge branch 'release/v0.5.8'

Jérôme BUISINE 2 months ago
parent
commit
5cff8d281f

+ 2 - 2
experimentConfig.default.js

@@ -18,7 +18,7 @@ export const mixins = {
   ExperimentBaseExtracts: {
     defaultConfig: {
       lockConfig: false,
-      showHoverBorder: true,
+      showHoverBorder: false,
       extractConfig: {
         x: 4,
         y: 4
@@ -43,7 +43,7 @@ export const experiments = {
     mixins: [mixins.ExperimentBaseExtracts],
     defaultConfig: {
       lockConfig: true,
-      showHoverBorder: true,
+      showHoverBorder: false,
       extractConfig: {
         x: 4,
         y: 4

+ 2 - 0
server/routes/getImageExtracts.js

@@ -206,8 +206,10 @@ export const cutImage = async (image, xExtracts, yExtracts) => {
         height: yCropSize
       }
 
+
       // Check the file already exist
       let fileAlreadyExists = false
+
       try {
         await fs.access(extractPath, fsConstants.R_OK)
         fileAlreadyExists = true

+ 40 - 1
src/mixins/ExperimentBaseExtracts.vue

@@ -48,6 +48,25 @@ export default {
       data.extracts = data.extracts.map(x => this.getHostURI + x)
       return data
     },
+    // There was an error loading extracts in v-img
+    // (extracts have probably been removed from the server)
+    // //
+    // Get all extracts qualities and remove duplicates
+    // Then do all the API extract-generation API calls then reload the page
+    async extractsRemovedFromServerFallback() {
+      this.loadingMessage = 'Synchronizing with the server...'
+      try {
+        const qualities = [...new Set(this.extracts.map(x => x.quality))]
+        await Promise.all(qualities.map(x => this.getExtracts(x)))
+      }
+      catch (err) {
+        console.error(err)
+        this.loadingErrorMessage = 'Failed to synchronize with the server. Try reloading the page.'
+      }
+      finally {
+        this.loadingMessage = null
+      }
+    },
 
     // Convert a simple API extracts object to get more informations
     getExtractFullObject(extractsApiObj) {
@@ -74,7 +93,8 @@ export default {
         this.extractConfig.quality = config.quality
         const data = await this.getExtracts(config.quality || undefined)
         this.extractsInfos = data.info
-        this.extracts = this.getExtractFullObject(data)
+        // Put extracts in cache if not already there
+        if (this.extracts.length === 0) this.extracts = this.getExtractFullObject(data)
 
         // If there is a configurator, retract it
         if (configuratorRef) configuratorRef.setVisibility(false)
@@ -93,13 +113,32 @@ export default {
     async extractAction(event, extractObj) {
       const { index, nextQuality, precQuality, quality } = extractObj
 
+      const qualityIndex = this.qualities.indexOf(quality)
       let action, newQuality
+
       if (event.button === 0) action = 'needLess' // Left click
       if (event.button === 2) action = 'needMore' // Right click
 
+      if (event.button === 0 && event.ctrlKey) action = 'need10Less' // ctrl + Right click
+      if (event.button === 2 && event.ctrlKey) action = 'need10More' // ctrl + Left click
+
       if (action === 'needLess') newQuality = precQuality
       if (action === 'needMore') newQuality = nextQuality
 
+
+      if (action === 'need10More') {
+        if (qualityIndex + 10 >= this.qualities.length - 1)
+          newQuality = this.qualities[this.qualities.length - 1]
+        else
+          newQuality = this.qualities[qualityIndex + 10]
+      }
+      if (action === 'need10Less') {
+        if (qualityIndex - 10 <= 0)
+          newQuality = this.qualities[0]
+        else
+          newQuality = this.qualities[qualityIndex - 10]
+      }
+
       // Do not load a new extract if same quality
       if (newQuality === quality) return
 

+ 0 - 1
src/store/mutations.js

@@ -17,7 +17,6 @@ const checkProgression = (state, experimentName, sceneName) => {
 const createProgressionObj = (state, scenes) => {
   const progressionObj = Experiments.reduce((accExpe, expe) => {
     const scenesProgressObj = scenes.reduce((accScene, scene) => {
-
       // check progression
       checkProgression(state, expe, scene)
 

+ 1 - 2
src/views/ExperimentValidated.vue

@@ -31,8 +31,7 @@
 </template>
 
 <script>
-import { mapState, mapGetters } from 'vuex'
-import getters from '@/store/getters'
+import { mapGetters } from 'vuex'
 import Experiments from '@/router/experiments'
 import { getExperimentSceneList } from '@/config.utils'
 import { rand } from '@/functions'

+ 5 - 4
src/views/Experiments/CalibrationMeasurement.vue

@@ -17,8 +17,8 @@
     </template>
 
     <template v-slot:content>
-      <v-flex xs12 sm6>
-        <v-card dark color="primary" :max-width="maxWidth">
+      <v-flex xs12 sm6 :style="{ 'max-width': maxWidth + 'px', 'min-width': maxWidth + 'px', 'margin-right': 20 + 'px' }">
+        <v-card dark color="primary" :max-width="maxWidth" :min-width="maxWidth">
           <v-card-text class="px-0">Experiment image</v-card-text>
 
           <v-container class="pa-1">
@@ -40,6 +40,7 @@
                       @click.right.prevent="extractAction($event, anExtract)"
                       class="cursor"
                       :class="{ 'extract-hover-border': showHoverBorder === true }"
+                      @error="extractsRemovedFromServerFallback"
                     >
                       <template v-slot:placeholder>
                         <v-layout fill-height align-center justify-center ma-0>
@@ -54,8 +55,8 @@
           </v-container>
         </v-card>
       </v-flex>
-      <v-flex sm6 xs12>
-        <v-card dark color="primary" :max-width="maxWidth">
+      <v-flex sm6 xs12 :style="{ 'max-width': maxWidth + 'px', 'min-width': maxWidth + 'px' }">
+        <v-card dark color="primary" :max-width="maxWidth" :min-width="maxWidth">
           <v-card-text>Reference image</v-card-text>
 
           <v-container v-if="referenceExtracts" class="pa-1">

+ 9 - 12
src/views/Experiments/MatchExtractsWithReference.vue

@@ -17,8 +17,8 @@
     </template>
 
     <template v-slot:content>
-      <v-flex xs12 sm6>
-        <v-card dark color="primary" :max-width="maxWidth">
+      <v-flex xs12 sm6 :style="{ 'max-width': maxWidth + 'px', 'min-width': maxWidth + 'px', 'margin-right': 20 + 'px' }">
+        <v-card dark color="primary" :max-width="maxWidth" :min-width="maxWidth">
           <!-- <v-card-text class="px-0">Experiment image</v-card-text> -->
 
           <v-container class="pa-1">
@@ -46,14 +46,10 @@
                       @click.right.prevent="extractAction($event, anExtract)"
                       class="cursor"
                       :class="{ 'extract-hover-border': showHoverBorder === true }"
+                      @error="extractsRemovedFromServerFallback"
                     >
                       <template v-slot:placeholder>
-                        <v-layout
-                          fill-height
-                          align-center
-                          justify-center
-                          ma-0
-                        >
+                        <v-layout fill-height align-center justify-center ma-0>
                           <v-progress-circular indeterminate color="grey lighten-5" />
                         </v-layout>
                       </template>
@@ -65,10 +61,10 @@
           </v-container>
         </v-card>
       </v-flex>
-      <v-flex sm6 xs12>
-        <v-card dark color="primary" :max-width="maxWidth">
+      <v-flex sm6 xs12 :style="{ 'max-width': maxWidth + 'px', 'min-width': maxWidth + 'px' }">
+        <v-card dark color="primary" :max-width="maxWidth" :min-width="maxWidth">
           <!-- <v-card-text>Reference image</v-card-text> -->
-          <v-img v-if="referenceImage" :src="referenceImage" :max-height="maxHeight" :max-width="maxWidth" />
+          <v-img v-if="referenceImage" :src="referenceImage" :max-height="maxHeight" :max-width="maxWidth" :min-width="maxWidth" />
         </v-card>
       </v-flex>
       <!-- Experiment validation button -->
@@ -128,7 +124,8 @@ export default {
     if (this.lockConfig === false) this.$refs.configurator.setDefaultConfig(this.extractConfig)
 
     // Load extracts if none were cached
-    if (this.extracts.length === 0) await this.setExtractConfig(this.extractConfig, this.$refs.configurator)
+    // if (this.extracts.length === 0)
+    await this.setExtractConfig(this.extractConfig, this.$refs.configurator)
 
     this.saveProgress()
   }