From 918753c38bbcd749168a539fe88a5ff79b9dddd5 Mon Sep 17 00:00:00 2001 From: Fabian Emilius Date: Thu, 26 Sep 2024 20:38:58 +0200 Subject: [PATCH] Add task for scientific writing --- .github/workflows/deploy_docker.yml | 2 ++ .../AuthenticatedArea/AuthenticatedArea.tsx | 5 +-- .../MyTasksSection/MyTasksSection.tsx | 12 +++++-- client/src/requests/handler.ts | 2 +- client/src/requests/payloads/application.ts | 9 ----- docker-compose.prod.yml | 1 + docs/CONFIGURATION.md | 1 + .../ls1/cron/ApplicationReminder.java | 2 +- .../ls1/service/DashboardService.java | 36 +++++++++++++------ server/src/main/resources/application.yml | 1 + 10 files changed, 46 insertions(+), 25 deletions(-) delete mode 100644 client/src/requests/payloads/application.ts diff --git a/.github/workflows/deploy_docker.yml b/.github/workflows/deploy_docker.yml index f82c0bca..d9d413c2 100644 --- a/.github/workflows/deploy_docker.yml +++ b/.github/workflows/deploy_docker.yml @@ -115,6 +115,8 @@ jobs: echo "GENDERS=${{ vars.GENDERS }}" >> .env.prod echo "LANGUAGES=${{ vars.LANGUAGES }}" >> .env.prod echo "CUSTOM_DATA=${{ vars.CUSTOM_DATA }}" >> .env.prod + + echo "SCIENTIFIC_WRITING_GUIDE=${{ vars.SCIENTIFIC_WRITING_GUIDE }}" >> .env.prod echo "MAIL_SENDER=${{ vars.MAIL_SENDER }}" >> .env.prod echo "MAIL_SIGNATURE=${{ vars.MAIL_SIGNATURE }}" >> .env.prod diff --git a/client/src/app/layout/AuthenticatedArea/AuthenticatedArea.tsx b/client/src/app/layout/AuthenticatedArea/AuthenticatedArea.tsx index 530068d8..dd09b986 100644 --- a/client/src/app/layout/AuthenticatedArea/AuthenticatedArea.tsx +++ b/client/src/app/layout/AuthenticatedArea/AuthenticatedArea.tsx @@ -11,7 +11,7 @@ import { Tooltip, } from '@mantine/core' import * as classes from './AuthenticatedArea.module.css' -import { Link, useLocation } from 'react-router-dom' +import { Link, useLocation, useNavigate } from 'react-router-dom' import { useDebouncedValue, useDisclosure } from '@mantine/hooks' import { CaretDoubleLeft, @@ -80,6 +80,7 @@ const AuthenticatedArea = (props: PropsWithChildren) => requiredGroups, } = props + const navigate = useNavigate() const [opened, { toggle, close }] = useDisclosure() const minimizeAnimationDuration = 200 @@ -154,7 +155,7 @@ const AuthenticatedArea = (props: PropsWithChildren) => {!minimized && ( - + navigate('/')}> ThesisTrack diff --git a/client/src/pages/DashboardPage/components/MyTasksSection/MyTasksSection.tsx b/client/src/pages/DashboardPage/components/MyTasksSection/MyTasksSection.tsx index 778dbd51..450e0c67 100644 --- a/client/src/pages/DashboardPage/components/MyTasksSection/MyTasksSection.tsx +++ b/client/src/pages/DashboardPage/components/MyTasksSection/MyTasksSection.tsx @@ -40,6 +40,14 @@ const MyTasksSection = () => { return null } + const redirectTask = (task: ITask) => { + if (task.link.startsWith('http')) { + window.location.replace(task.link) + } else { + navigate(task.link) + } + } + return ( My Tasks @@ -63,7 +71,7 @@ const MyTasksSection = () => { render: (record) => (
e.stopPropagation()} wrap='nowrap'> - navigate(record.link)}> + redirectTask(record)}> @@ -71,7 +79,7 @@ const MyTasksSection = () => { ), }, ]} - onRowClick={({ record }) => navigate(record.link)} + onRowClick={({ record }) => redirectTask(record)} /> ) diff --git a/client/src/requests/handler.ts b/client/src/requests/handler.ts index 3a9c942b..607151ef 100644 --- a/client/src/requests/handler.ts +++ b/client/src/requests/handler.ts @@ -26,7 +26,7 @@ export function getApiResponseErrorMessage(response: ApiResponse) { } else if (response.status === 501) { message = 'Endpoint not implemented yet' } else { - message = 'Unknown error' + message = `Unknown error ${response.status}` } if (!response.ok && response.error) { diff --git a/client/src/requests/payloads/application.ts b/client/src/requests/payloads/application.ts deleted file mode 100644 index 9f3547db..00000000 --- a/client/src/requests/payloads/application.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { IUpdateUserInformationPayload } from './user' - -export interface ILegacyCreateApplicationPayload extends IUpdateUserInformationPayload { - universityId: string - motivation: string - thesisTitle: string - thesisType: string | null - desiredStartDate: Date -} diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 88ac3aa0..e873b1db 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -75,6 +75,7 @@ services: - CALDAV_URL - CALDAV_USERNAME - CALDAV_PASSWORD + - SCIENTIFIC_WRITING_GUIDE networks: - thesis-track-network diff --git a/docs/CONFIGURATION.md b/docs/CONFIGURATION.md index 476b1437..6b00aea0 100644 --- a/docs/CONFIGURATION.md +++ b/docs/CONFIGURATION.md @@ -30,6 +30,7 @@ | MAIL_BCC_RECIPIENTS | server | | Default BCC recipients for important emails | | MAIL_TEMPLATE_FOLDER | server | /default-mail-templates | Folder where mail templates are stored. If not set, it will use the default emails of the repository | | UPLOAD_FOLDER | server | uploads | Folder where uploaded files will be stored | +| SCIENTIFIC_WRITING_GUIDE | server | | Link to a guide that explains scientific writing at the chair | | APPLICATION_TITLE | client | Thesis Track | HTML title of the client | | GENDERS | client | `{"MALE":"Male","FEMALE":"Female","OTHER":"Other","PREFER_NOT_TO_SAY":"Prefer not to say"}` | Available genders that a user can configure | | STUDY_DEGREES | client | `{"BACHELOR":"Bachelor","MASTER":"Master"}` | Available study degrees | diff --git a/server/src/main/java/thesistrack/ls1/cron/ApplicationReminder.java b/server/src/main/java/thesistrack/ls1/cron/ApplicationReminder.java index 0c3afcbe..e13147aa 100644 --- a/server/src/main/java/thesistrack/ls1/cron/ApplicationReminder.java +++ b/server/src/main/java/thesistrack/ls1/cron/ApplicationReminder.java @@ -30,7 +30,7 @@ public void emailReminder() { for (User user : userRepository.getRoleMembers(Set.of("admin", "supervisor", "advisor"))) { long unreviewedApplications = applicationRepository.countUnreviewedApplications(user.getId()); - if (unreviewedApplications > 10) { + if (unreviewedApplications > 0) { mailingService.sendApplicationReminderEmail(user, unreviewedApplications); } } diff --git a/server/src/main/java/thesistrack/ls1/service/DashboardService.java b/server/src/main/java/thesistrack/ls1/service/DashboardService.java index 8270927f..1c1fc5f5 100644 --- a/server/src/main/java/thesistrack/ls1/service/DashboardService.java +++ b/server/src/main/java/thesistrack/ls1/service/DashboardService.java @@ -1,5 +1,6 @@ package thesistrack.ls1.service; +import org.springframework.beans.factory.annotation.Value; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Sort; @@ -25,21 +26,34 @@ @Service public class DashboardService { - private final ThesisPresentationRepository thesisPresentationRepository; private final ThesisRepository thesisRepository; private final ApplicationRepository applicationRepository; private final TopicRepository topicRepository; - - public DashboardService(ThesisPresentationRepository thesisPresentationRepository, ThesisRepository thesisRepository, ApplicationRepository applicationRepository, TopicRepository topicRepository) { - this.thesisPresentationRepository = thesisPresentationRepository; + private final String scientificWritingGuide; + + public DashboardService( + ThesisRepository thesisRepository, + ApplicationRepository applicationRepository, + TopicRepository topicRepository, + @Value("${thesis-track.scientific-writing-guide}") String scientificWritingGuide + ) { this.thesisRepository = thesisRepository; this.applicationRepository = applicationRepository; this.topicRepository = topicRepository; + this.scientificWritingGuide = scientificWritingGuide; } public List getTasks(User user) { List tasks = new ArrayList<>(); + if (user.hasAnyGroup("student") && !scientificWritingGuide.isBlank()) { + tasks.add(new TaskDto( + "Please make yourself familiar with scientific writing", + scientificWritingGuide, + 50 + )); + } + // general student tasks for (Thesis thesis : thesisRepository.findActiveThesesForRole(user.getId(), Set.of(ThesisRoleName.STUDENT), null)) { if (thesis.getAbstractField().isBlank() || thesis.getInfo().isBlank()) { @@ -146,13 +160,15 @@ public List getTasks(User user) { if (user.hasAnyGroup("admin", "supervisor", "advisor")) { // review application task - long unreviewedApplications = applicationRepository.countUnreviewedApplications(user.hasAnyGroup("admin") ? null : user.getId()); + long unreviewedApplications = applicationRepository.countUnreviewedApplications(user.getId()); - tasks.add(new TaskDto( - "You have " + unreviewedApplications + " unreviewed applications.", - "/applications", - 10 - )); + if (unreviewedApplications > 0) { + tasks.add(new TaskDto( + "You have " + unreviewedApplications + " unreviewed applications.", + "/applications", + 10 + )); + } // no open topic task long openTopics = topicRepository.countOpenTopics(); diff --git a/server/src/main/resources/application.yml b/server/src/main/resources/application.yml index 77d4d355..06f201de 100644 --- a/server/src/main/resources/application.yml +++ b/server/src/main/resources/application.yml @@ -81,3 +81,4 @@ thesis-track: mail-template-location: ${MAIL_TEMPLATE_FOLDER:server/mail-templates} storage: upload-location: ${UPLOAD_FOLDER:uploads} + scientific-writing-guide: ${SCIENTIFIC_WRITING_GUIDE:}