|
@@ -3,102 +3,154 @@
|
|
|
-->
|
|
-->
|
|
|
<template>
|
|
<template>
|
|
|
<div class="container">
|
|
<div class="container">
|
|
|
- <button id="show-button" :class="{hidden : !hideLeftPanel}" title="Show sidebar" @click="togglePanel">
|
|
|
|
|
- <img alt="show" src="@/assets/double_arrow_black_24dp.svg">
|
|
|
|
|
|
|
+ <button
|
|
|
|
|
+ id="show-button"
|
|
|
|
|
+ :class="{ hidden: !hideLeftPanel }"
|
|
|
|
|
+ title="Show sidebar"
|
|
|
|
|
+ @click="togglePanel"
|
|
|
|
|
+ >
|
|
|
|
|
+ <img alt="show" src="@/assets/double_arrow_black_24dp.svg" />
|
|
|
</button>
|
|
</button>
|
|
|
- <div id="sidebar" :class="{ hidden : hideLeftPanel }">
|
|
|
|
|
|
|
+ <div id="sidebar" :class="{ hidden: hideLeftPanel }">
|
|
|
<div class="title-section">
|
|
<div class="title-section">
|
|
|
<h1>JPlag Comparison</h1>
|
|
<h1>JPlag Comparison</h1>
|
|
|
<button id="hide-button" title="Hide sidebar" @click="togglePanel">
|
|
<button id="hide-button" title="Hide sidebar" @click="togglePanel">
|
|
|
- <img alt="hide" src="@/assets/keyboard_double_arrow_left_black_24dp.svg"></button>
|
|
|
|
|
|
|
+ <img
|
|
|
|
|
+ alt="hide"
|
|
|
|
|
+ src="@/assets/keyboard_double_arrow_left_black_24dp.svg"
|
|
|
|
|
+ />
|
|
|
|
|
+ </button>
|
|
|
</div>
|
|
</div>
|
|
|
- <TextInformation :anonymous="store.state.anonymous.has(firstId)" :value="firstId" label="Submission 1"/>
|
|
|
|
|
- <TextInformation :anonymous="store.state.anonymous.has(secondId)" :value="secondId" label="Submission 2"/>
|
|
|
|
|
- <TextInformation :value="comparison.match_percentage" label="Match %"/>
|
|
|
|
|
- <MatchTable :id1="firstId" :id2="secondId" :matches="comparison.allMatches" @match-selected="showMatch"/>
|
|
|
|
|
|
|
+ <TextInformation
|
|
|
|
|
+ :anonymous="store.state.anonymous.has(firstId)"
|
|
|
|
|
+ :value="firstId"
|
|
|
|
|
+ label="Submission 1"
|
|
|
|
|
+ />
|
|
|
|
|
+ <TextInformation
|
|
|
|
|
+ :anonymous="store.state.anonymous.has(secondId)"
|
|
|
|
|
+ :value="secondId"
|
|
|
|
|
+ label="Submission 2"
|
|
|
|
|
+ />
|
|
|
|
|
+ <TextInformation :value="comparison.match_percentage" label="Match %" />
|
|
|
|
|
+ <MatchTable
|
|
|
|
|
+ :id1="firstId"
|
|
|
|
|
+ :id2="secondId"
|
|
|
|
|
+ :matches="comparison.allMatches"
|
|
|
|
|
+ @match-selected="showMatch"
|
|
|
|
|
+ />
|
|
|
</div>
|
|
</div>
|
|
|
- <FilesContainer :container-id="1" :files="filesOfFirst" :matches="comparison.matchesInFirstSubmission"
|
|
|
|
|
- files-owner="Submission 1"
|
|
|
|
|
- @toggle-collapse="toggleCollapseFirst"
|
|
|
|
|
- @line-selected="showMatchInSecond"/>
|
|
|
|
|
- <FilesContainer :container-id="2" :files="filesOfSecond" :matches="comparison.matchesInSecondSubmissions"
|
|
|
|
|
- files-owner="Submission 2"
|
|
|
|
|
- @toggle-collapse="toggleCollapseSecond"
|
|
|
|
|
- @line-selected="showMatchInFirst"/>
|
|
|
|
|
|
|
+ <FilesContainer
|
|
|
|
|
+ :container-id="1"
|
|
|
|
|
+ :files="filesOfFirst"
|
|
|
|
|
+ :matches="comparison.matchesInFirstSubmission"
|
|
|
|
|
+ files-owner="Submission 1"
|
|
|
|
|
+ @toggle-collapse="toggleCollapseFirst"
|
|
|
|
|
+ @line-selected="showMatchInSecond"
|
|
|
|
|
+ />
|
|
|
|
|
+ <FilesContainer
|
|
|
|
|
+ :container-id="2"
|
|
|
|
|
+ :files="filesOfSecond"
|
|
|
|
|
+ :matches="comparison.matchesInSecondSubmissions"
|
|
|
|
|
+ files-owner="Submission 2"
|
|
|
|
|
+ @toggle-collapse="toggleCollapseSecond"
|
|
|
|
|
+ @line-selected="showMatchInFirst"
|
|
|
|
|
+ />
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
-import {defineComponent, ref} from "vue";
|
|
|
|
|
-import {generateLineCodeLink} from "@/utils/Utils";
|
|
|
|
|
-import store from "@/store/store";
|
|
|
|
|
-import router from "@/router";
|
|
|
|
|
|
|
+import { defineComponent, ref } from "vue";
|
|
|
|
|
+import { generateLineCodeLink } from "@/utils/Utils";
|
|
|
import TextInformation from "@/components/TextInformation";
|
|
import TextInformation from "@/components/TextInformation";
|
|
|
import MatchTable from "@/components/MatchTable";
|
|
import MatchTable from "@/components/MatchTable";
|
|
|
-import {ComparisonFactory} from "@/model/factories/ComparisonFactory";
|
|
|
|
|
|
|
+import { ComparisonFactory } from "@/model/factories/ComparisonFactory";
|
|
|
import FilesContainer from "@/components/FilesContainer";
|
|
import FilesContainer from "@/components/FilesContainer";
|
|
|
|
|
+import { useStore } from "vuex";
|
|
|
|
|
+import { useRouter } from "vue-router";
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
export default defineComponent({
|
|
|
name: "ComparisonView",
|
|
name: "ComparisonView",
|
|
|
- components: {FilesContainer, MatchTable, TextInformation},
|
|
|
|
|
|
|
+ components: { FilesContainer, MatchTable, TextInformation },
|
|
|
props: {
|
|
props: {
|
|
|
firstId: {
|
|
firstId: {
|
|
|
type: String,
|
|
type: String,
|
|
|
|
|
+ required: true,
|
|
|
},
|
|
},
|
|
|
secondId: {
|
|
secondId: {
|
|
|
type: String,
|
|
type: String,
|
|
|
|
|
+ required: true,
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
setup(props) {
|
|
setup(props) {
|
|
|
|
|
+ const store = useStore();
|
|
|
|
|
+ const router = useRouter();
|
|
|
/**
|
|
/**
|
|
|
* 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 fileName1 = props.firstId.concat("-").concat(props.secondId)
|
|
|
|
|
- const fileName2 = props.firstId.concat("-").concat(props.secondId)
|
|
|
|
|
|
|
+ const fileName1 = props.firstId.concat("-").concat(props.secondId);
|
|
|
|
|
+ const fileName2 = props.firstId.concat("-").concat(props.secondId);
|
|
|
|
|
|
|
|
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
|
|
|
|
|
- comparison = ComparisonFactory.getComparison(require(`../files/${fileName1}.json`))
|
|
|
|
|
|
|
+ comparison = ComparisonFactory.getComparison(
|
|
|
|
|
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
|
|
|
+ require(`../files/${fileName1}.json`)
|
|
|
|
|
+ );
|
|
|
} catch (exception) {
|
|
} catch (exception) {
|
|
|
try {
|
|
try {
|
|
|
- // eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
|
|
|
- comparison = ComparisonFactory.getComparison(require(`../files/${fileName2}.json`))
|
|
|
|
|
|
|
+ comparison = ComparisonFactory.getComparison(
|
|
|
|
|
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
|
|
|
+ require(`../files/${fileName2}.json`)
|
|
|
|
|
+ );
|
|
|
} catch (exception) {
|
|
} catch (exception) {
|
|
|
- router.back()
|
|
|
|
|
|
|
+ router.back();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
} else if (store.state.zip) {
|
|
} else if (store.state.zip) {
|
|
|
- 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")]))
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ const getComparisonFileFor = (id1, id2) => {
|
|
|
|
|
+ const index = Object.keys(store.state.files).filter((name) =>
|
|
|
|
|
+ name.endsWith(
|
|
|
|
|
+ id1.concat("-").concat(id2).concat(".json") ||
|
|
|
|
|
+ name.endsWith(id2.concat("-").concat(id1).concat(".json"))
|
|
|
|
|
+ )
|
|
|
|
|
+ )[0];
|
|
|
|
|
+ return store.state.files[index];
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
|
|
+ let comparisonFile = getComparisonFileFor(props.firstId, props.secondId);
|
|
|
|
|
+ if (comparisonFile) {
|
|
|
|
|
+ comparison = ComparisonFactory.getComparison(
|
|
|
|
|
+ JSON.parse(comparisonFile)
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
} 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)
|
|
|
|
|
+ );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- const filesOfFirst = ref(comparison.filesOfFirstSubmission)
|
|
|
|
|
- const filesOfSecond = ref(comparison.filesOfSecondSubmission)
|
|
|
|
|
|
|
+ const filesOfFirst = ref(comparison.filesOfFirstSubmission);
|
|
|
|
|
+ const filesOfSecond = ref(comparison.filesOfSecondSubmission);
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Collapses a file in the first files container.
|
|
* Collapses a file in the first files container.
|
|
|
* @param title
|
|
* @param title
|
|
|
*/
|
|
*/
|
|
|
const toggleCollapseFirst = (title) => {
|
|
const toggleCollapseFirst = (title) => {
|
|
|
- filesOfFirst.value[title].collapsed = !filesOfFirst.value[title].collapsed
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ filesOfFirst.value[title].collapsed =
|
|
|
|
|
+ !filesOfFirst.value[title].collapsed;
|
|
|
|
|
+ };
|
|
|
/**
|
|
/**
|
|
|
* Collapses a file in the second files container.
|
|
* Collapses a file in the second files container.
|
|
|
* @param title
|
|
* @param title
|
|
|
*/
|
|
*/
|
|
|
const toggleCollapseSecond = (title) => {
|
|
const toggleCollapseSecond = (title) => {
|
|
|
- filesOfSecond.value[title].collapsed = !filesOfSecond.value[title].collapsed
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ filesOfSecond.value[title].collapsed =
|
|
|
|
|
+ !filesOfSecond.value[title].collapsed;
|
|
|
|
|
+ };
|
|
|
/**
|
|
/**
|
|
|
* Shows a match in the first files container
|
|
* Shows a match in the first files container
|
|
|
* @param e
|
|
* @param e
|
|
@@ -108,10 +160,12 @@ export default defineComponent({
|
|
|
*/
|
|
*/
|
|
|
const showMatchInFirst = (e, panel, file, line) => {
|
|
const showMatchInFirst = (e, panel, file, line) => {
|
|
|
if (!filesOfFirst.value[file].collapsed) {
|
|
if (!filesOfFirst.value[file].collapsed) {
|
|
|
- toggleCollapseFirst(file)
|
|
|
|
|
|
|
+ toggleCollapseFirst(file);
|
|
|
}
|
|
}
|
|
|
- document.getElementById(generateLineCodeLink(panel, file, line)).scrollIntoView()
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ document
|
|
|
|
|
+ .getElementById(generateLineCodeLink(panel, file, line))
|
|
|
|
|
+ .scrollIntoView();
|
|
|
|
|
+ };
|
|
|
/**
|
|
/**
|
|
|
* Shows a match in the second files container.
|
|
* Shows a match in the second files container.
|
|
|
* @param e
|
|
* @param e
|
|
@@ -121,22 +175,23 @@ export default defineComponent({
|
|
|
*/
|
|
*/
|
|
|
const showMatchInSecond = (e, panel, file, line) => {
|
|
const showMatchInSecond = (e, panel, file, line) => {
|
|
|
if (!filesOfSecond.value[file].collapsed) {
|
|
if (!filesOfSecond.value[file].collapsed) {
|
|
|
- toggleCollapseSecond(file)
|
|
|
|
|
|
|
+ toggleCollapseSecond(file);
|
|
|
}
|
|
}
|
|
|
- document.getElementById(generateLineCodeLink(panel, file, line)).scrollIntoView()
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ document
|
|
|
|
|
+ .getElementById(generateLineCodeLink(panel, file, line))
|
|
|
|
|
+ .scrollIntoView();
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
const showMatch = (e, match) => {
|
|
const showMatch = (e, match) => {
|
|
|
- showMatchInFirst(e, 1, match.firstFile, match.startInFirst)
|
|
|
|
|
- showMatchInSecond(e, 2, match.secondFile, match.startInSecond)
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+ showMatchInFirst(e, 1, match.firstFile, match.startInFirst);
|
|
|
|
|
+ showMatchInSecond(e, 2, match.secondFile, match.startInSecond);
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
//Left panel
|
|
//Left panel
|
|
|
- const hideLeftPanel = ref(true)
|
|
|
|
|
|
|
+ const hideLeftPanel = ref(true);
|
|
|
const togglePanel = () => {
|
|
const togglePanel = () => {
|
|
|
- hideLeftPanel.value = !hideLeftPanel.value
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ hideLeftPanel.value = !hideLeftPanel.value;
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
return {
|
|
return {
|
|
|
comparison,
|
|
comparison,
|
|
@@ -151,10 +206,10 @@ export default defineComponent({
|
|
|
showMatch,
|
|
showMatch,
|
|
|
togglePanel,
|
|
togglePanel,
|
|
|
|
|
|
|
|
- store
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-})
|
|
|
|
|
|
|
+ store,
|
|
|
|
|
+ };
|
|
|
|
|
+ },
|
|
|
|
|
+});
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
<style scoped>
|
|
@@ -234,4 +289,4 @@ h1 {
|
|
|
#show-button:hover img {
|
|
#show-button:hover img {
|
|
|
display: block;
|
|
display: block;
|
|
|
}
|
|
}
|
|
|
-</style>
|
|
|
|
|
|
|
+</style>
|