guests_show.html 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878
  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. window.location.href='/guests/boot_jobs_list';
  379. // refresh();
  380. }
  381. });
  382. }
  383. function boot_at(me) {
  384. var uuid = $(me).parent().parent().parent().parent().parent().children()[0].textContent;
  385. boot([uuid]);
  386. }
  387. function reboot_at(me) {
  388. var uuid = $(me).parent().parent().parent().parent().parent().children()[0].textContent;
  389. reboot([uuid]);
  390. }
  391. function force_reboot_at(me) {
  392. var uuid = $(me).parent().parent().parent().parent().parent().children()[0].textContent;
  393. force_reboot([uuid]);
  394. }
  395. function shutdown_at(me) {
  396. var uuid = $(me).parent().parent().parent().parent().parent().children()[0].textContent;
  397. shutdown([uuid]);
  398. }
  399. function force_shutdown_at(me) {
  400. var uuid = $(me).parent().parent().parent().parent().parent().children()[0].textContent;
  401. force_shutdown([uuid]);
  402. }
  403. function suspend_at(me) {
  404. var uuid = $(me).parent().parent().parent().parent().parent().children()[0].textContent;
  405. suspend([uuid]);
  406. }
  407. function resume_at(me) {
  408. var uuid = $(me).parent().parent().parent().parent().parent().children()[0].textContent;
  409. resume([uuid]);
  410. }
  411. function delete_at(me) {
  412. var uuid = $(me).parent().parent().parent().parent().parent().children()[0].textContent;
  413. remove([uuid]);
  414. }
  415. function migrate_go() {
  416. var migrate_type = $('#migrate_type').val();
  417. var uuids = [];
  418. if (migrate_type === 'single') {
  419. uuids = [$('#migrate_instance_uuid').val()];
  420. } else {
  421. uuids = get_checked_uuids();
  422. }
  423. var host = $('#migrate_host').val();
  424. $('#migrate_modal').modal('hide');
  425. migrate([uuids], host);
  426. }
  427. function reset_password_go() {
  428. var migrate_type = $('#reset_password_type').val();
  429. var uuids = [];
  430. if (migrate_type === 'single') {
  431. uuids = [$('#reset_password_instance_uuid').val()];
  432. } else {
  433. uuids = get_checked_uuids();
  434. }
  435. var password = $('#new_password').val();
  436. $('#reset_password_modal').modal('hide');
  437. reset_password([uuids], password);
  438. }
  439. function get_selected_uuids() {
  440. var selected_element = get_selected_element(true);
  441. var uuids = [];
  442. selected_element.each(function(i, e) {
  443. var uuid = $(e).parent().prev().text();
  444. uuids.push(uuid);
  445. });
  446. return uuids;
  447. }
  448. function get_checked_uuids() {
  449. var uuids = get_selected_uuids();
  450. if (uuids.length < 1) {
  451. alter_warning('未选择任何可操作的实例!');
  452. return false;
  453. }
  454. return uuids;
  455. }
  456. function batch_boot() {
  457. var uuids = get_checked_uuids();
  458. if (uuids) {
  459. boot(uuids);
  460. }
  461. }
  462. function batch_reboot() {
  463. var uuids = get_checked_uuids();
  464. if (uuids) {
  465. reboot(uuids);
  466. }
  467. }
  468. function batch_force_reboot() {
  469. var uuids = get_checked_uuids();
  470. if (uuids) {
  471. force_reboot(uuids);
  472. }
  473. }
  474. function batch_shutdown() {
  475. var uuids = get_checked_uuids();
  476. if (uuids) {
  477. shutdown(uuids);
  478. }
  479. }
  480. function batch_force_shutdown() {
  481. var uuids = get_checked_uuids();
  482. if (uuids) {
  483. force_shutdown(uuids);
  484. }
  485. }
  486. function batch_suspend() {
  487. var uuids = get_checked_uuids();
  488. if (uuids) {
  489. suspend(uuids);
  490. }
  491. }
  492. function batch_resume() {
  493. var uuids = get_checked_uuids();
  494. if (uuids) {
  495. resume(uuids);
  496. }
  497. }
  498. function batch_delete() {
  499. var uuids = get_checked_uuids();
  500. if (uuids) {
  501. remove(uuids);
  502. }
  503. }
  504. function batch_add_boot_job() {
  505. var uuids = get_checked_uuids();
  506. var boot_job_id = $('#boot_job_selector').val();
  507. if (uuids) {
  508. add_boot_job(uuids, boot_job_id);
  509. }
  510. $('#add_boot_job_modal').modal('hide');
  511. }
  512. </script>
  513. <div class="panel">
  514. <div class="panel-body">
  515. <h3 class="title-hero" style="font-size: 24px;">
  516. 虚拟机实例
  517. </h3>
  518. <div>
  519. <div id="datatable-row-highlight_wrapper" class="dataTables_wrapper form-inline">
  520. <div class="row" style="padding: 10px 10px 10px 0; width: 100%;">
  521. <div class="col-sm-12" style="padding-right: 0;">
  522. <div id="datatable-row-highlight_filter" class="dataTables_filter" style="display: inline-block;">
  523. <input id="content_search" type="search" class="form-control" placeholder="模糊搜索..." value="{%- if keyword -%} {{ keyword }} {%- endif -%}" style="margin-left: 0; border-radius: 0;">
  524. </div>
  525. <div class="pull-right">
  526. <button class="btn btn-default" onclick="refresh()" style="border-radius: 0;"><span class="glyph-icon icon-elusive-arrows-cw"></span></button>
  527. <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>
  528. </div>
  529. </div>
  530. </div>
  531. <table id="guest_list" class="table table-bordered table-hover" cellspacing="0" width="100%" role="grid"
  532. style="width: 100%; margin-bottom: 0; border-bottom-width: 0;">
  533. <thead>
  534. <tr role="row">
  535. <th style="display: none;">UUID</th>
  536. <th><input class="all_selector" title="选取所有" type="checkbox"></th>
  537. <th width="180px;">名称</th>
  538. <th></th>
  539. <th>状态</th>
  540. <th>计算节点</th>
  541. <th>配置</th>
  542. <th>IP</th>
  543. <th>密码</th>
  544. <th>创建时间</th>
  545. <th>操作</th>
  546. </tr>
  547. </thead>
  548. <tbody>
  549. {% for item in guests_ret.data %}
  550. <tr role="row" class="odd" onmouseover="row_onmouseover(this);" onmouseout="row_onmouseout(this);">
  551. <td style="display: none;">{{ item.uuid }}</td>
  552. <td><input title="选中" type="checkbox"></td>
  553. <td>
  554. <div>
  555. <a href="/guest/detail/{{ item.uuid }}">{{ item.label }}</a>
  556. </div>
  557. <div>
  558. <p style="display: inline-block;">{{ item.remark }}</p>
  559. <a href="javascript:;" class="edit_remark_trigger" data-toggle="modal" data-target="#edit_remark_modal" style="display: none; float: right;">
  560. <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>
  561. </a>
  562. </div>
  563. </td>
  564. <td><span class="{{ os_templates_mapping_by_id[item.os_template_id].icon }}"></span></td>
  565. <td>{{ format_guest_status(item.status)|safe }}</td>
  566. <td>{{ item.on_host }}</td>
  567. <td>CPU :&nbsp;&nbsp;{{ item.cpu }}&nbsp;核<br />内存 :&nbsp;&nbsp;{{ item.memory }}&nbsp;GB</td>
  568. <td>{{ item.ip }}</td>
  569. <td>{{ item.password }}</td>
  570. <td>{{ format_datetime_by_tus(item.create_time) }}</td>
  571. <td>
  572. <div class="dropdown inline-block">
  573. <a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown">
  574. 更多
  575. </a>
  576. <ul class="dropdown-menu">
  577. <li class="{% if item.status not in [4, 5, 6] %} disabled {% endif %}">
  578. <a href="javascript:;" onclick="boot_at(this);">启动</a>
  579. </li>
  580. <li class="{% if item.status not in [1] %} disabled {% endif %}">
  581. <a href="javascript:;" onclick="reboot_at(this);">重启</a>
  582. </li>
  583. <li class="{% if item.status not in [1] %} disabled {% endif %}">
  584. <a href="javascript:;" onclick="force_reboot_at(this);">强制重启</a>
  585. </li>
  586. <li class="{% if item.status not in [1] %} disabled {% endif %}">
  587. <a href="javascript:;" onclick="shutdown_at(this);">停止</a>
  588. </li>
  589. <li class="{% if item.status not in [1] %} disabled {% endif %}">
  590. <a href="javascript:;" onclick="force_shutdown_at(this);">强制停止</a>
  591. </li>
  592. <li class="divider"></li>
  593. <li class="{% if item.status not in [1] %} disabled {% endif %}">
  594. <a href="javascript:;" onclick="suspend_at(this);">暂停</a>
  595. </li>
  596. <li class="{% if item.status not in [3] %} disabled {% endif %}">
  597. <a href="javascript:;" onclick="resume_at(this);">恢复</a>
  598. </li>
  599. <li class="divider"></li>
  600. <li class="">
  601. <a href="/guest/vnc/{{ item.uuid }}" target="_blank">远程连接</a>
  602. </li>
  603. <li class="divider"></li>
  604. <li class="">
  605. <a href="/guest/boot_jobs/{{ item.uuid }}" target="_blank">启动作业</a>
  606. </li>
  607. <li class="divider"></li>
  608. <li class="">
  609. <a href="javascript:;" data-toggle="modal" data-target="#reset_password_modal"
  610. onclick="$('#reset_password_type').val('single')">
  611. 密码重置
  612. </a>
  613. </li>
  614. <li class="{% if item.status not in [1, 3, 4, 5, 6] %} disabled {% endif %}">
  615. <a href="javascript:;" data-toggle="modal" data-target="#migrate_modal"
  616. onclick="$('#migrate_type').val('single')">
  617. 迁移到
  618. </a>
  619. </li>
  620. <li class="divider"></li>
  621. <li class="{% if item.status not in [4, 5, 6, 255] %} disabled {% endif %}">
  622. <a href="javascript:;" onclick="delete_at(this);">删除</a>
  623. </li>
  624. </ul>
  625. </div>
  626. </td>
  627. </tr>
  628. {% endfor %}
  629. </tbody>
  630. </table>
  631. <table class="table table-bordered" style="border-top-width: 0; z-index: 99; position: sticky; bottom: 0;">
  632. <tfoot>
  633. <tr style="height: 70px;">
  634. <th><input type="checkbox" title="选取所有" class="all_selector"></th>
  635. <th>
  636. <div class="row">
  637. <div class="col-sm-6">
  638. <button class="btn btn-default btn-shortcut disabled" onclick="batch_boot();">启动</button>
  639. <button class="btn btn-default btn-shortcut disabled" onclick="batch_reboot();">重启</button>
  640. <button class="btn btn-default btn-shortcut disabled" onclick="batch_shutdown();">停止</button>
  641. <button class="btn btn-default btn-shortcut disabled" onclick="batch_suspend();">暂停</button>
  642. <button class="btn btn-default btn-shortcut disabled" onclick="batch_resume();">恢复</button>
  643. <div class="dropup inline-block">
  644. <button href="javascript:;" class="dropdown-toggle btn btn-default btn-shortcut disabled" data-toggle="dropdown">
  645. 更多
  646. </button>
  647. <ul class="dropdown-menu" style="width: 60px;">
  648. <li>
  649. <a href="javascript:;" onclick="batch_delete();">删除</a>
  650. </li>
  651. <li class="divider"></li>
  652. <li>
  653. <a href="javascript:;" onclick="$('#migrate_type').val('batch');"
  654. data-toggle="modal" data-target="#migrate_modal" >
  655. 迁移到
  656. </a>
  657. </li>
  658. <li>
  659. <a href="javascript:;" onclick="$('#reset_password_type').val('batch');"
  660. data-toggle="modal" data-target="#reset_password_modal">
  661. 密码重置
  662. </a>
  663. </li>
  664. <li class="divider"></li>
  665. <li>
  666. <a href="javascript:;" data-toggle="modal" data-target="#add_boot_job_modal">
  667. 启动作业
  668. </a>
  669. </li>
  670. <li class="divider"></li>
  671. <li>
  672. <a href="javascript:;" onclick="batch_force_shutdown();">强制停止</a>
  673. </li>
  674. <li>
  675. <a href="javascript:;" onclick="batch_force_reboot();">强制重启</a>
  676. </li>
  677. </ul>
  678. </div>
  679. </div>
  680. <div class="col-sm-3" style="font-size: 12px; padding-top: 5px; text-align: right;">
  681. 共有{{ guests_ret.paging.total }}条,每页显示:
  682. <select id="page_size" name="datatable-row-highlight_length" title="page_size" class="form-control" style="height: 22px; vertical-align: baseline;">
  683. <option value="10" {% if page_size == 10 %} selected {% endif %}>10</option>
  684. <option value="20" {% if page_size == 20 %} selected {% endif %}>20</option>
  685. <option value="50" {% if page_size == 50 %} selected {% endif %}>50</option>
  686. </select>&nbsp;&nbsp;条
  687. </div>
  688. <div class="col-sm-3" style="text-align: left;">
  689. <div class="dataTables_paginate paging_bootstrap" id="datatable-row-highlight_paginate">
  690. <ul id="pagination" class="pagination">
  691. <li class="{% if page == 1 %} disabled {% endif %}">
  692. <a href="{{ resource_path }}?page={{ page - 1 }}&page_size={{ page_size }}{% if keyword %}&keyword={{ keyword }}{% endif %}">«</a>
  693. </li>
  694. {% for item in pages %}
  695. <li class="{% if item == page %} active {% endif %}">
  696. <a href="{{ resource_path }}?page={{ item }}&page_size={{ page_size }}{% if keyword %}&keyword={{ keyword }}{% endif %}">{{ item }}</a>
  697. </li>
  698. {% endfor %}
  699. <li class="{% if page == last_page %} disabled {% endif %}">
  700. <a href="{{ resource_path }}?page={{ page + 1 }}&page_size={{ page_size }}{% if keyword %}&keyword={{ keyword }}{% endif %}">»</a>
  701. </li>
  702. </ul>
  703. </div>
  704. </div>
  705. </div>
  706. </th>
  707. </tr>
  708. </tfoot>
  709. </table>
  710. </div>
  711. </div>
  712. </div>
  713. </div>
  714. <div class="modal" id="edit_remark_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
  715. <div class="modal-dialog modal-sm">
  716. <div class="modal-content">
  717. <div class="modal-header">
  718. <h4 class="modal-title">编辑实例名称:</h4>
  719. </div>
  720. <div class="modal-body">
  721. <input id="instance_uuid" title="实例 UUID" class="form-control" name="uuid" hidden>
  722. <input id="edit_remark" title="实例名称" class="form-control" name="remark">
  723. </div>
  724. <div class="modal-footer">
  725. <button type="button" class="btn btn-sm btn-primary" onclick="remark_update();">确定</button>
  726. <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">取消</button>
  727. </div>
  728. </div>
  729. </div>
  730. </div>
  731. <div class="modal" id="migrate_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
  732. <div class="modal-dialog modal-sm">
  733. <div class="modal-content">
  734. <div class="modal-header">
  735. <h4 class="modal-title">实例迁移至:</h4>
  736. </div>
  737. <div class="modal-body">
  738. <input id="migrate_type" title="迁移类型" class="form-control" name="migrate_type" value="single" hidden>
  739. <input id="migrate_instance_uuid" title="实例 UUID" class="form-control" name="uuid" hidden>
  740. <select id="migrate_host" name="migrate_host" title="可迁移宿主机" class="chosen-select">
  741. </select>
  742. </div>
  743. <div class="modal-footer">
  744. <button type="button" class="btn btn-sm btn-primary" onclick="migrate_go();">确定</button>
  745. <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">取消</button>
  746. </div>
  747. </div>
  748. </div>
  749. </div>
  750. <div class="modal" id="reset_password_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
  751. <div class="modal-dialog modal-sm">
  752. <div class="modal-content">
  753. <div class="modal-header">
  754. <h4 class="modal-title">重置密码:</h4>
  755. </div>
  756. <div class="modal-body">
  757. <div class="form-group">
  758. <input id="reset_password_type" title="重置密码类型" class="form-control" name="reset_password_type" value="single" hidden>
  759. <input id="reset_password_instance_uuid" title="实例 UUID" class="form-control" name="uuid" hidden>
  760. <input id="new_password" title="新密码" class="form-control" name="new_password" type="password" placeholder="New password">
  761. </div>
  762. </div>
  763. <div class="modal-footer">
  764. <button type="button" class="btn btn-sm btn-primary" onclick="reset_password_go();">确定</button>
  765. <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">取消</button>
  766. </div>
  767. </div>
  768. </div>
  769. </div>
  770. <div class="modal" id="add_boot_job_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
  771. <div class="modal-dialog modal-lg">
  772. <div class="modal-content">
  773. <div class="modal-header">
  774. <h4 class="modal-title">添加启动作业:</h4>
  775. </div>
  776. <div class="modal-body" style="padding-top: 0; padding-bottom: 0;">
  777. <div class="example-box-wrapper">
  778. <form class="form-horizontal bordered-row">
  779. <div class="form-group">
  780. <div class="col-sm-2"></div>
  781. <label class="col-sm-2 control-label"><span class="glyph-icon icon-list-alt"></span>&nbsp;&nbsp;启动作业</label>
  782. <div class="col-sm-6">
  783. <select id="boot_job_selector" name="boot_job_selector" title="启动作业" class="selectpicker">
  784. </select>
  785. </div>
  786. </div>
  787. <div class="form-group">
  788. <div class="col-sm-4"></div>
  789. <div class="col-sm-6 pull-right">
  790. <button class="btn btn-blue-alt" style="width: 180px; height: 40px; font-size: 16px;" onclick="batch_add_boot_job();">添加</button>
  791. <button class="btn btn-default" style="width: 64px; height: 40px; font-size: 16px;" data-dismiss="modal">取消</button>
  792. </div>
  793. </div>
  794. </form>
  795. </div>
  796. </div>
  797. </div>
  798. </div>
  799. </div>
  800. {% endblock content %}