Skip to content

Commit

Permalink
Merge pull request #1444 from jplag/report-viewer/show-zip-name
Browse files Browse the repository at this point in the history
add zipfilename to title and overview
  • Loading branch information
sebinside authored Jan 12, 2024
2 parents d985ce7 + 93ef167 commit 256b149
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 2 deletions.
4 changes: 4 additions & 0 deletions report-viewer/src/stores/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ export interface State {

fileIdToDisplayName: Map<string, string>
submissionIdsToComparisonFileName: Map<string, Map<string, string>>
/**
* Name of the file uploaded
*/
uploadedFileName: string
}

/**
Expand Down
6 changes: 4 additions & 2 deletions report-viewer/src/stores/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ const store = defineStore('store', {
singleModeUsed: false,
// only used in single mode
singleFillRawContent: '',
fileIdToDisplayName: new Map()
fileIdToDisplayName: new Map(),
uploadedFileName: ''
},
uiState: {
useDarkMode: false,
Expand Down Expand Up @@ -125,7 +126,8 @@ const store = defineStore('store', {
zipModeUsed: false,
singleModeUsed: false,
singleFillRawContent: '',
fileIdToDisplayName: new Map()
fileIdToDisplayName: new Map(),
uploadedFileName: ''
}
},
/**
Expand Down
5 changes: 5 additions & 0 deletions report-viewer/src/views/FileUploadView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ fetch('/results.zip')
})
.catch(() => {})

document.title = 'JPlag Report Viewer'
const loadingFiles = ref(false)
type fileMethod = 'query' | 'local' | 'upload' | 'unknown'
const errors: Ref<{ error: Error; source: fileMethod }[]> = ref([])
Expand Down Expand Up @@ -162,6 +163,7 @@ async function uploadFileOnDrag(e: DragEvent) {
let dropped = e.dataTransfer?.files
try {
if (dropped?.length === 1) {
store().state.uploadedFileName = dropped[0].name
await handleFile(dropped[0])
} else {
throw new Error('Not exactly one file')
Expand All @@ -185,6 +187,7 @@ async function uploadFileThroughWindow() {
if (!file) {
return
}
store().state.uploadedFileName = file.name
handleFile(file)
}
input.click()
Expand All @@ -209,6 +212,7 @@ async function loadQueryFile(url: URL) {
* Handles click on Continue with local files.
*/
function continueWithLocal() {
store().state.uploadedFileName = 'results.zip'
store().setLoadingType({
local: true,
zip: localFiles.value === 'zip',
Expand All @@ -219,6 +223,7 @@ function continueWithLocal() {

function registerError(error: Error, source: fileMethod) {
loadingFiles.value = false
store().state.uploadedFileName = ''
errors.value.push({ error, source })
console.error(error)
}
Expand Down
3 changes: 3 additions & 0 deletions report-viewer/src/views/InformationView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
<TextInformation label="Min Token Match" class="pb-1">{{
overview.matchSensitivity
}}</TextInformation>
<TextInformation label="Result File Name">{{
store().state.uploadedFileName
}}</TextInformation>
</ScrollableComponent>
</Container>

Expand Down
5 changes: 5 additions & 0 deletions report-viewer/src/views/OverviewView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
<h2>JPlag Report</h2>
<div class="flex flex-row items-center space-x-5">
<TextInformation label="Submission Directory">{{ submissionPathValue }}</TextInformation>
<TextInformation label="Result name">{{
store().state.uploadedFileName
}}</TextInformation>
<TextInformation label="Total Submissions">{{
store().getSubmissionIds.length
}}</TextInformation>
Expand Down Expand Up @@ -139,6 +142,8 @@ const props = defineProps({
}
})

document.title = `${store().state.uploadedFileName} - JPlag Report Viewer`

const hasMoreSubmissionPaths = computed(() => props.overview.submissionFolderPath.length > 1)
const submissionPathValue = computed(() =>
hasMoreSubmissionPaths.value
Expand Down

0 comments on commit 256b149

Please sign in to comment.