Browse Source

[192-webreport] Added highlighting on demand, changed blur of anonymous ids to blurred string

Evgeni 4 năm trước cách đây
mục cha
commit
15952809aa

+ 2 - 7
report-viewer/src/components/CodePanel.vue

@@ -1,5 +1,5 @@
 <template>
-  <div class="code-panel-container">
+  <div class="code-panel-container" :id="panelId.toString().concat(title).concat(fileIndex.toString())">
     <div class="file-title">
       <p style="width: 90%">{{ title }}</p>
       <button style="width: 10%" class="collapse-button" @click="$emit('toggleCollapse')">
@@ -9,6 +9,7 @@
     </div>
     <div class="code-container" :class="{ hidden : !collapse }">
       <LineOfCode v-for="(line, index) in lines"
+                  :visible="collapse"
                 :key="index"
                 :color="coloringArray[index]"
                 :line-number="index"
@@ -50,10 +51,6 @@ export default defineComponent({
     }
   },
   setup(props) {
-    const isCollapsed = ref(false)
-    const toggleIsCollapsed = () => isCollapsed.value = !isCollapsed.value
-
-
     const coloringArray = ref({})
     const linksArray = ref({})
     const isLast = ref({})
@@ -80,12 +77,10 @@ export default defineComponent({
     }
 
     return {
-      isCollapsed,
       coloringArray,
       linksArray,
       isFirst,
       isLast,
-      toggleIsCollapsed
     }
   }
 })

+ 10 - 9
report-viewer/src/components/ComparisonsTable.vue

@@ -16,9 +16,9 @@
       @click="navigateToComparisonView(comparison.firstSubmissionId, comparison.secondSubmissionId)"
       >
     <td>{{ index + 1 }}.</td>
-    <td :class="{ blur : !notBlurred.includes(comparison.firstSubmissionId) }">{{ comparison.firstSubmissionId }}</td>
+    <td :class="{ anonymous : !notAnonymized.includes(comparison.firstSubmissionId)}">{{ notAnonymized.includes(comparison.firstSubmissionId) ? comparison.firstSubmissionId : "Hidden" }}</td>
     <td><img src="@/assets/double_arrow_black_18dp.svg" alt=">>"/></td>
-    <td :class="{ blur : !notBlurred.includes(comparison.secondSubmissionId) }">{{ comparison.secondSubmissionId }}</td>
+    <td :class="{ anonymous : !notAnonymized.includes(comparison.secondSubmissionId)}">{{ notAnonymized.includes(comparison.secondSubmissionId) ? comparison.secondSubmissionId : "Hidden" }}</td>
     <td>{{ formattedMatchPercentage(comparison.matchPercentage) }}</td>
   </tr>
 </table>
@@ -35,24 +35,23 @@ export default defineComponent({
      type: Array,
      required: true
    },
-    notBlurred : {
+    notAnonymized : {
      type: Array
     }
   },
-  setup() {
+  setup(props) {
     let formattedMatchPercentage = ( number ) => number.toFixed(2)
 
     const navigateToComparisonView = (id1, id2) => {
       router.push({
         name: "ComparisonView",
-        params: { id1 : id1, id2 : id2 }
+        query: {id1: id1, id2: id2},
+        params: { notAnonymized: props.notAnonymized}
       })
     }
-    const clickk = () => console.log('Clicked ')
     return {
       formattedMatchPercentage,
       navigateToComparisonView,
-      clickk
     }
   }
 })
@@ -77,9 +76,11 @@ td {
   padding-bottom: 3%;
 }
 
-.blur {
-  filter: blur(5px);
+.anonymous {
+  color: #777777;
+  filter: blur(1px);
 }
+
 .head-row {
   background: var(--primary-color-light);
 }

+ 3 - 3
report-viewer/src/components/FilesContainer.vue

@@ -1,5 +1,5 @@
 <template>
-  <div class="files-container" :id="containerId">
+  <div class="files-container">
     <h1>Files of {{ filesOwner }}</h1>
     <VueDraggableNext>
       <CodePanel v-for="(file, index) in Object.keys(files)"
@@ -11,7 +11,7 @@
                  :collapse="files[file].collapsed"
                  @toggle-collapse="$emit('toggle-collapse', file)"
                  @line-selected="lineSelected"
-                 :panel-id="1"
+                 :panel-id="containerId"
       />
     </VueDraggableNext>
   </div>
@@ -27,7 +27,7 @@ export default defineComponent({
   components: { CodePanel, VueDraggableNext},
   props: {
     containerId: {
-      type: String,
+      type: Number,
       required: true
     },
     filesOwner: {

+ 62 - 0
report-viewer/src/components/IDsList.vue

@@ -0,0 +1,62 @@
+<template>
+<div class="container">
+  <div class="column-list">
+    <p v-for="(id, index) in ids" :key="index" @click="$emit('idSent', id)">
+      {{ id }}
+    </p>
+  </div>
+  <button @click="$emit('idSent', ...ids)">Hide/Show all</button>
+</div>
+</template>
+
+<script>
+import { defineComponent } from "vue";
+
+export default defineComponent({
+  name: "IDsList",
+  props: {
+    ids: {
+      type: Array,
+      required: true
+    }
+  },
+  setup(props) {
+    // eslint-disable-next-line vue/no-setup-props-destructure
+    const savedIds = props.ids
+    return {
+      savedIds
+    }
+  }
+})
+</script>
+
+<style scoped>
+button {
+  height: 25%;
+  background: inherit;
+  font-family: "JetBrains Mono", serif;
+  border: none;
+  border-radius: 10px;
+}
+
+button:hover {
+  background: var(--primary-color-dark);
+  cursor: pointer;
+}
+
+.container {
+  display: flex;
+  justify-content: space-between;
+}
+
+.column-list {
+  display: flex;
+  flex-direction: column;
+  flex-wrap: nowrap;
+}
+
+.column-list > p:hover {
+  background: var(--primary-color-dark);
+  cursor: pointer;
+}
+</style>

+ 22 - 7
report-viewer/src/components/LineOfCode.vue

@@ -1,17 +1,20 @@
 <template>
-  <div class="line-wrap" :style="{background : color}" :class="{'first-line' : isFirst, 'last-line' : isLast}">
-      <hljs class="hljs" v-bind:class="{ 'match-line' : color !== '#ECECEC' }" language="java" :code="lineNumber.toString().concat(' ').concat(text)"/>
+  <div class="line-wrap" :style="{background : color}" :class="{'first-line' : isFirst, 'last-line' : isLast, 'visible' : visible}">
+    <pre ref="lineRef" :id="text" class="java" :class="{ 'match-line' : color !== '#ECECEC' }">{{ lineNumber }} {{ text }}</pre>
   </div>
 </template>
 
 <script>
-import { defineComponent } from "vue";
-import hljsVuePlugin from "@highlightjs/vue-plugin";
+import {defineComponent, onUpdated, ref} from "vue";
+import hljs from 'highlight.js';
 
 export default defineComponent({
   name: "LineOfCode",
-  components: { hljs: hljsVuePlugin.component},
   props: {
+    visible: {
+      type: Boolean,
+      required: true
+    },
     text: {
       type: String,
       required: true
@@ -37,8 +40,18 @@ export default defineComponent({
     }
   },
 
-  setup() {
-    return {}
+  setup(props) {
+    let highlighted = false
+    let lineRef = ref(null)
+    onUpdated( () => {
+      if ( props.visible && !highlighted ) {
+          hljs.highlightElement(lineRef.value)
+          highlighted = true
+      }
+    })
+    return {
+      lineRef
+    }
   }
 })
 </script>
@@ -51,6 +64,8 @@ pre {
   padding: 0;
   float: left;
 }
+
+
 .first-line {
   margin-top: 2%;
 }

+ 11 - 3
report-viewer/src/components/TextInformation.vue

@@ -2,7 +2,7 @@
   <div class="wrapper">
       <div class="text-container">
       <p class="label-text">{{ label }}</p>
-      <p class="value-text" :title="value">{{ value }}</p>
+      <p :class="{ anonymous : anonymous }" class="value-text" :title="anonymous ? '' : value">{{ anonymous ? "Hidden" : value }}</p>
       </div>
       <button class="collapse-button" :class="{ hidden : !hasAdditionalInfo }" @click="toggleIsCollapsed">
         <img v-if="isCollapsed" src="../assets/keyboard_double_arrow_up_black_18dp.svg" alt="hide info">
@@ -11,7 +11,7 @@
   </div>
   <div class="additional-info" :class="{ hidden : !isCollapsed }">
     <p class="additional-info-title">{{ additionalInfoTitle }}</p>
-    <p v-for="info in additionalInfo" :key="info">{{ info }}</p>
+    <slot></slot>
   </div>
   <hr>
 </template>
@@ -37,7 +37,10 @@ export default defineComponent({
       type: String,
       default: "",
     },
-    additionalInfo : [Array, String, Number, Boolean]
+    anonymous: {
+      type: Boolean,
+      default: false
+    }
   },
   setup() {
     const isCollapsed = ref(false)
@@ -68,6 +71,11 @@ hr {
   box-shadow: #D7E3FC 0 1px;
 }
 
+.anonymous {
+  filter: blur(1px);
+  color: #777777;
+}
+
 .wrapper {
   display: flex;
   background: var(--primary-color-light);

+ 2 - 8
report-viewer/src/router/index.ts

@@ -8,18 +8,12 @@ const routes: Array<RouteRecordRaw> = [
     name: "Overview",
     component: Overview,
     props:true
-  },
-    {
-    path: "/:notBlurred",
-    name: "OverviewBlurred",
-    component: Overview,
-    props:true
   },
   {
-    path: "/comparison/:id1/:id2",
+    path: "/comparison",
     name: "ComparisonView",
     component: ComparisonView,
-    props: true
+    props: route => ({ notAnonymized : route.params.notAnonymized, id1: route.query.id1, id2: route.query.id2})
   },
 ];
 

+ 5 - 16
report-viewer/src/views/ComparisonView.vue

@@ -9,16 +9,16 @@
         <button id="hide-button" @click="togglePanel" title="Hide sidebar">
           <img src="@/assets/keyboard_double_arrow_left_white_24dp.svg" alt="hide"></button>
       </div>
-      <TextInformation label="Submission 1" :value="id1"/>
-      <TextInformation label="Submission 2" :value="id2"/>
+      <TextInformation label="Submission 1" :value="id1" :anonymous="!notAnonymized.includes(id1)"/>
+      <TextInformation label="Submission 2" :value="id2" :anonymous="!notAnonymized.includes(id2)"/>
       <TextInformation label="Match %" :value="comparison.match_percentage"/>
       <MatchTable :matches="comparison.allMatches" :id1="id1" :id2="id2" @match-selected="showMatch" />
     </div>
-    <FilesContainer :matches="comparison.matchesInFirstSubmission" :files="filesOfFirst" container-id="files1"
+    <FilesContainer :matches="comparison.matchesInFirstSubmission" :files="filesOfFirst" :container-id="1"
                     files-owner="Submission 1"
                     @toggle-collapse="toggleCollapseFirst"
                     @line-selected="showMatchInSecond"/>
-    <FilesContainer :matches="comparison.matchesInSecondSubmissions" :files="filesOfSecond" container-id="files2"
+    <FilesContainer :matches="comparison.matchesInSecondSubmissions" :files="filesOfSecond" :container-id="2"
                     files-owner="Submission 2"
                     @toggle-collapse="toggleCollapseSecond"
                     @line-selected="showMatchInFirst"/>
@@ -28,8 +28,6 @@
 <script>
 import { defineComponent, ref } from "vue";
 import {generateLineCodeLink} from "@/utils/Utils";
-import { VueDraggableNext } from 'vue-draggable-next'
-import CodePanel from "@/components/CodePanel";
 import TextInformation from "@/components/TextInformation";
 import MatchTable from "@/components/MatchTable";
 import {ComparisonFactory} from "@/model/factories/ComparisonFactory";
@@ -45,7 +43,7 @@ export default defineComponent({
     id2: {
       type: String,
     },
-    notBlurred: {
+    notAnonymized: {
       type: Array
     }
   },
@@ -114,15 +112,6 @@ h1 {
   background: var(--background-color);
 }
 
-.files-container {
-  display: flex;
-  flex-wrap: nowrap;
-  flex-direction: column;
-  padding-top: 1%;
-  width: 100%;
-  overflow: auto;
-}
-
 .title-section {
   display: flex;
   justify-content: space-between;

+ 32 - 13
report-viewer/src/views/Overview.vue

@@ -5,9 +5,13 @@
       <p class="section-title">Main Info:</p>
       <div id="basicInfo">
         <TextInformation label="Directory path" :value="overview.submissionFolderPath"/>
-        <TextInformation label="Language" :value="overview.language" :has-additional-info="true" :additional-info="overview.fileExtensions" additional-info-title="File extensions:"/>
+        <TextInformation label="Language" :value="overview.language" :has-additional-info="true" additional-info-title="File extensions:">
+          <p v-for="info in overview.fileExtensions" :key="info">{{ info }}</p>
+        </TextInformation>
         <TextInformation :value="overview.matchSensitivity" label="Match Sensitivity"/>
-        <TextInformation label="Submissions" :value="overview.submissionIds.length" :has-additional-info="true" :additional-info="overview.submissionIds" additional-info-title="Submission IDs:"/>
+        <TextInformation label="Submissions" :value="overview.submissionIds.length" :has-additional-info="true" additional-info-title="Submission IDs:">
+          <IDsList :ids="overview.submissionIds" @id-sent="handleId"/>
+        </TextInformation>
         <TextInformation label="Date of execution" :value="overview.dateOfExecution"/>
         <TextInformation label="Duration (in ms)" :value="overview.durationOfExecution"/>
       </div>
@@ -35,7 +39,7 @@
         <p class="section-title">Top Comparisons:</p>
         <p class="section-subtitle">(Top n comparisons)</p>
         <div id="comparisonsList">
-          <ComparisonsTable :top-comparisons="topComps[selectedMetricIndex]" :not-blurred="notBlurredArray"/>
+          <ComparisonsTable :top-comparisons="topComps[selectedMetricIndex]" :not-anonymized="notAnonymized"/>
         </div>
     </div>
   </div>
@@ -49,23 +53,37 @@ import MetricButton from "@/components/MetricButton";
 import Overview from "../files/overview.json"
 import ComparisonsTable from "@/components/ComparisonsTable";
 import {OverviewFactory} from "@/model/factories/OverviewFactory";
+import IDsList from "@/components/IDsList";
 
 export default defineComponent({
   name: "Overview",
-  components: {ComparisonsTable, DistributionDiagram, MetricButton, TextInformation },
+  components: {IDsList, ComparisonsTable, DistributionDiagram, MetricButton, TextInformation },
   props: {
-    notBlurred: {
-      type: String,
-      default: "all"
-    }
   },
-  setup(props) {
+  setup() {
     const overview = OverviewFactory.getOverview(Overview)
-    let notBlurredArray = props.notBlurred.split(",")
-    if(notBlurredArray[0].match("all")) {
-      notBlurredArray = overview.submissionIds
+    let notAnonymized = ref([...overview.submissionIds])
+
+    const handleId = (...id) => {
+      if( id.length === overview.submissionIds.length) {
+        if(notAnonymized.value.length > 0) {
+          notAnonymized.value = []
+        } else {
+          notAnonymized.value = [...overview.submissionIds]
+        }
+      } else {
+          if ( notAnonymized.value.length === overview.submissionIds.length) {
+            notAnonymized.value = []
+          }
+          if (notAnonymized.value.includes(id[0])) {
+            notAnonymized.value.splice(notAnonymized.value.indexOf(id[0]), 1)
+          } else {
+            notAnonymized.value.push(id[0])
+          }
+      }
     }
 
+
     //Metrics
     let selectedMetric = ref(overview.metrics.map( () => false ))
     let selectedMetricIndex = ref(0)
@@ -90,7 +108,8 @@ export default defineComponent({
       selectedMetric,
       distributions,
       topComps,
-      notBlurredArray,
+      notAnonymized,
+      handleId,
       selectMetric
     }
   }