cluster_filers.templ 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. package app
  2. import (
  3. "fmt"
  4. "github.com/seaweedfs/seaweedfs/weed/admin/dash"
  5. )
  6. templ ClusterFilers(data dash.ClusterFilersData) {
  7. <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
  8. <h1 class="h2">
  9. <i class="fas fa-folder-open me-2"></i>Filers
  10. </h1>
  11. <div class="btn-toolbar mb-2 mb-md-0">
  12. <div class="btn-group me-2">
  13. <button type="button" class="btn btn-sm btn-outline-primary" onclick="exportFilers()">
  14. <i class="fas fa-download me-1"></i>Export
  15. </button>
  16. </div>
  17. </div>
  18. </div>
  19. <div id="filers-content">
  20. <!-- Summary Cards -->
  21. <div class="row mb-4">
  22. <div class="col-xl-12 col-md-12 mb-4">
  23. <div class="card border-left-primary shadow h-100 py-2">
  24. <div class="card-body">
  25. <div class="row no-gutters align-items-center">
  26. <div class="col mr-2">
  27. <div class="text-xs font-weight-bold text-primary text-uppercase mb-1">
  28. Total Filers
  29. </div>
  30. <div class="h5 mb-0 font-weight-bold text-gray-800">
  31. { fmt.Sprintf("%d", data.TotalFilers) }
  32. </div>
  33. </div>
  34. <div class="col-auto">
  35. <i class="fas fa-folder-open fa-2x text-gray-300"></i>
  36. </div>
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41. </div>
  42. <!-- Filers Table -->
  43. <div class="card shadow mb-4">
  44. <div class="card-header py-3">
  45. <h6 class="m-0 font-weight-bold text-primary">
  46. <i class="fas fa-folder-open me-2"></i>Filers
  47. </h6>
  48. </div>
  49. <div class="card-body">
  50. if len(data.Filers) > 0 {
  51. <div class="table-responsive">
  52. <table class="table table-hover" id="filersTable">
  53. <thead>
  54. <tr>
  55. <th>Address</th>
  56. <th>Version</th>
  57. <th>Data Center</th>
  58. <th>Rack</th>
  59. <th>Created At</th>
  60. <th>Actions</th>
  61. </tr>
  62. </thead>
  63. <tbody>
  64. for _, filer := range data.Filers {
  65. <tr>
  66. <td>
  67. <a href={ templ.SafeURL(fmt.Sprintf("http://%s", filer.Address)) } target="_blank" class="text-decoration-none">
  68. { filer.Address }
  69. <i class="fas fa-external-link-alt ms-1 text-muted"></i>
  70. </a>
  71. </td>
  72. <td>
  73. <span class="badge bg-light text-dark">{ filer.Version }</span>
  74. </td>
  75. <td>
  76. <span class="badge bg-light text-dark">{ filer.DataCenter }</span>
  77. </td>
  78. <td>
  79. <span class="badge bg-light text-dark">{ filer.Rack }</span>
  80. </td>
  81. <td>
  82. if !filer.CreatedAt.IsZero() {
  83. { filer.CreatedAt.Format("2006-01-02 15:04:05") }
  84. } else {
  85. <span class="text-muted">N/A</span>
  86. }
  87. </td>
  88. <td>
  89. <div class="btn-group btn-group-sm" role="group">
  90. <button type="button" class="btn btn-outline-secondary btn-sm" title="File Browser" data-action="open-filer" data-address={ filer.Address }>
  91. <i class="fas fa-folder-open"></i>
  92. </button>
  93. </div>
  94. </td>
  95. </tr>
  96. }
  97. </tbody>
  98. </table>
  99. </div>
  100. } else {
  101. <div class="text-center py-5">
  102. <i class="fas fa-folder-open fa-3x text-muted mb-3"></i>
  103. <h5 class="text-muted">No Filers Found</h5>
  104. <p class="text-muted">No filer servers are currently available in the cluster.</p>
  105. </div>
  106. }
  107. </div>
  108. </div>
  109. <!-- Last Updated -->
  110. <div class="row">
  111. <div class="col-12">
  112. <small class="text-muted">
  113. <i class="fas fa-clock me-1"></i>
  114. Last updated: { data.LastUpdated.Format("2006-01-02 15:04:05") }
  115. </small>
  116. </div>
  117. </div>
  118. </div>
  119. <!-- JavaScript for cluster filers functionality -->
  120. <script>
  121. document.addEventListener('DOMContentLoaded', function() {
  122. // Handle filer action buttons
  123. document.addEventListener('click', function(e) {
  124. const button = e.target.closest('[data-action]');
  125. if (!button) return;
  126. const action = button.getAttribute('data-action');
  127. const address = button.getAttribute('data-address');
  128. if (!address) return;
  129. switch(action) {
  130. case 'open-filer':
  131. openFilerBrowser(address);
  132. break;
  133. }
  134. });
  135. });
  136. function openFilerBrowser(address) {
  137. // Open file browser for specific filer
  138. window.open('/files?filer=' + encodeURIComponent(address), '_blank');
  139. }
  140. function exportFilers() {
  141. // Simple CSV export of filers list
  142. const rows = Array.from(document.querySelectorAll('#filersTable tbody tr')).map(row => {
  143. const cells = row.querySelectorAll('td');
  144. if (cells.length > 1) {
  145. return {
  146. address: cells[0].textContent.trim(),
  147. version: cells[1].textContent.trim(),
  148. datacenter: cells[2].textContent.trim(),
  149. rack: cells[3].textContent.trim(),
  150. created: cells[4].textContent.trim()
  151. };
  152. }
  153. return null;
  154. }).filter(row => row !== null);
  155. const csvContent = "data:text/csv;charset=utf-8," +
  156. "Address,Version,Data Center,Rack,Created At\n" +
  157. rows.map(r => '"' + r.address + '","' + r.version + '","' + r.datacenter + '","' + r.rack + '","' + r.created + '"').join("\n");
  158. const encodedUri = encodeURI(csvContent);
  159. const link = document.createElement("a");
  160. link.setAttribute("href", encodedUri);
  161. link.setAttribute("download", "filers.csv");
  162. document.body.appendChild(link);
  163. link.click();
  164. document.body.removeChild(link);
  165. }
  166. </script>
  167. }