Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance/add error page if overview or comparison missing #923

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
52d5247
add warning about missing comparisons
cyfml Dec 16, 2022
748a5f6
Merge branch 'enchance/back-button' into enhance/warning-if-some-comp…
cyfml Jan 11, 2023
cd2f999
Merge remote-tracking branch 'upstream/develop' into enhance/warning-…
cyfml Jan 11, 2023
1fd156a
show missing comparisons info when scrolling down
cyfml Jan 15, 2023
00be931
change warning position
cyfml Jan 15, 2023
7513bab
spotless check
cyfml Jan 15, 2023
fc81c50
add error page if overview.json can't be found
cyfml Jan 25, 2023
e627dd8
Merge remote-tracking branch 'upstream/develop' into enhance/warning-…
cyfml Jan 25, 2023
3fa11db
change tag
cyfml Jan 25, 2023
3471647
Merge remote-tracking branch 'upstream/develop' into enhance/add-erro…
cyfml Jan 25, 2023
31ddb2c
change position of warning
cyfml Jan 27, 2023
178cfc3
solve conflict
cyfml Jan 27, 2023
0b32c96
clean history
cyfml Jan 27, 2023
88e400e
solve code smell
cyfml Jan 27, 2023
b2546e1
code smell
cyfml Jan 27, 2023
288f84c
solve bad smell
cyfml Jan 27, 2023
5b4b859
spotless
cyfml Jan 27, 2023
a269723
small adjustment
cyfml Jan 27, 2023
b983fc8
pom
cyfml Jan 29, 2023
f21c9a7
add error page if comparison file is missing and error page component…
cyfml Jan 31, 2023
f0e0443
consider single file mode
cyfml Feb 4, 2023
07dad05
change layout of overview
cyfml Feb 8, 2023
42aeb2a
Merge remote-tracking branch 'upstream/develop' into enhance/warning-…
cyfml Feb 8, 2023
a7bbc5e
Merge remote-tracking branch 'upstream/develop' into enhance/warning-…
cyfml Feb 8, 2023
a547d76
Merge remote-tracking branch 'upstream/develop' into enhance/add-erro…
cyfml Feb 8, 2023
86d1667
clear store at fileupload view
cyfml Feb 8, 2023
74c13c0
refactor codes to minimum changes(keep one variable:totalComparisons …
cyfml Feb 9, 2023
460804c
code smell
cyfml Feb 9, 2023
55a9da1
compute shown comparisons based on table size
cyfml Feb 10, 2023
3affb1d
merge
cyfml Feb 10, 2023
5cccd25
solve conflict
cyfml Feb 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions report-viewer/src/components/ErrorMessage.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<template>
<h2>{{message}}</h2>
</template>

<script lang="ts">
export default {
name: "ErrorMessage",
props: {
/**
* Message of error.
*/
message: {
type: String,
required: true,
},
},
}
</script>

<style scoped>
h2 {
font-size: 24px;
color: #191919;
padding-bottom: 16px
}
</style>
41 changes: 41 additions & 0 deletions report-viewer/src/components/ErrorRouter.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<template>
<h5>
<router-link :to="to" class="back">{{routerInfo}}</router-link>
</h5>
</template>

<script>
export default {
name: "ErrorRouter",
props: {
/**
* Router of error.
*/
to: {
type: String,
required: true,
},
/**
* Info of router-link.
*/
routerInfo: {
type: String,
required: true,
},
},
}
</script>

<style scoped>
.back {
width: 200px;
height: 38px;
background: #c9141d;
line-height: 38px;
font-size: 16px;
color: #fff;
text-align: center;
display: inline-block;
border-radius: 2px
}
</style>
6 changes: 6 additions & 0 deletions report-viewer/src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {createRouter, createWebHistory, RouteRecordRaw} from "vue-router";
import OverviewView from "@/views/OverviewView.vue";
import ComparisonView from "@/views/ComparisonView.vue";
import FileUploadView from "@/views/FileUploadView.vue";
import ErrorView from "@/views/ErrorView.vue";

/**
* Router containing the navigation destinations.
Expand All @@ -24,6 +25,11 @@ const routes: Array<RouteRecordRaw> = [
component: ComparisonView,
props: true,
},
{
path: "/error",
name: "ErrorView",
component: ErrorView,
},
];

const router = createRouter({
Expand Down
13 changes: 13 additions & 0 deletions report-viewer/src/store/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,19 @@ const store = createStore<State>({
},
},
mutations: {
clearStore(){
store.replaceState({
submissionIdsToComparisonFileName: new Map<string, Map<string, string>>(),
anonymous: new Set(),
files: {},
submissions: {},
local: false,
zip: false,
single: false,
fileString: "",
fileIdToDisplayName: new Map(),
});
},
addAnonymous(state: State, id) {
for (let i = 0; i < id.length; i++) {
state.anonymous.add(id[i]);
Expand Down
34 changes: 28 additions & 6 deletions report-viewer/src/views/ComparisonView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
</template>

<script lang="ts">
import { defineComponent, ref } from "vue";
import {defineComponent, ref} from "vue";
import { generateLineCodeLink } from "@/utils/Utils";
import TextInformation from "@/components/TextInformation.vue";
import MatchTable from "@/components/MatchTable.vue";
Expand All @@ -77,6 +77,7 @@ import FilesContainer from "@/components/FilesContainer.vue";
import { useStore } from "vuex";
import { useRouter } from "vue-router";
import { Match } from "@/model/Match";
import {Comparison} from "@/model/Comparison";

export default defineComponent({
name: "ComparisonView",
Expand Down Expand Up @@ -119,15 +120,36 @@ export default defineComponent({
JSON.parse(comparisonFile)
);
} else {
console.log("Could not find comparison file."); // TODO introduce error page to navigate to
console.log("Could not find comparison file.");
router.push({
name: "ErrorView",
state: {
message: "Comparison file can't be found!",
to: "/overview",
routerInfo: "back to overview page"
}
});
}
} else if (store.state.single) {
comparison = ComparisonFactory.getComparison(
JSON.parse(store.state.fileString)
);
try {
comparison = ComparisonFactory.getComparison(
JSON.parse(store.state.fileString)
);
}catch (e){
router.push({
name: "ErrorView",
state: {
message: "Codes of matches can't be found! If you use single file mode, overview.json can only be accepted!",
to: "/",
routerInfo: "back to FileUpload page"
}
});
store.commit("clearStore");
}
}
if (!comparison) {
throw "Could not build comparison file";
comparison=new Comparison("","",0);
console.log("Could not build comparison file");
}
const filesOfFirst = ref(comparison.filesOfFirstSubmission);
const filesOfSecond = ref(comparison.filesOfSecondSubmission);
Expand Down
40 changes: 40 additions & 0 deletions report-viewer/src/views/ErrorView.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<template>
<div class="container">
<img alt="JPlag" src="@/assets/logo-nobg.png" />
<error-message :message="message"/>
<error-router :to="to" :routerInfo="routerInfo"/>
</div>
</template>

<script lang="ts">
import {defineComponent} from "vue";
import ErrorMessage from "@/components/ErrorMessage.vue";
import ErrorRouter from "@/components/ErrorRouter.vue";

export default defineComponent({
name: "OverviewErrorView",
components: {ErrorRouter, ErrorMessage},
setup() {
const message = history.state.message;
const to = history.state.to;
const routerInfo =history.state.routerInfo;
return{
message,
to,
routerInfo
}
},
});
</script>

<style scoped>
.container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
background: var(--primary-color-light);
}
</style>
1 change: 1 addition & 0 deletions report-viewer/src/views/FileUploadView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class LoadError extends Error {}
export default defineComponent({
name: "FileUploadView",
setup() {
store.commit("clearStore");
let hasLocalFile;
//Tries to detect local file. If no files detected, hides local mode from screen.
try {
Expand Down
22 changes: 19 additions & 3 deletions report-viewer/src/views/OverviewView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
</template>

<script lang="ts">
import { computed, defineComponent, Ref, ref } from "vue";
import { computed, defineComponent, onErrorCaptured, Ref, ref } from "vue";
import router from "@/router";
import TextInformation from "../components/TextInformation.vue";
import DistributionDiagram from "@/components/DistributionDiagram.vue";
Expand Down Expand Up @@ -120,7 +120,7 @@ export default defineComponent({
);
return index != undefined
? store.state.files[index]
: console.log("Could not find overview.json"); // TODO introduce error page to navigate to
: console.log("Could not find overview.json");
});

const getOverview = (): Overview => {
Expand All @@ -134,6 +134,9 @@ export default defineComponent({
router.back();
}
} else if (store.state.zip) {
if(overviewFile.value===undefined){
return new Overview([],"","",[],0,"",0,[],[],0, new Map<string, Map<string, string>>());
}
const overviewJson = JSON.parse(overviewFile.value);
temp = OverviewFactory.getOverview(overviewJson);
} else if (store.state.single) {
Expand Down Expand Up @@ -208,10 +211,23 @@ export default defineComponent({
: overview.submissionFolderPath[0];

const shownComparisons = computed(()=>{
return overview.metrics[selectedMetricIndex.value].comparisons.length;
return overview.metrics[selectedMetricIndex.value]?.comparisons.length;
});
const missingComparisons = overview.totalComparisons - shownComparisons.value;

onErrorCaptured(()=>{
router.push({
name: "ErrorView",
state: {
message: "Overview.json can't be found!",
to: "/",
routerInfo: "back to FileUpload page"
}
});
store.commit("clearStore");
return false;
});

return {
overview,
selectedMetricIndex,
Expand Down