Preskoči na vsebino

std-upload

Level: Atom | Entity: UploadFile | Persistence: runtime

4 states, 6 events, 7 transitions

Live Preview

orbital UploadFileOrbital {
entity UploadFile [runtime] {
id : string
name : string
description : string
status : string
createdAt : string
fileName : string
fileSize : number
uploadStatus : string
}
trait UploadFileUpload -> UploadFile [interaction] {
initial: idle
state idle {
INIT -> idle
(render-ui main { type: "stack", direction: "vertical", gap: "lg", align: "center", children: [{ type: "stack", direction: "horizontal", gap: "sm", align: "center", children: [{ type: "icon", name: "upload", size: "lg" }, { type: "typography", content: "Upload", variant: "h2" }] }, { type: "divider" }, { type: "upload-drop-zone", accept: "*/*", event: "UPLOAD", multiple: false, maxSize: 10485760 }] })
UPLOAD -> uploading
(set @entity.fileName @payload.fileName)
(set @entity.uploadStatus uploading)
(render-ui main { type: "stack", direction: "vertical", gap: "lg", align: "center", children: [{ type: "stack", direction: "horizontal", gap: "sm", align: "center", children: [{ type: "icon", name: "upload", size: "lg" }, { type: "typography", content: "Uploading...", variant: "h2" }] }, { type: "divider" }, { type: "typography", variant: "body", content: ["object/get", ["array/first", "@entity"], "fileName"] }, { type: "progress-bar", value: 50, showPercentage: true }, { type: "spinner", size: "md" }] })
}
state uploading {
COMPLETE -> complete
(set @entity.uploadStatus complete)
(render-ui main { type: "stack", direction: "vertical", gap: "lg", align: "center", children: [{ type: "stack", direction: "horizontal", gap: "sm", align: "center", children: [{ type: "icon", name: "check-circle", size: "lg" }, { type: "typography", content: "Upload Complete", variant: "h2" }] }, { type: "divider" }, { type: "alert", variant: "success", message: "File uploaded successfully." }, { type: "typography", variant: "caption", color: "muted", content: ["object/get", ["array/first", "@entity"], "fileName"] }, { type: "button", label: "Upload Another", event: "RESET", variant: "primary", icon: "upload" }] })
FAILED -> error
(set @entity.uploadStatus error)
(render-ui main { type: "stack", direction: "vertical", gap: "lg", align: "center", children: [{ type: "error-state", title: "Upload Failed", message: "Something went wrong. Please try again.", onRetry: "UPLOAD" }, { type: "stack", direction: "horizontal", gap: "sm", justify: "center", children: [{ type: "button", label: "Retry", event: "RETRY", variant: "primary", icon: "rotate-ccw" }, { type: "button", label: "Cancel", event: "RESET", variant: "ghost" }] }] })
}
state complete {
RESET -> idle
(set @entity.uploadStatus idle)
(render-ui main { type: "stack", direction: "vertical", gap: "lg", align: "center", children: [{ type: "stack", direction: "horizontal", gap: "sm", align: "center", children: [{ type: "icon", name: "upload", size: "lg" }, { type: "typography", content: "Upload", variant: "h2" }] }, { type: "divider" }, { type: "upload-drop-zone", accept: "*/*", event: "UPLOAD", multiple: false, maxSize: 10485760 }] })
}
state error {
RETRY -> uploading
(set @entity.uploadStatus uploading)
(render-ui main { type: "stack", direction: "vertical", gap: "lg", align: "center", children: [{ type: "stack", direction: "horizontal", gap: "sm", align: "center", children: [{ type: "icon", name: "upload", size: "lg" }, { type: "typography", content: "Uploading...", variant: "h2" }] }, { type: "divider" }, { type: "typography", variant: "body", content: ["object/get", ["array/first", "@entity"], "fileName"] }, { type: "progress-bar", value: 50, showPercentage: true }, { type: "spinner", size: "md" }] })
RESET -> idle
(set @entity.uploadStatus idle)
(render-ui main { type: "stack", direction: "vertical", gap: "lg", align: "center", children: [{ type: "stack", direction: "horizontal", gap: "sm", align: "center", children: [{ type: "icon", name: "upload", size: "lg" }, { type: "typography", content: "Upload", variant: "h2" }] }, { type: "divider" }, { type: "upload-drop-zone", accept: "*/*", event: "UPLOAD", multiple: false, maxSize: 10485760 }] })
}
}
page "/uploadfiles/upload" -> UploadFileUpload
}
Loading preview...

Orbital Visualization

Loading visualization...

Entity Fields

FieldTypeDefault
idstring-
namestring-
descriptionstring-
statusstring"active"
createdAtstring-
fileNamestring""
fileSizenumber0
uploadStatusstring"idle"

States

StateType
idleInitial
uploading-
complete-
error-

Events

EventPayload
INIT-
UPLOADfileName: string
COMPLETE-
FAILED-
RETRY-
RESET-

Transitions

FromEventToEffects
idleINITidle1 effect
idleUPLOADuploading3 effects
uploadingCOMPLETEcomplete2 effects
uploadingFAILEDerror2 effects
errorRETRYuploading2 effects
errorRESETidle2 effects
completeRESETidle2 effects