admin-dashboard-backend/modules/structs/grouptasks.go

130 lines
3.4 KiB
Go

package structs
import (
"encoding/json"
"time"
)
// structure for database
type GroupTasks struct {
Id string
CreatorUserId string
Category string
GroupId string
GroupName string
Description string // user-specific description for faster retrieval
CurrentTasksStep uint8
NumberOfSteps uint8
Status uint8
GlobalInputs string `gorm:"type:json"`
StartedAt time.Time
EndedAt time.Time
RememberId string `gorm:"-"` // used by the web client who requested this to open the modal after the backend sent the NewGroupTaskStarted message
}
// swagger:model GroupTaskSteps
type GroupTaskSteps struct {
Id string
GroupTasksId string
CreatorUserId string
Step uint8
Status uint8
Log string `gorm:"type:text"`
Inputs string `gorm:"type:text"`
Files string `gorm:"type:text"`
StartedAt time.Time
EndedAt time.Time
LockedByUserId string `gorm:"-"` // used by the web client to ensure that only one user can edit the input value
}
// read from file structure
type CategoryGroup struct {
Category string `json:"category"`
Groups []Group `json:"groups"`
}
type Group struct {
Category string `json:"category"`
Id string `json:"id"`
Name string `json:"name"`
GlobalInputs []GlobalInputs `json:"globalInputs"`
Tasks []Task `json:"tasks"`
}
type GlobalInputs struct {
ParameterName string `json:"parameterName"`
Type string `json:"type"`
DisplayName string `json:"displayName"`
}
type Task struct {
Name string `json:"name"`
OnFinish string `json:"onFinish"`
UndoPossible bool `json:"undoPossible"`
RepeatPossible bool `json:"repeatPossible"`
ScriptPath string `json:"scriptPath"`
Parameters []TaskParameter `json:"parameters"` // same as task inputs
}
type TaskParameter struct {
ParameterName string `json:"parameterName"`
Type string `json:"type"`
DisplayName string `json:"displayName"`
Global bool `json:"global"`
}
// used for ui when a user is writing into input field to lock the task step for other users
type LockedGroupTaskSteps struct {
LockedByUserId string
GroupTaskId string
Step uint8
LockedAt time.Time
RememberId string
}
// used for ui when a user types into input fields to sync to other users and show them this when opening the group task view
type GroupTaskStepsInput struct {
GroupTaskId string
Step uint8
ParameterName string
Value interface{}
}
type GroupTaskStepFile struct {
OriginalFileName string // file name which was used by the python script
SystemFileName string // file name which was set by this server
}
// swagger:model ApiGroupTaskRequest
type ApiGroupTaskRequest struct {
Category string
GroupId string
Description string
GlobalInputs json.RawMessage
}
type GroupTasksRequest struct {
Category string
}
// swagger:model GroupTasksResponse
type GroupTasksResponse struct {
CategoryGroup CategoryGroup
GroupTasks []GroupTasks
TotalPages int
}
// swagger:model GroupTasksStepsRequest
type GroupTaskStepsRequest struct {
Category string
GroupTaskId string
}
// swagger:model GetGroupTaskStepsResponse
type GetGroupTaskStepsResponse struct {
GroupTask GroupTasks
GroupTaskSteps []GroupTaskSteps
}