guests_boot_jobs.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. {% extends "layout.html" %}
  2. {% block head %}
  3. {{ super() }}
  4. <style type="text/css">
  5. .table {
  6. font-size: 12px;
  7. border-width: 1px;
  8. line-height: 20px;
  9. }
  10. .table > thead > tr > th,
  11. .table > tfoot > tr > th {
  12. color: #999999;
  13. font-weight: normal;
  14. border-bottom: 0 solid #e1e6eb;
  15. background-color: #F5F6FA;
  16. }
  17. .table > tbody > tr > td {
  18. color: #424547;
  19. }
  20. .table-bordered > tbody > tr {
  21. padding-top: 10px;
  22. padding-bottom: 10px;
  23. }
  24. .table-bordered > thead > tr > th,
  25. .table-bordered > tbody > tr > th,
  26. .table-bordered > tfoot > tr > th,
  27. .table-bordered > thead > tr > td,
  28. .table-bordered > tbody > tr > td,
  29. .table-bordered > tfoot > tr > td {
  30. border-style: solid;
  31. border-width: 1px 0 0 0;
  32. }
  33. .btn,
  34. .form-control,
  35. .modal-content {
  36. border-radius: 0 !important;
  37. }
  38. .tr-selected td,
  39. .tr-selected {
  40. color: #000 !important;
  41. background: #fffdf4 !important;
  42. }
  43. </style>
  44. {% endblock head %}
  45. {% block content %}
  46. <script type="text/javascript">
  47. var page = 1;
  48. var page_size = 10;
  49. var keyword = '';
  50. var resource_path = window.location.pathname;
  51. var cur_url = resource_path;
  52. $(document).ready(function() {
  53. page_size = $('#page_size').val();
  54. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size;
  55. var last_ready = null;
  56. $('#content_search').keydown(function() {
  57. if (last_ready !== null) {
  58. clearTimeout(last_ready);
  59. }
  60. last_ready = setTimeout(function () {
  61. keyword = $('#content_search').val();
  62. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size;
  63. if (keyword.length > 0) {
  64. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size + '&keyword=' + keyword;
  65. }
  66. window.location.href=cur_url;
  67. }, 1000);
  68. });
  69. $('#page_size').change(function () {
  70. keyword = $('#content_search').val();
  71. page_size = $('#page_size').val();
  72. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size;
  73. if (keyword.length > 0) {
  74. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size + '&keyword=' + keyword;
  75. }
  76. window.location.href=cur_url;
  77. });
  78. $("thead").on('click', ".all_selector", function() {
  79. if ($("thead .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. select_item_action();
  87. });
  88. $("tfoot").on('click', ".all_selector", function() {
  89. if ($("tfoot .all_selector").is(':checked')) {
  90. $("tbody tr").find('td input[type="checkbox"]:eq(0)').prop('checked', true);
  91. $(".all_selector").prop('checked', true);
  92. } else {
  93. $("tbody tr").find('td input[type="checkbox"]:eq(0)').prop('checked', false);
  94. $(".all_selector").prop('checked', false);
  95. }
  96. select_item_action();
  97. });
  98. $("tbody tr").on('click', "input[type='checkbox']", function() {
  99. select_item_action();
  100. });
  101. $('body').addClass('add-transition');
  102. $('.add-page-transition').on('click', function(){
  103. var transAttr = $(this).attr('data-transition');
  104. $('.add-transition').attr('class', 'add-transition');
  105. $('.add-transition').addClass(transAttr);
  106. });
  107. });
  108. function refresh() {
  109. keyword = $('#content_search').val();
  110. page = $('#pagination li.active a').text();
  111. page_size = $('#page_size').val();
  112. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size;
  113. if (keyword.length > 0) {
  114. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size + '&keyword=' + keyword;
  115. }
  116. window.location.href=cur_url;
  117. }
  118. </script>
  119. <div class="panel">
  120. <div class="panel-body">
  121. <h3 class="title-hero" style="font-size: 24px;">
  122. 虚拟机启动作业
  123. </h3>
  124. <div>
  125. <div id="datatable-row-highlight_wrapper" class="dataTables_wrapper form-inline">
  126. <div class="row" style="padding: 10px 10px 10px 0; width: 100%;">
  127. <div class="col-sm-12" style="padding-right: 0;">
  128. <div id="datatable-row-highlight_filter" class="dataTables_filter" style="display: inline-block;">
  129. <input id="content_search" type="search" class="form-control" placeholder="模糊搜索..." value="{%- if keyword -%} {{ keyword }} {%- endif -%}" style="margin-left: 0; border-radius: 0;">
  130. </div>
  131. <div class="pull-right">
  132. <button class="btn btn-default" onclick="refresh()" style="border-radius: 0;"><span class="glyph-icon icon-elusive-arrows-cw"></span></button>
  133. </div>
  134. </div>
  135. </div>
  136. <table id="guests_boot_jobs_list" class="table table-bordered table-hover" cellspacing="0" width="100%" role="grid"
  137. style="width: 100%; margin-bottom: 0; border-bottom-width: 0;">
  138. <thead>
  139. <tr role="row">
  140. <th style="display: none;">UUID</th>
  141. <th style="display: none;">启动作业 ID</th>
  142. <th><input class="all_selector" title="选取所有" type="checkbox"></th>
  143. <th width="180px;">有效时间</th>
  144. <th width="180px;">启动作业</th>
  145. <th width="180px;">名称</th>
  146. <th></th>
  147. <th>状态</th>
  148. <th>IP</th>
  149. <th>操作</th>
  150. </tr>
  151. </thead>
  152. <tbody>
  153. {% for uuid, boot_jobs in guests_boot_jobs_ret.data.iteritems() %}
  154. {% for boot_job_id in boot_jobs.boot_jobs %}
  155. <tr role="row" class="odd" onmouseover="row_onmouseover(this);" onmouseout="row_onmouseout(this);">
  156. <td style="display: none;">{{ uuid }}</td>
  157. <td style="display: none;">{{ boot_job_id }}</td>
  158. <td><input title="选中" type="checkbox"></td>
  159. <td>
  160. <span style="color: #b94a48; {% if boot_jobs.ttl // 60 == 0 %}display: none;{% endif %}">{{ boot_jobs.ttl // 60 }}分</span>
  161. <span style="color: #b94a48; {% if boot_jobs.ttl % 60 == 0 %}display: none;{% endif %}">{{ boot_jobs.ttl % 60 }}秒</span>
  162. </td>
  163. <td>
  164. <div>
  165. <a href="/operate_rules?boot_job_id={{ boot_job_id }}">
  166. <p style="display: inline-block;">{{ boot_jobs_mapping_by_id[boot_job_id | int].name }}</p>
  167. </a>
  168. </div>
  169. </td>
  170. <td>
  171. <div>
  172. <a href="/guest/detail/{{ uuid }}">
  173. <p style="display: inline-block;">
  174. {{ guests_mapping_by_uuid[uuid].label }}
  175. </p>
  176. </a>
  177. <div>
  178. <p style="display: inline-block;">{{ guests_mapping_by_uuid[uuid].remark }}</p>
  179. </div>
  180. </div>
  181. </td>
  182. <td><span class="{{ os_templates_mapping_by_id[guests_mapping_by_uuid[uuid].os_template_id].icon }}"></span></td>
  183. <td>{{ format_guest_status(guests_mapping_by_uuid[uuid].status)|safe }}</td>
  184. <td>{{ guests_mapping_by_uuid[uuid].ip }}</td>
  185. <td>
  186. <div class="dropdown inline-block">
  187. <a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown">
  188. 更多
  189. </a>
  190. <ul class="dropdown-menu">
  191. <li>
  192. <a href="javascript:;" onclick="delete_at(this);">删除</a>
  193. </li>
  194. </ul>
  195. </div>
  196. </td>
  197. </tr>
  198. {% endfor %}
  199. {% endfor %}
  200. </tbody>
  201. </table>
  202. <table class="table table-bordered" style="border-top-width: 0; z-index: 99; position: sticky; bottom: 0;">
  203. <tfoot>
  204. <tr style="height: 70px;">
  205. <th><input type="checkbox" title="选取所有" class="all_selector"></th>
  206. <th>
  207. <div class="row">
  208. <div class="col-sm-6">
  209. </div>
  210. <div class="col-sm-3" style="font-size: 12px; padding-top: 5px; text-align: right;">
  211. 共有{{ paging_total }}个,每页显示:
  212. <select id="page_size" name="datatable-row-highlight_length" title="page_size" class="form-control" style="height: 22px; vertical-align: baseline;">
  213. <option value="10" {% if page_size == 10 %} selected {% endif %}>10</option>
  214. <option value="20" {% if page_size == 20 %} selected {% endif %}>20</option>
  215. <option value="50" {% if page_size == 50 %} selected {% endif %}>50</option>
  216. </select>&nbsp;&nbsp;个
  217. </div>
  218. <div class="col-sm-3" style="text-align: left;">
  219. <div class="dataTables_paginate paging_bootstrap" id="datatable-row-highlight_paginate">
  220. <ul id="pagination" class="pagination">
  221. <li class="{% if page == 1 %} disabled {% endif %}">
  222. <a href="{{ resource_path }}?page={{ page - 1 }}&page_size={{ page_size }}{% if keyword %}&keyword={{ keyword }}{% endif %}">«</a>
  223. </li>
  224. {% for item in pages %}
  225. <li class="{% if item == page %} active {% endif %}">
  226. <a href="{{ resource_path }}?page={{ item }}&page_size={{ page_size }}{% if keyword %}&keyword={{ keyword }}{% endif %}">{{ item }}</a>
  227. </li>
  228. {% endfor %}
  229. <li class="{% if page == last_page %} disabled {% endif %}">
  230. <a href="{{ resource_path }}?page={{ page + 1 }}&page_size={{ page_size }}{% if keyword %}&keyword={{ keyword }}{% endif %}">»</a>
  231. </li>
  232. </ul>
  233. </div>
  234. </div>
  235. </div>
  236. </th>
  237. </tr>
  238. </tfoot>
  239. </table>
  240. </div>
  241. </div>
  242. </div>
  243. </div>
  244. <div class="modal" id="reset_password_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
  245. <div class="modal-dialog modal-sm">
  246. <div class="modal-content">
  247. <div class="modal-header">
  248. <h4 class="modal-title">重置密码:</h4>
  249. </div>
  250. <div class="modal-body">
  251. <div class="form-group">
  252. <input id="reset_password_type" title="重置密码类型" class="form-control" name="reset_password_type" value="single" hidden>
  253. <input id="reset_password_instance_uuid" title="实例 UUID" class="form-control" name="uuid" hidden>
  254. <input id="new_password" title="新密码" class="form-control" name="new_password" type="password" placeholder="New password">
  255. </div>
  256. </div>
  257. <div class="modal-footer">
  258. <button type="button" class="btn btn-sm btn-primary" onclick="reset_password_go();">确定</button>
  259. <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">取消</button>
  260. </div>
  261. </div>
  262. </div>
  263. </div>
  264. {% endblock content %}