-
Notifications
You must be signed in to change notification settings - Fork 0
#140: Fixed a bug that hindered download of large amounts of study data #6
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,7 @@ | |
| */ | ||
| import { computed, ComputedRef, ref, Ref } from 'vue'; | ||
| import { defineStore } from 'pinia'; | ||
| import { AuditLogMetadata, AuditLogEntry, Study, StudyRole, StudyStatus, DataExportInner } from '@gs'; | ||
| import { AuditLogEntry, AuditLogMetadata, DataExportInner, Study, StudyRole, StudyStatus } from '@gs'; | ||
| import { useAuditLogApi, useImportExportApi, useStudiesApi } from '../composable/useApi'; | ||
| import { AxiosError, AxiosResponse } from 'axios'; | ||
| import { useErrorHandling } from '../composable/useErrorHandling'; | ||
|
|
@@ -164,25 +164,35 @@ export const useStudyStore = defineStore('study', () => { | |
| ) | ||
| .then(async (rs) => { | ||
| if (rs && rs?.data?.token) { | ||
| await importExportApi.exportStudyData( | ||
| studyId, | ||
| rs.data.token, | ||
| studyGroupId, | ||
| participantId, | ||
| observationId, | ||
| from, | ||
| to | ||
| ).then((response) => { | ||
| window.open(response.headers.location); | ||
| const filename: string = 'study_data_' + studyId + '.json'; | ||
| downloadJSON(filename, response.data); | ||
| await importExportApi | ||
| .exportStudyData( | ||
| studyId, | ||
| rs.data.token, | ||
| studyGroupId, | ||
| participantId, | ||
| observationId, | ||
| from, | ||
| to, | ||
| { responseType: 'blob' }, | ||
| ) | ||
| .then((response) => { | ||
| const blob = response.data as unknown as Blob; | ||
|
|
||
| }).catch((e: AxiosError) => { | ||
| handleIndividualError( | ||
| e, | ||
| 'cannot export data despite of existing download token', | ||
| ); | ||
| } ); | ||
| const url = URL.createObjectURL(blob); | ||
| const link = document.createElement('a'); | ||
| link.href = url; | ||
| link.download = `study_data_${studyId}.json`; | ||
| document.body.appendChild(link); | ||
| link.click(); | ||
| document.body.removeChild(link); | ||
| URL.revokeObjectURL(url); | ||
| }) | ||
| .catch((e: AxiosError) => { | ||
| handleIndividualError( | ||
| e, | ||
| 'cannot export data despite of existing download token', | ||
| ); | ||
| }); | ||
|
Comment on lines
+167
to
+195
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Soviel isch sehe ist das der Fix für den Bug. Alle anderen Änderungen haben nichts mit dem #6 zu tun, oder? Es wäre echt besser, wenn Du einfach 2 Merge Requests aufmachst.
So schaue ich mir einen MR über 9 Files mit hunderten Zeilen an Änderungen an, aber der eigentliche fix sind nur 20 Zeilen.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ja es hat sonst leider bei mir immer Probleme gemacht, weswegen ich leider alles andere auch ändern musste. |
||
| } | ||
| }) | ||
| .catch((e: AxiosError) => { | ||
|
|
@@ -194,11 +204,12 @@ export const useStudyStore = defineStore('study', () => { | |
| } | ||
|
|
||
| async function exportAuditLog(studyId: number): Promise<void> { | ||
| await auditLogApi.exportAuditLog(studyId) | ||
| .then((response:AxiosResponse<AuditLogEntry[]>) => { | ||
| await auditLogApi | ||
| .exportAuditLog(studyId) | ||
| .then((response: AxiosResponse<AuditLogEntry[]>) => { | ||
| window.open(response.headers.location); | ||
| const filename: string = `study_auditlog_${studyId}.json`; | ||
| downloadJSON(filename, response.data) | ||
| downloadJSON(filename, response.data); | ||
| }) | ||
| .catch((e: AxiosError) => { | ||
| handleIndividualError( | ||
|
|
@@ -225,8 +236,9 @@ export const useStudyStore = defineStore('study', () => { | |
| } | ||
|
|
||
| async function getAuditLogMetadata(studyId: number): Promise<void> { | ||
| auditLogMetadata.value = await auditLogApi.getAuditLogMetadata(studyId) | ||
| .then((response: AxiosResponse) => response.data) | ||
| auditLogMetadata.value = await auditLogApi | ||
| .getAuditLogMetadata(studyId) | ||
| .then((response: AxiosResponse) => response.data); | ||
| } | ||
|
|
||
| // Getters | ||
|
|
@@ -257,6 +269,6 @@ export const useStudyStore = defineStore('study', () => { | |
| auditLogMetadata, | ||
| auditLogEntries, | ||
| getAuditLogMetadata, | ||
| exportAuditLog | ||
| exportAuditLog, | ||
| }; | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,49 +1,48 @@ | ||
| /// <reference types="vitest" /> | ||
| import { defineConfig } from 'vite'; | ||
| import { defineConfig, loadEnv } from 'vite'; | ||
| import vue from '@vitejs/plugin-vue'; | ||
| import { resolve } from 'path'; | ||
|
|
||
|
|
||
| // https://vitejs.dev/config/ | ||
| export default defineConfig({ | ||
| plugins: [vue()], | ||
| build: { | ||
| //TODO maybe remove on cleanup session | ||
| target: 'esnext', | ||
| }, | ||
| define: { | ||
| __APP_VERSION__: JSON.stringify(process.env.npm_package_version), | ||
| __BUILD_DATE__: JSON.stringify(new Date().toISOString()), | ||
| __BUILD_BRANCH__: JSON.stringify(process.env.VITE_GIT_BRANCH), | ||
| __BUILD_REVISION__: JSON.stringify(process.env.VITE_GIT_REVISION), | ||
| }, | ||
| resolve: { | ||
| alias: { | ||
| '@gs': resolve(__dirname, './src/generated-sources'), | ||
| } | ||
| }, | ||
| server: { | ||
| port: 3000, | ||
| proxy: { | ||
| '/api': { | ||
| target: process.env.VITE_LOCAL_BACKEND | ||
| ? 'http://localhost:8080/api' | ||
| : 'https://studymanager.platform-test.more.redlink.io/api', | ||
| changeOrigin: true, | ||
| secure: false, | ||
| rewrite: (path) => { | ||
| return path.replace(/^\/api/, ''); | ||
| }, | ||
| export default defineConfig(({ mode }) => { | ||
| const env = loadEnv(mode, process.cwd(), ''); | ||
| return { | ||
| plugins: [vue()], | ||
| build: { | ||
| //TODO maybe remove on cleanup session | ||
| target: 'esnext', | ||
| }, | ||
| define: { | ||
| __APP_VERSION__: JSON.stringify(process.env.npm_package_version), | ||
| __BUILD_DATE__: JSON.stringify(new Date().toISOString()), | ||
| __BUILD_BRANCH__: JSON.stringify(process.env.VITE_GIT_BRANCH), | ||
| __BUILD_REVISION__: JSON.stringify(process.env.VITE_GIT_REVISION), | ||
| }, | ||
| resolve: { | ||
| alias: { | ||
| '@gs': resolve(__dirname, './src/generated-sources'), | ||
| }, | ||
| }, | ||
| }, | ||
| test: { | ||
| include: ['tests/**/*.spec.ts'], | ||
| environment: 'jsdom', | ||
| coverage: { | ||
| provider: 'v8', | ||
| reportsDirectory: 'tests/coverage', | ||
| exclude: ['src/generated-sources/**'], | ||
| server: { | ||
| port: 3000, | ||
| proxy: { | ||
| '/api': { | ||
| target: process.env.VITE_LOCAL_BACKEND | ||
| ? 'http://localhost:8080/api' | ||
| : env.VITE_MORE_BACKEND_URL, | ||
| changeOrigin: true, | ||
| secure: false, | ||
| rewrite: (path) => path.replace(/^\/api/, ''), | ||
| }, | ||
| }, | ||
| watch: { | ||
| ignored: [ | ||
| '**/tests/coverage/**', | ||
| '**/node_modules/**', | ||
| '**/dist/**', | ||
| '**/src/generated/**', '**/src/generated-sources/**', '**/openapi/**' | ||
| ], | ||
| }, | ||
| }, | ||
| }, | ||
| }; | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| // vitest.config.ts | ||
| import { defineConfig } from 'vitest/config'; | ||
| import vue from '@vitejs/plugin-vue'; | ||
| import { resolve } from 'path'; | ||
|
|
||
| export default defineConfig({ | ||
| plugins: [vue()], | ||
| resolve: { | ||
| alias: { | ||
| '@gs': resolve(__dirname, './src/generated-sources'), | ||
| }, | ||
| }, | ||
| test: { | ||
| include: ['tests/**/*.spec.ts'], | ||
| environment: 'jsdom', | ||
| coverage: { | ||
| provider: 'v8', | ||
| reportsDirectory: 'tests/coverage', | ||
| exclude: ['src/generated-sources/**'], | ||
| }, | ||
| }, | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wäre es nicht besser, wenn das Webservice schon einen passenden
Content-DispositionHeader setzten würde. z.B.Würde in den Namen auch gleich noch andere Filter wie StudyGroup oder Participant sowie die Time-Range mit reincodieren (am Backend). Dieser Header sollte dann den Browser dazu veranlassen das Ergebnis direkt in einem File zu speichern