Browse Source

[192-webreport] Checking for two possible file names in ComparisonView

Evgeni 4 years ago
parent
commit
0cdd34aab2
1 changed files with 15 additions and 4 deletions
  1. 15 4
      report-viewer/src/views/ComparisonView.vue

+ 15 - 4
report-viewer/src/views/ComparisonView.vue

@@ -51,19 +51,30 @@ export default defineComponent({
      * Name of the comparison file. Comparison files should be named {ID1}-{ID2}
      * Name of the comparison file. Comparison files should be named {ID1}-{ID2}
      * @type {string}
      * @type {string}
      */
      */
-    const fileName = props.id1.concat("-").concat(props.id2)
+    const fileName1 = props.id1.concat("-").concat(props.id2)
+    const fileName2 = props.id2.concat("-").concat(props.id1)
 
 
     let comparison;
     let comparison;
     //getting the comparison file based on the used mode (zip, local, single)
     //getting the comparison file based on the used mode (zip, local, single)
     if(store.state.local) {
     if(store.state.local) {
       try {
       try {
         // eslint-disable-next-line @typescript-eslint/no-var-requires
         // eslint-disable-next-line @typescript-eslint/no-var-requires
-        comparison = ComparisonFactory.getComparison(require(`../files/${fileName}.json`))
+        comparison = ComparisonFactory.getComparison(require(`../files/${fileName1}.json`))
       } catch (exception) {
       } catch (exception) {
-        router.back()
+        try {
+          // eslint-disable-next-line @typescript-eslint/no-var-requires
+          comparison = ComparisonFactory.getComparison(require(`../files/${fileName2}.json`))
+        } catch (exception) {
+          router.back()
+        }
       }
       }
     } else if(store.state.zip) {
     } else if(store.state.zip) {
-      comparison = ComparisonFactory.getComparison(JSON.parse(store.state.files[fileName.concat(".json")]))
+      if(store.state.files[fileName1.concat(".json")]) {
+        comparison = ComparisonFactory.getComparison(JSON.parse(store.state.files[fileName1.concat(".json")]))
+      } else {
+        comparison = ComparisonFactory.getComparison(JSON.parse(store.state.files[fileName2.concat(".json")]))
+      }
+
     } else if(store.state.single) {
     } else if(store.state.single) {
       comparison = ComparisonFactory.getComparison(JSON.parse(store.state.fileString))
       comparison = ComparisonFactory.getComparison(JSON.parse(store.state.fileString))
     }
     }