ec_volume_details_templ.go 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  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. "fmt"
  9. "github.com/seaweedfs/seaweedfs/weed/admin/dash"
  10. )
  11. func EcVolumeDetails(data dash.EcVolumeDetailsData) templ.Component {
  12. return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
  13. templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
  14. if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
  15. return templ_7745c5c3_CtxErr
  16. }
  17. templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
  18. if !templ_7745c5c3_IsBuffer {
  19. defer func() {
  20. templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
  21. if templ_7745c5c3_Err == nil {
  22. templ_7745c5c3_Err = templ_7745c5c3_BufErr
  23. }
  24. }()
  25. }
  26. ctx = templ.InitializeContext(ctx)
  27. templ_7745c5c3_Var1 := templ.GetChildren(ctx)
  28. if templ_7745c5c3_Var1 == nil {
  29. templ_7745c5c3_Var1 = templ.NopComponent
  30. }
  31. ctx = templ.ClearChildren(ctx)
  32. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<div class=\"d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom\"><div><h1 class=\"h2\"><i class=\"fas fa-th-large me-2\"></i>EC Volume Details</h1><nav aria-label=\"breadcrumb\"><ol class=\"breadcrumb\"><li class=\"breadcrumb-item\"><a href=\"/admin\" class=\"text-decoration-none\">Dashboard</a></li><li class=\"breadcrumb-item\"><a href=\"/cluster/ec-shards\" class=\"text-decoration-none\">EC Volumes</a></li><li class=\"breadcrumb-item active\" aria-current=\"page\">Volume ")
  33. if templ_7745c5c3_Err != nil {
  34. return templ_7745c5c3_Err
  35. }
  36. var templ_7745c5c3_Var2 string
  37. templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d", data.VolumeID))
  38. if templ_7745c5c3_Err != nil {
  39. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/ec_volume_details.templ`, Line: 18, Col: 115}
  40. }
  41. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
  42. if templ_7745c5c3_Err != nil {
  43. return templ_7745c5c3_Err
  44. }
  45. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "</li></ol></nav></div><div class=\"btn-toolbar mb-2 mb-md-0\"><div class=\"btn-group me-2\"><button type=\"button\" class=\"btn btn-sm btn-outline-secondary\" onclick=\"history.back()\"><i class=\"fas fa-arrow-left me-1\"></i>Back</button> <button type=\"button\" class=\"btn btn-sm btn-outline-primary\" onclick=\"window.location.reload()\"><i class=\"fas fa-refresh me-1\"></i>Refresh</button></div></div></div><!-- EC Volume Summary --><div class=\"row mb-4\"><div class=\"col-md-6\"><div class=\"card\"><div class=\"card-header\"><h5 class=\"card-title mb-0\"><i class=\"fas fa-info-circle me-2\"></i>Volume Information</h5></div><div class=\"card-body\"><table class=\"table table-borderless\"><tr><td><strong>Volume ID:</strong></td><td>")
  46. if templ_7745c5c3_Err != nil {
  47. return templ_7745c5c3_Err
  48. }
  49. var templ_7745c5c3_Var3 string
  50. templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d", data.VolumeID))
  51. if templ_7745c5c3_Err != nil {
  52. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/ec_volume_details.templ`, Line: 47, Col: 65}
  53. }
  54. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
  55. if templ_7745c5c3_Err != nil {
  56. return templ_7745c5c3_Err
  57. }
  58. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "</td></tr><tr><td><strong>Collection:</strong></td><td>")
  59. if templ_7745c5c3_Err != nil {
  60. return templ_7745c5c3_Err
  61. }
  62. if data.Collection != "" {
  63. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "<span class=\"badge bg-info\">")
  64. if templ_7745c5c3_Err != nil {
  65. return templ_7745c5c3_Err
  66. }
  67. var templ_7745c5c3_Var4 string
  68. templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(data.Collection)
  69. if templ_7745c5c3_Err != nil {
  70. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/ec_volume_details.templ`, Line: 53, Col: 80}
  71. }
  72. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
  73. if templ_7745c5c3_Err != nil {
  74. return templ_7745c5c3_Err
  75. }
  76. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "</span>")
  77. if templ_7745c5c3_Err != nil {
  78. return templ_7745c5c3_Err
  79. }
  80. } else {
  81. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "<span class=\"text-muted\">default</span>")
  82. if templ_7745c5c3_Err != nil {
  83. return templ_7745c5c3_Err
  84. }
  85. }
  86. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "</td></tr><tr><td><strong>Status:</strong></td><td>")
  87. if templ_7745c5c3_Err != nil {
  88. return templ_7745c5c3_Err
  89. }
  90. if data.IsComplete {
  91. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "<span class=\"badge bg-success\"><i class=\"fas fa-check me-1\"></i>Complete (")
  92. if templ_7745c5c3_Err != nil {
  93. return templ_7745c5c3_Err
  94. }
  95. var templ_7745c5c3_Var5 string
  96. templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(data.TotalShards)
  97. if templ_7745c5c3_Err != nil {
  98. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/ec_volume_details.templ`, Line: 64, Col: 100}
  99. }
  100. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
  101. if templ_7745c5c3_Err != nil {
  102. return templ_7745c5c3_Err
  103. }
  104. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "/14 shards)</span>")
  105. if templ_7745c5c3_Err != nil {
  106. return templ_7745c5c3_Err
  107. }
  108. } else {
  109. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "<span class=\"badge bg-warning\"><i class=\"fas fa-exclamation-triangle me-1\"></i>Incomplete (")
  110. if templ_7745c5c3_Err != nil {
  111. return templ_7745c5c3_Err
  112. }
  113. var templ_7745c5c3_Var6 string
  114. templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(data.TotalShards)
  115. if templ_7745c5c3_Err != nil {
  116. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/ec_volume_details.templ`, Line: 68, Col: 117}
  117. }
  118. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
  119. if templ_7745c5c3_Err != nil {
  120. return templ_7745c5c3_Err
  121. }
  122. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "/14 shards)</span>")
  123. if templ_7745c5c3_Err != nil {
  124. return templ_7745c5c3_Err
  125. }
  126. }
  127. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "</td></tr>")
  128. if templ_7745c5c3_Err != nil {
  129. return templ_7745c5c3_Err
  130. }
  131. if !data.IsComplete {
  132. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "<tr><td><strong>Missing Shards:</strong></td><td>")
  133. if templ_7745c5c3_Err != nil {
  134. return templ_7745c5c3_Err
  135. }
  136. for i, shardID := range data.MissingShards {
  137. if i > 0 {
  138. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "<span>, </span>")
  139. if templ_7745c5c3_Err != nil {
  140. return templ_7745c5c3_Err
  141. }
  142. }
  143. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, " <span class=\"badge bg-danger\">")
  144. if templ_7745c5c3_Err != nil {
  145. return templ_7745c5c3_Err
  146. }
  147. var templ_7745c5c3_Var7 string
  148. templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%02d", shardID))
  149. if templ_7745c5c3_Err != nil {
  150. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/ec_volume_details.templ`, Line: 81, Col: 99}
  151. }
  152. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
  153. if templ_7745c5c3_Err != nil {
  154. return templ_7745c5c3_Err
  155. }
  156. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "</span>")
  157. if templ_7745c5c3_Err != nil {
  158. return templ_7745c5c3_Err
  159. }
  160. }
  161. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "</td></tr>")
  162. if templ_7745c5c3_Err != nil {
  163. return templ_7745c5c3_Err
  164. }
  165. }
  166. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "<tr><td><strong>Data Centers:</strong></td><td>")
  167. if templ_7745c5c3_Err != nil {
  168. return templ_7745c5c3_Err
  169. }
  170. for i, dc := range data.DataCenters {
  171. if i > 0 {
  172. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "<span>, </span>")
  173. if templ_7745c5c3_Err != nil {
  174. return templ_7745c5c3_Err
  175. }
  176. }
  177. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, " <span class=\"badge bg-primary\">")
  178. if templ_7745c5c3_Err != nil {
  179. return templ_7745c5c3_Err
  180. }
  181. var templ_7745c5c3_Var8 string
  182. templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(dc)
  183. if templ_7745c5c3_Err != nil {
  184. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/ec_volume_details.templ`, Line: 93, Col: 70}
  185. }
  186. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
  187. if templ_7745c5c3_Err != nil {
  188. return templ_7745c5c3_Err
  189. }
  190. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "</span>")
  191. if templ_7745c5c3_Err != nil {
  192. return templ_7745c5c3_Err
  193. }
  194. }
  195. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "</td></tr><tr><td><strong>Servers:</strong></td><td><span class=\"text-muted\">")
  196. if templ_7745c5c3_Err != nil {
  197. return templ_7745c5c3_Err
  198. }
  199. var templ_7745c5c3_Var9 string
  200. templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d servers", len(data.Servers)))
  201. if templ_7745c5c3_Err != nil {
  202. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/ec_volume_details.templ`, Line: 100, Col: 102}
  203. }
  204. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
  205. if templ_7745c5c3_Err != nil {
  206. return templ_7745c5c3_Err
  207. }
  208. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "</span></td></tr><tr><td><strong>Last Updated:</strong></td><td><span class=\"text-muted\">")
  209. if templ_7745c5c3_Err != nil {
  210. return templ_7745c5c3_Err
  211. }
  212. var templ_7745c5c3_Var10 string
  213. templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(data.LastUpdated.Format("2006-01-02 15:04:05"))
  214. if templ_7745c5c3_Err != nil {
  215. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/ec_volume_details.templ`, Line: 106, Col: 104}
  216. }
  217. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10))
  218. if templ_7745c5c3_Err != nil {
  219. return templ_7745c5c3_Err
  220. }
  221. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, "</span></td></tr></table></div></div></div><div class=\"col-md-6\"><div class=\"card\"><div class=\"card-header\"><h5 class=\"card-title mb-0\"><i class=\"fas fa-chart-pie me-2\"></i>Shard Distribution</h5></div><div class=\"card-body\"><div class=\"row text-center\"><div class=\"col-4\"><div class=\"border rounded p-3\"><h3 class=\"text-primary mb-1\">")
  222. if templ_7745c5c3_Err != nil {
  223. return templ_7745c5c3_Err
  224. }
  225. var templ_7745c5c3_Var11 string
  226. templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d", data.TotalShards))
  227. if templ_7745c5c3_Err != nil {
  228. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/ec_volume_details.templ`, Line: 125, Col: 98}
  229. }
  230. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11))
  231. if templ_7745c5c3_Err != nil {
  232. return templ_7745c5c3_Err
  233. }
  234. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "</h3><small class=\"text-muted\">Total Shards</small></div></div><div class=\"col-4\"><div class=\"border rounded p-3\"><h3 class=\"text-success mb-1\">")
  235. if templ_7745c5c3_Err != nil {
  236. return templ_7745c5c3_Err
  237. }
  238. var templ_7745c5c3_Var12 string
  239. templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d", len(data.DataCenters)))
  240. if templ_7745c5c3_Err != nil {
  241. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/ec_volume_details.templ`, Line: 131, Col: 103}
  242. }
  243. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12))
  244. if templ_7745c5c3_Err != nil {
  245. return templ_7745c5c3_Err
  246. }
  247. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, "</h3><small class=\"text-muted\">Data Centers</small></div></div><div class=\"col-4\"><div class=\"border rounded p-3\"><h3 class=\"text-info mb-1\">")
  248. if templ_7745c5c3_Err != nil {
  249. return templ_7745c5c3_Err
  250. }
  251. var templ_7745c5c3_Var13 string
  252. templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d", len(data.Servers)))
  253. if templ_7745c5c3_Err != nil {
  254. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/ec_volume_details.templ`, Line: 137, Col: 96}
  255. }
  256. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
  257. if templ_7745c5c3_Err != nil {
  258. return templ_7745c5c3_Err
  259. }
  260. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, "</h3><small class=\"text-muted\">Servers</small></div></div></div><!-- Shard Distribution Visualization --><div class=\"mt-3\"><h6>Present Shards:</h6><div class=\"d-flex flex-wrap gap-1\">")
  261. if templ_7745c5c3_Err != nil {
  262. return templ_7745c5c3_Err
  263. }
  264. for _, shard := range data.Shards {
  265. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "<span class=\"badge bg-success me-1 mb-1\">")
  266. if templ_7745c5c3_Err != nil {
  267. return templ_7745c5c3_Err
  268. }
  269. var templ_7745c5c3_Var14 string
  270. templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%02d", shard.ShardID))
  271. if templ_7745c5c3_Err != nil {
  272. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/ec_volume_details.templ`, Line: 148, Col: 108}
  273. }
  274. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14))
  275. if templ_7745c5c3_Err != nil {
  276. return templ_7745c5c3_Err
  277. }
  278. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, "</span>")
  279. if templ_7745c5c3_Err != nil {
  280. return templ_7745c5c3_Err
  281. }
  282. }
  283. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, "</div>")
  284. if templ_7745c5c3_Err != nil {
  285. return templ_7745c5c3_Err
  286. }
  287. if len(data.MissingShards) > 0 {
  288. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, "<h6 class=\"mt-2\">Missing Shards:</h6><div class=\"d-flex flex-wrap gap-1\">")
  289. if templ_7745c5c3_Err != nil {
  290. return templ_7745c5c3_Err
  291. }
  292. for _, shardID := range data.MissingShards {
  293. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 32, "<span class=\"badge bg-secondary me-1 mb-1\">")
  294. if templ_7745c5c3_Err != nil {
  295. return templ_7745c5c3_Err
  296. }
  297. var templ_7745c5c3_Var15 string
  298. templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%02d", shardID))
  299. if templ_7745c5c3_Err != nil {
  300. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/ec_volume_details.templ`, Line: 155, Col: 108}
  301. }
  302. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15))
  303. if templ_7745c5c3_Err != nil {
  304. return templ_7745c5c3_Err
  305. }
  306. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, "</span>")
  307. if templ_7745c5c3_Err != nil {
  308. return templ_7745c5c3_Err
  309. }
  310. }
  311. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, "</div>")
  312. if templ_7745c5c3_Err != nil {
  313. return templ_7745c5c3_Err
  314. }
  315. }
  316. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 35, "</div></div></div></div></div><!-- Shard Details Table --><div class=\"card\"><div class=\"card-header\"><h5 class=\"card-title mb-0\"><i class=\"fas fa-list me-2\"></i>Shard Details</h5></div><div class=\"card-body\">")
  317. if templ_7745c5c3_Err != nil {
  318. return templ_7745c5c3_Err
  319. }
  320. if len(data.Shards) > 0 {
  321. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, "<div class=\"table-responsive\"><table class=\"table table-striped table-hover\"><thead><tr><th><a href=\"#\" onclick=\"sortBy('shard_id')\" class=\"text-dark text-decoration-none\">Shard ID ")
  322. if templ_7745c5c3_Err != nil {
  323. return templ_7745c5c3_Err
  324. }
  325. if data.SortBy == "shard_id" {
  326. if data.SortOrder == "asc" {
  327. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 37, "<i class=\"fas fa-sort-up ms-1\"></i>")
  328. if templ_7745c5c3_Err != nil {
  329. return templ_7745c5c3_Err
  330. }
  331. } else {
  332. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 38, "<i class=\"fas fa-sort-down ms-1\"></i>")
  333. if templ_7745c5c3_Err != nil {
  334. return templ_7745c5c3_Err
  335. }
  336. }
  337. } else {
  338. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 39, "<i class=\"fas fa-sort ms-1 text-muted\"></i>")
  339. if templ_7745c5c3_Err != nil {
  340. return templ_7745c5c3_Err
  341. }
  342. }
  343. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 40, "</a></th><th><a href=\"#\" onclick=\"sortBy('server')\" class=\"text-dark text-decoration-none\">Server ")
  344. if templ_7745c5c3_Err != nil {
  345. return templ_7745c5c3_Err
  346. }
  347. if data.SortBy == "server" {
  348. if data.SortOrder == "asc" {
  349. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 41, "<i class=\"fas fa-sort-up ms-1\"></i>")
  350. if templ_7745c5c3_Err != nil {
  351. return templ_7745c5c3_Err
  352. }
  353. } else {
  354. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 42, "<i class=\"fas fa-sort-down ms-1\"></i>")
  355. if templ_7745c5c3_Err != nil {
  356. return templ_7745c5c3_Err
  357. }
  358. }
  359. } else {
  360. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 43, "<i class=\"fas fa-sort ms-1 text-muted\"></i>")
  361. if templ_7745c5c3_Err != nil {
  362. return templ_7745c5c3_Err
  363. }
  364. }
  365. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 44, "</a></th><th><a href=\"#\" onclick=\"sortBy('data_center')\" class=\"text-dark text-decoration-none\">Data Center ")
  366. if templ_7745c5c3_Err != nil {
  367. return templ_7745c5c3_Err
  368. }
  369. if data.SortBy == "data_center" {
  370. if data.SortOrder == "asc" {
  371. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 45, "<i class=\"fas fa-sort-up ms-1\"></i>")
  372. if templ_7745c5c3_Err != nil {
  373. return templ_7745c5c3_Err
  374. }
  375. } else {
  376. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 46, "<i class=\"fas fa-sort-down ms-1\"></i>")
  377. if templ_7745c5c3_Err != nil {
  378. return templ_7745c5c3_Err
  379. }
  380. }
  381. } else {
  382. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 47, "<i class=\"fas fa-sort ms-1 text-muted\"></i>")
  383. if templ_7745c5c3_Err != nil {
  384. return templ_7745c5c3_Err
  385. }
  386. }
  387. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 48, "</a></th><th><a href=\"#\" onclick=\"sortBy('rack')\" class=\"text-dark text-decoration-none\">Rack ")
  388. if templ_7745c5c3_Err != nil {
  389. return templ_7745c5c3_Err
  390. }
  391. if data.SortBy == "rack" {
  392. if data.SortOrder == "asc" {
  393. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 49, "<i class=\"fas fa-sort-up ms-1\"></i>")
  394. if templ_7745c5c3_Err != nil {
  395. return templ_7745c5c3_Err
  396. }
  397. } else {
  398. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 50, "<i class=\"fas fa-sort-down ms-1\"></i>")
  399. if templ_7745c5c3_Err != nil {
  400. return templ_7745c5c3_Err
  401. }
  402. }
  403. } else {
  404. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 51, "<i class=\"fas fa-sort ms-1 text-muted\"></i>")
  405. if templ_7745c5c3_Err != nil {
  406. return templ_7745c5c3_Err
  407. }
  408. }
  409. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 52, "</a></th><th class=\"text-dark\">Disk Type</th><th class=\"text-dark\">Shard Size</th><th class=\"text-dark\">Actions</th></tr></thead> <tbody>")
  410. if templ_7745c5c3_Err != nil {
  411. return templ_7745c5c3_Err
  412. }
  413. for _, shard := range data.Shards {
  414. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 53, "<tr><td><span class=\"badge bg-primary\">")
  415. if templ_7745c5c3_Err != nil {
  416. return templ_7745c5c3_Err
  417. }
  418. var templ_7745c5c3_Var16 string
  419. templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%02d", shard.ShardID))
  420. if templ_7745c5c3_Err != nil {
  421. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/ec_volume_details.templ`, Line: 243, Col: 110}
  422. }
  423. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16))
  424. if templ_7745c5c3_Err != nil {
  425. return templ_7745c5c3_Err
  426. }
  427. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 54, "</span></td><td><a href=\"")
  428. if templ_7745c5c3_Err != nil {
  429. return templ_7745c5c3_Err
  430. }
  431. var templ_7745c5c3_Var17 templ.SafeURL
  432. templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinURLErrs(templ.URL("/cluster/volume-servers/" + shard.Server))
  433. if templ_7745c5c3_Err != nil {
  434. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/ec_volume_details.templ`, Line: 246, Col: 106}
  435. }
  436. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17))
  437. if templ_7745c5c3_Err != nil {
  438. return templ_7745c5c3_Err
  439. }
  440. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 55, "\" class=\"text-primary text-decoration-none\"><code class=\"small\">")
  441. if templ_7745c5c3_Err != nil {
  442. return templ_7745c5c3_Err
  443. }
  444. var templ_7745c5c3_Var18 string
  445. templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(shard.Server)
  446. if templ_7745c5c3_Err != nil {
  447. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/ec_volume_details.templ`, Line: 247, Col: 81}
  448. }
  449. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18))
  450. if templ_7745c5c3_Err != nil {
  451. return templ_7745c5c3_Err
  452. }
  453. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 56, "</code></a></td><td><span class=\"badge bg-primary text-white\">")
  454. if templ_7745c5c3_Err != nil {
  455. return templ_7745c5c3_Err
  456. }
  457. var templ_7745c5c3_Var19 string
  458. templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(shard.DataCenter)
  459. if templ_7745c5c3_Err != nil {
  460. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/ec_volume_details.templ`, Line: 251, Col: 103}
  461. }
  462. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19))
  463. if templ_7745c5c3_Err != nil {
  464. return templ_7745c5c3_Err
  465. }
  466. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 57, "</span></td><td><span class=\"badge bg-secondary text-white\">")
  467. if templ_7745c5c3_Err != nil {
  468. return templ_7745c5c3_Err
  469. }
  470. var templ_7745c5c3_Var20 string
  471. templ_7745c5c3_Var20, templ_7745c5c3_Err = templ.JoinStringErrs(shard.Rack)
  472. if templ_7745c5c3_Err != nil {
  473. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/ec_volume_details.templ`, Line: 254, Col: 99}
  474. }
  475. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var20))
  476. if templ_7745c5c3_Err != nil {
  477. return templ_7745c5c3_Err
  478. }
  479. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 58, "</span></td><td><span class=\"text-dark\">")
  480. if templ_7745c5c3_Err != nil {
  481. return templ_7745c5c3_Err
  482. }
  483. var templ_7745c5c3_Var21 string
  484. templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(shard.DiskType)
  485. if templ_7745c5c3_Err != nil {
  486. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/ec_volume_details.templ`, Line: 257, Col: 83}
  487. }
  488. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21))
  489. if templ_7745c5c3_Err != nil {
  490. return templ_7745c5c3_Err
  491. }
  492. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 59, "</span></td><td><span class=\"text-success\">")
  493. if templ_7745c5c3_Err != nil {
  494. return templ_7745c5c3_Err
  495. }
  496. var templ_7745c5c3_Var22 string
  497. templ_7745c5c3_Var22, templ_7745c5c3_Err = templ.JoinStringErrs(bytesToHumanReadableUint64(shard.Size))
  498. if templ_7745c5c3_Err != nil {
  499. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/ec_volume_details.templ`, Line: 260, Col: 110}
  500. }
  501. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var22))
  502. if templ_7745c5c3_Err != nil {
  503. return templ_7745c5c3_Err
  504. }
  505. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 60, "</span></td><td><a href=\"")
  506. if templ_7745c5c3_Err != nil {
  507. return templ_7745c5c3_Err
  508. }
  509. var templ_7745c5c3_Var23 templ.SafeURL
  510. templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinURLErrs(templ.SafeURL(fmt.Sprintf("http://%s/ui/index.html", shard.Server)))
  511. if templ_7745c5c3_Err != nil {
  512. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/ec_volume_details.templ`, Line: 263, Col: 121}
  513. }
  514. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23))
  515. if templ_7745c5c3_Err != nil {
  516. return templ_7745c5c3_Err
  517. }
  518. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 61, "\" target=\"_blank\" class=\"btn btn-sm btn-primary\"><i class=\"fas fa-external-link-alt me-1\"></i>Volume Server</a></td></tr>")
  519. if templ_7745c5c3_Err != nil {
  520. return templ_7745c5c3_Err
  521. }
  522. }
  523. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 62, "</tbody></table></div>")
  524. if templ_7745c5c3_Err != nil {
  525. return templ_7745c5c3_Err
  526. }
  527. } else {
  528. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 63, "<div class=\"text-center py-4\"><i class=\"fas fa-exclamation-triangle fa-3x text-warning mb-3\"></i><h5>No EC shards found</h5><p class=\"text-muted\">This volume may not be EC encoded yet.</p></div>")
  529. if templ_7745c5c3_Err != nil {
  530. return templ_7745c5c3_Err
  531. }
  532. }
  533. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 64, "</div></div><script>\n // Sorting functionality\n function sortBy(field) {\n const currentSort = new URLSearchParams(window.location.search).get('sort_by');\n const currentOrder = new URLSearchParams(window.location.search).get('sort_order') || 'asc';\n \n let newOrder = 'asc';\n if (currentSort === field && currentOrder === 'asc') {\n newOrder = 'desc';\n }\n \n const url = new URL(window.location);\n url.searchParams.set('sort_by', field);\n url.searchParams.set('sort_order', newOrder);\n window.location.href = url.toString();\n }\n </script>")
  534. if templ_7745c5c3_Err != nil {
  535. return templ_7745c5c3_Err
  536. }
  537. return nil
  538. })
  539. }
  540. // Helper function to convert bytes to human readable format (uint64 version)
  541. func bytesToHumanReadableUint64(bytes uint64) string {
  542. const unit = 1024
  543. if bytes < unit {
  544. return fmt.Sprintf("%dB", bytes)
  545. }
  546. div, exp := uint64(unit), 0
  547. for n := bytes / unit; n >= unit; n /= unit {
  548. div *= unit
  549. exp++
  550. }
  551. return fmt.Sprintf("%.1f%cB", float64(bytes)/float64(div), "KMGTPE"[exp])
  552. }
  553. var _ = templruntime.GeneratedTemplate