guests_show.html 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886
  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. </script>
  516. <div class="panel">
  517. <div class="panel-body">
  518. <h3 class="title-hero" style="font-size: 24px;">
  519. 虚拟机实例
  520. </h3>
  521. <div>
  522. <div id="datatable-row-highlight_wrapper" class="dataTables_wrapper form-inline">
  523. <div class="row" style="padding: 10px 10px 10px 0; width: 100%;">
  524. <div class="col-sm-12" style="padding-right: 0;">
  525. <div id="datatable-row-highlight_filter" class="dataTables_filter" style="display: inline-block;">
  526. <input id="content_search" type="search" class="form-control" placeholder="模糊搜索..." value="{%- if keyword -%} {{ keyword }} {%- endif -%}" style="margin-left: 0; border-radius: 0;">
  527. </div>
  528. <div class="pull-right">
  529. <button class="btn btn-default" onclick="refresh()" style="border-radius: 0;"><span class="glyph-icon icon-elusive-arrows-cw"></span></button>
  530. <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>
  531. </div>
  532. </div>
  533. </div>
  534. <table id="guest_list" class="table table-bordered table-hover" cellspacing="0" width="100%" role="grid"
  535. style="width: 100%; margin-bottom: 0; border-bottom-width: 0;">
  536. <thead>
  537. <tr role="row">
  538. <th style="display: none;">UUID</th>
  539. <th><input class="all_selector" title="选取所有" type="checkbox"></th>
  540. <th width="180px;">名称</th>
  541. <th></th>
  542. <th>状态</th>
  543. <th>计算节点</th>
  544. <th>配置</th>
  545. <th>IP</th>
  546. <th>密码</th>
  547. <th>创建时间</th>
  548. <th>操作</th>
  549. </tr>
  550. </thead>
  551. <tbody>
  552. {% for item in guests_ret.data %}
  553. <tr role="row" class="odd" onmouseover="row_onmouseover(this);" onmouseout="row_onmouseout(this);">
  554. <td style="display: none;">{{ item.uuid }}</td>
  555. <td><input title="选中" type="checkbox"></td>
  556. <td>
  557. <div>
  558. <a href="/guest/detail/{{ item.uuid }}">{{ item.label }}</a>
  559. </div>
  560. <div>
  561. <p style="display: inline-block;">{{ item.remark }}</p>
  562. <a href="javascript:;" class="edit_remark_trigger" data-toggle="modal" data-target="#edit_remark_modal" style="display: none; float: right;">
  563. <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>
  564. </a>
  565. </div>
  566. </td>
  567. <td><span class="{{ os_templates_mapping_by_id[item.os_template_id].icon }}"></span></td>
  568. <td>{{ format_guest_status(item.status)|safe }}</td>
  569. <td>{{ item.on_host }}</td>
  570. <td>CPU :&nbsp;&nbsp;{{ item.cpu }}&nbsp;核<br />内存 :&nbsp;&nbsp;{{ item.memory }}&nbsp;GB</td>
  571. <td>{{ item.ip }}</td>
  572. <td>{{ item.password }}</td>
  573. <td>{{ format_datetime_by_tus(item.create_time) }}</td>
  574. <td>
  575. <div class="dropdown inline-block">
  576. <a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown">
  577. 更多
  578. </a>
  579. <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>
  580. <ul class="dropdown-menu">
  581. <li class="{% if item.status not in [4, 5, 6] %} disabled {% endif %}">
  582. <a href="javascript:;" onclick="boot_at(this);">启动</a>
  583. </li>
  584. <li class="{% if item.status not in [1] %} disabled {% endif %}">
  585. <a href="javascript:;" onclick="reboot_at(this);">重启</a>
  586. </li>
  587. <li class="{% if item.status not in [1] %} disabled {% endif %}">
  588. <a href="javascript:;" onclick="force_reboot_at(this);">强制重启</a>
  589. </li>
  590. <li class="{% if item.status not in [1] %} disabled {% endif %}">
  591. <a href="javascript:;" onclick="shutdown_at(this);">停止</a>
  592. </li>
  593. <li class="{% if item.status not in [1] %} disabled {% endif %}">
  594. <a href="javascript:;" onclick="force_shutdown_at(this);">强制停止</a>
  595. </li>
  596. <li class="divider"></li>
  597. <li class="{% if item.status not in [1] %} disabled {% endif %}">
  598. <a href="javascript:;" onclick="suspend_at(this);">暂停</a>
  599. </li>
  600. <li class="{% if item.status not in [3] %} disabled {% endif %}">
  601. <a href="javascript:;" onclick="resume_at(this);">恢复</a>
  602. </li>
  603. <li class="divider"></li>
  604. <li class="">
  605. <a href="/guest/vnc/{{ item.uuid }}" target="_blank">远程连接</a>
  606. </li>
  607. <li class="divider"></li>
  608. <li class="">
  609. <a href="/guest/boot_jobs/{{ item.uuid }}" target="_blank">
  610. 启动作业&nbsp;&nbsp;
  611. <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>
  612. </a>
  613. </li>
  614. <li class="divider"></li>
  615. <li class="">
  616. <a href="javascript:;" data-toggle="modal" data-target="#reset_password_modal"
  617. onclick="$('#reset_password_type').val('single')">
  618. 密码重置
  619. </a>
  620. </li>
  621. <li class="{% if item.status not in [1, 3, 4, 5, 6] %} disabled {% endif %}">
  622. <a href="javascript:;" data-toggle="modal" data-target="#migrate_modal"
  623. onclick="$('#migrate_type').val('single')">
  624. 迁移到
  625. </a>
  626. </li>
  627. <li class="divider"></li>
  628. <li class="{% if item.status not in [4, 5, 6, 255] %} disabled {% endif %}">
  629. <a href="javascript:;" onclick="delete_at(this);">删除</a>
  630. </li>
  631. </ul>
  632. </div>
  633. </td>
  634. </tr>
  635. {% endfor %}
  636. </tbody>
  637. </table>
  638. <table class="table table-bordered" style="border-top-width: 0; z-index: 99; position: sticky; bottom: 0;">
  639. <tfoot>
  640. <tr style="height: 70px;">
  641. <th><input type="checkbox" title="选取所有" class="all_selector"></th>
  642. <th>
  643. <div class="row">
  644. <div class="col-sm-6">
  645. <button class="btn btn-default btn-shortcut disabled" onclick="batch_boot();">启动</button>
  646. <button class="btn btn-default btn-shortcut disabled" onclick="batch_reboot();">重启</button>
  647. <button class="btn btn-default btn-shortcut disabled" onclick="batch_shutdown();">停止</button>
  648. <button class="btn btn-default btn-shortcut disabled" onclick="batch_suspend();">暂停</button>
  649. <button class="btn btn-default btn-shortcut disabled" onclick="batch_resume();">恢复</button>
  650. <div class="dropup inline-block">
  651. <button href="javascript:;" class="dropdown-toggle btn btn-default btn-shortcut disabled" data-toggle="dropdown">
  652. 更多
  653. </button>
  654. <ul class="dropdown-menu" style="width: 60px;">
  655. <li>
  656. <a href="javascript:;" onclick="batch_delete();">删除</a>
  657. </li>
  658. <li class="divider"></li>
  659. <li>
  660. <a href="javascript:;" onclick="$('#migrate_type').val('batch');"
  661. data-toggle="modal" data-target="#migrate_modal" >
  662. 迁移到
  663. </a>
  664. </li>
  665. <li>
  666. <a href="javascript:;" onclick="$('#reset_password_type').val('batch');"
  667. data-toggle="modal" data-target="#reset_password_modal">
  668. 密码重置
  669. </a>
  670. </li>
  671. <li class="divider"></li>
  672. <li>
  673. <a href="javascript:;" data-toggle="modal" data-target="#add_boot_job_modal">
  674. 启动作业
  675. </a>
  676. </li>
  677. <li class="divider"></li>
  678. <li>
  679. <a href="javascript:;" onclick="batch_force_shutdown();">强制停止</a>
  680. </li>
  681. <li>
  682. <a href="javascript:;" onclick="batch_force_reboot();">强制重启</a>
  683. </li>
  684. </ul>
  685. </div>
  686. </div>
  687. <div class="col-sm-3" style="font-size: 12px; padding-top: 5px; text-align: right;">
  688. 共有{{ guests_ret.paging.total }}条,每页显示:
  689. <select id="page_size" name="datatable-row-highlight_length" title="page_size" class="form-control" style="height: 22px; vertical-align: baseline;">
  690. <option value="10" {% if page_size == 10 %} selected {% endif %}>10</option>
  691. <option value="20" {% if page_size == 20 %} selected {% endif %}>20</option>
  692. <option value="50" {% if page_size == 50 %} selected {% endif %}>50</option>
  693. </select>&nbsp;&nbsp;条
  694. </div>
  695. <div class="col-sm-3" style="text-align: left;">
  696. <div class="dataTables_paginate paging_bootstrap" id="datatable-row-highlight_paginate">
  697. <ul id="pagination" class="pagination">
  698. <li class="{% if page == 1 %} disabled {% endif %}">
  699. <a href="{{ resource_path }}?page={{ page - 1 }}&page_size={{ page_size }}{% if keyword %}&keyword={{ keyword }}{% endif %}">«</a>
  700. </li>
  701. {% for item in pages %}
  702. <li class="{% if item == page %} active {% endif %}">
  703. <a href="{{ resource_path }}?page={{ item }}&page_size={{ page_size }}{% if keyword %}&keyword={{ keyword }}{% endif %}">{{ item }}</a>
  704. </li>
  705. {% endfor %}
  706. <li class="{% if page == last_page %} disabled {% endif %}">
  707. <a href="{{ resource_path }}?page={{ page + 1 }}&page_size={{ page_size }}{% if keyword %}&keyword={{ keyword }}{% endif %}">»</a>
  708. </li>
  709. </ul>
  710. </div>
  711. </div>
  712. </div>
  713. </th>
  714. </tr>
  715. </tfoot>
  716. </table>
  717. </div>
  718. </div>
  719. </div>
  720. </div>
  721. <div class="modal" id="edit_remark_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
  722. <div class="modal-dialog modal-sm">
  723. <div class="modal-content">
  724. <div class="modal-header">
  725. <h4 class="modal-title">编辑实例名称:</h4>
  726. </div>
  727. <div class="modal-body">
  728. <input id="instance_uuid" title="实例 UUID" class="form-control" name="uuid" hidden>
  729. <input id="edit_remark" title="实例名称" class="form-control" name="remark">
  730. </div>
  731. <div class="modal-footer">
  732. <button type="button" class="btn btn-sm btn-primary" onclick="remark_update();">确定</button>
  733. <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">取消</button>
  734. </div>
  735. </div>
  736. </div>
  737. </div>
  738. <div class="modal" id="migrate_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
  739. <div class="modal-dialog modal-sm">
  740. <div class="modal-content">
  741. <div class="modal-header">
  742. <h4 class="modal-title">实例迁移至:</h4>
  743. </div>
  744. <div class="modal-body">
  745. <input id="migrate_type" title="迁移类型" class="form-control" name="migrate_type" value="single" hidden>
  746. <input id="migrate_instance_uuid" title="实例 UUID" class="form-control" name="uuid" hidden>
  747. <select id="migrate_host" name="migrate_host" title="可迁移宿主机" class="chosen-select">
  748. </select>
  749. </div>
  750. <div class="modal-footer">
  751. <button type="button" class="btn btn-sm btn-primary" onclick="migrate_go();">确定</button>
  752. <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">取消</button>
  753. </div>
  754. </div>
  755. </div>
  756. </div>
  757. <div class="modal" id="reset_password_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
  758. <div class="modal-dialog modal-sm">
  759. <div class="modal-content">
  760. <div class="modal-header">
  761. <h4 class="modal-title">重置密码:</h4>
  762. </div>
  763. <div class="modal-body">
  764. <div class="form-group">
  765. <input id="reset_password_type" title="重置密码类型" class="form-control" name="reset_password_type" value="single" hidden>
  766. <input id="reset_password_instance_uuid" title="实例 UUID" class="form-control" name="uuid" hidden>
  767. <input id="new_password" title="新密码" class="form-control" name="new_password" type="password" placeholder="New password">
  768. </div>
  769. </div>
  770. <div class="modal-footer">
  771. <button type="button" class="btn btn-sm btn-primary" onclick="reset_password_go();">确定</button>
  772. <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">取消</button>
  773. </div>
  774. </div>
  775. </div>
  776. </div>
  777. <div class="modal" id="add_boot_job_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
  778. <div class="modal-dialog modal-lg">
  779. <div class="modal-content">
  780. <div class="modal-header">
  781. <h4 class="modal-title">添加启动作业:</h4>
  782. </div>
  783. <div class="modal-body" style="padding-top: 0; padding-bottom: 0;">
  784. <div class="example-box-wrapper">
  785. <form class="form-horizontal bordered-row">
  786. <div class="form-group">
  787. <div class="col-sm-2"></div>
  788. <label class="col-sm-2 control-label"><span class="glyph-icon icon-list-alt"></span>&nbsp;&nbsp;启动作业</label>
  789. <div class="col-sm-6">
  790. <select id="boot_job_selector" name="boot_job_selector" title="启动作业" class="selectpicker">
  791. </select>
  792. </div>
  793. </div>
  794. <div class="form-group">
  795. <div class="col-sm-4"></div>
  796. <div class="col-sm-6 pull-right">
  797. <button class="btn btn-blue-alt" style="width: 180px; height: 40px; font-size: 16px;" onclick="batch_add_boot_job();">添加</button>
  798. <button class="btn btn-default" style="width: 64px; height: 40px; font-size: 16px;" data-dismiss="modal">取消</button>
  799. </div>
  800. </div>
  801. </form>
  802. </div>
  803. </div>
  804. </div>
  805. </div>
  806. </div>
  807. {% endblock content %}