Skip to content

Commit

Permalink
Merge pull request #170 from hpi-sam/130-n05-action-check
Browse files Browse the repository at this point in the history
130 n05 action check
  • Loading branch information
JoshuaRiewesell authored May 15, 2024
2 parents 2d9fc99 + 0972865 commit 9383f0d
Show file tree
Hide file tree
Showing 10 changed files with 473 additions and 95 deletions.
20 changes: 17 additions & 3 deletions frontend/src/assets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -146,26 +146,30 @@ button:active {

.listItem {
position: relative;
background-color: #FFFFFF;
border: 1px solid rgb(209, 213, 219);
display: flex;
align-items: center;
text-align: left;
margin-top: -1px;
overflow: hidden;
text-overflow: ellipsis;
width: 100%;
}

.listItemButton {
position: relative;
background-color: #FFFFFF;
background-color: white;
border: none;
display: flex;
justify-content: space-between;
align-items: center;
font-size: 1.25rem;
padding: 0;
text-align: left;
height: 50px;
max-width: 100%;
width: 100%;
flex-grow: 1;
flex-wrap: nowrap;
}

.selected .listItemButton {
Expand All @@ -186,16 +190,26 @@ button:active {
margin-top: -1px;
}

.listItemIcon {
margin-left: 16px;
display: flex;
justify-content: center;
flex-shrink: 0;
}

.listItemId {
padding: .75rem 1rem;
width: fit-content;
flex-shrink: 0;
}

.listItemName {
padding: .75rem 1rem;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
flex: 1;
width: 100%;
}

.scroll {
Expand Down
23 changes: 14 additions & 9 deletions frontend/src/components/screensPatient/ScreenActions.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
<script setup lang="ts">
import PageActionOverview from './pagesAction/PageActionOverview.vue'
import PageActionSelection from './pagesAction/PageActionSelection.vue'
import PageActionCheck from './pagesAction/PageActionCheck.vue'
import PagePersonnel from './pagesAction/PagePersonnel.vue'
import PageMaterial from './pagesAction/PageMaterial.vue'
import {computed, ref} from 'vue'
enum Pages {
ACTION_OVERVIEW = "PageActionOverview",
ACTION_SELECTION = "PageActionSelection",
PERSONNEL = "PagePersonnel",
MATERIAL = "PageMaterial"
}
const currentPage = ref(Pages.ACTION_OVERVIEW)
const currentPageComponent = computed(() => getPageComponent(currentPage.value))
Expand All @@ -21,6 +15,8 @@
return PageActionOverview
case Pages.ACTION_SELECTION:
return PageActionSelection
case Pages.ACTION_CHECK:
return PageActionCheck
case Pages.PERSONNEL:
return PagePersonnel
case Pages.MATERIAL:
Expand All @@ -32,13 +28,23 @@
currentPage.value = newPage
}
</script>

<script lang="ts">
export enum Pages {
ACTION_OVERVIEW = "PageActionOverview",
ACTION_SELECTION = "PageActionSelection",
ACTION_CHECK = "PageActionCheck",
PERSONNEL = "PagePersonnel",
MATERIAL = "PageMaterial"
}
</script>
<template>
<div class="page">
<component
:is="currentPageComponent"
@add-action="setPage(Pages.ACTION_SELECTION)"
@close-action-selection="setPage(Pages.ACTION_OVERVIEW)"
@set-page="(page) => setPage(page as Pages)"
@close-action="setPage(Pages.ACTION_OVERVIEW)"
/>
</div>
<nav>
Expand All @@ -57,7 +63,6 @@
</button>
</nav>
</template>

<style scoped>
.page {
height: calc(100% - 60px);
Expand Down
243 changes: 243 additions & 0 deletions frontend/src/components/screensPatient/pagesAction/PageActionCheck.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@
<script setup lang="ts">
import socketPatient from '@/sockets/SocketPatient'
import { computed, ref } from 'vue'
import CloseButton from '@/components/widgets/CloseButton.vue'
import { useActionCheckStore } from '@/stores/ActionCheck'
import { svg } from '@/assets/Svg'
import ActionGroupPopup from '@/components/widgets/ActionGroupPopup.vue'
const emit = defineEmits(['close-action'])
const actionCheckStore = useActionCheckStore()
function addAction() {
socketPatient.actionAdd(actionCheckStore?.actionName)
newActionsAllowed.value = false
emit('close-action')
}
const errorMessage = ref(computed(() => {
if (actionCheckStore?.prohibitedActions?.length > 0) {
return "Eine durchgeführte Aktion verhindert die Anordnung."
} else if (actionCheckStore?.requiredActions?.singleActions?.length > 0 || actionCheckStore?.requiredActions?.actionGroups?.length > 0) {
return "Es müssen zuerst andere Aktionen durchgeführt werden."
} else if (!newActionsAllowed.value) {
return "Warte, bis wieder neue Aktionen angeordnet werden können."
} else {
return ""
}
}))
function getIconPath(available: number, assigned: number, needed: number) {
if (assigned < needed) {
return svg.blockIcon
} else if (available < needed) {
return svg.waitingIcon
} else {
return svg.playIcon
}
}
function openActionGroupPopup(actions: string[]) {
actionsOfGroup.value = actions
showActionGroupPopup.value = true
}
const showActionGroupPopup = ref(false)
const actionsOfGroup = ref([] as string[])
</script>
<script lang="ts">
const newActionsAllowed = ref(true)
export function allowNewActions() {
newActionsAllowed.value = true
}
</script>

<template>
<ActionGroupPopup
v-if="showActionGroupPopup"
:actions="actionsOfGroup"
@close-popup="showActionGroupPopup=false"
/>
<div class="flex-container">
<div>
<CloseButton @close="emit('close-action')" />
</div>
<div class="scroll">
<h1>{{ actionCheckStore?.actionName }}</h1>
<div class="list">
<p v-if="actionCheckStore?.applicationDuration">
Ausführungsdauer: {{ new Date(new Date(0).setSeconds(actionCheckStore?.applicationDuration)).toISOString().substring(14, 19) }}
</p>
<p v-if="actionCheckStore?.effectDuration > 0">
Effektdauer: {{ new Date(new Date(0).setSeconds(actionCheckStore?.effectDuration)).toISOString().substring(14, 19) }}
</p>
<br>
<p v-if="actionCheckStore?.personnel?.length > 0">
Personal (verfügbar / zugeordnet / benötigt)
</p>
<div
v-for="personnel in actionCheckStore?.personnel"
:key="personnel.name"
class="listItem"
>
<div class="listItemButton">
<div class="listItemIcon">
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24">
<path :d="getIconPath(personnel.available, personnel.assigned, personnel.needed)" />
</svg>
</div>
<div class="listItemName">
{{ personnel.name }}
</div>
<div class="rightText">
{{ personnel.available }} / {{ personnel.assigned }} / {{ personnel.needed }}
</div>
</div>
</div>
<br>
<p v-if="actionCheckStore?.material?.length > 0">
Material (verfügbar / zugeordnet / benötigt)
</p>
<div
v-for="material in actionCheckStore?.material"
:key="material.name"
class="listItem"
>
<div class="listItemButton">
<div class="listItemIcon">
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24">
<path :d="getIconPath(material.available, material.assigned, material.needed)" />
</svg>
</div>
<div class="listItemName">
{{ material.name }}
</div>
<div class="rightText">
{{ material.available }} / {{ material.assigned }} / {{ material.needed }}
</div>
</div>
</div>
<br>
<p v-if="actionCheckStore.labDevices?.length > 0">
Laborgeräte (verfügbar / benötigt)
</p>
<div
v-for="labDevice in actionCheckStore?.labDevices"
:key="labDevice.name"
class="listItem"
>
<div class="listItemButton">
<div class="listItemIcon">
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24">
<path :d="getIconPath(labDevice.available, labDevice.available, labDevice.needed)" />
</svg>
</div>
<div class="listItemName">
{{ labDevice.name }}
</div>
<div class="rightText">
{{ labDevice.available }} / {{ labDevice.needed }}
</div>
</div>
</div>
<br>
<p v-if="actionCheckStore?.requiredActions?.singleActions?.length > 0">
Folgende Aktionen müssen zuvor durchgeführt werden
</p>
<div
v-for="(action, index) in actionCheckStore?.requiredActions?.singleActions"
:key="index"
class="listItem"
>
<div class="listItemButton">
<div class="listItemIcon">
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24">
<path :d="svg.closeIcon" />
</svg>
</div>
<div class="listItemName">
{{ action }}
</div>
</div>
</div>
<div
v-for="(actionGroup, index) in actionCheckStore?.requiredActions?.actionGroups"
:key="index"
class="listItem"
>
<div class="listItemButton" @click="openActionGroupPopup(actionGroup.actions)">
<div class="listItemIcon">
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24">
<path :d="svg.closeIcon" />
</svg>
</div>
<div class="listItemName">
{{ actionGroup.groupName ? actionGroup.groupName : actionGroup.actions.join(' / ') }}
</div>
<div class="rightText">
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24">
<path :d="svg.descriptionIcon" />
</svg>
</div>
</div>
</div>
<br>
<p v-if="actionCheckStore?.prohibitedActions?.length > 0">
Folgende durchgeführte Aktionen verhindern die Anordnung
</p>
<div
v-for="(action, index) in actionCheckStore?.prohibitedActions"
:key="index"
class="listItem"
>
<div class="listItemButton">
<div class="listItemIcon">
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24">
<path :d="svg.closeIcon" />
</svg>
</div>
<div class="listItemName">
{{ action }}
</div>
</div>
</div>
</div>
</div>
<div v-if="actionCheckStore?.actionName">
<button class="main-button" :disabled="errorMessage.length > 0" @click="addAction()">
Aktion anordnen
<p v-if="errorMessage" class="error-message">
{{ errorMessage }}
</p>
</button>
</div>
</div>
</template>

<style scoped>
.main-button {
background-color: var(--green);
color: white;
}
.main-button:disabled {
background-color: var(--gray);
}
.scroll {
margin-bottom: 80px;
}
.rightText {
flex-shrink: 0;
margin-right: 16px;
white-space: nowrap;
width: auto;
}
.error-message {
font-size: 12px;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
class="listItem"
>
<button class="listItemButton" @click="openDeletePopup(action.actionName)">
<div class="icon">
<div class="listItemIcon">
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24">
<path :d="getIconPath(action.actionStatus)" />
</svg>
Expand All @@ -101,7 +101,7 @@
class="listItem"
>
<button class="listItemButton" @click="openResultPopup(action.actionName, action.actionResult)">
<div class="icon">
<div class="listItemIcon">
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24">
<path :d="getIconPath(action.actionStatus)" />
</svg>
Expand All @@ -121,12 +121,6 @@
</template>

<style scoped>
.icon {
margin-left: 16px;
display: flex;
justify-content: center;
}
.time {
margin-left: auto;
margin-right: 16px;
Expand Down
Loading

0 comments on commit 9383f0d

Please sign in to comment.