guests_show.html 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877
  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. height: 106px;
  24. }
  25. .table-bordered > thead > tr > th,
  26. .table-bordered > tbody > tr > th,
  27. .table-bordered > tfoot > tr > th,
  28. .table-bordered > thead > tr > td,
  29. .table-bordered > tbody > tr > td,
  30. .table-bordered > tfoot > tr > td {
  31. border-style: solid;
  32. border-width: 1px 0 0 0;
  33. }
  34. .btn,
  35. .form-control,
  36. .modal-content {
  37. border-radius: 0 !important;
  38. }
  39. .btn-shortcut {
  40. font-size: 12px !important;
  41. padding: 0 26px;
  42. }
  43. .show {
  44. display: inline-block !important;
  45. }
  46. .tr-selected td,
  47. .tr-selected {
  48. color: #000 !important;
  49. background: #fffdf4 !important;
  50. }
  51. </style>
  52. {% endblock head %}
  53. {% block content %}
  54. <script type="text/javascript">
  55. var page = 1;
  56. var page_size = 10;
  57. var keyword = '';
  58. var resource_path = window.location.pathname;
  59. var cur_url = resource_path;
  60. $(document).ready(function() {
  61. page_size = $('#page_size').val();
  62. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size;
  63. var last_ready = null;
  64. $('#content_search').keydown(function() {
  65. if (last_ready !== null) {
  66. clearTimeout(last_ready);
  67. }
  68. last_ready = setTimeout(function () {
  69. keyword = $('#content_search').val();
  70. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size;
  71. if (keyword.length > 0) {
  72. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size + '&keyword=' + keyword;
  73. }
  74. window.location.href=cur_url;
  75. }, 1000);
  76. });
  77. $('#page_size').change(function () {
  78. keyword = $('#content_search').val();
  79. page_size = $('#page_size').val();
  80. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size;
  81. if (keyword.length > 0) {
  82. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size + '&keyword=' + keyword;
  83. }
  84. window.location.href=cur_url;
  85. });
  86. $("thead").on('click', ".all_selector", function() {
  87. if ($("thead .all_selector").is(':checked')) {
  88. $("tbody tr").find('td input[type="checkbox"]:eq(0)').prop('checked', true);
  89. $(".all_selector").prop('checked', true);
  90. } else {
  91. $("tbody tr").find('td input[type="checkbox"]:eq(0)').prop('checked', false);
  92. $(".all_selector").prop('checked', false);
  93. }
  94. select_item_action();
  95. });
  96. $("tfoot").on('click', ".all_selector", function() {
  97. if ($("tfoot .all_selector").is(':checked')) {
  98. $("tbody tr").find('td input[type="checkbox"]:eq(0)').prop('checked', true);
  99. $(".all_selector").prop('checked', true);
  100. } else {
  101. $("tbody tr").find('td input[type="checkbox"]:eq(0)').prop('checked', false);
  102. $(".all_selector").prop('checked', false);
  103. }
  104. select_item_action();
  105. });
  106. $("tbody tr").on('click', "input[type='checkbox']", function() {
  107. select_item_action();
  108. });
  109. $('body').addClass('add-transition');
  110. $('.add-page-transition').on('click', function(){
  111. var transAttr = $(this).attr('data-transition');
  112. $('.add-transition').attr('class', 'add-transition');
  113. $('.add-transition').addClass(transAttr);
  114. });
  115. $('#edit_remark_modal').on('show.bs.modal', function (me) {
  116. $('#instance_uuid').val($(me.relatedTarget).parent().parent().prev().prev().text());
  117. $('#edit_remark').val($(me.relatedTarget).prev().text());
  118. });
  119. $('#migrate_host').chosen({
  120. "disable_search": true
  121. });
  122. $('#migrate_modal').on('show.bs.modal', function (me) {
  123. $('#migrate_instance_uuid').val(
  124. $(me.relatedTarget).parent().parent().parent().parent().parent().children()[0].textContent);
  125. $.ajax({
  126. url : '/api/hosts',
  127. type : 'GET',
  128. contentType: "application/json; charset=utf-8",
  129. dataType: 'json',
  130. error : function() {
  131. },
  132. success : function(data, textStatus, xhr) {
  133. $('#migrate_host').empty();
  134. $.each(data.data, function(k, v) {
  135. $('#migrate_host').append(
  136. $('<option>', {value: v['hostname'], text: v['hostname']})
  137. );
  138. });
  139. $('#migrate_host').trigger("chosen:updated");
  140. }
  141. });
  142. });
  143. $('#reset_password_modal').on('show.bs.modal', function (me) {
  144. $('#reset_password_instance_uuid').val(
  145. $(me.relatedTarget).parent().parent().parent().parent().parent().children()[0].textContent);
  146. });
  147. $('#add_boot_job_modal').on('show.bs.modal', function (me) {
  148. refresh_boot_job_selectpicker($('#boot_job_selector'));
  149. });
  150. });
  151. function refresh() {
  152. keyword = $('#content_search').val();
  153. page = $('#pagination li.active a').text();
  154. page_size = $('#page_size').val();
  155. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size;
  156. if (keyword.length > 0) {
  157. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size + '&keyword=' + keyword;
  158. }
  159. window.location.href=cur_url;
  160. }
  161. function refresh_boot_job_selectpicker(selectpicker) {
  162. $.ajax({
  163. url : '/api/boot_jobs?filter=use_for:eq:2',
  164. type : 'GET',
  165. contentType: "application/json; charset=utf-8",
  166. dataType: 'json',
  167. error : function() {
  168. },
  169. success : function(data, textStatus, xhr) {
  170. selectpicker.empty();
  171. $.each(data.data, function(k, v) {
  172. selectpicker.append(
  173. $('<option>', {value: v['id'], text: v['name'], 'data-subtext': v['remark']})
  174. );
  175. });
  176. selectpicker.selectpicker('refresh');
  177. }
  178. });
  179. }
  180. function row_onmouseover(me) {
  181. $(me).find(".edit_remark_trigger").css('display','inline-flex');
  182. }
  183. function row_onmouseout(me) {
  184. $(me).find(".edit_remark_trigger").css('display','none');
  185. }
  186. function remark_update(me) {
  187. var uuid = $('#instance_uuid').val();
  188. var remark = $('#edit_remark').val();
  189. $('#edit_remark_modal').modal('hide');
  190. $.ajax({
  191. url : '/api/guest/' + uuid,
  192. type : 'PATCH',
  193. contentType: "application/json; charset=utf-8",
  194. data : JSON.stringify({
  195. remark: remark
  196. }),
  197. error : function() {
  198. alter_danger('实例备注更新失败!');
  199. },
  200. success : function() {
  201. $('#guest_list tbody').find('td:contains(' + uuid + ')').next().next().find('p').text(remark);
  202. alter_success('实例备注更新成功!');
  203. }
  204. });
  205. }
  206. function get_selected_element(checked) {
  207. if (checked === null) {
  208. checked = true;
  209. }
  210. if (checked) {
  211. return $('tbody :checked');
  212. } else {
  213. return $('tbody input:not(:checked)');
  214. }
  215. }
  216. function highlight_selected_element() {
  217. var selected_element = get_selected_element(true);
  218. var no_selected_element = get_selected_element(false);
  219. selected_element.each(function(i, e) {
  220. $(e).parent().parent().toggleClass('tr-selected', true);
  221. });
  222. no_selected_element.each(function(i, e) {
  223. $(e).parent().parent().toggleClass('tr-selected', false);
  224. });
  225. }
  226. function shortcut_bar_enable() {
  227. var selected_element = get_selected_element(true);
  228. if (selected_element.length > 0) {
  229. $('.btn-shortcut').toggleClass('disabled', false);
  230. } else {
  231. $('.btn-shortcut').toggleClass('disabled', true);
  232. }
  233. }
  234. function select_item_action() {
  235. highlight_selected_element();
  236. shortcut_bar_enable();
  237. }
  238. function boot(uuids) {
  239. $.ajax({
  240. url : '/api/guests/_boot/' + uuids.join(','),
  241. type : 'PUT',
  242. contentType: "application/json; charset=utf-8",
  243. error : function() {
  244. alter_danger('实例启动指令发送失败!');
  245. },
  246. success : function() {
  247. alter_success('实例启动指令发送成功!');
  248. }
  249. });
  250. }
  251. function reboot(uuids) {
  252. $.ajax({
  253. url : '/api/guests/_reboot/' + uuids.join(','),
  254. type : 'PUT',
  255. contentType: "application/json; charset=utf-8",
  256. error : function() {
  257. alter_danger('实例重启指令发送失败!');
  258. },
  259. success : function() {
  260. alter_success('实例重启指令发送成功!');
  261. }
  262. });
  263. }
  264. function force_reboot(uuids) {
  265. $.ajax({
  266. url : '/api/guests/_force_reboot/' + uuids.join(','),
  267. type : 'PUT',
  268. contentType: "application/json; charset=utf-8",
  269. error : function() {
  270. alter_danger('实例强制重启指令发送失败!');
  271. },
  272. success : function() {
  273. alter_success('实例强制重启指令发送成功!');
  274. }
  275. });
  276. }
  277. function shutdown(uuids) {
  278. $.ajax({
  279. url : '/api/guests/_shutdown/' + uuids.join(','),
  280. type : 'PUT',
  281. contentType: "application/json; charset=utf-8",
  282. error : function() {
  283. alter_danger('实例停止指令发送失败!');
  284. },
  285. success : function() {
  286. alter_success('实例停止指令发送成功!');
  287. }
  288. });
  289. }
  290. function force_shutdown(uuids) {
  291. $.ajax({
  292. url : '/api/guests/_force_shutdown/' + uuids.join(','),
  293. type : 'PUT',
  294. contentType: "application/json; charset=utf-8",
  295. error : function() {
  296. alter_danger('实例强制停止指令发送失败!');
  297. },
  298. success : function() {
  299. alter_success('实例强制停止指令发送成功!');
  300. }
  301. });
  302. }
  303. function suspend(uuids) {
  304. $.ajax({
  305. url : '/api/guests/_suspend/' + uuids.join(','),
  306. type : 'PUT',
  307. contentType: "application/json; charset=utf-8",
  308. error : function() {
  309. alter_danger('实例暂停指令发送失败!');
  310. },
  311. success : function() {
  312. alter_success('实例暂停指令发送成功!');
  313. }
  314. });
  315. }
  316. function resume(uuids) {
  317. $.ajax({
  318. url : '/api/guests/_resume/' + uuids.join(','),
  319. type : 'PUT',
  320. contentType: "application/json; charset=utf-8",
  321. error : function() {
  322. alter_danger('实例恢复指令发送失败!');
  323. },
  324. success : function() {
  325. alter_success('实例恢复指令发送成功!');
  326. }
  327. });
  328. }
  329. function remove(uuids) {
  330. $.ajax({
  331. url : '/api/guests/' + uuids.join(','),
  332. type : 'DELETE',
  333. contentType: "application/json; charset=utf-8",
  334. error : function() {
  335. alter_danger('实例删除指令发送失败!');
  336. },
  337. success : function() {
  338. alter_success('实例删除指令发送成功!');
  339. }
  340. });
  341. }
  342. function migrate(uuids, host) {
  343. $.ajax({
  344. url : '/api/guests/_migrate/' + uuids.join(',') + '/' + host,
  345. type : 'PUT',
  346. contentType: "application/json; charset=utf-8",
  347. error : function() {
  348. alter_danger('实例迁移指令发送失败!');
  349. },
  350. success : function() {
  351. alter_success('实例迁移指令发送成功!');
  352. }
  353. });
  354. }
  355. function reset_password(uuids, password) {
  356. $.ajax({
  357. url : '/api/guests/_reset_password/' + uuids.join(',') + '/' + password,
  358. type : 'PUT',
  359. contentType: "application/json; charset=utf-8",
  360. error : function() {
  361. alter_danger('实例重置密码指令发送失败!');
  362. },
  363. success : function() {
  364. alter_success('实例重置密码指令发送成功!');
  365. }
  366. });
  367. }
  368. function add_boot_job(uuids, boot_job_id) {
  369. $.ajax({
  370. url : '/api/guests/_boot_jobs/' + uuids.join(',') + '/' + boot_job_id,
  371. type : 'PUT',
  372. contentType: "application/json; charset=utf-8",
  373. error : function() {
  374. alter_danger('启动作业添加指令发送失败!');
  375. },
  376. success : function() {
  377. alter_success('启动作业添加指令发送成功!');
  378. refresh();
  379. }
  380. });
  381. }
  382. function boot_at(me) {
  383. var uuid = $(me).parent().parent().parent().parent().parent().children()[0].textContent;
  384. boot([uuid]);
  385. }
  386. function reboot_at(me) {
  387. var uuid = $(me).parent().parent().parent().parent().parent().children()[0].textContent;
  388. reboot([uuid]);
  389. }
  390. function force_reboot_at(me) {
  391. var uuid = $(me).parent().parent().parent().parent().parent().children()[0].textContent;
  392. force_reboot([uuid]);
  393. }
  394. function shutdown_at(me) {
  395. var uuid = $(me).parent().parent().parent().parent().parent().children()[0].textContent;
  396. shutdown([uuid]);
  397. }
  398. function force_shutdown_at(me) {
  399. var uuid = $(me).parent().parent().parent().parent().parent().children()[0].textContent;
  400. force_shutdown([uuid]);
  401. }
  402. function suspend_at(me) {
  403. var uuid = $(me).parent().parent().parent().parent().parent().children()[0].textContent;
  404. suspend([uuid]);
  405. }
  406. function resume_at(me) {
  407. var uuid = $(me).parent().parent().parent().parent().parent().children()[0].textContent;
  408. resume([uuid]);
  409. }
  410. function delete_at(me) {
  411. var uuid = $(me).parent().parent().parent().parent().parent().children()[0].textContent;
  412. remove([uuid]);
  413. }
  414. function migrate_go() {
  415. var migrate_type = $('#migrate_type').val();
  416. var uuids = [];
  417. if (migrate_type === 'single') {
  418. uuids = [$('#migrate_instance_uuid').val()];
  419. } else {
  420. uuids = get_checked_uuids();
  421. }
  422. var host = $('#migrate_host').val();
  423. $('#migrate_modal').modal('hide');
  424. migrate([uuids], host);
  425. }
  426. function reset_password_go() {
  427. var migrate_type = $('#reset_password_type').val();
  428. var uuids = [];
  429. if (migrate_type === 'single') {
  430. uuids = [$('#reset_password_instance_uuid').val()];
  431. } else {
  432. uuids = get_checked_uuids();
  433. }
  434. var password = $('#new_password').val();
  435. $('#reset_password_modal').modal('hide');
  436. reset_password([uuids], password);
  437. }
  438. function get_selected_uuids() {
  439. var selected_element = get_selected_element(true);
  440. var uuids = [];
  441. selected_element.each(function(i, e) {
  442. var uuid = $(e).parent().prev().text();
  443. uuids.push(uuid);
  444. });
  445. return uuids;
  446. }
  447. function get_checked_uuids() {
  448. var uuids = get_selected_uuids();
  449. if (uuids.length < 1) {
  450. alter_warning('未选择任何可操作的实例!');
  451. return false;
  452. }
  453. return uuids;
  454. }
  455. function batch_boot() {
  456. var uuids = get_checked_uuids();
  457. if (uuids) {
  458. boot(uuids);
  459. }
  460. }
  461. function batch_reboot() {
  462. var uuids = get_checked_uuids();
  463. if (uuids) {
  464. reboot(uuids);
  465. }
  466. }
  467. function batch_force_reboot() {
  468. var uuids = get_checked_uuids();
  469. if (uuids) {
  470. force_reboot(uuids);
  471. }
  472. }
  473. function batch_shutdown() {
  474. var uuids = get_checked_uuids();
  475. if (uuids) {
  476. shutdown(uuids);
  477. }
  478. }
  479. function batch_force_shutdown() {
  480. var uuids = get_checked_uuids();
  481. if (uuids) {
  482. force_shutdown(uuids);
  483. }
  484. }
  485. function batch_suspend() {
  486. var uuids = get_checked_uuids();
  487. if (uuids) {
  488. suspend(uuids);
  489. }
  490. }
  491. function batch_resume() {
  492. var uuids = get_checked_uuids();
  493. if (uuids) {
  494. resume(uuids);
  495. }
  496. }
  497. function batch_delete() {
  498. var uuids = get_checked_uuids();
  499. if (uuids) {
  500. remove(uuids);
  501. }
  502. }
  503. function batch_add_boot_job() {
  504. var uuids = get_checked_uuids();
  505. var boot_job_id = $('#boot_job_selector').val();
  506. if (uuids) {
  507. add_boot_job(uuids, boot_job_id);
  508. }
  509. $('#add_boot_job_modal').modal('hide');
  510. }
  511. </script>
  512. <div class="panel">
  513. <div class="panel-body">
  514. <h3 class="title-hero" style="font-size: 24px;">
  515. 虚拟机实例
  516. </h3>
  517. <div>
  518. <div id="datatable-row-highlight_wrapper" class="dataTables_wrapper form-inline">
  519. <div class="row" style="padding: 10px 10px 10px 0; width: 100%;">
  520. <div class="col-sm-12" style="padding-right: 0;">
  521. <div id="datatable-row-highlight_filter" class="dataTables_filter" style="display: inline-block;">
  522. <input id="content_search" type="search" class="form-control" placeholder="模糊搜索..." value="{%- if keyword -%} {{ keyword }} {%- endif -%}" style="margin-left: 0; border-radius: 0;">
  523. </div>
  524. <div class="pull-right">
  525. <button class="btn btn-default" onclick="refresh()" style="border-radius: 0;"><span class="glyph-icon icon-elusive-arrows-cw"></span></button>
  526. <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>
  527. </div>
  528. </div>
  529. </div>
  530. <table id="guest_list" class="table table-bordered table-hover" cellspacing="0" width="100%" role="grid"
  531. style="width: 100%; margin-bottom: 0; border-bottom-width: 0;">
  532. <thead>
  533. <tr role="row">
  534. <th style="display: none;">UUID</th>
  535. <th><input class="all_selector" title="选取所有" type="checkbox"></th>
  536. <th width="180px;">名称</th>
  537. <th></th>
  538. <th>状态</th>
  539. <th>计算节点</th>
  540. <th>配置</th>
  541. <th>IP</th>
  542. <th>密码</th>
  543. <th>创建时间</th>
  544. <th>操作</th>
  545. </tr>
  546. </thead>
  547. <tbody>
  548. {% for item in guests_ret.data %}
  549. <tr role="row" class="odd" onmouseover="row_onmouseover(this);" onmouseout="row_onmouseout(this);">
  550. <td style="display: none;">{{ item.uuid }}</td>
  551. <td><input title="选中" type="checkbox"></td>
  552. <td>
  553. <div>
  554. <a href="/guest/detail/{{ item.uuid }}">{{ item.label }}</a>
  555. </div>
  556. <div>
  557. <p style="display: inline-block;">{{ item.remark }}</p>
  558. <a href="javascript:;" class="edit_remark_trigger" data-toggle="modal" data-target="#edit_remark_modal" style="display: none; float: right;">
  559. <span class="glyph-icon icon-elusive-pencil" style="width: 20px; height: 20px; margin-left: 10px; border-radius: 0; border: 1px solid rgb(220, 233, 255); background-color: #ffffff;"></span>
  560. </a>
  561. </div>
  562. </td>
  563. <td><span class="{{ os_templates_mapping_by_id[item.os_template_id].icon }}"></span></td>
  564. <td>{{ format_guest_status(item.status)|safe }}</td>
  565. <td>{{ item.on_host }}</td>
  566. <td>CPU :&nbsp;&nbsp;{{ item.cpu }}&nbsp;核<br />内存 :&nbsp;&nbsp;{{ item.memory }}&nbsp;GB</td>
  567. <td>{{ item.ip }}</td>
  568. <td>{{ item.password }}</td>
  569. <td>{{ format_datetime_by_tus(item.create_time) }}</td>
  570. <td>
  571. <div class="dropdown inline-block">
  572. <a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown">
  573. 更多
  574. </a>
  575. <ul class="dropdown-menu">
  576. <li class="{% if item.status not in [4, 5, 6] %} disabled {% endif %}">
  577. <a href="javascript:;" onclick="boot_at(this);">启动</a>
  578. </li>
  579. <li class="{% if item.status not in [1] %} disabled {% endif %}">
  580. <a href="javascript:;" onclick="reboot_at(this);">重启</a>
  581. </li>
  582. <li class="{% if item.status not in [1] %} disabled {% endif %}">
  583. <a href="javascript:;" onclick="force_reboot_at(this);">强制重启</a>
  584. </li>
  585. <li class="{% if item.status not in [1] %} disabled {% endif %}">
  586. <a href="javascript:;" onclick="shutdown_at(this);">停止</a>
  587. </li>
  588. <li class="{% if item.status not in [1] %} disabled {% endif %}">
  589. <a href="javascript:;" onclick="force_shutdown_at(this);">强制停止</a>
  590. </li>
  591. <li class="divider"></li>
  592. <li class="{% if item.status not in [1] %} disabled {% endif %}">
  593. <a href="javascript:;" onclick="suspend_at(this);">暂停</a>
  594. </li>
  595. <li class="{% if item.status not in [3] %} disabled {% endif %}">
  596. <a href="javascript:;" onclick="resume_at(this);">恢复</a>
  597. </li>
  598. <li class="divider"></li>
  599. <li class="">
  600. <a href="/guest/vnc/{{ item.uuid }}" target="_blank">远程连接</a>
  601. </li>
  602. <li class="divider"></li>
  603. <li class="">
  604. <a href="/guest/boot_jobs/{{ item.uuid }}" target="_blank">启动作业</a>
  605. </li>
  606. <li class="divider"></li>
  607. <li class="">
  608. <a href="javascript:;" data-toggle="modal" data-target="#reset_password_modal"
  609. onclick="$('#reset_password_type').val('single')">
  610. 密码重置
  611. </a>
  612. </li>
  613. <li class="{% if item.status not in [1, 3, 4, 5, 6] %} disabled {% endif %}">
  614. <a href="javascript:;" data-toggle="modal" data-target="#migrate_modal"
  615. onclick="$('#migrate_type').val('single')">
  616. 迁移到
  617. </a>
  618. </li>
  619. <li class="divider"></li>
  620. <li class="{% if item.status not in [4, 5, 6, 255] %} disabled {% endif %}">
  621. <a href="javascript:;" onclick="delete_at(this);">删除</a>
  622. </li>
  623. </ul>
  624. </div>
  625. </td>
  626. </tr>
  627. {% endfor %}
  628. </tbody>
  629. </table>
  630. <table class="table table-bordered" style="border-top-width: 0; z-index: 99; position: sticky; bottom: 0;">
  631. <tfoot>
  632. <tr style="height: 70px;">
  633. <th><input type="checkbox" title="选取所有" class="all_selector"></th>
  634. <th>
  635. <div class="row">
  636. <div class="col-sm-6">
  637. <button class="btn btn-default btn-shortcut disabled" onclick="batch_boot();">启动</button>
  638. <button class="btn btn-default btn-shortcut disabled" onclick="batch_reboot();">重启</button>
  639. <button class="btn btn-default btn-shortcut disabled" onclick="batch_shutdown();">停止</button>
  640. <button class="btn btn-default btn-shortcut disabled" onclick="batch_suspend();">暂停</button>
  641. <button class="btn btn-default btn-shortcut disabled" onclick="batch_resume();">恢复</button>
  642. <div class="dropup inline-block">
  643. <button href="javascript:;" class="dropdown-toggle btn btn-default btn-shortcut disabled" data-toggle="dropdown">
  644. 更多
  645. </button>
  646. <ul class="dropdown-menu" style="width: 60px;">
  647. <li>
  648. <a href="javascript:;" onclick="batch_delete();">删除</a>
  649. </li>
  650. <li class="divider"></li>
  651. <li>
  652. <a href="javascript:;" onclick="$('#migrate_type').val('batch');"
  653. data-toggle="modal" data-target="#migrate_modal" >
  654. 迁移到
  655. </a>
  656. </li>
  657. <li>
  658. <a href="javascript:;" onclick="$('#reset_password_type').val('batch');"
  659. data-toggle="modal" data-target="#reset_password_modal">
  660. 密码重置
  661. </a>
  662. </li>
  663. <li class="divider"></li>
  664. <li>
  665. <a href="javascript:;" data-toggle="modal" data-target="#add_boot_job_modal">
  666. 启动作业
  667. </a>
  668. </li>
  669. <li class="divider"></li>
  670. <li>
  671. <a href="javascript:;" onclick="batch_force_shutdown();">强制停止</a>
  672. </li>
  673. <li>
  674. <a href="javascript:;" onclick="batch_force_reboot();">强制重启</a>
  675. </li>
  676. </ul>
  677. </div>
  678. </div>
  679. <div class="col-sm-3" style="font-size: 12px; padding-top: 5px; text-align: right;">
  680. 共有{{ guests_ret.paging.total }}条,每页显示:
  681. <select id="page_size" name="datatable-row-highlight_length" title="page_size" class="form-control" style="height: 22px; vertical-align: baseline;">
  682. <option value="10" {% if page_size == 10 %} selected {% endif %}>10</option>
  683. <option value="20" {% if page_size == 20 %} selected {% endif %}>20</option>
  684. <option value="50" {% if page_size == 50 %} selected {% endif %}>50</option>
  685. </select>&nbsp;&nbsp;条
  686. </div>
  687. <div class="col-sm-3" style="text-align: left;">
  688. <div class="dataTables_paginate paging_bootstrap" id="datatable-row-highlight_paginate">
  689. <ul id="pagination" class="pagination">
  690. <li class="{% if page == 1 %} disabled {% endif %}">
  691. <a href="{{ resource_path }}?page={{ page - 1 }}&page_size={{ page_size }}{% if keyword %}&keyword={{ keyword }}{% endif %}">«</a>
  692. </li>
  693. {% for item in pages %}
  694. <li class="{% if item == page %} active {% endif %}">
  695. <a href="{{ resource_path }}?page={{ item }}&page_size={{ page_size }}{% if keyword %}&keyword={{ keyword }}{% endif %}">{{ item }}</a>
  696. </li>
  697. {% endfor %}
  698. <li class="{% if page == last_page %} disabled {% endif %}">
  699. <a href="{{ resource_path }}?page={{ page + 1 }}&page_size={{ page_size }}{% if keyword %}&keyword={{ keyword }}{% endif %}">»</a>
  700. </li>
  701. </ul>
  702. </div>
  703. </div>
  704. </div>
  705. </th>
  706. </tr>
  707. </tfoot>
  708. </table>
  709. </div>
  710. </div>
  711. </div>
  712. </div>
  713. <div class="modal" id="edit_remark_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
  714. <div class="modal-dialog modal-sm">
  715. <div class="modal-content">
  716. <div class="modal-header">
  717. <h4 class="modal-title">编辑实例名称:</h4>
  718. </div>
  719. <div class="modal-body">
  720. <input id="instance_uuid" title="实例 UUID" class="form-control" name="uuid" hidden>
  721. <input id="edit_remark" title="实例名称" class="form-control" name="remark">
  722. </div>
  723. <div class="modal-footer">
  724. <button type="button" class="btn btn-sm btn-primary" onclick="remark_update();">确定</button>
  725. <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">取消</button>
  726. </div>
  727. </div>
  728. </div>
  729. </div>
  730. <div class="modal" id="migrate_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
  731. <div class="modal-dialog modal-sm">
  732. <div class="modal-content">
  733. <div class="modal-header">
  734. <h4 class="modal-title">实例迁移至:</h4>
  735. </div>
  736. <div class="modal-body">
  737. <input id="migrate_type" title="迁移类型" class="form-control" name="migrate_type" value="single" hidden>
  738. <input id="migrate_instance_uuid" title="实例 UUID" class="form-control" name="uuid" hidden>
  739. <select id="migrate_host" name="migrate_host" title="可迁移宿主机" class="chosen-select">
  740. </select>
  741. </div>
  742. <div class="modal-footer">
  743. <button type="button" class="btn btn-sm btn-primary" onclick="migrate_go();">确定</button>
  744. <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">取消</button>
  745. </div>
  746. </div>
  747. </div>
  748. </div>
  749. <div class="modal" id="reset_password_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
  750. <div class="modal-dialog modal-sm">
  751. <div class="modal-content">
  752. <div class="modal-header">
  753. <h4 class="modal-title">重置密码:</h4>
  754. </div>
  755. <div class="modal-body">
  756. <div class="form-group">
  757. <input id="reset_password_type" title="重置密码类型" class="form-control" name="reset_password_type" value="single" hidden>
  758. <input id="reset_password_instance_uuid" title="实例 UUID" class="form-control" name="uuid" hidden>
  759. <input id="new_password" title="新密码" class="form-control" name="new_password" type="password" placeholder="New password">
  760. </div>
  761. </div>
  762. <div class="modal-footer">
  763. <button type="button" class="btn btn-sm btn-primary" onclick="reset_password_go();">确定</button>
  764. <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">取消</button>
  765. </div>
  766. </div>
  767. </div>
  768. </div>
  769. <div class="modal" id="add_boot_job_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
  770. <div class="modal-dialog modal-lg">
  771. <div class="modal-content">
  772. <div class="modal-header">
  773. <h4 class="modal-title">添加启动作业:</h4>
  774. </div>
  775. <div class="modal-body" style="padding-top: 0; padding-bottom: 0;">
  776. <div class="example-box-wrapper">
  777. <form class="form-horizontal bordered-row">
  778. <div class="form-group">
  779. <div class="col-sm-2"></div>
  780. <label class="col-sm-2 control-label"><span class="glyph-icon icon-list-alt"></span>&nbsp;&nbsp;启动作业</label>
  781. <div class="col-sm-6">
  782. <select id="boot_job_selector" name="boot_job_selector" title="启动作业" class="selectpicker">
  783. </select>
  784. </div>
  785. </div>
  786. <div class="form-group">
  787. <div class="col-sm-4"></div>
  788. <div class="col-sm-6 pull-right">
  789. <button class="btn btn-blue-alt" style="width: 180px; height: 40px; font-size: 16px;" onclick="batch_add_boot_job();">添加</button>
  790. <button class="btn btn-default" style="width: 64px; height: 40px; font-size: 16px;" data-dismiss="modal">取消</button>
  791. </div>
  792. </div>
  793. </form>
  794. </div>
  795. </div>
  796. </div>
  797. </div>
  798. </div>
  799. {% endblock content %}