guest.html 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. {% extends "layout.html" %}
  2. {% block title %} Guest {% endblock %}
  3. {% block head %}
  4. {{ super() }}
  5. <style type="text/css">
  6. .table {
  7. font-size: 12px;
  8. border-width: 1px;
  9. line-height: 20px;
  10. }
  11. .table > thead > tr > th,
  12. .table > tfoot > tr > th {
  13. color: #999999;
  14. font-weight: normal;
  15. border-bottom: 0 solid #e1e6eb;
  16. background-color: #F5F6FA;
  17. }
  18. .table > tbody > tr > td {
  19. color: #6d6e6f;
  20. }
  21. .table-bordered > tbody > tr {
  22. padding-top: 10px;
  23. padding-bottom: 10px;
  24. height: 106px;
  25. }
  26. .table-bordered > thead > tr > th,
  27. .table-bordered > tbody > tr > th,
  28. .table-bordered > tfoot > tr > th,
  29. .table-bordered > thead > tr > td,
  30. .table-bordered > tbody > tr > td,
  31. .table-bordered > tfoot > tr > td {
  32. border-style: solid;
  33. border-width: 1px 0 0 0;
  34. }
  35. </style>
  36. {% endblock head %}
  37. {% block content %}
  38. <script type="text/javascript">
  39. $(document).ready(function() {
  40. var page = 1;
  41. var page_size = $('#page_size').val();
  42. var cur_url = '/api/guests?page=' + page + '&page_size=' + page_size;
  43. var last_ready = null;
  44. $('#content_search').keydown(function() {
  45. if (last_ready !== null) {
  46. clearTimeout(last_ready);
  47. }
  48. last_ready = setTimeout(function () {
  49. var keyword = $('#content_search').val();
  50. cur_url = '/guests?page=' + page + '&page_size=' + page_size;
  51. if (keyword.length > 0) {
  52. cur_url = '/guests?page=' + page + '&page_size=' + page_size + '&keyword=' + keyword;
  53. }
  54. window.location.href=cur_url;
  55. }, 1000);
  56. });
  57. $('#page_size').change(function () {
  58. var keyword = $('#content_search').val();
  59. page_size = $('#page_size').val();
  60. cur_url = '/guests?page=' + page + '&page_size=' + page_size;
  61. if (keyword.length > 0) {
  62. cur_url = '/guests?page=' + page + '&page_size=' + page_size + '&keyword=' + keyword;
  63. }
  64. window.location.href=cur_url;
  65. });
  66. });
  67. /* Datatable row highlight */
  68. /*
  69. $(document).ready(function() {
  70. $('#datatable-row-highlight tbody').on( 'click', 'tr', function () {
  71. $(this).toggleClass('tr-selected');
  72. } );
  73. });
  74. */
  75. </script>
  76. <div class="panel">
  77. <div class="panel-body">
  78. <h3 class="title-hero" style="font-size: 24px;">
  79. 虚拟机实例
  80. </h3>
  81. <div>
  82. <div id="datatable-row-highlight_wrapper" class="dataTables_wrapper form-inline">
  83. <div class="row" style="padding: 10px 10px 10px 0;">
  84. <div class="col-sm-4">
  85. <div id="datatable-row-highlight_filter" class="dataTables_filter">
  86. <input id="content_search" type="search" class="form-control" placeholder="模糊搜索..." value="{%- if keyword -%} {{ keyword }} {%- endif -%}" style="margin-left: 0;">
  87. </div>
  88. </div>
  89. </div>
  90. <table id="guest_list" class="table table-bordered table-hover" cellspacing="0" width="100%" role="grid"
  91. style="width: 100%; margin-bottom: 0; border-bottom-width: 0;">
  92. <thead>
  93. <tr role="row">
  94. <th><input type="checkbox"></th>
  95. <th>名称</th>
  96. <th></th>
  97. <th>状态</th>
  98. <th>计算节点</th>
  99. <th>配置</th>
  100. <th>IP</th>
  101. <th>密码</th>
  102. <th>创建时间</th>
  103. <th>操作</th>
  104. </tr>
  105. </thead>
  106. <tbody>
  107. {% for item in guests_ret.data %}
  108. <tr role="row" class="odd">
  109. <td><input type="checkbox"></td>
  110. <td>
  111. <a href="javascript:;">{{ item.name }}</a>
  112. <br />
  113. {{ item.remark }}
  114. </td>
  115. <td><span class="{{ os_template_mapping_by_id[item.os_template_id].icon }}"></span></td>
  116. <td>{{ format_guest_status(item.status)|safe }}</td>
  117. <td>{{ item.on_host }}</td>
  118. <td>CPU :&nbsp;&nbsp;{{ item.cpu }}&nbsp;核<br />内存 :&nbsp;&nbsp;{{ item.memory }}&nbsp;GB</td>
  119. <td>{{ item.ip }}</td>
  120. <td>{{ item.password }}</td>
  121. <td>{{ format_datetime_by_tus(item.create_time) }}</td>
  122. <td>
  123. <div class="dropdown inline-block">
  124. <a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown">
  125. 更多
  126. </a>
  127. <ul class="dropdown-menu">
  128. <li>
  129. <a href="javascript:;">
  130. <span>启用</span>
  131. </a>
  132. </li>
  133. <li>
  134. <a href="javascript:;">
  135. <span>禁用</span>
  136. </a>
  137. </li>
  138. <li class="">
  139. <a href="javascript:;">
  140. <span>编辑</span>
  141. </a>
  142. </li>
  143. <li class="">
  144. <a href="javascript:;">
  145. <span>密码重置</span>
  146. </a>
  147. </li>
  148. <li class="">
  149. <a href="javascript:;">
  150. <span>删除</span>
  151. </a>
  152. </li>
  153. </ul>
  154. </div>
  155. </td>
  156. </tr>
  157. {% endfor %}
  158. </tbody>
  159. </table>
  160. <table class="table table-bordered" style="border-top-width: 0; z-index: 99; position: sticky; bottom: 0;">
  161. <tfoot>
  162. <tr>
  163. <th><input type="checkbox" title="select-all"></th>
  164. <th>
  165. <div class="row">
  166. <div class="col-sm-8" style="font-size: 12px; padding-top: 5px; text-align: right;">
  167. 共有{{ guests_ret.paging.total }}条,每页显示:
  168. <select id="page_size" name="datatable-row-highlight_length" title="page_size" class="form-control" style="height: 22px; vertical-align: baseline;">
  169. <option value="1" {% if page_size == 1 %} selected {% endif %}>1</option>
  170. <option value="2" {% if page_size == 2 %} selected {% endif %}>2</option>
  171. <option value="10" {% if page_size == 10 %} selected {% endif %}>10</option>
  172. <option value="20" {% if page_size == 20 %} selected {% endif %}>20</option>
  173. <option value="50" {% if page_size == 50 %} selected {% endif %}>50</option>
  174. </select>&nbsp;&nbsp;条
  175. </div>
  176. <div class="col-sm-4" style="text-align: left;">
  177. <div class="dataTables_paginate paging_bootstrap" id="datatable-row-highlight_paginate">
  178. <ul id="pagination" class="pagination">
  179. <li class="previous {% if page == 1 %} disabled {% endif %}">
  180. <a href="/guests?page={{ page - 1 }}&page_size={{ page_size }}{% if keyword %} &keyword={{ keyword }} {% endif %}">Previous</a>
  181. </li>
  182. {% for item in pages %}
  183. <li class="{% if item == page %} active {% endif %}">
  184. <a href="/guests?page={{ item }}&page_size={{ page_size }}{% if keyword %} &keyword={{ keyword }} {% endif %}">{{ item }}</a>
  185. </li>
  186. {% endfor %}
  187. <li class="next {% if page == last_page %} disabled {% endif %}">
  188. <a href="/guests?page={{ page + 1 }}&page_size={{ page_size }}{% if keyword %} &keyword={{ keyword }} {% endif %}">Next</a>
  189. </li>
  190. </ul>
  191. </div>
  192. </div>
  193. </div>
  194. </th>
  195. </tr>
  196. </tfoot>
  197. </table>
  198. </div>
  199. </div>
  200. </div>
  201. </div>
  202. {% endblock content %}