guest_show.html 12 KB

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