guests_show.html 38 KB

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