Skip to content

Commit

Permalink
#90 frontend: add ActionSelection and ActionConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaRiewesell committed Mar 27, 2024
1 parent bc258dc commit 3f137e3
Show file tree
Hide file tree
Showing 5 changed files with 154 additions and 10 deletions.
8 changes: 7 additions & 1 deletion frontend/src/components/screensPatient/ScreenActions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
</script>

<template>
<component :is="currentPageComponent" />
<div class="page">
<component :is="currentPageComponent" />
</div>
<nav>
<button id="nav-action-overview" :class="{ 'selected': currentPage === Pages.ACTION_OVERVIEW }" @click="setPage(Pages.ACTION_OVERVIEW)">
Übersicht
Expand All @@ -45,6 +47,10 @@
</template>

<style scoped>
.page {
height: calc(100% - 60px);
}
nav {
width: 100%;
height: 60px;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,63 @@
<script setup lang="ts">
import socketPatient from '@/sockets/SocketPatient'
import { ref } from 'vue'
import { useAvailablesStore } from '@/stores/Availables'
import ActionConfig from '@/components/widgets/ActionConfig.vue'
function actionAdd(actionName: string) {
socketPatient.actionAdd(actionName)
const availablesStore = useAvailablesStore()
const availableActions = ref(availablesStore.actions)
const currentAction = ref('Keine Aktion ausgewählt')
function filteredActions(actionType: string) {
return availableActions.value.filter(action => action.actionType === actionType)
}
function getTypeLabel(actionType: string) {
switch (actionType) {
case 'treatment':
return 'Behandlung'
case 'lab':
return 'Labor'
default:
return 'Sonstiges'
}
}
function openAction(actionName: string) {
currentAction.value = actionName
showAction.value = true
}
const showAction = ref(false)
</script>

<template>
<h1>ActionSelection</h1>
<button @click="actionAdd('stabile-seitenlage')">
Fügt eine Test-Aktion hinzu
</button>
</template>
<ActionConfig v-if="showAction" :current-action="currentAction" @close-action="showAction=false" />
<div v-if="!showAction">
<h1>Wähle eine Aktion</h1>
<div
v-for="actionTyp in availablesStore.getActionTypes"
:key="actionTyp"
class="list"
>
<h2>{{ getTypeLabel(actionTyp) }}</h2>
<div
v-for="action in filteredActions(actionTyp)"
:key="action.actionName"
class="listItem"
>
<button class="listItemButton" @click="openAction(action.actionName)">
<div class="listItemName">
{{ action.actionName }}
</div>
</button>
</div>
</div>
</div>
</template>
<style scoped>
h1 {
text-align: center;
margin-top: 30px;
}
</style>
69 changes: 69 additions & 0 deletions frontend/src/components/widgets/ActionConfig.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<script setup lang="ts">
const emit = defineEmits(['close-action'])
const props = defineProps({
currentAction: {
type: String,
default: "Kein Name angegeben"
}
})
</script>

<template>
<div class="flex-container">
<div>
<h1>{{ props.currentAction }}</h1>
<button class="close-button" @click="emit('close-action')">
X
</button>
</div>
<button class="main-button">
Aktion ausführen
</button>
</div>
</template>

<style scoped>
h1 {
text-align: center;
margin-top: 30px;
}
.flex-container {
display: flex;
flex-direction: column;
justify-content: space-between;
height: 100%;
position: relative;
}
.close-button {
display: flex;
justify-content: center;
align-items: center;
position: absolute;
align-self: flex-end;
background-color: #FFFFFF;
border: 1px solid rgb(209, 213, 219);
border-radius: .5rem;
top: 1rem;
right: 1rem;
width: 3rem;
height: 3rem;
font-size: 1.25rem;
line-height: 1.25rem;
padding: .75rem 1rem;
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}
.main-button {
align-self: center;
background-color: #FFFFFF;
border: 1px solid rgb(209, 213, 219);
border-radius: .5rem;
width: calc(100% - 2rem);
font-size: 1.25rem;
line-height: 1.25rem;
padding: .75rem 1rem;
margin: 1rem;
text-align: center;
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}
</style>
16 changes: 16 additions & 0 deletions frontend/src/sockets/SocketPatient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ class SocketPatient {
availablesStore.loadAvailablePatients(data.availablePatients as AvailablePatients)
patientStore.initializePatientFromAvailablePatients()
break
case 'available-actions':
console.log('Socket: Available actions:', data.availableActions)
availablesStore.loadAvailableActions(data.availableActions as AvailableActions)
break
case 'exercise':
exerciseStore.createFromJSON(data.exercise as Exercise)
patientStore.initializePatientFromExercise()
Expand Down Expand Up @@ -159,6 +163,18 @@ export const serverMockEvents = [
'"patientPersonalDetails":"männlich, 39 Jahre alt","patientBiometrics":"Größe: 173cm, Gewicht: 61kg"}'+
']}}'
},
{
id: 'available-actions',
data: '{"messageType":"available-actions","availableActions":{"availableActions":[' +
'{"actionName":"Blutdruck messen","actionType":"treatment"},{"actionName":"Blutprobe untersuchen","actionType":"lab"},'+
'{"actionName":"Beatmungsmaske anlegen","actionType":"treatment"},' +
'{"actionName":"Infusion anlegen","actionType":"treatment"},{"actionName":"Blut abnehmen","actionType":"treatment"},'+
'{"actionName":"Medikament verabreichen","actionType":"treatment"},' +
'{"actionName":"Ruheposition einnehmen","actionType":"treatment"},{"actionName":"Röntgen","actionType":"lab"},'+
'{"actionName":"Wundversorgung","actionType":"treatment"},{"actionName":"Stabile Seitenlage","actionType":"treatment"},' +
'{"actionName":"Schienung anlegen","actionType":"treatment"},{"actionName":"Vitalwerte messen","actionType":"treatment"}'+
']}}'
},
{
id: 'exercise',
data: '{"messageType":"exercise","exercise":{"exerciseId":123456,"areas":[' +
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/stores/Availables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ export const useAvailablesStore = defineStore('availables', {
})
return foundPatient
}
}
},
getActionTypes: (state) => {
return [...new Set(state.actions.map((action) => action.actionType))]
},
},
actions: {
loadAvailableActions(json: AvailableActions) {
console.log('Store: Available actions:', json.availableActions)
this.actions = json.availableActions
},
loadAvailablePatients(json: AvailablePatients) {
Expand Down

0 comments on commit 3f137e3

Please sign in to comment.