hosts_show.html 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. {% extends "layout.html" %}
  2. {% block head %}
  3. {{ super() }}
  4. {% endblock head %}
  5. {% block content %}
  6. <script type="text/javascript">
  7. var page = 1;
  8. var page_size = 10;
  9. var keyword = '';
  10. var resource_path = window.location.pathname;
  11. var cur_url = resource_path;
  12. $(document).ready(function() {
  13. page_size = $('#page_size').val();
  14. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size;
  15. var last_ready = null;
  16. $('#content_search').keydown(function() {
  17. if (last_ready !== null) {
  18. clearTimeout(last_ready);
  19. }
  20. last_ready = setTimeout(function () {
  21. keyword = $('#content_search').val();
  22. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size;
  23. if (keyword.length > 0) {
  24. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size + '&keyword=' + keyword;
  25. }
  26. window.location.href=cur_url;
  27. }, 1000);
  28. });
  29. $('#page_size').change(function () {
  30. keyword = $('#content_search').val();
  31. page_size = $('#page_size').val();
  32. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size;
  33. if (keyword.length > 0) {
  34. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size + '&keyword=' + keyword;
  35. }
  36. window.location.href=cur_url;
  37. });
  38. $('body').addClass('add-transition');
  39. $('.add-page-transition').on('click', function(){
  40. var transAttr = $(this).attr('data-transition');
  41. $('.add-transition').attr('class', 'add-transition');
  42. $('.add-transition').addClass(transAttr);
  43. });
  44. });
  45. function refresh() {
  46. keyword = $('#content_search').val();
  47. page = $('#pagination li.active a').text();
  48. page_size = $('#page_size').val();
  49. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size;
  50. if (keyword.length > 0) {
  51. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size + '&keyword=' + keyword;
  52. }
  53. window.location.href=cur_url;
  54. }
  55. </script>
  56. <div class="panel">
  57. <div class="panel-body">
  58. <h3 class="title-hero" style="font-size: 24px;">
  59. 宿主机
  60. </h3>
  61. <div>
  62. <div id="datatable-row-highlight_wrapper" class="dataTables_wrapper form-inline">
  63. <div class="row" style="padding: 10px 10px 10px 0; width: 100%;">
  64. <div class="col-sm-12" style="padding-right: 0;">
  65. <div id="datatable-row-highlight_filter" class="dataTables_filter" style="display: inline-block;">
  66. <input id="content_search" type="search" class="form-control" placeholder="模糊搜索..." value="{%- if keyword -%} {{ keyword }} {%- endif -%}" style="margin-left: 0; border-radius: 0;">
  67. </div>
  68. <div class="pull-right">
  69. <button class="btn btn-default" onclick="refresh()" style="border-radius: 0;"><span class="glyph-icon icon-elusive-arrows-cw"></span></button>
  70. </div>
  71. </div>
  72. </div>
  73. </div>
  74. <div class="row">
  75. {% for item in hosts_ret.data %}
  76. <div class="col-md-4">
  77. <div class="host-box content-box">
  78. <h3 class="bg-black host-title">{{ item.hostname }}</h3>
  79. <div class="bg-blue host-specs">
  80. <span><sup>$</sup>1.5</span>
  81. <i>当前负载</i>
  82. </div>
  83. <ul>
  84. <li>CPU: {{ item.cpu }}核</li>
  85. <li>内存: {{ item.memory / 1024 / 1024 / 1024 }}</li>
  86. <li><i class="glyph-icon icon-circle font-size-23 {% if item.alive == true %}font-green{% else %}font-red{% endif %}"></i></li>
  87. </ul>
  88. </div>
  89. </div>
  90. {% endfor %}
  91. </div>
  92. </div>
  93. </div>
  94. </div>
  95. {% endblock content %}