Add session timeline logging and admin sessions view

This commit is contained in:
Remi
2025-09-21 23:08:10 +02:00
parent 10cae457f9
commit ba93c494c9
18 changed files with 1303 additions and 808 deletions

View File

@@ -43,6 +43,9 @@ export default defineEventHandler(async (event) => {
.filter((phase: string) => phase.length)
: []
const entryMode = body.entryMode === 'linear' ? 'linear' : 'parallel'
const isMain = body.isMain === true
const endStates = Array.isArray(body.endStates)
? body.endStates
.map((state: any) => (typeof state === 'string' ? state.trim() : ''))
@@ -62,10 +65,19 @@ export default defineEventHandler(async (event) => {
hooks: body.hooks && typeof body.hooks === 'object' ? body.hooks : {},
roles,
phases,
entryMode,
isMain,
})
await flow.save()
if (isMain) {
await DecisionFlow.updateMany(
{ _id: { $ne: flow._id } },
{ $set: { isMain: false } }
)
}
const { flow: serialized } = await getFlowWithNodes(slug)
return serialized
})

View File

@@ -59,6 +59,14 @@ export default defineEventHandler(async (event) => {
flow.phases = phases
}
if (typeof body.entryMode === 'string') {
flow.entryMode = body.entryMode === 'linear' ? 'linear' : 'parallel'
}
if (typeof body.isMain === 'boolean') {
flow.isMain = body.isMain
}
if (body.variables && typeof body.variables === 'object') {
flow.variables = body.variables
flow.markModified('variables')
@@ -145,6 +153,13 @@ export default defineEventHandler(async (event) => {
await flow.save()
if (flow.isMain) {
await DecisionFlow.updateMany(
{ _id: { $ne: flow._id } },
{ $set: { isMain: false } }
)
}
const data = await getFlowWithNodes(slug)
return data
})