task_config_schema_templ.go 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948
  1. // Code generated by templ - DO NOT EDIT.
  2. // templ: version: v0.3.906
  3. package app
  4. //lint:file-ignore SA4006 This context is only used if a nested component is present.
  5. import "github.com/a-h/templ"
  6. import templruntime "github.com/a-h/templ/runtime"
  7. import (
  8. "encoding/base64"
  9. "encoding/json"
  10. "fmt"
  11. "github.com/seaweedfs/seaweedfs/weed/admin/config"
  12. "github.com/seaweedfs/seaweedfs/weed/admin/maintenance"
  13. "github.com/seaweedfs/seaweedfs/weed/admin/view/components"
  14. "github.com/seaweedfs/seaweedfs/weed/storage/erasure_coding"
  15. "github.com/seaweedfs/seaweedfs/weed/worker/tasks"
  16. "reflect"
  17. "strings"
  18. )
  19. // Helper function to convert task schema to JSON string
  20. func taskSchemaToJSON(schema *tasks.TaskConfigSchema) string {
  21. if schema == nil {
  22. return "{}"
  23. }
  24. data := map[string]interface{}{
  25. "fields": schema.Fields,
  26. }
  27. jsonBytes, err := json.Marshal(data)
  28. if err != nil {
  29. return "{}"
  30. }
  31. return string(jsonBytes)
  32. }
  33. // Helper function to base64 encode the JSON to avoid HTML escaping issues
  34. func taskSchemaToBase64JSON(schema *tasks.TaskConfigSchema) string {
  35. jsonStr := taskSchemaToJSON(schema)
  36. return base64.StdEncoding.EncodeToString([]byte(jsonStr))
  37. }
  38. func TaskConfigSchema(data *maintenance.TaskConfigData, schema *tasks.TaskConfigSchema, config interface{}) templ.Component {
  39. return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
  40. templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
  41. if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
  42. return templ_7745c5c3_CtxErr
  43. }
  44. templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
  45. if !templ_7745c5c3_IsBuffer {
  46. defer func() {
  47. templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
  48. if templ_7745c5c3_Err == nil {
  49. templ_7745c5c3_Err = templ_7745c5c3_BufErr
  50. }
  51. }()
  52. }
  53. ctx = templ.InitializeContext(ctx)
  54. templ_7745c5c3_Var1 := templ.GetChildren(ctx)
  55. if templ_7745c5c3_Var1 == nil {
  56. templ_7745c5c3_Var1 = templ.NopComponent
  57. }
  58. ctx = templ.ClearChildren(ctx)
  59. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<div class=\"container-fluid\"><div class=\"row mb-4\"><div class=\"col-12\"><div class=\"d-flex justify-content-between align-items-center\"><h2 class=\"mb-0\">")
  60. if templ_7745c5c3_Err != nil {
  61. return templ_7745c5c3_Err
  62. }
  63. var templ_7745c5c3_Var2 = []any{schema.Icon + " me-2"}
  64. templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var2...)
  65. if templ_7745c5c3_Err != nil {
  66. return templ_7745c5c3_Err
  67. }
  68. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "<i class=\"")
  69. if templ_7745c5c3_Err != nil {
  70. return templ_7745c5c3_Err
  71. }
  72. var templ_7745c5c3_Var3 string
  73. templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(templ.CSSClasses(templ_7745c5c3_Var2).String())
  74. if templ_7745c5c3_Err != nil {
  75. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/task_config_schema.templ`, Line: 1, Col: 0}
  76. }
  77. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
  78. if templ_7745c5c3_Err != nil {
  79. return templ_7745c5c3_Err
  80. }
  81. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "\"></i> ")
  82. if templ_7745c5c3_Err != nil {
  83. return templ_7745c5c3_Err
  84. }
  85. var templ_7745c5c3_Var4 string
  86. templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(schema.DisplayName)
  87. if templ_7745c5c3_Err != nil {
  88. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/task_config_schema.templ`, Line: 47, Col: 43}
  89. }
  90. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
  91. if templ_7745c5c3_Err != nil {
  92. return templ_7745c5c3_Err
  93. }
  94. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, " Configuration</h2><div class=\"btn-group\"><a href=\"/maintenance/config\" class=\"btn btn-outline-secondary\"><i class=\"fas fa-arrow-left me-1\"></i> Back to System Config</a></div></div></div></div><!-- Configuration Card --><div class=\"row\"><div class=\"col-12\"><div class=\"card\"><div class=\"card-header\"><h5 class=\"mb-0\"><i class=\"fas fa-cogs me-2\"></i> Task Configuration</h5><p class=\"mb-0 text-muted small\">")
  95. if templ_7745c5c3_Err != nil {
  96. return templ_7745c5c3_Err
  97. }
  98. var templ_7745c5c3_Var5 string
  99. templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(schema.Description)
  100. if templ_7745c5c3_Err != nil {
  101. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/task_config_schema.templ`, Line: 68, Col: 76}
  102. }
  103. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
  104. if templ_7745c5c3_Err != nil {
  105. return templ_7745c5c3_Err
  106. }
  107. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "</p></div><div class=\"card-body\"><form id=\"taskConfigForm\" method=\"POST\"><!-- Dynamically render all schema fields in defined order -->")
  108. if templ_7745c5c3_Err != nil {
  109. return templ_7745c5c3_Err
  110. }
  111. for _, field := range schema.Fields {
  112. templ_7745c5c3_Err = TaskConfigField(field, config).Render(ctx, templ_7745c5c3_Buffer)
  113. if templ_7745c5c3_Err != nil {
  114. return templ_7745c5c3_Err
  115. }
  116. }
  117. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "<div class=\"d-flex gap-2\"><button type=\"submit\" class=\"btn btn-primary\"><i class=\"fas fa-save me-1\"></i> Save Configuration</button> <button type=\"button\" class=\"btn btn-secondary\" onclick=\"resetToDefaults()\"><i class=\"fas fa-undo me-1\"></i> Reset to Defaults</button></div></form></div></div></div></div><!-- Performance Notes Card --><div class=\"row mt-4\"><div class=\"col-12\"><div class=\"card\"><div class=\"card-header\"><h5 class=\"mb-0\"><i class=\"fas fa-info-circle me-2\"></i> Important Notes</h5></div><div class=\"card-body\"><div class=\"alert alert-info\" role=\"alert\">")
  118. if templ_7745c5c3_Err != nil {
  119. return templ_7745c5c3_Err
  120. }
  121. if schema.TaskName == "vacuum" {
  122. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "<h6 class=\"alert-heading\">Vacuum Operations:</h6><p class=\"mb-2\"><strong>Performance:</strong> Vacuum operations are I/O intensive and may impact cluster performance.</p><p class=\"mb-2\"><strong>Safety:</strong> Only volumes meeting age and garbage thresholds will be processed.</p><p class=\"mb-0\"><strong>Recommendation:</strong> Monitor cluster load and adjust concurrent limits accordingly.</p>")
  123. if templ_7745c5c3_Err != nil {
  124. return templ_7745c5c3_Err
  125. }
  126. } else if schema.TaskName == "balance" {
  127. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "<h6 class=\"alert-heading\">Balance Operations:</h6><p class=\"mb-2\"><strong>Performance:</strong> Volume balancing involves data movement and can impact cluster performance.</p><p class=\"mb-2\"><strong>Safety:</strong> Requires adequate server count to ensure data safety during moves.</p><p class=\"mb-0\"><strong>Recommendation:</strong> Run during off-peak hours to minimize impact on production workloads.</p>")
  128. if templ_7745c5c3_Err != nil {
  129. return templ_7745c5c3_Err
  130. }
  131. } else if schema.TaskName == "erasure_coding" {
  132. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "<h6 class=\"alert-heading\">Erasure Coding Operations:</h6><p class=\"mb-2\"><strong>Performance:</strong> Erasure coding is CPU and I/O intensive. Consider running during off-peak hours.</p><p class=\"mb-2\"><strong>Durability:</strong> With ")
  133. if templ_7745c5c3_Err != nil {
  134. return templ_7745c5c3_Err
  135. }
  136. var templ_7745c5c3_Var6 string
  137. templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d+%d", erasure_coding.DataShardsCount, erasure_coding.ParityShardsCount))
  138. if templ_7745c5c3_Err != nil {
  139. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/task_config_schema.templ`, Line: 118, Col: 170}
  140. }
  141. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
  142. if templ_7745c5c3_Err != nil {
  143. return templ_7745c5c3_Err
  144. }
  145. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, " configuration, can tolerate up to ")
  146. if templ_7745c5c3_Err != nil {
  147. return templ_7745c5c3_Err
  148. }
  149. var templ_7745c5c3_Var7 string
  150. templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d", erasure_coding.ParityShardsCount))
  151. if templ_7745c5c3_Err != nil {
  152. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/task_config_schema.templ`, Line: 118, Col: 260}
  153. }
  154. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
  155. if templ_7745c5c3_Err != nil {
  156. return templ_7745c5c3_Err
  157. }
  158. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, " shard failures.</p><p class=\"mb-0\"><strong>Configuration:</strong> Fullness ratio should be between 0.5 and 1.0 (e.g., 0.90 for 90%).</p>")
  159. if templ_7745c5c3_Err != nil {
  160. return templ_7745c5c3_Err
  161. }
  162. }
  163. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "</div></div></div></div></div></div><script>\n function resetToDefaults() {\n if (confirm('Are you sure you want to reset to default configuration? This will overwrite your current settings.')) {\n // Reset form fields to their default values\n const form = document.getElementById('taskConfigForm');\n const schemaFields = window.taskConfigSchema ? window.taskConfigSchema.fields : {};\n \n Object.keys(schemaFields).forEach(fieldName => {\n const field = schemaFields[fieldName];\n const element = document.getElementById(fieldName);\n \n if (element && field.default_value !== undefined) {\n if (field.input_type === 'checkbox') {\n element.checked = field.default_value;\n } else if (field.input_type === 'interval') {\n // Handle interval fields with value and unit\n const valueElement = document.getElementById(fieldName + '_value');\n const unitElement = document.getElementById(fieldName + '_unit');\n if (valueElement && unitElement && field.default_value) {\n const defaultSeconds = field.default_value;\n const { value, unit } = convertSecondsToTaskIntervalValueUnit(defaultSeconds);\n valueElement.value = value;\n unitElement.value = unit;\n }\n } else {\n element.value = field.default_value;\n }\n }\n });\n }\n }\n\n function convertSecondsToTaskIntervalValueUnit(totalSeconds) {\n if (totalSeconds === 0) {\n return { value: 0, unit: 'minutes' };\n }\n\n // Check if it's evenly divisible by days\n if (totalSeconds % (24 * 3600) === 0) {\n return { value: totalSeconds / (24 * 3600), unit: 'days' };\n }\n\n // Check if it's evenly divisible by hours\n if (totalSeconds % 3600 === 0) {\n return { value: totalSeconds / 3600, unit: 'hours' };\n }\n\n // Default to minutes\n return { value: totalSeconds / 60, unit: 'minutes' };\n }\n\n // Store schema data for JavaScript access (moved to after div is created)\n </script><!-- Hidden element to store schema data --><div data-task-schema=\"")
  164. if templ_7745c5c3_Err != nil {
  165. return templ_7745c5c3_Err
  166. }
  167. var templ_7745c5c3_Var8 string
  168. templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(taskSchemaToBase64JSON(schema))
  169. if templ_7745c5c3_Err != nil {
  170. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/task_config_schema.templ`, Line: 183, Col: 58}
  171. }
  172. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
  173. if templ_7745c5c3_Err != nil {
  174. return templ_7745c5c3_Err
  175. }
  176. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "\" style=\"display: none;\"></div><script>\n // Load schema data now that the div exists\n const base64Data = document.querySelector('[data-task-schema]').getAttribute('data-task-schema');\n const jsonStr = atob(base64Data);\n window.taskConfigSchema = JSON.parse(jsonStr);\n </script>")
  177. if templ_7745c5c3_Err != nil {
  178. return templ_7745c5c3_Err
  179. }
  180. return nil
  181. })
  182. }
  183. // TaskConfigField renders a single task configuration field based on schema with typed field lookup
  184. func TaskConfigField(field *config.Field, config interface{}) templ.Component {
  185. return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
  186. templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
  187. if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
  188. return templ_7745c5c3_CtxErr
  189. }
  190. templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
  191. if !templ_7745c5c3_IsBuffer {
  192. defer func() {
  193. templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
  194. if templ_7745c5c3_Err == nil {
  195. templ_7745c5c3_Err = templ_7745c5c3_BufErr
  196. }
  197. }()
  198. }
  199. ctx = templ.InitializeContext(ctx)
  200. templ_7745c5c3_Var9 := templ.GetChildren(ctx)
  201. if templ_7745c5c3_Var9 == nil {
  202. templ_7745c5c3_Var9 = templ.NopComponent
  203. }
  204. ctx = templ.ClearChildren(ctx)
  205. if field.InputType == "interval" {
  206. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "<!-- Interval field with number input + unit dropdown --> <div class=\"mb-3\"><label for=\"")
  207. if templ_7745c5c3_Err != nil {
  208. return templ_7745c5c3_Err
  209. }
  210. var templ_7745c5c3_Var10 string
  211. templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(field.JSONName)
  212. if templ_7745c5c3_Err != nil {
  213. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/task_config_schema.templ`, Line: 198, Col: 39}
  214. }
  215. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10))
  216. if templ_7745c5c3_Err != nil {
  217. return templ_7745c5c3_Err
  218. }
  219. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "\" class=\"form-label\">")
  220. if templ_7745c5c3_Err != nil {
  221. return templ_7745c5c3_Err
  222. }
  223. var templ_7745c5c3_Var11 string
  224. templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(field.DisplayName)
  225. if templ_7745c5c3_Err != nil {
  226. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/task_config_schema.templ`, Line: 199, Col: 35}
  227. }
  228. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11))
  229. if templ_7745c5c3_Err != nil {
  230. return templ_7745c5c3_Err
  231. }
  232. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, " ")
  233. if templ_7745c5c3_Err != nil {
  234. return templ_7745c5c3_Err
  235. }
  236. if field.Required {
  237. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "<span class=\"text-danger\">*</span>")
  238. if templ_7745c5c3_Err != nil {
  239. return templ_7745c5c3_Err
  240. }
  241. }
  242. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "</label><div class=\"input-group\"><input type=\"number\" class=\"form-control\" id=\"")
  243. if templ_7745c5c3_Err != nil {
  244. return templ_7745c5c3_Err
  245. }
  246. var templ_7745c5c3_Var12 string
  247. templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(field.JSONName + "_value")
  248. if templ_7745c5c3_Err != nil {
  249. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/task_config_schema.templ`, Line: 208, Col: 50}
  250. }
  251. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12))
  252. if templ_7745c5c3_Err != nil {
  253. return templ_7745c5c3_Err
  254. }
  255. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "\" name=\"")
  256. if templ_7745c5c3_Err != nil {
  257. return templ_7745c5c3_Err
  258. }
  259. var templ_7745c5c3_Var13 string
  260. templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(field.JSONName + "_value")
  261. if templ_7745c5c3_Err != nil {
  262. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/task_config_schema.templ`, Line: 209, Col: 52}
  263. }
  264. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
  265. if templ_7745c5c3_Err != nil {
  266. return templ_7745c5c3_Err
  267. }
  268. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "\" value=\"")
  269. if templ_7745c5c3_Err != nil {
  270. return templ_7745c5c3_Err
  271. }
  272. var templ_7745c5c3_Var14 string
  273. templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%.0f", components.ConvertInt32SecondsToDisplayValue(getTaskConfigInt32Field(config, field.JSONName))))
  274. if templ_7745c5c3_Err != nil {
  275. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/task_config_schema.templ`, Line: 210, Col: 142}
  276. }
  277. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14))
  278. if templ_7745c5c3_Err != nil {
  279. return templ_7745c5c3_Err
  280. }
  281. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "\" step=\"1\" min=\"1\"")
  282. if templ_7745c5c3_Err != nil {
  283. return templ_7745c5c3_Err
  284. }
  285. if field.Required {
  286. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, " required")
  287. if templ_7745c5c3_Err != nil {
  288. return templ_7745c5c3_Err
  289. }
  290. }
  291. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "> <select class=\"form-select\" id=\"")
  292. if templ_7745c5c3_Err != nil {
  293. return templ_7745c5c3_Err
  294. }
  295. var templ_7745c5c3_Var15 string
  296. templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(field.JSONName + "_unit")
  297. if templ_7745c5c3_Err != nil {
  298. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/task_config_schema.templ`, Line: 219, Col: 49}
  299. }
  300. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15))
  301. if templ_7745c5c3_Err != nil {
  302. return templ_7745c5c3_Err
  303. }
  304. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, "\" name=\"")
  305. if templ_7745c5c3_Err != nil {
  306. return templ_7745c5c3_Err
  307. }
  308. var templ_7745c5c3_Var16 string
  309. templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(field.JSONName + "_unit")
  310. if templ_7745c5c3_Err != nil {
  311. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/task_config_schema.templ`, Line: 220, Col: 51}
  312. }
  313. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16))
  314. if templ_7745c5c3_Err != nil {
  315. return templ_7745c5c3_Err
  316. }
  317. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "\" style=\"max-width: 120px;\"")
  318. if templ_7745c5c3_Err != nil {
  319. return templ_7745c5c3_Err
  320. }
  321. if field.Required {
  322. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, " required")
  323. if templ_7745c5c3_Err != nil {
  324. return templ_7745c5c3_Err
  325. }
  326. }
  327. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, "><option value=\"minutes\"")
  328. if templ_7745c5c3_Err != nil {
  329. return templ_7745c5c3_Err
  330. }
  331. if components.GetInt32DisplayUnit(getTaskConfigInt32Field(config, field.JSONName)) == "minutes" {
  332. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, " selected")
  333. if templ_7745c5c3_Err != nil {
  334. return templ_7745c5c3_Err
  335. }
  336. }
  337. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, ">Minutes</option> <option value=\"hours\"")
  338. if templ_7745c5c3_Err != nil {
  339. return templ_7745c5c3_Err
  340. }
  341. if components.GetInt32DisplayUnit(getTaskConfigInt32Field(config, field.JSONName)) == "hours" {
  342. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, " selected")
  343. if templ_7745c5c3_Err != nil {
  344. return templ_7745c5c3_Err
  345. }
  346. }
  347. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, ">Hours</option> <option value=\"days\"")
  348. if templ_7745c5c3_Err != nil {
  349. return templ_7745c5c3_Err
  350. }
  351. if components.GetInt32DisplayUnit(getTaskConfigInt32Field(config, field.JSONName)) == "days" {
  352. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 32, " selected")
  353. if templ_7745c5c3_Err != nil {
  354. return templ_7745c5c3_Err
  355. }
  356. }
  357. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, ">Days</option></select></div>")
  358. if templ_7745c5c3_Err != nil {
  359. return templ_7745c5c3_Err
  360. }
  361. if field.Description != "" {
  362. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, "<div class=\"form-text text-muted\">")
  363. if templ_7745c5c3_Err != nil {
  364. return templ_7745c5c3_Err
  365. }
  366. var templ_7745c5c3_Var17 string
  367. templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(field.Description)
  368. if templ_7745c5c3_Err != nil {
  369. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/task_config_schema.templ`, Line: 253, Col: 69}
  370. }
  371. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17))
  372. if templ_7745c5c3_Err != nil {
  373. return templ_7745c5c3_Err
  374. }
  375. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 35, "</div>")
  376. if templ_7745c5c3_Err != nil {
  377. return templ_7745c5c3_Err
  378. }
  379. }
  380. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, "</div>")
  381. if templ_7745c5c3_Err != nil {
  382. return templ_7745c5c3_Err
  383. }
  384. } else if field.InputType == "checkbox" {
  385. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 37, "<!-- Checkbox field --> <div class=\"mb-3\"><div class=\"form-check form-switch\"><input class=\"form-check-input\" type=\"checkbox\" id=\"")
  386. if templ_7745c5c3_Err != nil {
  387. return templ_7745c5c3_Err
  388. }
  389. var templ_7745c5c3_Var18 string
  390. templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(field.JSONName)
  391. if templ_7745c5c3_Err != nil {
  392. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/task_config_schema.templ`, Line: 263, Col: 39}
  393. }
  394. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18))
  395. if templ_7745c5c3_Err != nil {
  396. return templ_7745c5c3_Err
  397. }
  398. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 38, "\" name=\"")
  399. if templ_7745c5c3_Err != nil {
  400. return templ_7745c5c3_Err
  401. }
  402. var templ_7745c5c3_Var19 string
  403. templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(field.JSONName)
  404. if templ_7745c5c3_Err != nil {
  405. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/task_config_schema.templ`, Line: 264, Col: 41}
  406. }
  407. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19))
  408. if templ_7745c5c3_Err != nil {
  409. return templ_7745c5c3_Err
  410. }
  411. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 39, "\" value=\"on\"")
  412. if templ_7745c5c3_Err != nil {
  413. return templ_7745c5c3_Err
  414. }
  415. if getTaskConfigBoolField(config, field.JSONName) {
  416. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 40, " checked")
  417. if templ_7745c5c3_Err != nil {
  418. return templ_7745c5c3_Err
  419. }
  420. }
  421. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 41, "> <label class=\"form-check-label\" for=\"")
  422. if templ_7745c5c3_Err != nil {
  423. return templ_7745c5c3_Err
  424. }
  425. var templ_7745c5c3_Var20 string
  426. templ_7745c5c3_Var20, templ_7745c5c3_Err = templ.JoinStringErrs(field.JSONName)
  427. if templ_7745c5c3_Err != nil {
  428. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/task_config_schema.templ`, Line: 270, Col: 68}
  429. }
  430. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var20))
  431. if templ_7745c5c3_Err != nil {
  432. return templ_7745c5c3_Err
  433. }
  434. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 42, "\"><strong>")
  435. if templ_7745c5c3_Err != nil {
  436. return templ_7745c5c3_Err
  437. }
  438. var templ_7745c5c3_Var21 string
  439. templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(field.DisplayName)
  440. if templ_7745c5c3_Err != nil {
  441. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/task_config_schema.templ`, Line: 271, Col: 47}
  442. }
  443. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21))
  444. if templ_7745c5c3_Err != nil {
  445. return templ_7745c5c3_Err
  446. }
  447. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 43, "</strong></label></div>")
  448. if templ_7745c5c3_Err != nil {
  449. return templ_7745c5c3_Err
  450. }
  451. if field.Description != "" {
  452. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 44, "<div class=\"form-text text-muted\">")
  453. if templ_7745c5c3_Err != nil {
  454. return templ_7745c5c3_Err
  455. }
  456. var templ_7745c5c3_Var22 string
  457. templ_7745c5c3_Var22, templ_7745c5c3_Err = templ.JoinStringErrs(field.Description)
  458. if templ_7745c5c3_Err != nil {
  459. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/task_config_schema.templ`, Line: 275, Col: 69}
  460. }
  461. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var22))
  462. if templ_7745c5c3_Err != nil {
  463. return templ_7745c5c3_Err
  464. }
  465. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 45, "</div>")
  466. if templ_7745c5c3_Err != nil {
  467. return templ_7745c5c3_Err
  468. }
  469. }
  470. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 46, "</div>")
  471. if templ_7745c5c3_Err != nil {
  472. return templ_7745c5c3_Err
  473. }
  474. } else if field.InputType == "text" {
  475. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 47, "<!-- Text field --> <div class=\"mb-3\"><label for=\"")
  476. if templ_7745c5c3_Err != nil {
  477. return templ_7745c5c3_Err
  478. }
  479. var templ_7745c5c3_Var23 string
  480. templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(field.JSONName)
  481. if templ_7745c5c3_Err != nil {
  482. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/task_config_schema.templ`, Line: 281, Col: 39}
  483. }
  484. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23))
  485. if templ_7745c5c3_Err != nil {
  486. return templ_7745c5c3_Err
  487. }
  488. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 48, "\" class=\"form-label\">")
  489. if templ_7745c5c3_Err != nil {
  490. return templ_7745c5c3_Err
  491. }
  492. var templ_7745c5c3_Var24 string
  493. templ_7745c5c3_Var24, templ_7745c5c3_Err = templ.JoinStringErrs(field.DisplayName)
  494. if templ_7745c5c3_Err != nil {
  495. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/task_config_schema.templ`, Line: 282, Col: 35}
  496. }
  497. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var24))
  498. if templ_7745c5c3_Err != nil {
  499. return templ_7745c5c3_Err
  500. }
  501. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 49, " ")
  502. if templ_7745c5c3_Err != nil {
  503. return templ_7745c5c3_Err
  504. }
  505. if field.Required {
  506. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 50, "<span class=\"text-danger\">*</span>")
  507. if templ_7745c5c3_Err != nil {
  508. return templ_7745c5c3_Err
  509. }
  510. }
  511. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 51, "</label> <input type=\"text\" class=\"form-control\" id=\"")
  512. if templ_7745c5c3_Err != nil {
  513. return templ_7745c5c3_Err
  514. }
  515. var templ_7745c5c3_Var25 string
  516. templ_7745c5c3_Var25, templ_7745c5c3_Err = templ.JoinStringErrs(field.JSONName)
  517. if templ_7745c5c3_Err != nil {
  518. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/task_config_schema.templ`, Line: 290, Col: 35}
  519. }
  520. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var25))
  521. if templ_7745c5c3_Err != nil {
  522. return templ_7745c5c3_Err
  523. }
  524. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 52, "\" name=\"")
  525. if templ_7745c5c3_Err != nil {
  526. return templ_7745c5c3_Err
  527. }
  528. var templ_7745c5c3_Var26 string
  529. templ_7745c5c3_Var26, templ_7745c5c3_Err = templ.JoinStringErrs(field.JSONName)
  530. if templ_7745c5c3_Err != nil {
  531. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/task_config_schema.templ`, Line: 291, Col: 37}
  532. }
  533. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var26))
  534. if templ_7745c5c3_Err != nil {
  535. return templ_7745c5c3_Err
  536. }
  537. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 53, "\" value=\"")
  538. if templ_7745c5c3_Err != nil {
  539. return templ_7745c5c3_Err
  540. }
  541. var templ_7745c5c3_Var27 string
  542. templ_7745c5c3_Var27, templ_7745c5c3_Err = templ.JoinStringErrs(getTaskConfigStringField(config, field.JSONName))
  543. if templ_7745c5c3_Err != nil {
  544. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/task_config_schema.templ`, Line: 292, Col: 72}
  545. }
  546. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var27))
  547. if templ_7745c5c3_Err != nil {
  548. return templ_7745c5c3_Err
  549. }
  550. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 54, "\" placeholder=\"")
  551. if templ_7745c5c3_Err != nil {
  552. return templ_7745c5c3_Err
  553. }
  554. var templ_7745c5c3_Var28 string
  555. templ_7745c5c3_Var28, templ_7745c5c3_Err = templ.JoinStringErrs(field.Placeholder)
  556. if templ_7745c5c3_Err != nil {
  557. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/task_config_schema.templ`, Line: 293, Col: 47}
  558. }
  559. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var28))
  560. if templ_7745c5c3_Err != nil {
  561. return templ_7745c5c3_Err
  562. }
  563. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 55, "\"")
  564. if templ_7745c5c3_Err != nil {
  565. return templ_7745c5c3_Err
  566. }
  567. if field.Required {
  568. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 56, " required")
  569. if templ_7745c5c3_Err != nil {
  570. return templ_7745c5c3_Err
  571. }
  572. }
  573. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 57, "> ")
  574. if templ_7745c5c3_Err != nil {
  575. return templ_7745c5c3_Err
  576. }
  577. if field.Description != "" {
  578. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 58, "<div class=\"form-text text-muted\">")
  579. if templ_7745c5c3_Err != nil {
  580. return templ_7745c5c3_Err
  581. }
  582. var templ_7745c5c3_Var29 string
  583. templ_7745c5c3_Var29, templ_7745c5c3_Err = templ.JoinStringErrs(field.Description)
  584. if templ_7745c5c3_Err != nil {
  585. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/task_config_schema.templ`, Line: 299, Col: 69}
  586. }
  587. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var29))
  588. if templ_7745c5c3_Err != nil {
  589. return templ_7745c5c3_Err
  590. }
  591. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 59, "</div>")
  592. if templ_7745c5c3_Err != nil {
  593. return templ_7745c5c3_Err
  594. }
  595. }
  596. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 60, "</div>")
  597. if templ_7745c5c3_Err != nil {
  598. return templ_7745c5c3_Err
  599. }
  600. } else {
  601. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 61, "<!-- Number field --> <div class=\"mb-3\"><label for=\"")
  602. if templ_7745c5c3_Err != nil {
  603. return templ_7745c5c3_Err
  604. }
  605. var templ_7745c5c3_Var30 string
  606. templ_7745c5c3_Var30, templ_7745c5c3_Err = templ.JoinStringErrs(field.JSONName)
  607. if templ_7745c5c3_Err != nil {
  608. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/task_config_schema.templ`, Line: 305, Col: 39}
  609. }
  610. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var30))
  611. if templ_7745c5c3_Err != nil {
  612. return templ_7745c5c3_Err
  613. }
  614. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 62, "\" class=\"form-label\">")
  615. if templ_7745c5c3_Err != nil {
  616. return templ_7745c5c3_Err
  617. }
  618. var templ_7745c5c3_Var31 string
  619. templ_7745c5c3_Var31, templ_7745c5c3_Err = templ.JoinStringErrs(field.DisplayName)
  620. if templ_7745c5c3_Err != nil {
  621. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/task_config_schema.templ`, Line: 306, Col: 35}
  622. }
  623. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var31))
  624. if templ_7745c5c3_Err != nil {
  625. return templ_7745c5c3_Err
  626. }
  627. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 63, " ")
  628. if templ_7745c5c3_Err != nil {
  629. return templ_7745c5c3_Err
  630. }
  631. if field.Required {
  632. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 64, "<span class=\"text-danger\">*</span>")
  633. if templ_7745c5c3_Err != nil {
  634. return templ_7745c5c3_Err
  635. }
  636. }
  637. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 65, "</label> <input type=\"number\" class=\"form-control\" id=\"")
  638. if templ_7745c5c3_Err != nil {
  639. return templ_7745c5c3_Err
  640. }
  641. var templ_7745c5c3_Var32 string
  642. templ_7745c5c3_Var32, templ_7745c5c3_Err = templ.JoinStringErrs(field.JSONName)
  643. if templ_7745c5c3_Err != nil {
  644. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/task_config_schema.templ`, Line: 314, Col: 35}
  645. }
  646. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var32))
  647. if templ_7745c5c3_Err != nil {
  648. return templ_7745c5c3_Err
  649. }
  650. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 66, "\" name=\"")
  651. if templ_7745c5c3_Err != nil {
  652. return templ_7745c5c3_Err
  653. }
  654. var templ_7745c5c3_Var33 string
  655. templ_7745c5c3_Var33, templ_7745c5c3_Err = templ.JoinStringErrs(field.JSONName)
  656. if templ_7745c5c3_Err != nil {
  657. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/task_config_schema.templ`, Line: 315, Col: 37}
  658. }
  659. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var33))
  660. if templ_7745c5c3_Err != nil {
  661. return templ_7745c5c3_Err
  662. }
  663. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 67, "\" value=\"")
  664. if templ_7745c5c3_Err != nil {
  665. return templ_7745c5c3_Err
  666. }
  667. var templ_7745c5c3_Var34 string
  668. templ_7745c5c3_Var34, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%.6g", getTaskConfigFloatField(config, field.JSONName)))
  669. if templ_7745c5c3_Err != nil {
  670. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/task_config_schema.templ`, Line: 316, Col: 92}
  671. }
  672. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var34))
  673. if templ_7745c5c3_Err != nil {
  674. return templ_7745c5c3_Err
  675. }
  676. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 68, "\" placeholder=\"")
  677. if templ_7745c5c3_Err != nil {
  678. return templ_7745c5c3_Err
  679. }
  680. var templ_7745c5c3_Var35 string
  681. templ_7745c5c3_Var35, templ_7745c5c3_Err = templ.JoinStringErrs(field.Placeholder)
  682. if templ_7745c5c3_Err != nil {
  683. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/task_config_schema.templ`, Line: 317, Col: 47}
  684. }
  685. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var35))
  686. if templ_7745c5c3_Err != nil {
  687. return templ_7745c5c3_Err
  688. }
  689. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 69, "\"")
  690. if templ_7745c5c3_Err != nil {
  691. return templ_7745c5c3_Err
  692. }
  693. if field.MinValue != nil {
  694. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 70, " min=\"")
  695. if templ_7745c5c3_Err != nil {
  696. return templ_7745c5c3_Err
  697. }
  698. var templ_7745c5c3_Var36 string
  699. templ_7745c5c3_Var36, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%v", field.MinValue))
  700. if templ_7745c5c3_Err != nil {
  701. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/task_config_schema.templ`, Line: 319, Col: 59}
  702. }
  703. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var36))
  704. if templ_7745c5c3_Err != nil {
  705. return templ_7745c5c3_Err
  706. }
  707. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 71, "\"")
  708. if templ_7745c5c3_Err != nil {
  709. return templ_7745c5c3_Err
  710. }
  711. }
  712. if field.MaxValue != nil {
  713. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 72, " max=\"")
  714. if templ_7745c5c3_Err != nil {
  715. return templ_7745c5c3_Err
  716. }
  717. var templ_7745c5c3_Var37 string
  718. templ_7745c5c3_Var37, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%v", field.MaxValue))
  719. if templ_7745c5c3_Err != nil {
  720. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/task_config_schema.templ`, Line: 322, Col: 59}
  721. }
  722. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var37))
  723. if templ_7745c5c3_Err != nil {
  724. return templ_7745c5c3_Err
  725. }
  726. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 73, "\"")
  727. if templ_7745c5c3_Err != nil {
  728. return templ_7745c5c3_Err
  729. }
  730. }
  731. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 74, " step=\"")
  732. if templ_7745c5c3_Err != nil {
  733. return templ_7745c5c3_Err
  734. }
  735. var templ_7745c5c3_Var38 string
  736. templ_7745c5c3_Var38, templ_7745c5c3_Err = templ.JoinStringErrs(getTaskNumberStep(field))
  737. if templ_7745c5c3_Err != nil {
  738. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/task_config_schema.templ`, Line: 324, Col: 47}
  739. }
  740. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var38))
  741. if templ_7745c5c3_Err != nil {
  742. return templ_7745c5c3_Err
  743. }
  744. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 75, "\"")
  745. if templ_7745c5c3_Err != nil {
  746. return templ_7745c5c3_Err
  747. }
  748. if field.Required {
  749. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 76, " required")
  750. if templ_7745c5c3_Err != nil {
  751. return templ_7745c5c3_Err
  752. }
  753. }
  754. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 77, "> ")
  755. if templ_7745c5c3_Err != nil {
  756. return templ_7745c5c3_Err
  757. }
  758. if field.Description != "" {
  759. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 78, "<div class=\"form-text text-muted\">")
  760. if templ_7745c5c3_Err != nil {
  761. return templ_7745c5c3_Err
  762. }
  763. var templ_7745c5c3_Var39 string
  764. templ_7745c5c3_Var39, templ_7745c5c3_Err = templ.JoinStringErrs(field.Description)
  765. if templ_7745c5c3_Err != nil {
  766. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/task_config_schema.templ`, Line: 330, Col: 69}
  767. }
  768. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var39))
  769. if templ_7745c5c3_Err != nil {
  770. return templ_7745c5c3_Err
  771. }
  772. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 79, "</div>")
  773. if templ_7745c5c3_Err != nil {
  774. return templ_7745c5c3_Err
  775. }
  776. }
  777. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 80, "</div>")
  778. if templ_7745c5c3_Err != nil {
  779. return templ_7745c5c3_Err
  780. }
  781. }
  782. return nil
  783. })
  784. }
  785. // Typed field getters for task configs - avoiding interface{} where possible
  786. func getTaskConfigBoolField(config interface{}, fieldName string) bool {
  787. switch fieldName {
  788. case "enabled":
  789. // Use reflection only for the common 'enabled' field in BaseConfig
  790. if value := getTaskFieldValue(config, fieldName); value != nil {
  791. if boolVal, ok := value.(bool); ok {
  792. return boolVal
  793. }
  794. }
  795. return false
  796. default:
  797. // For other boolean fields, use reflection
  798. if value := getTaskFieldValue(config, fieldName); value != nil {
  799. if boolVal, ok := value.(bool); ok {
  800. return boolVal
  801. }
  802. }
  803. return false
  804. }
  805. }
  806. func getTaskConfigInt32Field(config interface{}, fieldName string) int32 {
  807. switch fieldName {
  808. case "scan_interval_seconds", "max_concurrent":
  809. // Common fields that should be int/int32
  810. if value := getTaskFieldValue(config, fieldName); value != nil {
  811. switch v := value.(type) {
  812. case int32:
  813. return v
  814. case int:
  815. return int32(v)
  816. case int64:
  817. return int32(v)
  818. }
  819. }
  820. return 0
  821. default:
  822. // For other int fields, use reflection
  823. if value := getTaskFieldValue(config, fieldName); value != nil {
  824. switch v := value.(type) {
  825. case int32:
  826. return v
  827. case int:
  828. return int32(v)
  829. case int64:
  830. return int32(v)
  831. case float64:
  832. return int32(v)
  833. }
  834. }
  835. return 0
  836. }
  837. }
  838. func getTaskConfigFloatField(config interface{}, fieldName string) float64 {
  839. if value := getTaskFieldValue(config, fieldName); value != nil {
  840. switch v := value.(type) {
  841. case float64:
  842. return v
  843. case float32:
  844. return float64(v)
  845. case int:
  846. return float64(v)
  847. case int32:
  848. return float64(v)
  849. case int64:
  850. return float64(v)
  851. }
  852. }
  853. return 0.0
  854. }
  855. func getTaskConfigStringField(config interface{}, fieldName string) string {
  856. if value := getTaskFieldValue(config, fieldName); value != nil {
  857. if strVal, ok := value.(string); ok {
  858. return strVal
  859. }
  860. // Convert numbers to strings for form display
  861. switch v := value.(type) {
  862. case int:
  863. return fmt.Sprintf("%d", v)
  864. case int32:
  865. return fmt.Sprintf("%d", v)
  866. case int64:
  867. return fmt.Sprintf("%d", v)
  868. case float64:
  869. return fmt.Sprintf("%.6g", v)
  870. case float32:
  871. return fmt.Sprintf("%.6g", v)
  872. }
  873. }
  874. return ""
  875. }
  876. func getTaskNumberStep(field *config.Field) string {
  877. if field.Type == config.FieldTypeFloat {
  878. return "0.01"
  879. }
  880. return "1"
  881. }
  882. func getTaskFieldValue(config interface{}, fieldName string) interface{} {
  883. if config == nil {
  884. return nil
  885. }
  886. // Use reflection to get the field value from the config struct
  887. configValue := reflect.ValueOf(config)
  888. if configValue.Kind() == reflect.Ptr {
  889. configValue = configValue.Elem()
  890. }
  891. if configValue.Kind() != reflect.Struct {
  892. return nil
  893. }
  894. configType := configValue.Type()
  895. for i := 0; i < configValue.NumField(); i++ {
  896. field := configValue.Field(i)
  897. fieldType := configType.Field(i)
  898. // Handle embedded structs recursively (before JSON tag check)
  899. if field.Kind() == reflect.Struct && fieldType.Anonymous {
  900. if value := getTaskFieldValue(field.Interface(), fieldName); value != nil {
  901. return value
  902. }
  903. continue
  904. }
  905. // Get JSON tag name
  906. jsonTag := fieldType.Tag.Get("json")
  907. if jsonTag == "" {
  908. continue
  909. }
  910. // Remove options like ",omitempty"
  911. if commaIdx := strings.Index(jsonTag, ","); commaIdx > 0 {
  912. jsonTag = jsonTag[:commaIdx]
  913. }
  914. // Check if this is the field we're looking for
  915. if jsonTag == fieldName {
  916. return field.Interface()
  917. }
  918. }
  919. return nil
  920. }
  921. var _ = templruntime.GeneratedTemplate