Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ COPY --from=build-stage /app/dist /usr/share/nginx/html
COPY docker/nginx/*.conf.template /etc/nginx/templates/
EXPOSE 80

ENV MORE_BACKEND_URL=https://studymanager.more.redlink.io/
ENV VITE_MORE_BACKEND_URL=https://studymanager.more.redlink.io/

CMD ["nginx", "-g", "daemon off;"]
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ Make sure that the enum structure within `openapi/StudyManagerApi.yml` is
Otherwise, the generated enums will be duplicated, leading to errors.

## Testing Environment with Vitest

To test the frontend with a deployed backend server, you have to set environment variable `VITE_MORE_BACKEND_URL` to the desired backend.
For testing with a local backend use `npm run dev:local`

Run

```
Expand Down
6 changes: 3 additions & 3 deletions docker/nginx/default.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ server {

# Proxy API and other backend services
location /api {
proxy_pass ${MORE_BACKEND_URL}/api;
proxy_pass ${VITE_MORE_BACKEND_URL}/api;
}
location /login {
proxy_pass ${MORE_BACKEND_URL}/login;
proxy_pass ${VITE_MORE_BACKEND_URL}/login;
}
location /logout {
proxy_pass ${MORE_BACKEND_URL}/logout;
proxy_pass ${VITE_MORE_BACKEND_URL}/logout;
}

}
1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default tseslint.config(
'docs',
'src/generated-sources',
'**/*.gitignore',
'vite.config.ts',
],
},
{
Expand Down
1,258 changes: 623 additions & 635 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ const uiConfig = await uiConfigApi
return {
title: 'Unknown Legacy Backend',
auth: {
server: 'https://auth.more.redlink.io',
realm: 'Auth-Client-Test',
clientId: 'oauth2-pkce-client',
server: 'https://auth.more.redlink.io/',
realm: 'UMM',
clientId: 'oauth2-umm-client',
},
} as FrontendConfiguration;
});
Expand All @@ -88,7 +88,7 @@ const authService = new AuthService({
});
const loggedIn = await authService.init();
if (!loggedIn) {
window.location.reload();
// window.location.reload();
}

axios.interceptors.request.use(
Expand Down
62 changes: 37 additions & 25 deletions src/stores/studyStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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`;
Copy link
Member

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-Disposition Header setzten würde. z.B.

Content-Disposition: attachment; filename="study_data_study-{id}.json"

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

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
Copy link
Member

Choose a reason for hiding this comment

The 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.

  • Den ersten für das Refactoring - auch wenn da dann kein Issue mit dabei ist.
  • Den zweiten mit nur den Fix für den Bug im Issue!

So schaue ich mir einen MR über 9 Files mit hunderten Zeilen an Änderungen an, aber der eigentliche fix sind nur 20 Zeilen.

Copy link
Author

Choose a reason for hiding this comment

The 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) => {
Expand All @@ -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(
Expand All @@ -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
Expand Down Expand Up @@ -257,6 +269,6 @@ export const useStudyStore = defineStore('study', () => {
auditLogMetadata,
auditLogEntries,
getAuditLogMetadata,
exportAuditLog
exportAuditLog,
};
});
79 changes: 39 additions & 40 deletions vite.config.ts
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/**'
],
},
},
},
};
});
22 changes: 22 additions & 0 deletions vitest.config.ts
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/**'],
},
},
});