You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

135 lines
3.9 KiB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  1. package master_ui
  2. import (
  3. "html/template"
  4. "strconv"
  5. "strings"
  6. )
  7. func join(data []int64) string {
  8. var ret []string
  9. for _, d := range data {
  10. ret = append(ret, strconv.Itoa(int(d)))
  11. }
  12. return strings.Join(ret, ",")
  13. }
  14. var funcMap = template.FuncMap{
  15. "join": join,
  16. }
  17. var StatusTpl = template.Must(template.New("status").Funcs(funcMap).Parse(`<!DOCTYPE html>
  18. <html>
  19. <head>
  20. <title>SeaweedFS {{ .Version }}</title>
  21. <link rel="icon" href="http://7viirv.com1.z0.glb.clouddn.com/seaweed_favicon.png" sizes="32x32" />
  22. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
  23. <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
  24. <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-sparklines/2.1.2/jquery.sparkline.min.js"></script>
  25. <script type="text/javascript">
  26. $(function() {
  27. var periods = ['second', 'minute', 'hour', 'day'];
  28. for (i = 0; i < periods.length; i++) {
  29. var period = periods[i];
  30. $('.inlinesparkline-'+period).sparkline('html', {
  31. type: 'line',
  32. barColor: 'red',
  33. tooltipSuffix:' request per '+period,
  34. });
  35. }
  36. });
  37. </script>
  38. <style>
  39. #jqstooltip{
  40. height: 28px !important;
  41. width: 150px !important;
  42. }
  43. </style>
  44. </head>
  45. <body>
  46. <div class="container">
  47. <div class="page-header">
  48. <h1>
  49. <img src="http://7viirv.com1.z0.glb.clouddn.com/seaweed50x50.png"></img>
  50. SeaweedFS <small>{{ .Version }}</small>
  51. </h1>
  52. </div>
  53. <div class="row">
  54. <div class="col-sm-6">
  55. <h2>Disk Stats</h2>
  56. <table class="table table-condensed table-striped">
  57. {{ range .DiskStatuses }}
  58. <tr>
  59. <th>{{ .Dir }}</th>
  60. <td>{{ .Free }} Bytes Free</td>
  61. </tr>
  62. {{ end }}
  63. </table>
  64. </div>
  65. <div class="col-sm-6">
  66. <h2>System Stats</h2>
  67. <table class="table table-condensed table-striped">
  68. <tr>
  69. <th>Master</th>
  70. <td><a href="http://{{.Master}}/ui/index.html">{{.Master}}</a></td>
  71. </tr>
  72. <tr>
  73. <th>Weekly # ReadRequests</th>
  74. <td><span class="inlinesparkline-day">{{ .Counters.ReadRequests.WeekCounter.ToList | join }}</span></td>
  75. </tr>
  76. <tr>
  77. <th>Daily # ReadRequests</th>
  78. <td><span class="inlinesparkline-hour">{{ .Counters.ReadRequests.DayCounter.ToList | join }}</span></td>
  79. </tr>
  80. <tr>
  81. <th>Hourly # ReadRequests</th>
  82. <td><span class="inlinesparkline-minute">{{ .Counters.ReadRequests.HourCounter.ToList | join }}</span></td>
  83. </tr>
  84. <tr>
  85. <th>Last Minute # ReadRequests</th>
  86. <td><span class="inlinesparkline-second">{{ .Counters.ReadRequests.MinuteCounter.ToList | join }}</span></td>
  87. </tr>
  88. {{ range $key, $val := .Stats }}
  89. <tr>
  90. <th>{{ $key }}</th>
  91. <td>{{ $val }}</td>
  92. </tr>
  93. {{ end }}
  94. </table>
  95. </div>
  96. </div>
  97. <div class="row">
  98. <h2>Volumes</h2>
  99. <table class="table table-striped">
  100. <thead>
  101. <tr>
  102. <th>Id</th>
  103. <th>Collection</th>
  104. <th>Size</th>
  105. <th>Files</th>
  106. <th>Trash</th>
  107. <th>TTL</th>
  108. </tr>
  109. </thead>
  110. <tbody>
  111. {{ range .Volumes }}
  112. <tr>
  113. <td><code>{{ .Id }}</code></td>
  114. <td>{{ .Collection }}</td>
  115. <td>{{ .Size }} Bytes</td>
  116. <td>{{ .FileCount }}</td>
  117. <td>{{ .DeleteCount }} / {{.DeletedByteCount}} Bytes</td>
  118. <td>{{ .Ttl }}</td>
  119. </tr>
  120. {{ end }}
  121. </tbody>
  122. </table>
  123. </div>
  124. </div>
  125. </body>
  126. </html>
  127. `))