|
@@ -1,115 +1,207 @@
|
|
|
<template>
|
|
<template>
|
|
|
-<div class="container">
|
|
|
|
|
- <div id="leftPanel">
|
|
|
|
|
- <img id="logo" src="@/assets/logo.png" alt="JPlag">
|
|
|
|
|
- <TextInformation :has-additional-info="false" value="Match Report" label=""/>
|
|
|
|
|
- <TextInformation label="First Submission:" value="324567" :has-additional-info="false"/>
|
|
|
|
|
- <TextInformation label="Second Submission:" value="789223" :has-additional-info="false"/>
|
|
|
|
|
- <TextInformation label="Match percentage:" value="75.34%" :has-additional-info="false"/>
|
|
|
|
|
- <MatchList :submission1="json.first_submission_id"
|
|
|
|
|
- :submission2="json.second_submission_id"
|
|
|
|
|
- :matches="groupedMatches"
|
|
|
|
|
- @selection-changed="selectFiles"
|
|
|
|
|
- @match-selected="selectMatch"/>
|
|
|
|
|
|
|
+ <div class="container">
|
|
|
|
|
+ <button id="show-button" :class="{hidden : !hideLeftPanel}" @click="togglePanel" title="Show sidebar">
|
|
|
|
|
+ <img src="@/assets/double_arrow_white_24dp.svg" alt="show">
|
|
|
|
|
+ </button>
|
|
|
|
|
+ <div id="sidebar" :class="{ hidden : hideLeftPanel }">
|
|
|
|
|
+ <div class="title-section">
|
|
|
|
|
+ <h1>JPlag Comparison</h1>
|
|
|
|
|
+ <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" :has-additional-info="false"/>
|
|
|
|
|
+ <TextInformation label="Submission 2" :value="id2" :has-additional-info="false"/>
|
|
|
|
|
+ <TextInformation label="Match %" :value="comparison.match_percentage" :has-additional-info="false"/>
|
|
|
|
|
+ <MatchTable :matches="comparison.allMatches" :id1="id1" :id2="id2" @match-selected="showMatch" />
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div class="files-container" id="files1">
|
|
|
|
|
+ <h1>Files of {{ id1 }}</h1>
|
|
|
|
|
+ <VueDraggableNext>
|
|
|
|
|
+ <CodePanel v-for="(file, index) in Object.keys(filesOfFirst)"
|
|
|
|
|
+ :lines="filesOfFirst[file].lines"
|
|
|
|
|
+ :title="file"
|
|
|
|
|
+ :file-index="index"
|
|
|
|
|
+ :matches="!comparison.matchesInFirstSubmission[file] ? [] : comparison.matchesInFirstSubmission[file]"
|
|
|
|
|
+ :key="file.concat(index)"
|
|
|
|
|
+ :collapse="filesOfFirst[file].collapsed"
|
|
|
|
|
+ @toggle-collapse="toggleCollapseFirst(file)"
|
|
|
|
|
+ @line-selected="showMatchInSecond"
|
|
|
|
|
+ :panel-id="1"
|
|
|
|
|
+ />
|
|
|
|
|
+ </VueDraggableNext>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div class="files-container" id="files2">
|
|
|
|
|
+ <h1>Files of {{ id2 }}</h1>
|
|
|
|
|
+ <VueDraggableNext>
|
|
|
|
|
+ <CodePanel v-for="(file, index) in Object.keys(filesOfSecond)"
|
|
|
|
|
+ :lines="filesOfSecond[file].lines"
|
|
|
|
|
+ :title="file"
|
|
|
|
|
+ :file-index="index"
|
|
|
|
|
+ :matches="!comparison.matchesInSecondSubmissions[file] ? [] : comparison.matchesInSecondSubmissions[file]"
|
|
|
|
|
+ :key="file.concat(index)"
|
|
|
|
|
+ :collapse="filesOfSecond[file].collapsed"
|
|
|
|
|
+ @toggle-collapse="toggleCollapseSecond(file)"
|
|
|
|
|
+ @line-selected="showMatchInFirst"
|
|
|
|
|
+ :panel-id="2"
|
|
|
|
|
+ />
|
|
|
|
|
+ </VueDraggableNext>
|
|
|
|
|
+ </div>
|
|
|
</div>
|
|
</div>
|
|
|
- <div id="rightPanel">
|
|
|
|
|
- <CodePanel :lines="filesOfFirst[selectedFileOfFirst]" :not-blurred="[]"/>
|
|
|
|
|
- <CodePanel :lines="filesOfSecond[selectedFileOfSecond]" :not-blurred="[]"/>
|
|
|
|
|
- </div>
|
|
|
|
|
-</div>
|
|
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
import { defineComponent, ref } from "vue";
|
|
import { defineComponent, ref } from "vue";
|
|
|
-import TextInformation from "@/components/TextInformation";
|
|
|
|
|
-import MatchList from "@/components/MatchList";
|
|
|
|
|
|
|
+import {generateLineCodeLink} from "@/utils/Utils";
|
|
|
|
|
+import { VueDraggableNext } from 'vue-draggable-next'
|
|
|
import CodePanel from "@/components/CodePanel";
|
|
import CodePanel from "@/components/CodePanel";
|
|
|
|
|
+import TextInformation from "@/components/TextInformation";
|
|
|
|
|
+import MatchTable from "@/components/MatchTable";
|
|
|
|
|
+import {ComparisonFactory} from "@/model/factories/ComparisonFactory";
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
export default defineComponent({
|
|
|
name: "ComparisonView",
|
|
name: "ComparisonView",
|
|
|
- components: {CodePanel, MatchList, TextInformation},
|
|
|
|
|
|
|
+ components: {MatchTable, TextInformation, VueDraggableNext, CodePanel},
|
|
|
props: {
|
|
props: {
|
|
|
- jsonString: {
|
|
|
|
|
- type: String
|
|
|
|
|
|
|
+ id1: {
|
|
|
|
|
+ type: String,
|
|
|
|
|
+ },
|
|
|
|
|
+ id2: {
|
|
|
|
|
+ type: String,
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
setup(props) {
|
|
setup(props) {
|
|
|
- const selectedFileOfFirst = ref([])
|
|
|
|
|
- const selectedFileOfSecond = ref([])
|
|
|
|
|
- const json = JSON.parse(props.jsonString)
|
|
|
|
|
- const filesOfFirst = json.files_of_first_submission.reduce( (acc, val) => {
|
|
|
|
|
- if(!acc[val.file_name]) {
|
|
|
|
|
- acc[val.file_name] = []
|
|
|
|
|
- }
|
|
|
|
|
- acc[val.file_name] = val.lines
|
|
|
|
|
- return acc
|
|
|
|
|
- }, {})
|
|
|
|
|
- const filesOfSecond = json.files_of_second_submission.reduce( (acc, val) => {
|
|
|
|
|
- if(!acc[val.file_name]) {
|
|
|
|
|
- acc[val.file_name] = []
|
|
|
|
|
- }
|
|
|
|
|
- acc[val.file_name] = val.lines
|
|
|
|
|
- return acc
|
|
|
|
|
- }, {})
|
|
|
|
|
-
|
|
|
|
|
- const groupedMatches = json.matches.reduce( (acc, val) => {
|
|
|
|
|
- let name = val.first_file_name + " - " + val.second_file_name
|
|
|
|
|
- if(!acc[name]) {
|
|
|
|
|
- acc[name] = []
|
|
|
|
|
- }
|
|
|
|
|
- acc[name].push(val)
|
|
|
|
|
- return acc;
|
|
|
|
|
- }, {})
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- const selectFiles = (e , s) => {
|
|
|
|
|
- let split = s.split(" - ")
|
|
|
|
|
- selectedFileOfFirst.value = split[0]
|
|
|
|
|
- selectedFileOfSecond.value = split[1]
|
|
|
|
|
|
|
+ const fileName = props.id1.concat("-").concat(props.id2)
|
|
|
|
|
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
|
|
|
+ const json = require(`../files/${fileName}.json`)
|
|
|
|
|
+ const comparison = ComparisonFactory.getComparison(json)
|
|
|
|
|
+
|
|
|
|
|
+ const filesOfFirst = ref(comparison.filesOfFirstSubmission)
|
|
|
|
|
+ const filesOfSecond = ref(comparison.filesOfSecondSubmission)
|
|
|
|
|
+
|
|
|
|
|
+ const toggleCollapseFirst = (title) => { filesOfFirst.value[title].collapsed = !filesOfFirst.value[title].collapsed }
|
|
|
|
|
+ const toggleCollapseSecond = (title) => { filesOfSecond.value[title].collapsed = !filesOfSecond.value[title].collapsed }
|
|
|
|
|
+
|
|
|
|
|
+ const showMatchInFirst = ( e, panel, file, line ) => {
|
|
|
|
|
+ if( !filesOfFirst.value[file].collapsed ) { toggleCollapseFirst(file) }
|
|
|
|
|
+ document.getElementById(generateLineCodeLink(panel, file, line)).scrollIntoView()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- const selectMatch = (e, i) => {
|
|
|
|
|
- console.log(e, i)
|
|
|
|
|
|
|
+ const showMatchInSecond = ( e, panel, file, line ) => {
|
|
|
|
|
+ if( !filesOfSecond.value[file].collapsed ) { toggleCollapseSecond(file) }
|
|
|
|
|
+ document.getElementById(generateLineCodeLink(panel, file, line)).scrollIntoView()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const showMatch = ( e, match ) => {
|
|
|
|
|
+ showMatchInFirst(e, 1, match.firstFile, match.startInFirst)
|
|
|
|
|
+ showMatchInSecond(e, 2, match.secondFile, match.startInSecond)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ const hideLeftPanel = ref(true)
|
|
|
|
|
+ const togglePanel = () => {
|
|
|
|
|
+ hideLeftPanel.value = !hideLeftPanel.value
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
return {
|
|
return {
|
|
|
- json, groupedMatches, filesOfFirst, filesOfSecond, selectedFileOfFirst, selectedFileOfSecond,
|
|
|
|
|
- selectFiles,
|
|
|
|
|
- selectMatch,
|
|
|
|
|
|
|
+ comparison,
|
|
|
|
|
+ filesOfFirst,
|
|
|
|
|
+ filesOfSecond,
|
|
|
|
|
+ hideLeftPanel,
|
|
|
|
|
+
|
|
|
|
|
+ toggleCollapseFirst,
|
|
|
|
|
+ toggleCollapseSecond,
|
|
|
|
|
+ showMatchInFirst,
|
|
|
|
|
+ showMatchInSecond,
|
|
|
|
|
+ showMatch,
|
|
|
|
|
+ togglePanel
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
<style scoped>
|
|
|
|
|
+h1 {
|
|
|
|
|
+ color: var(--on-primary-color);
|
|
|
|
|
+ text-align: center;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
.container {
|
|
.container {
|
|
|
display: flex;
|
|
display: flex;
|
|
|
align-items: stretch;
|
|
align-items: stretch;
|
|
|
|
|
+ flex-wrap: nowrap;
|
|
|
width: 100%;
|
|
width: 100%;
|
|
|
height: 100%;
|
|
height: 100%;
|
|
|
- margin: 0;
|
|
|
|
|
|
|
+ background: var(--background-color);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-#leftPanel {
|
|
|
|
|
- width: 20%;
|
|
|
|
|
- background: #FF5353;
|
|
|
|
|
|
|
+.files-container {
|
|
|
display: flex;
|
|
display: flex;
|
|
|
|
|
+ flex-wrap: nowrap;
|
|
|
flex-direction: column;
|
|
flex-direction: column;
|
|
|
- align-items: stretch;
|
|
|
|
|
- padding: 1%;
|
|
|
|
|
|
|
+ padding-top: 1%;
|
|
|
|
|
+ width: 100%;
|
|
|
|
|
+ overflow: auto;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+.title-section {
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ justify-content: space-between;
|
|
|
|
|
+}
|
|
|
|
|
+.title-section > h1 {
|
|
|
|
|
+ text-align: left !important;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-#rightPanel {
|
|
|
|
|
- width: 80%;
|
|
|
|
|
- background: #ECECEC;
|
|
|
|
|
|
|
+.hidden {
|
|
|
|
|
+ display: none !important;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+#sidebar {
|
|
|
display: flex;
|
|
display: flex;
|
|
|
|
|
+ flex-direction: column;
|
|
|
flex-wrap: nowrap;
|
|
flex-wrap: nowrap;
|
|
|
- justify-content: stretch;
|
|
|
|
|
|
|
+ width: 60%;
|
|
|
|
|
+ background: var(--primary-color-light);
|
|
|
padding: 1%;
|
|
padding: 1%;
|
|
|
|
|
+ border-top-right-radius: 10px;
|
|
|
|
|
+ border-bottom-right-radius: 10px;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-#logo {
|
|
|
|
|
- width: 60%;
|
|
|
|
|
- height: 20%;
|
|
|
|
|
- margin-bottom: 5%;
|
|
|
|
|
|
|
+#hide-button {
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ flex-direction: column;
|
|
|
|
|
+ background: transparent;
|
|
|
|
|
+ border-radius: 10px;
|
|
|
|
|
+ height: max-content;
|
|
|
|
|
+ border: none;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+#hide-button:hover {
|
|
|
|
|
+ cursor: pointer;
|
|
|
|
|
+ background: var(--primary-color-dark);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+#show-button {
|
|
|
|
|
+ position: absolute;
|
|
|
|
|
+ z-index: 1000;
|
|
|
|
|
+ left: 0;
|
|
|
|
|
+ background: var(--secondary-color);
|
|
|
|
|
+ border: none;
|
|
|
|
|
+ border-top-right-radius: 10px;
|
|
|
|
|
+ border-bottom-right-radius: 10px;
|
|
|
|
|
+ height: 100%;
|
|
|
|
|
+ width: 1%;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+#show-button img {
|
|
|
|
|
+ display: none;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+#show-button:hover {
|
|
|
|
|
+ cursor: pointer;
|
|
|
|
|
+ width: 3%;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+#show-button:hover img {
|
|
|
|
|
+ display: block;
|
|
|
}
|
|
}
|
|
|
</style>
|
|
</style>
|