Skip to content

Commit

Permalink
Merge pull request #369 from redlink-gmbh/Feature_MORE2-1_dynamic-stu…
Browse files Browse the repository at this point in the history
…dy-start

Feature dynamic study start
  • Loading branch information
alireza-dhp authored Nov 28, 2023
2 parents 0d4bff7 + 137ea1b commit 9e48937
Show file tree
Hide file tree
Showing 27 changed files with 2,377 additions and 1,051 deletions.
26 changes: 15 additions & 11 deletions .github/workflows/test-build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ name: Test, Build and Publish
on:
push:
workflow_dispatch:
inputs:
dockerTag:
description: If set, docker img is built and tagged accordingly
required: false

env:
REGISTRY: ghcr.io
Expand Down Expand Up @@ -57,23 +61,23 @@ jobs:
- name: Check licenses
run: npm run license:check

# - name: Run tests
# run: npm run test:unit:once
#
# - name: Upload Test Results
# if: always()
# uses: actions/upload-artifact@v3
# with:
# name: Test Results
# path: "target/testResults.xml"
# - name: Run tests
# run: npm run test:unit:once
#
# - name: Upload Test Results
# if: always()
# uses: actions/upload-artifact@v3
# with:
# name: Test Results
# path: "target/testResults.xml"

- name: Run build
run: npm run package

build-and-push-image:
name: Build and Push Docker Image
runs-on: ubuntu-latest
if: (github.ref_type == 'branch' && github.ref_name == 'main') || (github.ref_type == 'tag' && startsWith(github.ref_name, 'v'))
if: github.ref_name == 'main' || github.event.inputs.dockerTag != ''
needs:
- test
permissions:
Expand All @@ -97,7 +101,7 @@ jobs:
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=raw,value=${{github.event.inputs.dockerTag || 'latest'}}
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
Expand Down
32 changes: 32 additions & 0 deletions docs/gherkin/absolute-scheduler_after-cleanup.md

Large diffs are not rendered by default.

80 changes: 80 additions & 0 deletions docs/gherkin/relative-scheduler_manual-integration-test.md

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions openapi/Event.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ components:
Event:
type: object
properties:
type:
type: string
default: Event
dtstart:
type: string
format: date-time
Expand Down
62 changes: 62 additions & 0 deletions openapi/RelativeEvent.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
openapi: "3.0.3"
info:
title: TimeRange Model for Relative Events
version: "1.0"

components:
schemas:
Duration:
type: object
description: A duration of time
properties:
value:
type: integer
description: number of units
unit:
type: string
description: unit of time
enum:
- MINUTE
- HOUR
- DAY
RelativeDate:
type: object
description: A date relative to a specific base date (e.g study start)
properties:
offset:
$ref: '#/components/schemas/Duration'
time:
type: string
format: time
description: Follows ISO 8601 format for time
RelativeRecurrenceRule:
type: object
description: A recurrence rule relative to dtstart
properties:
frequency:
$ref: '#/components/schemas/Duration'
description: How often to repeat
endAfter:
$ref: '#/components/schemas/Duration'
description: How long to repeat

RelativeEvent:
type: object
description: An event that occurs at a relative time
required:
- type
- dtstart
- dtend
properties:
type:
type: string
default: RelativeEvent
dtstart:
$ref: '#/components/schemas/RelativeDate'
description: When the event starts
dtend:
$ref: '#/components/schemas/RelativeDate'
description: When the event ends
rrrule:
$ref: '#/components/schemas/RelativeRecurrenceRule'
description: How to repeat the event
34 changes: 31 additions & 3 deletions openapi/StudyManagerAPI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1277,6 +1277,8 @@ components:
type: string
consentInfo:
type: string
duration:
$ref: '#/components/schemas/StudyDuration'
finishText:
type: string
status:
Expand Down Expand Up @@ -1354,6 +1356,8 @@ components:
type: string
purpose:
type: string
duration:
$ref: '#/components/schemas/StudyDuration'
numberOfParticipants:
type: integer
readOnly: true
Expand All @@ -1365,7 +1369,18 @@ components:
type: string
format: date-time
readOnly: true

StudyDuration:
type: object
properties:
value:
type: integer
unit:
type: string
description: unit of time
enum:
- MINUTE
- HOUR
- DAY
Participant:
type: object
properties:
Expand Down Expand Up @@ -1422,7 +1437,16 @@ components:
type: object
additionalProperties: true
schedule:
$ref: './Event.yaml/#/components/schemas/Event'
oneOf:
- $ref: './Event.yaml/#/components/schemas/Event'
- $ref: './RelativeEvent.yaml/#/components/schemas/RelativeEvent'
discriminator:
propertyName: type
# mapping:
# event:
# $ref: './Event.yaml/#/components/schemas/Event'
# relativeEvent:
# $ref: './RelativeEvent.yaml/#/components/schemas/RelativeEvent'
created:
type: string
format: date-time
Expand Down Expand Up @@ -1514,7 +1538,11 @@ components:
purpose:
type: string
schedule:
$ref: './Event.yaml/#/components/schemas/Event'
oneOf:
- $ref: './Event.yaml/#/components/schemas/Event'
- $ref: './RelativeEvent.yaml/#/components/schemas/RelativeEvent'
discriminator:
propertyName: type
trigger:
$ref: '#/components/schemas/Trigger'
actions:
Expand Down
100 changes: 95 additions & 5 deletions src/components/ObservationList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ Licensed under the Elastic License 2.0. */
import { useComponentsApi, useObservationsApi } from '../composable/useApi';
import {
ComponentFactory,
Event,
Observation,
ObservationSchedule,
RelativeEvent,
StudyGroup,
StudyRole,
StudyStatus,
Expand All @@ -32,6 +35,8 @@ Licensed under the Elastic License 2.0. */
import { useI18n } from 'vue-i18n';
import { useErrorHandling } from '../composable/useErrorHandling';
import DeleteMoreTableRowDialog from './dialog/DeleteMoreTableRowDialog.vue';
import dayjs from 'dayjs';
import { ZTimeStringToOffsetTimeString } from '../utils/dateUtils';
const loader = useLoader();
const { observationsApi } = useObservationsApi();
Expand Down Expand Up @@ -122,19 +127,30 @@ Licensed under the Elastic License 2.0. */
editable: true,
},
{
field: 'schedule.dtstart',
field: 'scheduleType',
header: t('global.labels.scheduleType'),
columnWidth: '3vw',
sortable: true,
},
{
field: 'scheduleStart',
header: t('global.labels.start'),
type: MoreTableFieldType.nestedDatetime,
columnWidth: '3vw',
sortable: true,
},
{
field: 'schedule.dtend',
field: 'scheduleEnd',
header: t('global.labels.end'),
type: MoreTableFieldType.nestedDatetime,
columnWidth: '3vw',
sortable: true,
},
{
field: 'hasRepetition',
header: t('scheduler.labels.repeat'),
type: MoreTableFieldType.binaryIcon,
columnWidth: '2vw',
sortable: true,
},
];
const tableActions: MoreTableAction[] = [
Expand Down Expand Up @@ -230,10 +246,16 @@ Licensed under the Elastic License 2.0. */
typeLabel: getObservationTypeString(item.type as string),
properties: item.properties,
schedule: item.schedule,
scheduleType: item.schedule?.type
? t(`scheduler.type.${item.schedule?.type}`)
: '',
scheduleStart: getScheduleDate(item.schedule, 'dtstart'),
scheduleEnd: getScheduleDate(item.schedule, 'dtend'),
created: item.created,
modified: item.modified,
hidden: item.hidden,
noSchedule: item.noSchedule,
hasRepetition: getScheduleHasRepetition(item.schedule),
};
});
})
Expand All @@ -242,6 +264,75 @@ Licensed under the Elastic License 2.0. */
);
}
function getScheduleHasRepetition(
schedule: ObservationSchedule | undefined
): boolean {
if (schedule) {
switch (schedule.type) {
case 'Event': {
const s = schedule as Event;
return !!s.rrule;
}
case 'RelativeEvent': {
const s = schedule as RelativeEvent;
return !!s.rrrule;
}
}
}
return false;
}
function getScheduleDate(
scheduler: ObservationSchedule | undefined,
prop: string
) {
switch (scheduler?.type) {
case 'Event': {
const schedule = scheduler as Event;
switch (prop) {
case 'dtstart':
return schedule.dtstart
? `${dayjs(schedule.dtstart).format('DD/MM/YYYY')}, ${dayjs(
schedule.dtstart
).format('HH:mm')}`
: undefined;
case 'dtend':
return schedule.dtend
? `${dayjs(schedule.dtend).format('DD/MM/YYYY')}, ${dayjs(
schedule.dtend
).format('HH:mm')}`
: undefined;
default:
return undefined;
}
}
case 'RelativeEvent': {
const schedule = scheduler as RelativeEvent;
switch (prop) {
case 'dtstart':
return schedule.dtstart.offset?.value &&
schedule.dtstart.offset?.unit
? `${t(
`scheduler.preview.unit.${schedule.dtstart.offset.unit}`
)} ${
schedule.dtstart.offset.value
}, ${ZTimeStringToOffsetTimeString(schedule.dtstart.time)}`
: undefined;
case 'dtend':
return schedule.dtend.offset?.value && schedule.dtend.offset?.unit
? `${t(`scheduler.preview.unit.${schedule.dtend.offset.unit}`)} ${
schedule.dtend.offset.value
}, ${ZTimeStringToOffsetTimeString(schedule.dtend.time)} `
: undefined;
default:
return undefined;
}
}
}
return '';
}
function execute(action: any) {
switch (action.id) {
case 'delete':
Expand Down Expand Up @@ -372,7 +463,6 @@ Licensed under the Elastic License 2.0. */
openObservationDialog(dialogTitle, observation);
}
}
listObservations();
</script>

Expand Down
1 change: 1 addition & 0 deletions src/components/StudyCollaboratorList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ Licensed under the Elastic License 2.0. */

<template>
<div class="collaborator-list">
>
<MoreTable
row-id="studyGroupId"
:title="$t('studyCollaborator.collaboratorList.title')"
Expand Down
Loading

0 comments on commit 9e48937

Please sign in to comment.