Skip to content

Commit

Permalink
Revert "#330 frontend: use enum for the exercise status"
Browse files Browse the repository at this point in the history
This reverts commit 78e6c1e.
  • Loading branch information
Wolkenfarmer committed Sep 6, 2024
1 parent 8b65607 commit 860bebf
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 39 deletions.
20 changes: 13 additions & 7 deletions frontend/src/components/screensPatient/ScreenWaiting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,29 @@
const title = computed(() => {
switch (exerciseStore.status) {
case ExerciseStatus.RUNNING:
case 'running':
return patientStore.relocatingInfo
case ExerciseStatus.NOT_STARTED:
case 'not-started':
return 'Warte, bis die Übung beginnt'
case ExerciseStatus.PAUSED:
case 'paused':
return 'Übung pausiert'
case ExerciseStatus.ENDED:
case 'ended':
return 'Übung beendet'
default:
return 'Warte auf Übung'
}
})
const info = computed(() => {
if (exerciseStore.status == ExerciseStatus.RUNNING) {
return new Date(new Date(0).setSeconds(patientStore.timeUntilBack)).toISOString().substring(12, 19)
} else return 'Bereich: '+ exerciseStore.getAreaName(patientStore.areaId)
switch (exerciseStore.status) {
case 'running':
return new Date(new Date(0).setSeconds(patientStore.timeUntilBack)).toISOString().substring(12, 19)
case 'not-started':
case 'paused':
case 'ended':
default:
return 'Bereich: '+ exerciseStore.getAreaName(patientStore.areaId)
}
})
</script>

Expand Down
24 changes: 12 additions & 12 deletions frontend/src/components/widgets/ExerciseControlPanel.vue
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<script setup lang="ts">
import {svg} from "@/assets/Svg"
import {computed, ref, watch} from "vue"
import { svg } from "@/assets/Svg"
import { ref, computed, watch } from "vue"
import socketTrainer from "@/sockets/SocketTrainer"
import {useExerciseStore} from "@/stores/Exercise"
import { useExerciseStore } from "@/stores/Exercise"
import ButtonPopup from "./ButtonPopup.vue"
import SpeedSelectorPopup from "./SpeedSelectorPopup.vue"
import {useAvailablesStore} from "@/stores/Availables"
import {useLogStore} from "@/stores/Log"
import {Modules, setModule} from "@/App.vue"
import {ListItem, ListItemLeft, ListItemName, ListItemRight} from "@/components/widgets/List"
import { useAvailablesStore } from "@/stores/Availables"
import { useLogStore } from "@/stores/Log"
import { Modules, setModule } from "@/App.vue"
import {CustomList, ListItem, ListItemButton, ListItemName, ListItemAddButton, ListItemRight, ListItemLeft} from "@/components/widgets/List"
const exerciseStore = useExerciseStore()
const status = ref(ExerciseStatus.UNKNOWN)
const status = ref('')
const speed = ref(1)
status.value = exerciseStore.status
Expand All @@ -28,13 +28,13 @@
const info = computed(() => {
switch (status.value) {
case ExerciseStatus.NOT_STARTED:
case "not-started":
return "Die Übung wurde noch nicht gestartet"
case ExerciseStatus.RUNNING:
case "running":
return "Die Übung läuft"
case ExerciseStatus.PAUSED:
case "paused":
return "Die Übung ist pausiert"
case ExerciseStatus.ENDED:
case "ended":
return "Die Übung ist beendet"
default:
return "Fehler"
Expand Down
10 changes: 1 addition & 9 deletions frontend/src/sockets/MessageData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,11 @@ interface MessageData {

interface Exercise {
exerciseId: string
status: ExerciseStatus
status: string
speed: number
areas: Area[]
}

enum ExerciseStatus {
RUNNING = "running",
PAUSED = "paused",
ENDED = "ended",
NOT_STARTED = "not-started",
UNKNOWN = "unknown",
}

interface Area {
areaId: number
areaName: string
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/sockets/SocketPatient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,21 @@ class SocketPatient {
patientStore.initializePatientFromExercise()
break
case 'exercise-start':
exerciseStore.status = ExerciseStatus.RUNNING
exerciseStore.status = 'running'
setScreen(Screens.STATUS, ScreenPosition.LEFT)
setScreen(Screens.ACTIONS, ScreenPosition.RIGHT)
break
case 'exercise-pause':
exerciseStore.status = ExerciseStatus.PAUSED
exerciseStore.status = 'paused'
setScreen(Screens.WAITING, ScreenPosition.FULL)
break
case 'exercise-resume':
exerciseStore.status = ExerciseStatus.RUNNING
exerciseStore.status = 'running'
setScreen(Screens.STATUS, ScreenPosition.LEFT)
setScreen(Screens.ACTIONS, ScreenPosition.RIGHT)
break
case 'exercise-end':
exerciseStore.status = ExerciseStatus.ENDED
exerciseStore.status = 'ended'
setScreen(Screens.ENDED, ScreenPosition.FULL)
break
case 'delete':
Expand Down
12 changes: 6 additions & 6 deletions frontend/src/sockets/SocketTrainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,22 @@ class SocketTrainer {
break
case 'exercise':
useExerciseStore().createFromJSON(data.exercise as Exercise)
if (exerciseStore.status == ExerciseStatus.UNKNOWN) {
exerciseStore.status = ExerciseStatus.NOT_STARTED
if (exerciseStore.status == '') {
exerciseStore.status = 'not-started'
setModule(Modules.TRAINER)
}
break
case 'exercise-start':
exerciseStore.status = ExerciseStatus.RUNNING
exerciseStore.status = 'running'
break
case 'exercise-pause':
exerciseStore.status = ExerciseStatus.PAUSED
exerciseStore.status = 'paused'
break
case 'exercise-resume':
exerciseStore.status = ExerciseStatus.RUNNING
exerciseStore.status = 'running'
break
case 'exercise-end':
exerciseStore.status = ExerciseStatus.ENDED
exerciseStore.status = 'ended'
break
case 'log-update':
useLogStore().addLogEntries(data.logEntries as LogEntry[])
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/stores/Exercise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {defineStore} from 'pinia'
export const useExerciseStore = defineStore('exercise', {
state: (): Exercise => ({
exerciseId: "",
status: ExerciseStatus.RUNNING,
status: "",
speed: 1,
areas: [],
}),
Expand Down

0 comments on commit 860bebf

Please sign in to comment.