package app import ( "fmt" "reflect" "strings" "github.com/seaweedfs/seaweedfs/weed/admin/maintenance" "github.com/seaweedfs/seaweedfs/weed/worker/tasks" "github.com/seaweedfs/seaweedfs/weed/admin/config" ) templ TaskConfigSchema(data *maintenance.TaskConfigData, schema *tasks.TaskConfigSchema, config interface{}) {

{schema.DisplayName} Configuration

{schema.DisplayName} Settings

{schema.Description}

for _, field := range schema.Fields { @TaskConfigField(field, getTaskFieldValue(config, field.JSONName)) }
Important Notes
} // TaskConfigField renders a single task configuration field based on schema templ TaskConfigField(field *config.Field, value interface{}) { if field.InputType == "interval" {
if field.Description != "" {
{ field.Description }
}
} else if field.InputType == "checkbox" {
if field.Description != "" {
{ field.Description }
}
} else if field.InputType == "text" {
if field.Description != "" {
{ field.Description }
}
} else {
if field.Description != "" {
{ field.Description }
}
} } // Helper functions for the template func getTaskBoolValue(value interface{}) bool { if boolVal, ok := value.(bool); ok { return boolVal } return false } func convertTaskSecondsToDisplayValue(value interface{}, field *config.Field) float64 { if intVal, ok := value.(int); ok { if intVal == 0 { return 0 } // Check if it's evenly divisible by days if intVal%(24*3600) == 0 { return float64(intVal / (24 * 3600)) } // Check if it's evenly divisible by hours if intVal%3600 == 0 { return float64(intVal / 3600) } // Default to minutes return float64(intVal / 60) } return 0 } func getTaskDisplayUnit(value interface{}, field *config.Field) string { if intVal, ok := value.(int); ok { if intVal == 0 { return "minutes" } // Check if it's evenly divisible by days if intVal%(24*3600) == 0 { return "days" } // Check if it's evenly divisible by hours if intVal%3600 == 0 { return "hours" } // Default to minutes return "minutes" } return "minutes" } func getTaskNumberStep(field *config.Field) string { if field.Type == config.FieldTypeFloat { return "0.01" } return "1" } func getTaskFieldValue(config interface{}, fieldName string) interface{} { if config == nil { return nil } // Use reflection to get the field value from the config struct configValue := reflect.ValueOf(config) if configValue.Kind() == reflect.Ptr { configValue = configValue.Elem() } if configValue.Kind() != reflect.Struct { return nil } configType := configValue.Type() for i := 0; i < configValue.NumField(); i++ { field := configValue.Field(i) fieldType := configType.Field(i) // Get JSON tag name jsonTag := fieldType.Tag.Get("json") if jsonTag == "" { continue } // Remove options like ",omitempty" if commaIdx := strings.Index(jsonTag, ","); commaIdx > 0 { jsonTag = jsonTag[:commaIdx] } if jsonTag == fieldName { return field.Interface() } } return nil } // Helper function to convert schema to JSON for JavaScript templ taskSchemaToTaskJSON(schema *tasks.TaskConfigSchema) { {`{}`} }