hosts_show.html 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size;
  14. var last_ready = null;
  15. $('#content_search').keydown(function() {
  16. if (last_ready !== null) {
  17. clearTimeout(last_ready);
  18. }
  19. last_ready = setTimeout(function () {
  20. keyword = $('#content_search').val();
  21. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size;
  22. if (keyword.length > 0) {
  23. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size + '&keyword=' + keyword;
  24. }
  25. window.location.href=cur_url;
  26. }, 1000);
  27. });
  28. $('body').addClass('add-transition');
  29. $('.add-page-transition').on('click', function(){
  30. var transAttr = $(this).attr('data-transition');
  31. $('.add-transition').attr('class', 'add-transition');
  32. $('.add-transition').addClass(transAttr);
  33. });
  34. });
  35. function refresh() {
  36. window.location.href=resource_path;
  37. }
  38. function remove(uuids) {
  39. $.ajax({
  40. url : '/api/hosts/' + uuids.join(','),
  41. type : 'DELETE',
  42. contentType: "application/json; charset=utf-8",
  43. error : function() {
  44. alter_danger('计算节点删除指令发送失败!');
  45. },
  46. success : function() {
  47. alter_success('计算节点删除指令发送成功!');
  48. }
  49. });
  50. }
  51. function delete_at(me) {
  52. var node_id = $(me).prev().text();
  53. remove([node_id]);
  54. refresh()
  55. }
  56. function panel_onmouseover(me) {
  57. $(me).find(".show_detail_link").css('display','block');
  58. }
  59. function panel_onmouseout(me) {
  60. $(me).find(".show_detail_link").css('display','none');
  61. }
  62. </script>
  63. <div class="panel">
  64. <div class="panel-body">
  65. <h3 class="title-hero" style="font-size: 24px;">
  66. 计算节点
  67. </h3>
  68. <div>
  69. <div id="datatable-row-highlight_wrapper" class="dataTables_wrapper form-inline">
  70. <div class="row" style="padding: 10px 10px 10px 0; width: 100%;">
  71. <div class="col-sm-12" style="padding-right: 0;">
  72. <div id="datatable-row-highlight_filter" class="dataTables_filter" style="display: inline-block;">
  73. <input id="content_search" type="search" class="form-control" placeholder="模糊搜索..." value="{%- if keyword -%} {{ keyword }} {%- endif -%}" style="margin-left: 0; border-radius: 0;">
  74. </div>
  75. <div class="pull-right">
  76. </div>
  77. </div>
  78. </div>
  79. </div>
  80. <div class="row">
  81. {% for item in hosts_ret.data %}
  82. <div class="col-md-4" onmouseover="panel_onmouseover(this);" onmouseout="panel_onmouseout(this);">
  83. <div class="host-box content-box {% if not item.alive %}panel-gray{% endif %}">
  84. <h2 class="bg-black host-title">{{ item.hostname }}
  85. <i style="float: right;" class="glyph-icon icon-circle font-size-23 {% if item.alive == true %}font-green{% else %}font-red{% endif %}"></i>
  86. </h2>
  87. <div class="bg-blue host-specs">
  88. <div class="show_detail_link" style="display: none; position: absolute; z-index: 9999; margin-top: 20px; right: 2%;">
  89. <a href="/host/detail/{{ item.node_id }}" style="color: white; background-color: black;">&nbsp;&nbsp;&nbsp;&nbsp;主机详情&nbsp;&nbsp;&nbsp;&nbsp;</a>
  90. </div>
  91. <div style="{% if item.alive == true %}display: none;{% endif %}position: absolute; z-index: 9999; margin-top: 0; top: 56px; right: 0; left: 0;">
  92. <span style="color: white; background-color: black; font-size: 13px; display: block; color: #2d2d2d; background-color: #cbcbcb;">&nbsp;&nbsp;&nbsp;&nbsp;最后在线时间: {{ format_datetime_by_tus(item.timestamp * 1000 * 1000) }}&nbsp;&nbsp;&nbsp;&nbsp;
  93. <span style="display: none;">{{ item.node_id }}</span>
  94. <a href="javascript:;" onclick="delete_at(this);" style="color: black;">删除该计算节点</a>
  95. </span>
  96. </div>
  97. <span>{{ '%0.2f'| format(item.system_load[0] / item.cpu) }}</span>
  98. <i>当前系统负载</i>
  99. </div>
  100. <div class="bg-orange host-specs">
  101. <span>{{(((item.memory - item.memory_available) / item.memory) * 100) | int}}%</span>
  102. <i>内存使用率</i>
  103. </div>
  104. <ul {% if not item.alive %}class="bg-gray"{% endif %}>
  105. <li>CPU: {{ item.cpu }} 核</li>
  106. <li>内存: {{ (item.memory / 1024 / 1024 / 1024)|int }} GB</li>
  107. <!--<li><i class="glyph-icon icon-circle font-size-23 {% if item.alive == true %}font-green{% else %}font-red{% endif %}"></i></li>-->
  108. {% for nic_name, nic in item.interfaces.iteritems() %}
  109. <li>网卡: {{ nic_name }} | IP: {{ nic.ip }}</li>
  110. {% endfor %}
  111. {% for mountpoint, disk in item.disks.iteritems() %}
  112. <li>挂载点: {{ mountpoint }} | {{ (disk.total / 1024 / 1024 / 1024) | int }} GB | 使用率: {{ disk.percent }}%</li>
  113. {% endfor %}
  114. </ul>
  115. </div>
  116. </div>
  117. {% endfor %}
  118. </div>
  119. </div>
  120. </div>
  121. </div>
  122. {% endblock content %}