Skip to content

Commit

Permalink
Add task for scientific writing
Browse files Browse the repository at this point in the history
  • Loading branch information
fabian-emilius committed Sep 26, 2024
1 parent 152bb7a commit 918753c
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 25 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/deploy_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions client/src/app/layout/AuthenticatedArea/AuthenticatedArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -80,6 +80,7 @@ const AuthenticatedArea = (props: PropsWithChildren<IAuthenticatedAreaProps>) =>
requiredGroups,
} = props

const navigate = useNavigate()
const [opened, { toggle, close }] = useDisclosure()

const minimizeAnimationDuration = 200
Expand Down Expand Up @@ -154,7 +155,7 @@ const AuthenticatedArea = (props: PropsWithChildren<IAuthenticatedAreaProps>) =>
{!minimized && (
<Group preventGrowOverflow={false}>
<Logo className={classes.logo} />
<Text className={classes.siteName} fw='bold'>
<Text className={classes.siteName} fw='bold' style={{cursor: 'pointer'}} onClick={() => navigate('/')}>
ThesisTrack
</Text>
<ColorSchemeToggleButton ml='auto' />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Stack gap='xs'>
<Title order={2}>My Tasks</Title>
Expand All @@ -63,15 +71,15 @@ const MyTasksSection = () => {
render: (record) => (
<Center>
<Group gap='xs' onClick={(e) => e.stopPropagation()} wrap='nowrap'>
<ActionIcon onClick={() => navigate(record.link)}>
<ActionIcon onClick={() => redirectTask(record)}>
<LinkIcon />
</ActionIcon>
</Group>
</Center>
),
},
]}
onRowClick={({ record }) => navigate(record.link)}
onRowClick={({ record }) => redirectTask(record)}
/>
</Stack>
)
Expand Down
2 changes: 1 addition & 1 deletion client/src/requests/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function getApiResponseErrorMessage(response: ApiResponse<unknown>) {
} else if (response.status === 501) {
message = 'Endpoint not implemented yet'
} else {
message = 'Unknown error'
message = `Unknown error ${response.status}`
}

if (!response.ok && response.error) {
Expand Down
9 changes: 0 additions & 9 deletions client/src/requests/payloads/application.ts

This file was deleted.

1 change: 1 addition & 0 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ services:
- CALDAV_URL
- CALDAV_USERNAME
- CALDAV_PASSWORD
- SCIENTIFIC_WRITING_GUIDE
networks:
- thesis-track-network

Expand Down
1 change: 1 addition & 0 deletions docs/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
36 changes: 26 additions & 10 deletions server/src/main/java/thesistrack/ls1/service/DashboardService.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<TaskDto> getTasks(User user) {
List<TaskDto> 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()) {
Expand Down Expand Up @@ -146,13 +160,15 @@ public List<TaskDto> 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();
Expand Down
1 change: 1 addition & 0 deletions server/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:}

0 comments on commit 918753c

Please sign in to comment.