warn.tmpl 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. {{template "header.tmpl" .}}
  2. </head>
  3. <body>
  4. {{template "navbar.tmpl" .}}
  5. <div class="container-fluid">
  6. <h4 class="text-center">Redis报警日志列表</h4>
  7. <hr />
  8. <form class="form-inline" id="filterform" style="margin-bottom:10px;">
  9. <div class="form-group" style="margin-right:20px;">
  10. <label>Redis实例:</label>
  11. <select class="form-control" name="redis_id" autocomplete="off">
  12. <option value="0">所有</option>
  13. </select>
  14. </div>
  15. <div class="form-group">
  16. <label>排序方式:</label>
  17. <select class="form-control" name="order" autocomplete="off">
  18. <option value="ASC">正序</option>
  19. <option value="DESC" selected="selected">倒序</option>
  20. </select>
  21. </div>
  22. </form>
  23. <table class="table table-bordered table-striped">
  24. <thead>
  25. <tr>
  26. <th>ID</th>
  27. <th>Redis ID</th>
  28. <th>Redis地址</th>
  29. <th>Redis备注</th>
  30. <th>记录时间</th>
  31. <th>日志内容</th>
  32. </tr>
  33. </thead>
  34. <tbody id="list"></tbody>
  35. </table>
  36. <div id="pager" class="text-center"></div>
  37. </div>
  38. <script type="text/javascript">
  39. var $SESS = {{.Sess}};
  40. $(function(){
  41. var PAGE_SIZE = 20;
  42. var form = $('#filterform').get(0);
  43. function init() {
  44. $.get('/syscfg/redis_list', {}, function(resp) {
  45. if (resp && resp.errno == 0) {
  46. var selector = $(form.redis_id);
  47. for (var i=0; i<resp.data.length; i++) {
  48. var item = resp.data[i];
  49. selector.append($(`<option value="${item.Id}">#${item.Id}[${item.Address}] ${item.Remark}</opton>`));
  50. }
  51. }
  52. }, 'json');
  53. }
  54. function load(p) {
  55. $.get('/log/warn_list', {
  56. 'size': PAGE_SIZE,
  57. 'page': p || 1,
  58. 'redis_id': form.redis_id.value,
  59. 'order': form.order.value
  60. }, function(resp){
  61. if (resp && resp.errno == 0) {
  62. var html = '';
  63. for (var i=0; i<resp.data.List.length; i++) {
  64. html += '<tr>';
  65. html += ' <td>' + resp.data.List[i].Id + '</td>';
  66. html += ' <td>' + resp.data.List[i].RedisId + '</td>';
  67. html += ' <td>' + resp.data.List[i].RedisAddress + '</td>';
  68. html += ' <td>' + resp.data.List[i].RedisRemark + '</td>';
  69. html += ' <td>' + time2str(resp.data.List[i].WarnTime) + '</td>';
  70. html += ' <td>' + resp.data.List[i].WarnMsg + '</td>';
  71. html += '</tr>';
  72. }
  73. $('#list').html(html);
  74. pager({
  75. 'id': 'pager',
  76. 'total': resp.data.Count,
  77. 'page_size': PAGE_SIZE,
  78. 'page_num': p,
  79. 'callback': load
  80. });
  81. }
  82. }, 'json');
  83. return false;
  84. }
  85. $('select', form).change(function(){
  86. load(1);
  87. return false;
  88. });
  89. init();
  90. load(1);
  91. });
  92. </script>
  93. </body>
  94. </html>