os_templates_image_show.html 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027
  1. {% extends "layout.html" %}
  2. {% block head %}
  3. {{ super() }}
  4. <style type="text/css">
  5. @media (min-width: 768px) {
  6. .form-horizontal .control-label {
  7. text-align: left;
  8. }
  9. }
  10. label>span {
  11. color: deepskyblue;
  12. }
  13. .table {
  14. font-size: 12px;
  15. border-width: 1px;
  16. line-height: 20px;
  17. }
  18. .table > thead > tr > th,
  19. .table > tfoot > tr > th {
  20. color: #999999;
  21. font-weight: normal;
  22. border-bottom: 0 solid #e1e6eb;
  23. background-color: #F5F6FA;
  24. }
  25. .table > tbody > tr > td {
  26. color: #424547;
  27. }
  28. .table-bordered > tbody > tr {
  29. padding-top: 10px;
  30. padding-bottom: 10px;
  31. }
  32. .table-bordered > thead > tr > th,
  33. .table-bordered > tbody > tr > th,
  34. .table-bordered > tfoot > tr > th,
  35. .table-bordered > thead > tr > td,
  36. .table-bordered > tbody > tr > td,
  37. .table-bordered > tfoot > tr > td {
  38. border-style: solid;
  39. border-width: 1px 0 0 0;
  40. }
  41. .btn,
  42. .form-control,
  43. .modal-content {
  44. border-radius: 0 !important;
  45. }
  46. .btn-shortcut {
  47. font-size: 12px !important;
  48. padding: 0 26px;
  49. }
  50. .show {
  51. display: inline-block !important;
  52. }
  53. .tr-selected td,
  54. .tr-selected {
  55. color: #000 !important;
  56. background: #fafaff !important;
  57. }
  58. </style>
  59. {% endblock head %}
  60. {% block content %}
  61. <script type="text/javascript">
  62. var keyword = '';
  63. var resource_path = window.location.pathname;
  64. var cur_url = resource_path;
  65. var sheet_tag = window.location.hash;
  66. $(document).ready(function() {
  67. keyword = url('?keyword', window.location.href);
  68. if (keyword !== undefined && typeof(keyword) === 'string') {
  69. $('#content_search_by_public').val(keyword);
  70. $('#content_search_by_custom').val(keyword);
  71. }
  72. var last_ready = null;
  73. $('#content_search_by_public').keydown(function() {
  74. if (last_ready !== null) {
  75. clearTimeout(last_ready);
  76. }
  77. last_ready = setTimeout(function () {
  78. keyword = $('#content_search_by_public').val();
  79. refresh();
  80. }, 1000);
  81. });
  82. $('#content_search_by_custom').keydown(function() {
  83. if (last_ready !== null) {
  84. clearTimeout(last_ready);
  85. }
  86. last_ready = setTimeout(function () {
  87. keyword = $('#content_search_by_custom').val();
  88. refresh();
  89. }, 1000);
  90. });
  91. $("thead").on('click', ".all_selector", function() {
  92. if ($("thead .all_selector").is(':checked')) {
  93. $("tbody tr").find('td input[type="checkbox"]:eq(0)').prop('checked', true);
  94. $(".all_selector").prop('checked', true);
  95. } else {
  96. $("tbody tr").find('td input[type="checkbox"]:eq(0)').prop('checked', false);
  97. $(".all_selector").prop('checked', false);
  98. }
  99. select_item_action();
  100. });
  101. $("tfoot").on('click', ".all_selector", function() {
  102. if ($("tfoot .all_selector").is(':checked')) {
  103. $("tbody tr").find('td input[type="checkbox"]:eq(0)').prop('checked', true);
  104. $(".all_selector").prop('checked', true);
  105. } else {
  106. $("tbody tr").find('td input[type="checkbox"]:eq(0)').prop('checked', false);
  107. $(".all_selector").prop('checked', false);
  108. }
  109. select_item_action();
  110. });
  111. $("tbody tr").on('click', "input[type='checkbox']", function() {
  112. select_item_action();
  113. });
  114. $('#edit_label_modal').on('show.bs.modal', function (me) {
  115. $('#os_template_image_id').val($(me.relatedTarget).parent().parent().prev().prev().text());
  116. $('#edit_label').val($(me.relatedTarget).prev().text());
  117. });
  118. $('#edit_path_modal').on('show.bs.modal', function (me) {
  119. $('#os_template_image_id').val($(me.relatedTarget).parent().parent().prev().prev().prev().prev().text());
  120. $('#edit_path').val($(me.relatedTarget).prev().text());
  121. });
  122. $('#add_os_template_image_modal').on('show.bs.modal', function (me) {
  123. refresh_os_template_profile_os_distro_selectpicker($('#os_distro'));
  124. });
  125. $('#os_distro').on('changed.bs.select', function (me) {
  126. refresh_os_template_profile_id_selectpicker($('#os_template_profile_id'), me.currentTarget.value);
  127. $('#os_template_profile_id').removeAttr('disabled');
  128. });
  129. $('#update_os_template_image_profile_id_modal').on('show.bs.modal', function (me) {
  130. refresh_os_template_profile_os_distro_selectpicker($('#update_os_distro'));
  131. });
  132. $('#update_os_distro').on('changed.bs.select', function (me) {
  133. refresh_os_template_profile_id_selectpicker($('#update_os_template_profile_id'), me.currentTarget.value);
  134. $('#update_os_template_profile_id').removeAttr('disabled');
  135. });
  136. $('#update_logo_modal').on('show.bs.modal', function (me) {
  137. $('#os_template_image_id').val($(me.relatedTarget).parent().parent().prev().prev().prev().prev().prev().text());
  138. $('#update_logo_instance_desc').text($(me.relatedTarget).parent().parent().prev().prev().prev().text());
  139. });
  140. $('#add_os_template_image_form').formValidation({
  141. framework: 'bootstrap4',
  142. icon: {
  143. valid: 'fa fa-check',
  144. invalid: 'fa fa-times',
  145. validating: 'fa fa-refresh'
  146. },
  147. // Since the Bootstrap Button hides the radio and checkbox
  148. // We exclude the disabled elements only
  149. excluded: ':disabled',
  150. locale: 'zh_CN',
  151. fields: {
  152. label: {
  153. validators: {
  154. notEmpty: {},
  155. stringLength: {
  156. min: 2,
  157. max: 255
  158. }
  159. }
  160. },
  161. logo: {
  162. validators: {
  163. notEmpty: {}
  164. }
  165. },
  166. path: {
  167. validators: {
  168. notEmpty: {},
  169. stringLength: {
  170. min: 2,
  171. max: 255
  172. }
  173. }
  174. },
  175. os_template_profile_id: {
  176. validators: {
  177. notEmpty: {}
  178. }
  179. }
  180. }
  181. })
  182. .on('success.field.fv', function(e, data) {
  183. if (data.fv.getInvalidFields().length > 0) { // There is invalid field
  184. data.fv.disableSubmitButtons(true);
  185. }
  186. }).on('success.form.fv', function (e, data) {
  187. create();
  188. });
  189. nav_to_sheet_tag();
  190. });
  191. function create() {
  192. var data = {
  193. label: $('#label').val(),
  194. description: $('#description').val(),
  195. path: $('#path').val(),
  196. logo: $('#logo').val(),
  197. active: $('#active').val(),
  198. os_template_profile_id: parseInt($('#os_template_profile_id').val()),
  199. kind: 0
  200. };
  201. var go_back_url = '/os_templates_image';
  202. $.ajax({
  203. url : '/api/os_template_image',
  204. type : 'POST',
  205. contentType: "application/json; charset=utf-8",
  206. async: false,
  207. dataType: "json",
  208. data : JSON.stringify(data),
  209. error : function(data, textStatus, xhr) {
  210. alter_warning('创建模板镜像失败!');
  211. alter_danger(data.responseText);
  212. },
  213. success : function(data, textStatus, xhr) {
  214. alter_success('您所提交的模板镜像已创建。页面将在3秒钟后自动跳转到模板列表页面!');
  215. }
  216. });
  217. setTimeout(function() {
  218. window.location.href=go_back_url;
  219. }, 3000);
  220. }
  221. function refresh() {
  222. if (keyword !== undefined && keyword.length > 0) {
  223. cur_url = resource_path + '?keyword=' + keyword + '&r=' + new RandomPassword().create(16);
  224. }
  225. sheet_tag = window.location.hash;
  226. if (sheet_tag !== '') {
  227. if (keyword === undefined) {
  228. cur_url = '?r=' + new RandomPassword().create(16);
  229. }
  230. cur_url += sheet_tag;
  231. }
  232. window.location.href = cur_url;
  233. }
  234. function select_this(me) {
  235. $(me).parent().parent().children().removeClass('active');
  236. $(me).parent().addClass('active');
  237. $('#public_os_templates_image, #custom_os_templates_image').css('display', 'none');
  238. if (me.id === 'custom_os_templates_image_label') {
  239. $('#custom_os_templates_image').css('display', 'unset');
  240. window.location.hash = "custom";
  241. } else {
  242. $('#public_os_templates_image').css('display', 'unset');
  243. history.replaceState(null, null, ' ');
  244. }
  245. }
  246. function nav_to_sheet_tag() {
  247. var public_os_templates_image_label = $('#public_os_templates_image_label');
  248. var custom_os_templates_image_label = $('#custom_os_templates_image_label');
  249. public_os_templates_image_label.parent().parent().children().removeClass('active');
  250. $('#public_os_templates_image, #custom_os_templates_image').css('display', 'none');
  251. if (sheet_tag === '#custom') {
  252. custom_os_templates_image_label.parent().addClass('active');
  253. $('#custom_os_templates_image').css('display', 'unset');
  254. } else {
  255. public_os_templates_image_label.parent().addClass('active');
  256. $('#public_os_templates_image').css('display', 'unset');
  257. }
  258. }
  259. function row_onmouseover(me) {
  260. $(me).find(".edit_label_trigger, .edit_path_trigger").css('display','inline-flex');
  261. }
  262. function row_onmouseout(me) {
  263. $(me).find(".edit_label_trigger, .edit_path_trigger").css('display','none');
  264. }
  265. function refresh_os_template_profile_os_distro_selectpicker(selectpicker) {
  266. $.ajax({
  267. url : '/api/os_templates_profile?filter=active:eq:1',
  268. type : 'GET',
  269. contentType: "application/json; charset=utf-8",
  270. dataType: 'json',
  271. error : function() {
  272. },
  273. success : function(data, textStatus, xhr) {
  274. var os_distro = [];
  275. selectpicker.empty();
  276. $.each(data.data, function(k, v) {
  277. if (jQuery.inArray(v['os_distro'], os_distro) >= 0) {
  278. return;
  279. }
  280. os_distro.push(v['os_distro']);
  281. selectpicker.append(
  282. $('<option>', {value: v['os_distro'], text: v['os_distro'], 'data-icon': v['icon']})
  283. );
  284. });
  285. selectpicker.selectpicker('refresh');
  286. }
  287. });
  288. }
  289. function refresh_os_template_profile_id_selectpicker(selectpicker, os_distro) {
  290. $.ajax({
  291. url : '/api/os_templates_profile?filter=os_distro:eq:' + os_distro,
  292. type : 'GET',
  293. contentType: "application/json; charset=utf-8",
  294. dataType: 'json',
  295. error : function() {
  296. },
  297. success : function(data, textStatus, xhr) {
  298. selectpicker.empty();
  299. $.each(data.data, function(k, v) {
  300. selectpicker.append(
  301. $('<option>', {value: v['id'], text: v['label'], 'data-subtext': v['os_product_name']})
  302. );
  303. });
  304. selectpicker.selectpicker('refresh');
  305. }
  306. });
  307. }
  308. function label_update(me) {
  309. var os_template_image_id = $('#os_template_image_id').val();
  310. var label = $('#edit_label').val();
  311. $('#edit_label_modal').modal('hide');
  312. $.ajax({
  313. url : '/api/os_template_image/' + os_template_image_id,
  314. type : 'PATCH',
  315. contentType: "application/json; charset=utf-8",
  316. data : JSON.stringify({
  317. label: label
  318. }),
  319. error : function() {
  320. alter_danger('模板镜像名称更新失败!');
  321. },
  322. success : function() {
  323. alter_success('模板镜像名称更新成功!');
  324. setTimeout(function() {
  325. refresh();
  326. }, 1000);
  327. }
  328. });
  329. }
  330. function path_update(me) {
  331. var os_template_image_id = $('#os_template_image_id').val();
  332. var path = $('#edit_path').val();
  333. $('#edit_path_modal').modal('hide');
  334. $.ajax({
  335. url : '/api/os_template_image/' + os_template_image_id,
  336. type : 'PATCH',
  337. contentType: "application/json; charset=utf-8",
  338. data : JSON.stringify({
  339. path: path
  340. }),
  341. error : function() {
  342. alter_danger('模板镜像路径更新失败!');
  343. },
  344. success : function() {
  345. alter_success('模板镜像路径更新成功!');
  346. setTimeout(function() {
  347. refresh();
  348. }, 1000);
  349. }
  350. });
  351. }
  352. function update_os_template_image_profile_id(id) {
  353. $.ajax({
  354. url : '/api/os_template_image/' + id,
  355. type : 'PATCH',
  356. contentType: "application/json; charset=utf-8",
  357. data : JSON.stringify({
  358. os_template_profile_id: parseInt($('#update_os_template_profile_id').val())
  359. }),
  360. error : function() {
  361. alter_danger('变更模板系统发行版本指令发送失败!');
  362. },
  363. success : function() {
  364. alter_success('变更模板系统发行版本指令发送成功!');
  365. setTimeout(function() {
  366. refresh();
  367. }, 1000);
  368. }
  369. });
  370. }
  371. function update_logo(id) {
  372. $.ajax({
  373. url : '/api/os_template_image/' + id,
  374. type : 'PATCH',
  375. contentType: "application/json; charset=utf-8",
  376. data : JSON.stringify({
  377. logo: $('#update_logo').val()
  378. }),
  379. error : function() {
  380. alter_danger('变更 LOGO 指令发送失败!');
  381. },
  382. success : function() {
  383. alter_success('变更 LOGO 指令发送成功!');
  384. setTimeout(function() {
  385. refresh();
  386. }, 1000);
  387. }
  388. });
  389. }
  390. function get_selected_element(checked) {
  391. if (checked === null) {
  392. checked = true;
  393. }
  394. if (checked) {
  395. return $('tbody :checked');
  396. } else {
  397. return $('tbody input:not(:checked)');
  398. }
  399. }
  400. function highlight_selected_element() {
  401. var selected_element = get_selected_element(true);
  402. var no_selected_element = get_selected_element(false);
  403. selected_element.each(function(i, e) {
  404. $(e).parent().parent().toggleClass('tr-selected', true);
  405. });
  406. no_selected_element.each(function(i, e) {
  407. $(e).parent().parent().toggleClass('tr-selected', false);
  408. });
  409. }
  410. function shortcut_bar_enable() {
  411. var selected_element = get_selected_element(true);
  412. if (selected_element.length > 0) {
  413. $('.btn-shortcut').toggleClass('disabled', false);
  414. } else {
  415. $('.btn-shortcut').toggleClass('disabled', true);
  416. }
  417. }
  418. function select_item_action() {
  419. highlight_selected_element();
  420. shortcut_bar_enable();
  421. }
  422. function enable(id) {
  423. $.ajax({
  424. url : '/api/os_template_image/' + id,
  425. type : 'PATCH',
  426. contentType: "application/json; charset=utf-8",
  427. data : JSON.stringify({
  428. active: true
  429. }),
  430. error : function() {
  431. alter_danger('启用指令发送失败!');
  432. },
  433. success : function() {
  434. alter_success('启用指令发送成功!');
  435. refresh();
  436. }
  437. });
  438. }
  439. function disable(id) {
  440. $.ajax({
  441. url : '/api/os_template_image/' + id,
  442. type : 'PATCH',
  443. contentType: "application/json; charset=utf-8",
  444. data : JSON.stringify({
  445. active: false
  446. }),
  447. error : function() {
  448. alter_danger('禁用指令发送失败!');
  449. },
  450. success : function() {
  451. alter_success('禁用指令发送成功!');
  452. refresh();
  453. }
  454. });
  455. }
  456. function remove(id) {
  457. $.ajax({
  458. url : '/api/os_templates_image/' + id,
  459. type : 'DELETE',
  460. contentType: "application/json; charset=utf-8",
  461. error : function() {
  462. alter_danger('模板镜像删除指令发送失败!');
  463. },
  464. success : function() {
  465. alter_success('模板镜像删除指令发送成功!');
  466. setTimeout(function() {
  467. refresh();
  468. }, 1000);
  469. }
  470. });
  471. }
  472. function enable_at(me) {
  473. var id = $(me).parent().parent().parent().parent().parent().children()[0].textContent;
  474. enable(id);
  475. }
  476. function disable_at(me) {
  477. var id = $(me).parent().parent().parent().parent().parent().children()[0].textContent;
  478. disable(id);
  479. }
  480. function delete_at(me) {
  481. var id = $('#os_template_image_id').val();
  482. remove(id);
  483. $('#delete_modal').modal('hide');
  484. }
  485. function update_os_template_image_profile_id_at(me) {
  486. var id = $('#os_template_image_id').val();
  487. update_os_template_image_profile_id(id);
  488. $('#update_os_template_image_profile_id_modal').modal('hide');
  489. }
  490. function update_logo_at(me) {
  491. var id = $('#os_template_image_id').val();
  492. update_logo(id);
  493. $('#update_logo_modal').modal('hide');
  494. }
  495. </script>
  496. <div class="panel">
  497. <div class="panel-body">
  498. <ul class="nav nav-tabs mrg25B">
  499. <li class="active"><a href="javascript:;" onclick="select_this(this);" id="public_os_templates_image_label">公共镜像</a></li>
  500. <li><a href="javascript:;" onclick="select_this(this);" id="custom_os_templates_image_label">自定义镜像</a></li>
  501. </ul>
  502. <div id="public_os_templates_image" class="dataTables_wrapper form-inline">
  503. <div class="row" style="padding: 10px 10px 10px 0; width: 100%;">
  504. <div class="col-sm-12" style="padding-right: 0;">
  505. <div id="datatable-row-highlight_filter" class="dataTables_filter" style="display: inline-block;">
  506. <input id="content_search_by_public" type="search" class="form-control" placeholder="模糊搜索..." value="{%- if keyword -%} {{ keyword }} {%- endif -%}" style="margin-left: 0; border-radius: 0;">
  507. </div>
  508. <div class="pull-right">
  509. <button class="btn btn-default" onclick="refresh()" style="border-radius: 0;"><span class="glyph-icon icon-elusive-arrows-cw"></span></button>
  510. <a class="btn btn-info" href="javascript:;" data-toggle="modal" data-target="#add_os_template_image_modal" style="border-radius: 0; padding-left: 40px; padding-right: 40px;">添加模板</a>
  511. </div>
  512. </div>
  513. </div>
  514. <table id="os_templates_image_list" class="table table-bordered table-hover" cellspacing="0" width="100%" role="grid"
  515. style="width: 100%; margin-bottom: 0; border-bottom-width: 0;">
  516. <thead>
  517. <tr role="row">
  518. <th style="display: none;">ID</th>
  519. <th><input class="all_selector" title="选取所有" type="checkbox"></th>
  520. <th width="180px;">名称</th>
  521. <th>状态</th>
  522. <th width="500px;">路径</th>
  523. <th>发行版本</th>
  524. <th>操作</th>
  525. </tr>
  526. </thead>
  527. <tbody>
  528. {% for item in os_templates_image if item.kind == 0 %}
  529. <tr role="row" class="odd" onmouseover="row_onmouseover(this);" onmouseout="row_onmouseout(this);">
  530. <td style="display: none;">{{ item.id }}</td>
  531. <td><input title="选中" type="checkbox"></td>
  532. <td>
  533. <div>
  534. <p style="display: inline-block;">{{ item.label }}</p>
  535. <a href="javascript:;" class="edit_label_trigger" data-toggle="modal" data-target="#edit_label_modal" style="display: none; float: right;">
  536. <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>
  537. </a>
  538. </div>
  539. </td>
  540. <td>{% if item.active == 0 %}
  541. <span style="color: #990000;">未启用</span>
  542. {% else %}
  543. <span style="color: #00BB00;">启用</span>
  544. {% endif %}
  545. </td>
  546. <td>
  547. <div>
  548. <p style="display: inline-block;">{{ item.path }}</p>
  549. <a href="javascript:;" class="edit_path_trigger" data-toggle="modal" data-target="#edit_path_modal" style="display: none; float: right;">
  550. <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>
  551. </a>
  552. </div>
  553. </td>
  554. <td>
  555. <div>
  556. <a href="javascript:;" data-toggle="modal" data-target="#update_logo_modal">
  557. {% if item.logo == "" %}
  558. <span class="{{ os_templates_profile_mapping_by_id[item.os_template_profile_id | string].icon }}"></span>
  559. {% else %}
  560. <span class="{{ item.logo }}"></span>
  561. {% endif %}
  562. </a>
  563. <p style="display: inline-block;">{{ os_templates_profile_mapping_by_id[item.os_template_profile_id | string].os_product_name }}</p>
  564. </div>
  565. </td>
  566. <td>
  567. <div class="dropdown inline-block">
  568. <a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown">
  569. 更多
  570. </a>
  571. <ul class="dropdown-menu">
  572. <li class="{% if item.active == true %} disabled {% endif %}" style="{% if item.sequence == 0 %} display: none; {% endif %}">
  573. <a href="javascript:;" onclick="enable_at(this);">
  574. 启用
  575. </a>
  576. </li>
  577. <li class="{% if item.active != true %} disabled {% endif %}" style="{% if item.sequence == 0 %} display: none; {% endif %}">
  578. <a href="javascript:;" onclick="disable_at(this);">
  579. 禁用
  580. </a>
  581. </li>
  582. <li class="divider" style="{% if item.sequence == 0 %} display: none; {% endif %}"></li>
  583. <li>
  584. <a href="javascript:;" data-toggle="modal" data-target="#update_os_template_image_profile_id_modal"
  585. onclick="$('#os_template_image_id').val($(this).parent().parent().parent().parent().parent().children()[0].textContent);
  586. $('#update_os_template_image_profile_id_instance_desc').text($(this).parent().parent().parent().parent().parent().children()[2].textContent)">
  587. 变更发行版本
  588. </a>
  589. </li>
  590. <li class="divider" style="{% if item.sequence == 0 %} display: none; {% endif %}"></li>
  591. <li class="{% if 'guests' in item %} disabled {% endif %}">
  592. <a href="javascript:;" data-toggle="modal" data-target="#delete_modal"
  593. onclick="$('#os_template_image_id').val($(this).parent().parent().parent().parent().parent().children()[0].textContent);
  594. $('#delete_instance_desc').text($(this).parent().parent().parent().parent().parent().children()[2].textContent)">
  595. 删除
  596. </a>
  597. </li>
  598. </ul>
  599. </div>
  600. </td>
  601. </tr>
  602. {% endfor %}
  603. </tbody>
  604. </table>
  605. <table class="table table-bordered" style="border-top-width: 0; z-index: 99; position: sticky; bottom: 0;">
  606. <tfoot>
  607. <tr style="height: 70px;">
  608. <th><input type="checkbox" title="选取所有" class="all_selector"></th>
  609. <th>
  610. <div class="row">
  611. <div class="col-sm-6">
  612. </div>
  613. <div class="col-sm-3" style="font-size: 12px; padding-top: 5px; text-align: right;">
  614. 共有{{ public_count }}条
  615. </div>
  616. <div class="col-sm-3" style="text-align: left;">
  617. </div>
  618. </div>
  619. </th>
  620. </tr>
  621. </tfoot>
  622. </table>
  623. </div>
  624. <div id="custom_os_templates_image" class="dataTables_wrapper form-inline" style="display: none;">
  625. <div class="row" style="padding: 10px 10px 10px 0; width: 100%;">
  626. <div class="col-sm-12" style="padding-right: 0;">
  627. <div id="datatable-row-highlight_filter" class="dataTables_filter" style="display: inline-block;">
  628. <input id="content_search_by_custom" type="search" class="form-control" placeholder="模糊搜索..." value="{%- if keyword -%} {{ keyword }} {%- endif -%}" style="margin-left: 0; border-radius: 0;">
  629. </div>
  630. <div class="pull-right">
  631. <button class="btn btn-default" onclick="refresh()" style="border-radius: 0;"><span class="glyph-icon icon-elusive-arrows-cw"></span></button>
  632. </div>
  633. </div>
  634. </div>
  635. <table id="os_templates_image_list" class="table table-bordered table-hover" cellspacing="0" width="100%" role="grid"
  636. style="width: 100%; margin-bottom: 0; border-bottom-width: 0;">
  637. <thead>
  638. <tr role="row">
  639. <th style="display: none;">ID</th>
  640. <th><input class="all_selector" title="选取所有" type="checkbox"></th>
  641. <th width="220px;">名称</th>
  642. <th>状态</th>
  643. <th>进度</th>
  644. <th>创建时间</th>
  645. <th>发行版本</th>
  646. <th>操作</th>
  647. </tr>
  648. </thead>
  649. <tbody>
  650. {% for item in os_templates_image if item.kind == 1 %}
  651. <tr role="row" class="odd" onmouseover="row_onmouseover(this);" onmouseout="row_onmouseout(this);">
  652. <td style="display: none;">{{ item.id }}</td>
  653. <td><input title="选中" type="checkbox"></td>
  654. <td>
  655. <div>
  656. <p style="display: inline-block;">{{ item.label }}</p>
  657. <a href="javascript:;" class="edit_label_trigger" data-toggle="modal" data-target="#edit_label_modal" style="display: none; float: right;">
  658. <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>
  659. </a>
  660. </div>
  661. </td>
  662. <td>{% if item.active == 0 %}
  663. <span style="color: #990000;">未启用</span>
  664. {% else %}
  665. <span style="color: #00BB00;">启用</span>
  666. {% endif %}
  667. </td>
  668. <td>
  669. {% if item.progress == 255 %}
  670. <span style="color: #990000;">创建失败</span>
  671. {% elif item.progress == 254 %}
  672. <span style="color: #ff0000dd;">删除中...</span>
  673. {% elif item.progress == 100 %}
  674. <span style="color: #00BB00;">{{ item.progress }}%</span>
  675. {% else %}
  676. <span style="color: #e5b715;">{{ item.progress }}%</span>
  677. {% endif %}
  678. </td>
  679. <td>{{ format_datetime_by_tus(item.create_time) }}</td>
  680. <td>
  681. <div>
  682. <a href="javascript:;" data-toggle="modal" data-target="#update_logo_modal">
  683. {% if item.logo == "" %}
  684. <span class="{{ os_templates_profile_mapping_by_id[item.os_template_profile_id | string].icon }}"></span>
  685. {% else %}
  686. <span class="{{ item.logo }}"></span>
  687. {% endif %}
  688. </a>
  689. <p style="display: inline-block;">{{ os_templates_profile_mapping_by_id[item.os_template_profile_id | string].os_product_name }}</p>
  690. </div>
  691. </td>
  692. <td>
  693. <div class="dropdown inline-block">
  694. <a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown">
  695. 更多
  696. </a>
  697. <ul class="dropdown-menu">
  698. <li class="{% if item.active == true %} disabled {% endif %}" style="{% if item.sequence == 0 %} display: none; {% endif %}">
  699. <a href="javascript:;" onclick="enable_at(this);">
  700. 启用
  701. </a>
  702. </li>
  703. <li class="{% if item.active != true %} disabled {% endif %}" style="{% if item.sequence == 0 %} display: none; {% endif %}">
  704. <a href="javascript:;" onclick="disable_at(this);">
  705. 禁用
  706. </a>
  707. </li>
  708. <li class="divider" style="{% if item.sequence == 0 %} display: none; {% endif %}"></li>
  709. <li>
  710. <a href="javascript:;" data-toggle="modal" data-target="#update_os_template_image_profile_id_modal"
  711. onclick="$('#os_template_image_id').val($(this).parent().parent().parent().parent().parent().children()[0].textContent);
  712. $('#update_os_template_image_profile_id_instance_desc').text($(this).parent().parent().parent().parent().parent().children()[2].textContent)">
  713. 变更发行版本
  714. </a>
  715. </li>
  716. <li class="divider" style="{% if item.sequence == 0 %} display: none; {% endif %}"></li>
  717. <li class="{% if item.progress != 100 or 'guests' in item %} disabled {% endif %}">
  718. <a href="javascript:;" data-toggle="modal" data-target="#delete_modal"
  719. onclick="$('#os_template_image_id').val($(this).parent().parent().parent().parent().parent().children()[0].textContent);
  720. $('#delete_instance_desc').text($(this).parent().parent().parent().parent().parent().children()[2].textContent)">
  721. 删除
  722. </a>
  723. </li>
  724. </ul>
  725. </div>
  726. </td>
  727. </tr>
  728. {% endfor %}
  729. </tbody>
  730. </table>
  731. <table class="table table-bordered" style="border-top-width: 0; z-index: 99; position: sticky; bottom: 0;">
  732. <tfoot>
  733. <tr style="height: 70px;">
  734. <th><input type="checkbox" title="选取所有" class="all_selector"></th>
  735. <th>
  736. <div class="row">
  737. <div class="col-sm-6">
  738. </div>
  739. <div class="col-sm-3" style="font-size: 12px; padding-top: 5px; text-align: right;">
  740. 共有{{ custom_count }}条
  741. </div>
  742. <div class="col-sm-3" style="text-align: left;">
  743. </div>
  744. </div>
  745. </th>
  746. </tr>
  747. </tfoot>
  748. </table>
  749. </div>
  750. </div>
  751. </div>
  752. <input id="os_template_image_id" title="模板 ID" class="form-control" name="os_template_image_id" hidden>
  753. <div class="modal" id="edit_label_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
  754. <div class="modal-dialog modal-sm">
  755. <div class="modal-content">
  756. <div class="modal-header">
  757. <h4 class="modal-title">编辑模板镜像名称:</h4>
  758. </div>
  759. <div class="modal-body">
  760. <input id="edit_label" title="系统模板镜像名称" class="form-control" name="os_template_image_label">
  761. </div>
  762. <div class="modal-footer">
  763. <button type="button" class="btn btn-sm btn-primary" onclick="label_update();">确定</button>
  764. <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">取消</button>
  765. </div>
  766. </div>
  767. </div>
  768. </div>
  769. <div class="modal" id="edit_path_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
  770. <div class="modal-dialog">
  771. <div class="modal-content">
  772. <div class="modal-header">
  773. <h4 class="modal-title">编辑模板镜像路径:</h4>
  774. </div>
  775. <div class="modal-body">
  776. <input id="edit_path" title="系统模板镜像路径" class="form-control" name="os_template_image_path">
  777. </div>
  778. <div class="modal-footer">
  779. <button type="button" class="btn btn-sm btn-primary" onclick="path_update();">确定</button>
  780. <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">取消</button>
  781. </div>
  782. </div>
  783. </div>
  784. </div>
  785. <div class="modal" id="delete_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
  786. <div class="modal-dialog">
  787. <div class="modal-content">
  788. <div class="modal-header">
  789. <h4 class="modal-title">删除模板:</h4>
  790. </div>
  791. <div class="modal-body">
  792. <p>您确定要删除该模板镜像吗?</p>
  793. <h3 style="color: orangered;" id="delete_instance_desc"></h3>
  794. </div>
  795. <div class="modal-footer">
  796. <button type="button" class="btn btn-sm btn-primary" onclick="delete_at();">确定</button>
  797. <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">取消</button>
  798. </div>
  799. </div>
  800. </div>
  801. </div>
  802. <div class="modal" id="add_os_template_image_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
  803. <div class="modal-dialog modal-lg">
  804. <div class="modal-content">
  805. <div class="modal-header">
  806. <h4 class="modal-title">添加模板镜像:</h4>
  807. </div>
  808. <div class="modal-body" style="padding-top: 0; padding-bottom: 0;">
  809. <div class="example-box-wrapper">
  810. <form id="add_os_template_image_form" class="form-horizontal bordered-row" action="javascript:;">
  811. <input id="active" name="active" value="1" type="hidden" title="激活" class="form-control">
  812. <div class="form-group">
  813. <div class="col-sm-2"></div>
  814. <label class="col-sm-2 control-label"><span class="glyph-icon icon-elusive-compass-circled"></span>&nbsp;&nbsp;模板镜像名称</label>
  815. <div class="col-sm-6">
  816. <input id="label" name="label" type="text" title="模板镜像名称" class="form-control">
  817. </div>
  818. </div>
  819. <div class="form-group">
  820. <div class="col-sm-2"></div>
  821. <label class="col-sm-2 control-label"><span class="glyph-icon icon-elusive-stumbleupon"></span>&nbsp;&nbsp;模板路径</label>
  822. <div class="col-sm-6">
  823. <input id="path" name="path" type="text" title="模板路径" class="form-control">
  824. </div>
  825. </div>
  826. <div class="form-group">
  827. <div class="col-sm-2"></div>
  828. <label class="col-sm-2 control-label"><span class="glyph-icon icon-child"></span>&nbsp;&nbsp;LOGO</label>
  829. <div class="col-sm-6">
  830. <select id="logo" name="logo" title="请选择 LOGO" class="selectpicker">
  831. <option value="icon-os icon-os-centos" data-icon="icon-os icon-os-centos">CentOS</option>
  832. <option value="icon-os icon-os-linux" data-icon="icon-os icon-os-linux">Linux</option>
  833. <option value="icon-os icon-os-ubuntu" data-icon="icon-os icon-os-ubuntu">Ubuntu</option>
  834. <option value="icon-os icon-os-suse" data-icon="icon-os icon-os-suse">Suse</option>
  835. <option value="icon-os icon-os-gentoo" data-icon="icon-os icon-os-gentoo">Gentoo</option>
  836. <option value="icon-os icon-os-debian" data-icon="icon-os icon-os-debian">Debian</option>
  837. <option value="icon-os icon-os-redhat" data-icon="icon-os icon-os-redhat">Redhat</option>
  838. <option value="icon-os icon-os-bsd" data-icon="icon-os icon-os-bsd">BSD</option>
  839. <option value="icon-os icon-os-windows" data-icon="icon-os icon-os-windows">Windows</option>
  840. </select>
  841. </div>
  842. </div>
  843. <div class="form-group">
  844. <div class="col-sm-2"></div>
  845. <label class="col-sm-2 control-label"><span class="glyph-icon icon-bookmark-o"></span>&nbsp;&nbsp;发行版本</label>
  846. <div class="col-sm-8">
  847. <select id="os_distro" name="os_distro" title="请选择发行版" class="selectpicker" data-width="140px">
  848. </select>
  849. <select id="os_template_profile_id" name="os_template_profile_id" title="请选择版本" class="selectpicker" data-width="237px" disabled>
  850. </select>
  851. </div>
  852. </div>
  853. <div class="form-group">
  854. <div class="col-sm-2"></div>
  855. <label class="col-sm-2 control-label"><span class="glyph-icon icon-newspaper-o"></span>&nbsp;&nbsp;模板镜像描述</label>
  856. <div class="col-sm-6">
  857. <textarea id="description" name="description" title="模板镜像描述" class="form-control"></textarea>
  858. </div>
  859. </div>
  860. <div class="form-group">
  861. <div class="col-sm-4"></div>
  862. <div class="col-sm-6 pull-right">
  863. <button type="submit" class="btn btn-blue-alt" style="width: 180px; height: 40px; font-size: 16px;" disabled>创建</button>
  864. <button class="btn btn-default" style="width: 64px; height: 40px; font-size: 16px;" data-dismiss="modal">取消</button>
  865. </div>
  866. </div>
  867. </form>
  868. </div>
  869. </div>
  870. </div>
  871. </div>
  872. </div>
  873. <div class="modal" id="update_os_template_image_profile_id_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
  874. <div class="modal-dialog modal-lg">
  875. <div class="modal-content">
  876. <div class="modal-header">
  877. <h4 class="modal-title">变更模板系统发行版:</h4>
  878. </div>
  879. <div class="modal-body" style="padding-top: 0;">
  880. <form class="form-horizontal bordered-row">
  881. <div class="form-group">
  882. <div class="col-sm-1"></div>
  883. <label class="col-sm-3 control-label"><span class="glyph-icon icon-elusive-compass-circled"></span>&nbsp;&nbsp;模板镜像名称</label>
  884. <div class="col-sm-8">
  885. <h3 style="color: orangered;" id="update_os_template_image_profile_id_instance_desc"></h3>
  886. </div>
  887. </div>
  888. <div class="form-group">
  889. <div class="col-sm-1"></div>
  890. <label class="col-sm-3 control-label"><span class="glyph-icon icon-bookmark-o"></span>&nbsp;&nbsp;发行版本</label>
  891. <div class="col-sm-8">
  892. <select id="update_os_distro" name="os_distro" title="请选择发行版" class="selectpicker" data-width="140px">
  893. </select>
  894. <select id="update_os_template_profile_id" name="os_template_profile_id" title="请选择版本" class="selectpicker" data-width="237px" disabled>
  895. </select>
  896. </div>
  897. </div>
  898. </form>
  899. </div>
  900. <div class="modal-footer">
  901. <button type="button" class="btn btn-sm btn-primary" onclick="update_os_template_image_profile_id_at();">确定</button>
  902. <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">取消</button>
  903. </div>
  904. </div>
  905. </div>
  906. </div>
  907. <div class="modal" id="update_logo_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
  908. <div class="modal-dialog">
  909. <div class="modal-content">
  910. <div class="modal-header">
  911. <h4 class="modal-title">变更 LOGO:</h4>
  912. </div>
  913. <div class="modal-body" style="padding-top: 0;">
  914. <form class="form-horizontal bordered-row">
  915. <div class="form-group">
  916. <div class="col-sm-1"></div>
  917. <label class="col-sm-3 control-label"><span class="glyph-icon icon-elusive-compass-circled"></span>&nbsp;&nbsp;模板镜像名称</label>
  918. <div class="col-sm-8">
  919. <h3 style="color: orangered;" id="update_logo_instance_desc"></h3>
  920. </div>
  921. </div>
  922. <div class="form-group">
  923. <div class="col-sm-1"></div>
  924. <label class="col-sm-3 control-label"><span class="glyph-icon icon-child"></span>&nbsp;&nbsp;LOGO</label>
  925. <div class="col-sm-8">
  926. <select id="update_logo" name="logo" title="模板 LOGO" class="selectpicker">
  927. <option value="icon-os icon-os-centos" data-icon="icon-os icon-os-centos" selected>CentOS</option>
  928. <option value="icon-os icon-os-linux" data-icon="icon-os icon-os-linux">Linux</option>
  929. <option value="icon-os icon-os-ubuntu" data-icon="icon-os icon-os-ubuntu">Ubuntu</option>
  930. <option value="icon-os icon-os-suse" data-icon="icon-os icon-os-suse">Suse</option>
  931. <option value="icon-os icon-os-gentoo" data-icon="icon-os icon-os-gentoo">Gentoo</option>
  932. <option value="icon-os icon-os-debian" data-icon="icon-os icon-os-debian">Debian</option>
  933. <option value="icon-os icon-os-redhat" data-icon="icon-os icon-os-redhat">Redhat</option>
  934. <option value="icon-os icon-os-bsd" data-icon="icon-os icon-os-bsd">BSD</option>
  935. <option value="icon-os icon-os-windows" data-icon="icon-os icon-os-windows">Windows</option>
  936. </select>
  937. </div>
  938. </div>
  939. </form>
  940. </div>
  941. <div class="modal-footer">
  942. <button type="button" class="btn btn-sm btn-primary" onclick="update_logo_at();">确定</button>
  943. <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">取消</button>
  944. </div>
  945. </div>
  946. </div>
  947. </div>
  948. {% endblock content %}