syslog.tmpl 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. {{template "header.tmpl" .}}
  2. </head>
  3. <body>
  4. {{template "navbar.tmpl" .}}
  5. <div class="container-fluid">
  6. <h4 class="text-center">系统日志列表</h4>
  7. <hr />
  8. <form class="form-inline" id="filterform" style="margin-bottom:10px;">
  9. <div class="form-group">
  10. <label>排序方式:</label>
  11. <select class="form-control" name="order" autocomplete="off">
  12. <option value="ASC">正序</option>
  13. <option value="DESC" selected="selected">倒序</option>
  14. </select>
  15. </div>
  16. </form>
  17. <table class="table table-bordered table-striped">
  18. <thead>
  19. <tr>
  20. <th>ID</th>
  21. <th>记录时间</th>
  22. <th>日志级别</th>
  23. <th>日志内容</th>
  24. </tr>
  25. </thead>
  26. <tbody id="list"></tbody>
  27. </table>
  28. <div id="pager" class="text-center"></div>
  29. </div>
  30. <script type="text/javascript">
  31. var $SESS = {{.Sess}};
  32. $(function(){
  33. var PAGE_SIZE = 20;
  34. var form = $('#filterform').get(0);
  35. function load(p) {
  36. $.get('/log/syslog_list', {
  37. 'size': PAGE_SIZE,
  38. 'page': p || 1,
  39. 'order': form.order.value
  40. }, function(resp){
  41. if (resp && resp.errno == 0) {
  42. var html = '';
  43. for (var i=0; i<resp.data.List.length; i++) {
  44. html += '<tr>';
  45. html += ' <td>' + resp.data.List[i].Id + '</td>';
  46. html += ' <td>' + time2str(resp.data.List[i].LogTime) + '</td>';
  47. html += ' <td>' + resp.data.List[i].LogLevel + '</td>';
  48. html += ' <td>' + resp.data.List[i].LogMsg + '</td>';
  49. html += '</tr>';
  50. }
  51. $('#list').html(html);
  52. pager({
  53. 'id': 'pager',
  54. 'total': resp.data.Count,
  55. 'page_size': PAGE_SIZE,
  56. 'page_num': p,
  57. 'callback': load
  58. });
  59. }
  60. }, 'json');
  61. return false;
  62. }
  63. $(form.order).change(function(){
  64. load(1);
  65. return false;
  66. });
  67. load(1);
  68. });
  69. </script>
  70. </body>
  71. </html>