logs.html 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. {% extends "layout.html" %}
  2. {% block head %}
  3. {{ super() }}
  4. <style type="text/css">
  5. .table {
  6. font-size: 12px;
  7. border-width: 1px;
  8. line-height: 20px;
  9. }
  10. .table > thead > tr > th,
  11. .table > tfoot > tr > th {
  12. color: #999999;
  13. font-weight: normal;
  14. border-bottom: 0 solid #e1e6eb;
  15. background-color: #F5F6FA;
  16. }
  17. .table > tbody > tr > td {
  18. color: #424547;
  19. }
  20. .table-bordered > tbody > tr {
  21. padding-top: 10px;
  22. padding-bottom: 10px;
  23. }
  24. .table-bordered > thead > tr > th,
  25. .table-bordered > tbody > tr > th,
  26. .table-bordered > tfoot > tr > th,
  27. .table-bordered > thead > tr > td,
  28. .table-bordered > tbody > tr > td,
  29. .table-bordered > tfoot > tr > td {
  30. border-style: solid;
  31. border-width: 1px 0 0 0;
  32. }
  33. .btn,
  34. .form-control,
  35. .modal-content {
  36. border-radius: 0 !important;
  37. }
  38. .btn-shortcut {
  39. font-size: 12px !important;
  40. padding: 0 26px;
  41. }
  42. .show {
  43. display: inline-block !important;
  44. }
  45. .tr-selected td,
  46. .tr-selected {
  47. color: #000 !important;
  48. background: #fffdf4 !important;
  49. }
  50. </style>
  51. {% endblock head %}
  52. {% block content %}
  53. <script type="text/javascript">
  54. var page = 1;
  55. var page_size = 10;
  56. var keyword = '';
  57. var resource_path = window.location.pathname;
  58. var cur_url = resource_path;
  59. $(document).ready(function() {
  60. page_size = $('#page_size').val();
  61. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size;
  62. var last_ready = null;
  63. $('#content_search').keydown(function() {
  64. if (last_ready !== null) {
  65. clearTimeout(last_ready);
  66. }
  67. last_ready = setTimeout(function () {
  68. keyword = $('#content_search').val();
  69. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size;
  70. if (keyword.length > 0) {
  71. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size + '&keyword=' + keyword;
  72. }
  73. window.location.href=cur_url;
  74. }, 1000);
  75. });
  76. $('#page_size').change(function () {
  77. keyword = $('#content_search').val();
  78. page_size = $('#page_size').val();
  79. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size;
  80. if (keyword.length > 0) {
  81. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size + '&keyword=' + keyword;
  82. }
  83. window.location.href=cur_url;
  84. });
  85. $('body').addClass('add-transition');
  86. $('.add-page-transition').on('click', function(){
  87. var transAttr = $(this).attr('data-transition');
  88. $('.add-transition').attr('class', 'add-transition');
  89. $('.add-transition').addClass(transAttr);
  90. });
  91. });
  92. function refresh() {
  93. keyword = $('#content_search').val();
  94. page = $('#pagination li.active a').text();
  95. page_size = $('#page_size').val();
  96. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size;
  97. if (keyword.length > 0) {
  98. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size + '&keyword=' + keyword;
  99. }
  100. window.location.href=cur_url;
  101. }
  102. </script>
  103. <div class="panel">
  104. <div class="panel-body">
  105. <h3 class="title-hero" style="font-size: 24px;">
  106. 平台日志
  107. </h3>
  108. <div>
  109. <div id="datatable-row-highlight_wrapper" class="dataTables_wrapper form-inline">
  110. <div class="row" style="padding: 10px 10px 10px 0; width: 100%;">
  111. <div class="col-sm-12" style="padding-right: 0;">
  112. <div id="datatable-row-highlight_filter" class="dataTables_filter" style="display: inline-block;">
  113. <input id="content_search" type="search" class="form-control" placeholder="模糊搜索..." value="{%- if keyword -%} {{ keyword }} {%- endif -%}" style="margin-left: 0; border-radius: 0;">
  114. </div>
  115. <div class="pull-right">
  116. <button class="btn btn-default" onclick="refresh()" style="border-radius: 0;"><span class="glyph-icon icon-elusive-arrows-cw"></span></button>
  117. </div>
  118. </div>
  119. </div>
  120. <table id="log_list" class="table table-bordered table-hover" cellspacing="0" width="100%" role="grid"
  121. style="width: 100%; margin-bottom: 0; border-bottom-width: 0;">
  122. <thead>
  123. <tr role="row">
  124. <th>ID</th>
  125. <th>类型</th>
  126. <th>时间</th>
  127. <th>源</th>
  128. <th>日志</th>
  129. </tr>
  130. </thead>
  131. <tbody>
  132. {% for item in logs_ret.data %}
  133. <tr role="row" class="odd" style="
  134. {% if item.type == 3 %}
  135. background-color: #ffffff;
  136. {% elif item.type == 4 %}
  137. background-color: #bbf6ff;
  138. {% elif item.type == 0 %}
  139. background-color: #ffbaba;
  140. {% elif item.type == 1 %}
  141. background-color: #fd4949;
  142. {% elif item.type == 2 %}
  143. background-color: #fff580;
  144. {% else %}
  145. background-color: #ababab;
  146. {% endif %}">
  147. <td>{{ item.id }}</td>
  148. <td>
  149. {% if item.type == 3 %}
  150. Info
  151. {% elif item.type == 4 %}
  152. Debug
  153. {% elif item.type == 0 %}
  154. Critical
  155. {% elif item.type == 1 %}
  156. Error
  157. {% elif item.type == 2 %}
  158. Warn
  159. {% else %}
  160. Unknown
  161. {% endif %}
  162. </td>
  163. <td>{{ format_datetime_by_ts(item.timestamp) }}</td>
  164. <td>{{ item.host }}</td>
  165. <td>{{ item.message }}</td>
  166. </tr>
  167. {% endfor %}
  168. </tbody>
  169. </table>
  170. <table class="table table-bordered" style="border-top-width: 0; z-index: 99; position: sticky; bottom: 0;">
  171. <tfoot>
  172. <tr style="height: 70px;">
  173. <th>
  174. <div class="row">
  175. <div class="col-sm-6">
  176. </div>
  177. <div class="col-sm-3" style="font-size: 12px; padding-top: 5px; text-align: right;">
  178. 共有{{ logs_ret.paging.total }}条,每页显示:
  179. <select id="page_size" name="datatable-row-highlight_length" title="page_size" class="form-control" style="height: 22px; vertical-align: baseline;">
  180. <option value="20" {% if page_size == 20 %} selected {% endif %}>20</option>
  181. <option value="50" {% if page_size == 50 %} selected {% endif %}>50</option>
  182. <option value="100" {% if page_size == 100 %} selected {% endif %}>100</option>
  183. </select>&nbsp;&nbsp;条
  184. </div>
  185. <div class="col-sm-3" style="text-align: left;">
  186. <div class="dataTables_paginate paging_bootstrap" id="datatable-row-highlight_paginate">
  187. <ul id="pagination" class="pagination">
  188. <li class="{% if page == 1 %} disabled {% endif %}">
  189. <a href="{{ resource_path }}?page={{ page - 1 }}&page_size={{ page_size }}{% if keyword %}&keyword={{ keyword }}{% endif %}{% if order_by %}&order_by={{ order_by }}{% endif %}{% if order %}&order={{ order }}{% endif %}">«</a>
  190. </li>
  191. {% for item in pages %}
  192. <li class="{% if item == page %} active {% endif %}">
  193. <a href="{{ resource_path }}?page={{ item }}&page_size={{ page_size }}{% if keyword %}&keyword={{ keyword }}{% endif %}{% if order_by %}&order_by={{ order_by }}{% endif %}{% if order %}&order={{ order }}{% endif %}">{{ item }}</a>
  194. </li>
  195. {% endfor %}
  196. <li class="{% if page == last_page %} disabled {% endif %}">
  197. <a href="{{ resource_path }}?page={{ page + 1 }}&page_size={{ page_size }}{% if keyword %}&keyword={{ keyword }}{% endif %}{% if order_by %}&order_by={{ order_by }}{% endif %}{% if order %}&order={{ order }}{% endif %}">»</a>
  198. </li>
  199. </ul>
  200. </div>
  201. </div>
  202. </div>
  203. </th>
  204. </tr>
  205. </tfoot>
  206. </table>
  207. </div>
  208. </div>
  209. </div>
  210. </div>
  211. {% endblock content %}