Skip to content

Commit ad664c6

Browse files
authored
Merge pull request #1492 from jplag/report-viewer/fix-single-upload
Remove comparison single file upload
2 parents 22c3053 + 1787f35 commit ad664c6

File tree

4 files changed

+12
-27
lines changed

4 files changed

+12
-27
lines changed

report-viewer/src/utils/fileHandling/FileHandler.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ export abstract class FileHandler {
66
* Loads the content of the given file and stores it in the store.
77
* @param file File to handle
88
*/
9-
public abstract handleFile(file: Blob): Promise<any>
9+
public abstract handleFile(file: Blob): Promise<void>
1010
}

report-viewer/src/utils/fileHandling/JsonFileHandler.ts

+3-9
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,13 @@ import { FileHandler } from './FileHandler'
55
* Class for handling single json files.
66
*/
77
export class JsonFileHandler extends FileHandler {
8-
public async handleFile(
9-
file: Blob
10-
): Promise<{ fileType: 'overview' } | { fileType: 'comparison'; id1: string; id2: string }> {
8+
public async handleFile(file: Blob) {
119
const content = await file.text()
1210
const json = JSON.parse(content)
1311

1412
store().setSingleFileRawContent(content)
15-
if (json['submission_folder_path']) {
16-
return { fileType: 'overview' }
17-
} else if (json['id1'] && json['id2']) {
18-
return { fileType: 'comparison', id1: json['id1'], id2: json['id2'] }
19-
} else {
20-
throw new Error(`Invalid JSON: ${json}`)
13+
if (!json['submission_folder_path']) {
14+
throw new Error(`Invalid JSON: File is not an overview file.`)
2115
}
2216
}
2317
}

report-viewer/src/utils/fileHandling/ZipFileHandler.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { FileHandler } from './FileHandler'
77
* Class for handling zip files.
88
*/
99
export class ZipFileHandler extends FileHandler {
10-
public async handleFile(file: Blob): Promise<void> {
10+
public async handleFile(file: Blob) {
1111
console.log('Start handling zip file and storing necessary data...')
1212
return jszip.loadAsync(file).then(async (zip) => {
1313
for (const originalFileName of Object.keys(zip.files)) {

report-viewer/src/views/FileUploadView.vue

+7-16
Original file line numberDiff line numberDiff line change
@@ -107,32 +107,23 @@ function navigateToOverview() {
107107
})
108108
}
109109

110-
function navigateToComparisonView(firstId: string, secondId: string) {
111-
router.push({
112-
name: 'ComparisonView',
113-
params: {
114-
firstId,
115-
secondId
116-
}
117-
})
118-
}
119-
120110
/**
121111
* Handles a json file on drop. It read the file and passes the file string to next window.
122112
* @param file The json file to handle
123113
*/
124114
async function handleJsonFile(file: Blob) {
115+
try {
116+
await new JsonFileHandler().handleFile(file)
117+
} catch (e) {
118+
registerError(e as Error, 'upload')
119+
return
120+
}
125121
store().setLoadingType({
126122
local: false,
127123
zip: false,
128124
single: true
129125
})
130-
const fileContentType = await new JsonFileHandler().handleFile(file)
131-
if (fileContentType.fileType === 'overview') {
132-
navigateToOverview()
133-
} else if (fileContentType.fileType === 'comparison') {
134-
navigateToComparisonView(fileContentType.id1, fileContentType.id2)
135-
}
126+
navigateToOverview()
136127
}
137128

138129
/**

0 commit comments

Comments
 (0)