subscribers_templ.go 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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 "fmt"
  8. import "github.com/seaweedfs/seaweedfs/weed/admin/dash"
  9. func Subscribers(data dash.SubscribersData) templ.Component {
  10. return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
  11. templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
  12. if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
  13. return templ_7745c5c3_CtxErr
  14. }
  15. templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
  16. if !templ_7745c5c3_IsBuffer {
  17. defer func() {
  18. templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
  19. if templ_7745c5c3_Err == nil {
  20. templ_7745c5c3_Err = templ_7745c5c3_BufErr
  21. }
  22. }()
  23. }
  24. ctx = templ.InitializeContext(ctx)
  25. templ_7745c5c3_Var1 := templ.GetChildren(ctx)
  26. if templ_7745c5c3_Var1 == nil {
  27. templ_7745c5c3_Var1 = templ.NopComponent
  28. }
  29. ctx = templ.ClearChildren(ctx)
  30. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<div class=\"container-fluid\"><div class=\"row\"><div class=\"col-12\"><div class=\"d-flex justify-content-between align-items-center mb-4\"><h1 class=\"h3 mb-0\">Message Queue Subscribers</h1><small class=\"text-muted\">Last updated: ")
  31. if templ_7745c5c3_Err != nil {
  32. return templ_7745c5c3_Err
  33. }
  34. var templ_7745c5c3_Var2 string
  35. templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(data.LastUpdated.Format("2006-01-02 15:04:05"))
  36. if templ_7745c5c3_Err != nil {
  37. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/subscribers.templ`, Line: 12, Col: 107}
  38. }
  39. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
  40. if templ_7745c5c3_Err != nil {
  41. return templ_7745c5c3_Err
  42. }
  43. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "</small></div><!-- Summary Cards --><div class=\"row mb-4\"><div class=\"col-md-4\"><div class=\"card text-center\"><div class=\"card-body\"><h5 class=\"card-title\">Total Subscribers</h5><h3 class=\"text-primary\">")
  44. if templ_7745c5c3_Err != nil {
  45. return templ_7745c5c3_Err
  46. }
  47. var templ_7745c5c3_Var3 string
  48. templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d", data.TotalSubscribers))
  49. if templ_7745c5c3_Err != nil {
  50. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/subscribers.templ`, Line: 21, Col: 98}
  51. }
  52. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
  53. if templ_7745c5c3_Err != nil {
  54. return templ_7745c5c3_Err
  55. }
  56. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "</h3></div></div></div><div class=\"col-md-4\"><div class=\"card text-center\"><div class=\"card-body\"><h5 class=\"card-title\">Active Subscribers</h5><h3 class=\"text-success\">")
  57. if templ_7745c5c3_Err != nil {
  58. return templ_7745c5c3_Err
  59. }
  60. var templ_7745c5c3_Var4 string
  61. templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d", data.ActiveSubscribers))
  62. if templ_7745c5c3_Err != nil {
  63. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/subscribers.templ`, Line: 29, Col: 99}
  64. }
  65. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
  66. if templ_7745c5c3_Err != nil {
  67. return templ_7745c5c3_Err
  68. }
  69. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "</h3></div></div></div><div class=\"col-md-4\"><div class=\"card text-center\"><div class=\"card-body\"><h5 class=\"card-title\">Inactive Subscribers</h5><h3 class=\"text-warning\">")
  70. if templ_7745c5c3_Err != nil {
  71. return templ_7745c5c3_Err
  72. }
  73. var templ_7745c5c3_Var5 string
  74. templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d", data.TotalSubscribers-data.ActiveSubscribers))
  75. if templ_7745c5c3_Err != nil {
  76. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/subscribers.templ`, Line: 37, Col: 123}
  77. }
  78. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
  79. if templ_7745c5c3_Err != nil {
  80. return templ_7745c5c3_Err
  81. }
  82. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "</h3></div></div></div></div><!-- Subscribers Table --><div class=\"card\"><div class=\"card-header d-flex justify-content-between align-items-center\"><h5 class=\"mb-0\">Subscribers</h5><div><button class=\"btn btn-sm btn-outline-secondary\" onclick=\"exportSubscribersCSV()\"><i class=\"fas fa-download me-1\"></i>Export CSV</button></div></div><div class=\"card-body\">")
  83. if templ_7745c5c3_Err != nil {
  84. return templ_7745c5c3_Err
  85. }
  86. if len(data.Subscribers) == 0 {
  87. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "<div class=\"text-center py-4\"><i class=\"fas fa-user-friends fa-3x text-muted mb-3\"></i><h5>No Subscribers Found</h5><p class=\"text-muted\">No message queue subscribers are currently active.</p></div>")
  88. if templ_7745c5c3_Err != nil {
  89. return templ_7745c5c3_Err
  90. }
  91. } else {
  92. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "<div class=\"table-responsive\"><table class=\"table table-striped\" id=\"subscribersTable\"><thead><tr><th>Subscriber Name</th><th>Topic</th><th>Consumer Group</th><th>Status</th><th>Messages Processed</th><th>Last Seen</th><th>Created</th></tr></thead> <tbody>")
  93. if templ_7745c5c3_Err != nil {
  94. return templ_7745c5c3_Err
  95. }
  96. for _, subscriber := range data.Subscribers {
  97. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "<tr><td><strong>")
  98. if templ_7745c5c3_Err != nil {
  99. return templ_7745c5c3_Err
  100. }
  101. var templ_7745c5c3_Var6 string
  102. templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(subscriber.Name)
  103. if templ_7745c5c3_Err != nil {
  104. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/subscribers.templ`, Line: 78, Col: 76}
  105. }
  106. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
  107. if templ_7745c5c3_Err != nil {
  108. return templ_7745c5c3_Err
  109. }
  110. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "</strong></td><td><span class=\"badge bg-info\">")
  111. if templ_7745c5c3_Err != nil {
  112. return templ_7745c5c3_Err
  113. }
  114. var templ_7745c5c3_Var7 string
  115. templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(subscriber.Topic)
  116. if templ_7745c5c3_Err != nil {
  117. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/subscribers.templ`, Line: 81, Col: 97}
  118. }
  119. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
  120. if templ_7745c5c3_Err != nil {
  121. return templ_7745c5c3_Err
  122. }
  123. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "</span></td><td>")
  124. if templ_7745c5c3_Err != nil {
  125. return templ_7745c5c3_Err
  126. }
  127. var templ_7745c5c3_Var8 string
  128. templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(subscriber.ConsumerGroup)
  129. if templ_7745c5c3_Err != nil {
  130. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/subscribers.templ`, Line: 83, Col: 77}
  131. }
  132. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
  133. if templ_7745c5c3_Err != nil {
  134. return templ_7745c5c3_Err
  135. }
  136. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "</td><td>")
  137. if templ_7745c5c3_Err != nil {
  138. return templ_7745c5c3_Err
  139. }
  140. if subscriber.Status == "active" {
  141. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "<span class=\"badge bg-success\">Active</span>")
  142. if templ_7745c5c3_Err != nil {
  143. return templ_7745c5c3_Err
  144. }
  145. } else if subscriber.Status == "inactive" {
  146. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "<span class=\"badge bg-warning\">Inactive</span>")
  147. if templ_7745c5c3_Err != nil {
  148. return templ_7745c5c3_Err
  149. }
  150. } else {
  151. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "<span class=\"badge bg-secondary\">")
  152. if templ_7745c5c3_Err != nil {
  153. return templ_7745c5c3_Err
  154. }
  155. var templ_7745c5c3_Var9 string
  156. templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(subscriber.Status)
  157. if templ_7745c5c3_Err != nil {
  158. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/subscribers.templ`, Line: 90, Col: 107}
  159. }
  160. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
  161. if templ_7745c5c3_Err != nil {
  162. return templ_7745c5c3_Err
  163. }
  164. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "</span>")
  165. if templ_7745c5c3_Err != nil {
  166. return templ_7745c5c3_Err
  167. }
  168. }
  169. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "</td><td>")
  170. if templ_7745c5c3_Err != nil {
  171. return templ_7745c5c3_Err
  172. }
  173. var templ_7745c5c3_Var10 string
  174. templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d", subscriber.MessageCount))
  175. if templ_7745c5c3_Err != nil {
  176. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/subscribers.templ`, Line: 93, Col: 95}
  177. }
  178. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10))
  179. if templ_7745c5c3_Err != nil {
  180. return templ_7745c5c3_Err
  181. }
  182. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "</td><td>")
  183. if templ_7745c5c3_Err != nil {
  184. return templ_7745c5c3_Err
  185. }
  186. if !subscriber.LastSeen.IsZero() {
  187. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "<span class=\"text-muted\">")
  188. if templ_7745c5c3_Err != nil {
  189. return templ_7745c5c3_Err
  190. }
  191. var templ_7745c5c3_Var11 string
  192. templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(subscriber.LastSeen.Format("2006-01-02 15:04:05"))
  193. if templ_7745c5c3_Err != nil {
  194. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/subscribers.templ`, Line: 96, Col: 131}
  195. }
  196. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11))
  197. if templ_7745c5c3_Err != nil {
  198. return templ_7745c5c3_Err
  199. }
  200. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "</span>")
  201. if templ_7745c5c3_Err != nil {
  202. return templ_7745c5c3_Err
  203. }
  204. } else {
  205. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "<span class=\"text-muted\">Never</span>")
  206. if templ_7745c5c3_Err != nil {
  207. return templ_7745c5c3_Err
  208. }
  209. }
  210. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "</td><td><span class=\"text-muted\">")
  211. if templ_7745c5c3_Err != nil {
  212. return templ_7745c5c3_Err
  213. }
  214. var templ_7745c5c3_Var12 string
  215. templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(subscriber.CreatedAt.Format("2006-01-02 15:04:05"))
  216. if templ_7745c5c3_Err != nil {
  217. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/subscribers.templ`, Line: 102, Col: 128}
  218. }
  219. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12))
  220. if templ_7745c5c3_Err != nil {
  221. return templ_7745c5c3_Err
  222. }
  223. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "</span></td></tr>")
  224. if templ_7745c5c3_Err != nil {
  225. return templ_7745c5c3_Err
  226. }
  227. }
  228. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "</tbody></table></div>")
  229. if templ_7745c5c3_Err != nil {
  230. return templ_7745c5c3_Err
  231. }
  232. }
  233. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, "</div></div></div></div></div><script>\n function exportSubscribersCSV() {\n const table = document.getElementById('subscribersTable');\n if (!table) return;\n \n let csv = 'Subscriber Name,Topic,Consumer Group,Status,Messages Processed,Last Seen,Created\\n';\n \n const rows = table.querySelectorAll('tbody tr');\n rows.forEach(row => {\n const cells = row.querySelectorAll('td');\n if (cells.length >= 7) {\n const rowData = [\n cells[0].querySelector('strong')?.textContent || '',\n cells[1].querySelector('.badge')?.textContent || '',\n cells[2].textContent || '',\n cells[3].querySelector('.badge')?.textContent || '',\n cells[4].textContent || '',\n cells[5].querySelector('span')?.textContent || '',\n cells[6].querySelector('span')?.textContent || ''\n ];\n csv += rowData.map(field => `\"${field.replace(/\"/g, '\"\"')}\"`).join(',') + '\\n';\n }\n });\n \n const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' });\n const link = document.createElement('a');\n const url = URL.createObjectURL(blob);\n link.setAttribute('href', url);\n link.setAttribute('download', 'subscribers.csv');\n link.style.visibility = 'hidden';\n document.body.appendChild(link);\n link.click();\n document.body.removeChild(link);\n }\n </script>")
  234. if templ_7745c5c3_Err != nil {
  235. return templ_7745c5c3_Err
  236. }
  237. return nil
  238. })
  239. }
  240. var _ = templruntime.GeneratedTemplate