guest.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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. var page = 1;
  40. var page_size = 10;
  41. var keyword = '';
  42. var cur_url = '/guests';
  43. $(document).ready(function() {
  44. page_size = $('#page_size').val();
  45. cur_url = '/guests?page=' + page + '&page_size=' + page_size;
  46. var last_ready = null;
  47. $('#content_search').keydown(function() {
  48. if (last_ready !== null) {
  49. clearTimeout(last_ready);
  50. }
  51. last_ready = setTimeout(function () {
  52. keyword = $('#content_search').val();
  53. cur_url = '/guests?page=' + page + '&page_size=' + page_size;
  54. if (keyword.length > 0) {
  55. cur_url = '/guests?page=' + page + '&page_size=' + page_size + '&keyword=' + keyword;
  56. }
  57. window.location.href=cur_url;
  58. }, 1000);
  59. });
  60. $('#page_size').change(function () {
  61. keyword = $('#content_search').val();
  62. page_size = $('#page_size').val();
  63. cur_url = '/guests?page=' + page + '&page_size=' + page_size;
  64. if (keyword.length > 0) {
  65. cur_url = '/guests?page=' + page + '&page_size=' + page_size + '&keyword=' + keyword;
  66. }
  67. window.location.href=cur_url;
  68. });
  69. $("thead").on('click', ".all_selector", function() {
  70. if ($("thead .all_selector").is(':checked')) {
  71. $("tbody tr").find('td input[type="checkbox"]:eq(0)').prop('checked', true);
  72. $(".all_selector").prop('checked', true);
  73. } else {
  74. $("tbody tr").find('td input[type="checkbox"]:eq(0)').prop('checked', false);
  75. $(".all_selector").prop('checked', false);
  76. }
  77. });
  78. $("tfoot").on('click', ".all_selector", function() {
  79. if ($("tfoot .all_selector").is(':checked')) {
  80. $("tbody tr").find('td input[type="checkbox"]:eq(0)').prop('checked', true);
  81. $(".all_selector").prop('checked', true);
  82. } else {
  83. $("tbody tr").find('td input[type="checkbox"]:eq(0)').prop('checked', false);
  84. $(".all_selector").prop('checked', false);
  85. }
  86. });
  87. });
  88. function refresh() {
  89. keyword = $('#content_search').val();
  90. page = $('#pagination li.active a').text();
  91. page_size = $('#page_size').val();
  92. cur_url = '/guests?page=' + page + '&page_size=' + page_size;
  93. if (keyword.length > 0) {
  94. cur_url = '/guests?page=' + page + '&page_size=' + page_size + '&keyword=' + keyword;
  95. }
  96. window.location.href=cur_url;
  97. }
  98. /* Datatable row highlight */
  99. /*
  100. $(document).ready(function() {
  101. $('#datatable-row-highlight tbody').on( 'click', 'tr', function () {
  102. $(this).toggleClass('tr-selected');
  103. } );
  104. });
  105. */
  106. </script>
  107. <div class="panel">
  108. <div class="panel-body">
  109. <h3 class="title-hero" style="font-size: 24px;">
  110. 虚拟机实例
  111. </h3>
  112. <div>
  113. <div id="datatable-row-highlight_wrapper" class="dataTables_wrapper form-inline">
  114. <div class="row" style="padding: 10px 10px 10px 0; width: 100%;">
  115. <div class="col-sm-12" style="padding-right: 0;">
  116. <div id="datatable-row-highlight_filter" class="dataTables_filter" style="display: inline-block;">
  117. <input id="content_search" type="search" class="form-control" placeholder="模糊搜索..." value="{%- if keyword -%} {{ keyword }} {%- endif -%}" style="margin-left: 0;">
  118. </div>
  119. <div class="pull-right">
  120. <button class="btn btn-default" onclick="refresh()" style="border-radius: 0;"><span class="glyph-icon icon-elusive-arrows-cw"></span></button>
  121. <button class="btn btn-info" style="border-radius: 0; padding-left: 40px; padding-right: 40px;">创建实例</button>
  122. </div>
  123. </div>
  124. </div>
  125. <table id="guest_list" class="table table-bordered table-hover" cellspacing="0" width="100%" role="grid"
  126. style="width: 100%; margin-bottom: 0; border-bottom-width: 0;">
  127. <thead>
  128. <tr role="row">
  129. <th><input class="all_selector" title="选取所有" type="checkbox"></th>
  130. <th>名称</th>
  131. <th></th>
  132. <th>状态</th>
  133. <th>计算节点</th>
  134. <th>配置</th>
  135. <th>IP</th>
  136. <th>密码</th>
  137. <th>创建时间</th>
  138. <th>操作</th>
  139. </tr>
  140. </thead>
  141. <tbody>
  142. {% for item in guests_ret.data %}
  143. <tr role="row" class="odd">
  144. <td><input title="选中" type="checkbox"></td>
  145. <td>
  146. <a href="javascript:;">{{ item.name }}</a>
  147. <br />
  148. {{ item.remark }}
  149. </td>
  150. <td><span class="{{ os_template_mapping_by_id[item.os_template_id].icon }}"></span></td>
  151. <td>{{ format_guest_status(item.status)|safe }}</td>
  152. <td>{{ item.on_host }}</td>
  153. <td>CPU :&nbsp;&nbsp;{{ item.cpu }}&nbsp;核<br />内存 :&nbsp;&nbsp;{{ item.memory }}&nbsp;GB</td>
  154. <td>{{ item.ip }}</td>
  155. <td>{{ item.password }}</td>
  156. <td>{{ format_datetime_by_tus(item.create_time) }}</td>
  157. <td>
  158. <div class="dropdown inline-block">
  159. <a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown">
  160. 更多
  161. </a>
  162. <ul class="dropdown-menu">
  163. <li>
  164. <a href="javascript:;">
  165. <span>启用</span>
  166. </a>
  167. </li>
  168. <li>
  169. <a href="javascript:;">
  170. <span>禁用</span>
  171. </a>
  172. </li>
  173. <li class="">
  174. <a href="javascript:;">
  175. <span>编辑</span>
  176. </a>
  177. </li>
  178. <li class="">
  179. <a href="javascript:;">
  180. <span>密码重置</span>
  181. </a>
  182. </li>
  183. <li class="">
  184. <a href="javascript:;">
  185. <span>删除</span>
  186. </a>
  187. </li>
  188. </ul>
  189. </div>
  190. </td>
  191. </tr>
  192. {% endfor %}
  193. </tbody>
  194. </table>
  195. <table class="table table-bordered" style="border-top-width: 0; z-index: 99; position: sticky; bottom: 0;">
  196. <tfoot>
  197. <tr>
  198. <th><input type="checkbox" title="选取所有" class="all_selector"></th>
  199. <th>
  200. <div class="row">
  201. <div class="col-sm-8" style="font-size: 12px; padding-top: 5px; text-align: right;">
  202. 共有{{ guests_ret.paging.total }}条,每页显示:
  203. <select id="page_size" name="datatable-row-highlight_length" title="page_size" class="form-control" style="height: 22px; vertical-align: baseline;">
  204. <option value="1" {% if page_size == 1 %} selected {% endif %}>1</option>
  205. <option value="2" {% if page_size == 2 %} selected {% endif %}>2</option>
  206. <option value="10" {% if page_size == 10 %} selected {% endif %}>10</option>
  207. <option value="20" {% if page_size == 20 %} selected {% endif %}>20</option>
  208. <option value="50" {% if page_size == 50 %} selected {% endif %}>50</option>
  209. </select>&nbsp;&nbsp;条
  210. </div>
  211. <div class="col-sm-4" style="text-align: left;">
  212. <div class="dataTables_paginate paging_bootstrap" id="datatable-row-highlight_paginate">
  213. <ul id="pagination" class="pagination">
  214. <li class="{% if page == 1 %} disabled {% endif %}">
  215. <a href="/guests?page={{ page - 1 }}&page_size={{ page_size }}{% if keyword %} &keyword={{ keyword }} {% endif %}">«</a>
  216. </li>
  217. {% for item in pages %}
  218. <li class="{% if item == page %} active {% endif %}">
  219. <a href="/guests?page={{ item }}&page_size={{ page_size }}{% if keyword %} &keyword={{ keyword }} {% endif %}">{{ item }}</a>
  220. </li>
  221. {% endfor %}
  222. <li class="{% if page == last_page %} disabled {% endif %}">
  223. <a href="/guests?page={{ page + 1 }}&page_size={{ page_size }}{% if keyword %} &keyword={{ keyword }} {% endif %}">»</a>
  224. </li>
  225. </ul>
  226. </div>
  227. </div>
  228. </div>
  229. </th>
  230. </tr>
  231. </tfoot>
  232. </table>
  233. </div>
  234. </div>
  235. </div>
  236. </div>
  237. {% endblock content %}