os_templates_image_show.html 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991
  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. });
  187. nav_to_sheet_tag();
  188. });
  189. function refresh() {
  190. if (keyword !== undefined && keyword.length > 0) {
  191. cur_url = resource_path + '?keyword=' + keyword + '&r=' + new RandomPassword().create(16);
  192. }
  193. sheet_tag = window.location.hash;
  194. if (sheet_tag !== '') {
  195. if (keyword === undefined) {
  196. cur_url = '?r=' + new RandomPassword().create(16);
  197. }
  198. cur_url += sheet_tag;
  199. }
  200. window.location.href = cur_url;
  201. }
  202. function select_this(me) {
  203. $(me).parent().parent().children().removeClass('active');
  204. $(me).parent().addClass('active');
  205. $('#public_os_templates_image, #custom_os_templates_image').css('display', 'none');
  206. if (me.id === 'custom_os_templates_image_label') {
  207. $('#custom_os_templates_image').css('display', 'unset');
  208. window.location.hash = "custom";
  209. } else {
  210. $('#public_os_templates_image').css('display', 'unset');
  211. history.replaceState(null, null, ' ');
  212. }
  213. }
  214. function nav_to_sheet_tag() {
  215. var public_os_templates_image_label = $('#public_os_templates_image_label');
  216. var custom_os_templates_image_label = $('#custom_os_templates_image_label');
  217. public_os_templates_image_label.parent().parent().children().removeClass('active');
  218. $('#public_os_templates_image, #custom_os_templates_image').css('display', 'none');
  219. if (sheet_tag === '#custom') {
  220. custom_os_templates_image_label.parent().addClass('active');
  221. $('#custom_os_templates_image').css('display', 'unset');
  222. } else {
  223. public_os_templates_image_label.parent().addClass('active');
  224. $('#public_os_templates_image').css('display', 'unset');
  225. }
  226. }
  227. function row_onmouseover(me) {
  228. $(me).find(".edit_label_trigger, .edit_path_trigger").css('display','inline-flex');
  229. }
  230. function row_onmouseout(me) {
  231. $(me).find(".edit_label_trigger, .edit_path_trigger").css('display','none');
  232. }
  233. function refresh_os_template_profile_os_distro_selectpicker(selectpicker) {
  234. $.ajax({
  235. url : '/api/os_templates_profile?filter=active:eq:1',
  236. type : 'GET',
  237. contentType: "application/json; charset=utf-8",
  238. dataType: 'json',
  239. error : function() {
  240. },
  241. success : function(data, textStatus, xhr) {
  242. var os_distro = [];
  243. selectpicker.empty();
  244. $.each(data.data, function(k, v) {
  245. if (jQuery.inArray(v['os_distro'], os_distro) >= 0) {
  246. return;
  247. }
  248. os_distro.push(v['os_distro']);
  249. selectpicker.append(
  250. $('<option>', {value: v['os_distro'], text: v['os_distro'], 'data-icon': v['icon']})
  251. );
  252. });
  253. selectpicker.selectpicker('refresh');
  254. }
  255. });
  256. }
  257. function refresh_os_template_profile_id_selectpicker(selectpicker, os_distro) {
  258. $.ajax({
  259. url : '/api/os_templates_profile?filter=os_distro:eq:' + os_distro,
  260. type : 'GET',
  261. contentType: "application/json; charset=utf-8",
  262. dataType: 'json',
  263. error : function() {
  264. },
  265. success : function(data, textStatus, xhr) {
  266. selectpicker.empty();
  267. $.each(data.data, function(k, v) {
  268. selectpicker.append(
  269. $('<option>', {value: v['id'], text: v['label'], 'data-subtext': v['os_product_name']})
  270. );
  271. });
  272. selectpicker.selectpicker('refresh');
  273. }
  274. });
  275. }
  276. function label_update(me) {
  277. var os_template_image_id = $('#os_template_image_id').val();
  278. var label = $('#edit_label').val();
  279. $('#edit_label_modal').modal('hide');
  280. $.ajax({
  281. url : '/api/os_template_image/' + os_template_image_id,
  282. type : 'PATCH',
  283. contentType: "application/json; charset=utf-8",
  284. data : JSON.stringify({
  285. label: label
  286. }),
  287. error : function() {
  288. alter_danger('模板镜像名称更新失败!');
  289. },
  290. success : function() {
  291. alter_success('模板镜像名称更新成功!');
  292. setTimeout(function() {
  293. refresh();
  294. }, 1000);
  295. }
  296. });
  297. }
  298. function path_update(me) {
  299. var os_template_image_id = $('#os_template_image_id').val();
  300. var path = $('#edit_path').val();
  301. $('#edit_path_modal').modal('hide');
  302. $.ajax({
  303. url : '/api/os_template_image/' + os_template_image_id,
  304. type : 'PATCH',
  305. contentType: "application/json; charset=utf-8",
  306. data : JSON.stringify({
  307. path: path
  308. }),
  309. error : function() {
  310. alter_danger('模板镜像路径更新失败!');
  311. },
  312. success : function() {
  313. alter_success('模板镜像路径更新成功!');
  314. setTimeout(function() {
  315. refresh();
  316. }, 1000);
  317. }
  318. });
  319. }
  320. function update_os_template_image_profile_id(id) {
  321. $.ajax({
  322. url : '/api/os_template_image/' + id,
  323. type : 'PATCH',
  324. contentType: "application/json; charset=utf-8",
  325. data : JSON.stringify({
  326. os_template_profile_id: parseInt($('#update_os_template_profile_id').val())
  327. }),
  328. error : function() {
  329. alter_danger('变更模板系统发行版本指令发送失败!');
  330. },
  331. success : function() {
  332. alter_success('变更模板系统发行版本指令发送成功!');
  333. setTimeout(function() {
  334. refresh();
  335. }, 1000);
  336. }
  337. });
  338. }
  339. function update_logo(id) {
  340. $.ajax({
  341. url : '/api/os_template_image/' + id,
  342. type : 'PATCH',
  343. contentType: "application/json; charset=utf-8",
  344. data : JSON.stringify({
  345. logo: $('#update_logo').val()
  346. }),
  347. error : function() {
  348. alter_danger('变更 LOGO 指令发送失败!');
  349. },
  350. success : function() {
  351. alter_success('变更 LOGO 指令发送成功!');
  352. setTimeout(function() {
  353. refresh();
  354. }, 1000);
  355. }
  356. });
  357. }
  358. function get_selected_element(checked) {
  359. if (checked === null) {
  360. checked = true;
  361. }
  362. if (checked) {
  363. return $('tbody :checked');
  364. } else {
  365. return $('tbody input:not(:checked)');
  366. }
  367. }
  368. function highlight_selected_element() {
  369. var selected_element = get_selected_element(true);
  370. var no_selected_element = get_selected_element(false);
  371. selected_element.each(function(i, e) {
  372. $(e).parent().parent().toggleClass('tr-selected', true);
  373. });
  374. no_selected_element.each(function(i, e) {
  375. $(e).parent().parent().toggleClass('tr-selected', false);
  376. });
  377. }
  378. function shortcut_bar_enable() {
  379. var selected_element = get_selected_element(true);
  380. if (selected_element.length > 0) {
  381. $('.btn-shortcut').toggleClass('disabled', false);
  382. } else {
  383. $('.btn-shortcut').toggleClass('disabled', true);
  384. }
  385. }
  386. function select_item_action() {
  387. highlight_selected_element();
  388. shortcut_bar_enable();
  389. }
  390. function enable(id) {
  391. $.ajax({
  392. url : '/api/os_template_image/' + id,
  393. type : 'PATCH',
  394. contentType: "application/json; charset=utf-8",
  395. data : JSON.stringify({
  396. active: true
  397. }),
  398. error : function() {
  399. alter_danger('启用指令发送失败!');
  400. },
  401. success : function() {
  402. alter_success('启用指令发送成功!');
  403. refresh();
  404. }
  405. });
  406. }
  407. function disable(id) {
  408. $.ajax({
  409. url : '/api/os_template_image/' + id,
  410. type : 'PATCH',
  411. contentType: "application/json; charset=utf-8",
  412. data : JSON.stringify({
  413. active: false
  414. }),
  415. error : function() {
  416. alter_danger('禁用指令发送失败!');
  417. },
  418. success : function() {
  419. alter_success('禁用指令发送成功!');
  420. refresh();
  421. }
  422. });
  423. }
  424. function remove(id) {
  425. $.ajax({
  426. url : '/api/os_templates_image/' + id,
  427. type : 'DELETE',
  428. contentType: "application/json; charset=utf-8",
  429. error : function() {
  430. alter_danger('模板镜像删除指令发送失败!');
  431. },
  432. success : function() {
  433. alter_success('模板镜像删除指令发送成功!');
  434. setTimeout(function() {
  435. refresh();
  436. }, 1000);
  437. }
  438. });
  439. }
  440. function enable_at(me) {
  441. var id = $(me).parent().parent().parent().parent().parent().children()[0].textContent;
  442. enable(id);
  443. }
  444. function disable_at(me) {
  445. var id = $(me).parent().parent().parent().parent().parent().children()[0].textContent;
  446. disable(id);
  447. }
  448. function delete_at(me) {
  449. var id = $('#os_template_image_id').val();
  450. remove(id);
  451. $('#delete_modal').modal('hide');
  452. }
  453. function update_os_template_image_profile_id_at(me) {
  454. var id = $('#os_template_image_id').val();
  455. update_os_template_image_profile_id(id);
  456. $('#update_os_template_image_profile_id_modal').modal('hide');
  457. }
  458. function update_logo_at(me) {
  459. var id = $('#os_template_image_id').val();
  460. update_logo(id);
  461. $('#update_logo_modal').modal('hide');
  462. }
  463. </script>
  464. <div class="panel">
  465. <div class="panel-body">
  466. <ul class="nav nav-tabs mrg25B">
  467. <li class="active"><a href="javascript:;" onclick="select_this(this);" id="public_os_templates_image_label">公共镜像</a></li>
  468. <li><a href="javascript:;" onclick="select_this(this);" id="custom_os_templates_image_label">自定义镜像</a></li>
  469. </ul>
  470. <div id="public_os_templates_image" class="dataTables_wrapper form-inline">
  471. <div class="row" style="padding: 10px 10px 10px 0; width: 100%;">
  472. <div class="col-sm-12" style="padding-right: 0;">
  473. <div id="datatable-row-highlight_filter" class="dataTables_filter" style="display: inline-block;">
  474. <input id="content_search_by_public" type="search" class="form-control" placeholder="模糊搜索..." value="{%- if keyword -%} {{ keyword }} {%- endif -%}" style="margin-left: 0; border-radius: 0;">
  475. </div>
  476. <div class="pull-right">
  477. <button class="btn btn-default" onclick="refresh()" style="border-radius: 0;"><span class="glyph-icon icon-elusive-arrows-cw"></span></button>
  478. <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>
  479. </div>
  480. </div>
  481. </div>
  482. <table id="os_templates_image_list" class="table table-bordered table-hover" cellspacing="0" width="100%" role="grid"
  483. style="width: 100%; margin-bottom: 0; border-bottom-width: 0;">
  484. <thead>
  485. <tr role="row">
  486. <th style="display: none;">ID</th>
  487. <th><input class="all_selector" title="选取所有" type="checkbox"></th>
  488. <th width="180px;">名称</th>
  489. <th>状态</th>
  490. <th width="500px;">路径</th>
  491. <th>发行版本</th>
  492. <th>操作</th>
  493. </tr>
  494. </thead>
  495. <tbody>
  496. {% for item in os_templates_image_ret.data if item.kind == 0 %}
  497. <tr role="row" class="odd" onmouseover="row_onmouseover(this);" onmouseout="row_onmouseout(this);">
  498. <td style="display: none;">{{ item.id }}</td>
  499. <td><input title="选中" type="checkbox"></td>
  500. <td>
  501. <div>
  502. <p style="display: inline-block;">{{ item.label }}</p>
  503. <a href="javascript:;" class="edit_label_trigger" data-toggle="modal" data-target="#edit_label_modal" style="display: none; float: right;">
  504. <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>
  505. </a>
  506. </div>
  507. </td>
  508. <td>{% if item.active == 0 %}
  509. <span style="color: #990000;">未启用</span>
  510. {% else %}
  511. <span style="color: #00BB00;">启用</span>
  512. {% endif %}
  513. </td>
  514. <td>
  515. <div>
  516. <p style="display: inline-block;">{{ item.path }}</p>
  517. <a href="javascript:;" class="edit_path_trigger" data-toggle="modal" data-target="#edit_path_modal" style="display: none; float: right;">
  518. <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>
  519. </a>
  520. </div>
  521. </td>
  522. <td>
  523. <div>
  524. <a href="javascript:;" data-toggle="modal" data-target="#update_logo_modal">
  525. {% if item.logo == "" %}
  526. <span class="{{ os_templates_profile_mapping_by_id[item.os_template_profile_id].icon }}"></span>
  527. {% else %}
  528. <span class="{{ item.logo }}"></span>
  529. {% endif %}
  530. </a>
  531. <p style="display: inline-block;">{{ os_templates_profile_mapping_by_id[item.os_template_profile_id].os_product_name }}</p>
  532. </div>
  533. </td>
  534. <td>
  535. <div class="dropdown inline-block">
  536. <a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown">
  537. 更多
  538. </a>
  539. <ul class="dropdown-menu">
  540. <li class="{% if item.active == true %} disabled {% endif %}" style="{% if item.sequence == 0 %} display: none; {% endif %}">
  541. <a href="javascript:;" onclick="enable_at(this);">
  542. 启用
  543. </a>
  544. </li>
  545. <li class="{% if item.active != true %} disabled {% endif %}" style="{% if item.sequence == 0 %} display: none; {% endif %}">
  546. <a href="javascript:;" onclick="disable_at(this);">
  547. 禁用
  548. </a>
  549. </li>
  550. <li class="divider" style="{% if item.sequence == 0 %} display: none; {% endif %}"></li>
  551. <li>
  552. <a href="javascript:;" data-toggle="modal" data-target="#update_os_template_image_profile_id_modal"
  553. onclick="$('#os_template_image_id').val($(this).parent().parent().parent().parent().parent().children()[0].textContent);
  554. $('#update_os_template_image_profile_id_instance_desc').text($(this).parent().parent().parent().parent().parent().children()[2].textContent)">
  555. 变更发行版本
  556. </a>
  557. </li>
  558. <li class="divider" style="{% if item.sequence == 0 %} display: none; {% endif %}"></li>
  559. <li class="{% if 'guests' in item %} disabled {% endif %}">
  560. <a href="javascript:;" data-toggle="modal" data-target="#delete_modal"
  561. onclick="$('#os_template_image_id').val($(this).parent().parent().parent().parent().parent().children()[0].textContent);
  562. $('#delete_instance_desc').text($(this).parent().parent().parent().parent().parent().children()[2].textContent)">
  563. 删除
  564. </a>
  565. </li>
  566. </ul>
  567. </div>
  568. </td>
  569. </tr>
  570. {% endfor %}
  571. </tbody>
  572. </table>
  573. <table class="table table-bordered" style="border-top-width: 0; z-index: 99; position: sticky; bottom: 0;">
  574. <tfoot>
  575. <tr style="height: 70px;">
  576. <th><input type="checkbox" title="选取所有" class="all_selector"></th>
  577. <th>
  578. <div class="row">
  579. <div class="col-sm-6">
  580. </div>
  581. <div class="col-sm-3" style="font-size: 12px; padding-top: 5px; text-align: right;">
  582. 共有{{ public_count }}条
  583. </div>
  584. <div class="col-sm-3" style="text-align: left;">
  585. </div>
  586. </div>
  587. </th>
  588. </tr>
  589. </tfoot>
  590. </table>
  591. </div>
  592. <div id="custom_os_templates_image" class="dataTables_wrapper form-inline" style="display: none;">
  593. <div class="row" style="padding: 10px 10px 10px 0; width: 100%;">
  594. <div class="col-sm-12" style="padding-right: 0;">
  595. <div id="datatable-row-highlight_filter" class="dataTables_filter" style="display: inline-block;">
  596. <input id="content_search_by_custom" type="search" class="form-control" placeholder="模糊搜索..." value="{%- if keyword -%} {{ keyword }} {%- endif -%}" style="margin-left: 0; border-radius: 0;">
  597. </div>
  598. <div class="pull-right">
  599. <button class="btn btn-default" onclick="refresh()" style="border-radius: 0;"><span class="glyph-icon icon-elusive-arrows-cw"></span></button>
  600. </div>
  601. </div>
  602. </div>
  603. <table id="os_templates_image_list" class="table table-bordered table-hover" cellspacing="0" width="100%" role="grid"
  604. style="width: 100%; margin-bottom: 0; border-bottom-width: 0;">
  605. <thead>
  606. <tr role="row">
  607. <th style="display: none;">ID</th>
  608. <th><input class="all_selector" title="选取所有" type="checkbox"></th>
  609. <th width="220px;">名称</th>
  610. <th>状态</th>
  611. <th>进度</th>
  612. <th>创建时间</th>
  613. <th>发行版本</th>
  614. <th>操作</th>
  615. </tr>
  616. </thead>
  617. <tbody>
  618. {% for item in os_templates_image_ret.data if item.kind == 1 %}
  619. <tr role="row" class="odd" onmouseover="row_onmouseover(this);" onmouseout="row_onmouseout(this);">
  620. <td style="display: none;">{{ item.id }}</td>
  621. <td><input title="选中" type="checkbox"></td>
  622. <td>
  623. <div>
  624. <p style="display: inline-block;">{{ item.label }}</p>
  625. <a href="javascript:;" class="edit_label_trigger" data-toggle="modal" data-target="#edit_label_modal" style="display: none; float: right;">
  626. <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>
  627. </a>
  628. </div>
  629. </td>
  630. <td>{% if item.active == 0 %}
  631. <span style="color: #990000;">未启用</span>
  632. {% else %}
  633. <span style="color: #00BB00;">启用</span>
  634. {% endif %}
  635. </td>
  636. <td>
  637. {% if item.progress == 255 %}
  638. <span style="color: #990000;">创建失败</span>
  639. {% elif item.progress == 254 %}
  640. <span style="color: #ff0000dd;">删除中...</span>
  641. {% elif item.progress == 100 %}
  642. <span style="color: #00BB00;">{{ item.progress }}%</span>
  643. {% else %}
  644. <span style="color: #e5b715;">{{ item.progress }}%</span>
  645. {% endif %}
  646. </td>
  647. <td>{{ format_datetime_by_tus(item.create_time) }}</td>
  648. <td>
  649. <div>
  650. <a href="javascript:;" data-toggle="modal" data-target="#update_logo_modal">
  651. {% if item.logo == "" %}
  652. <span class="{{ os_templates_profile_mapping_by_id[item.os_template_profile_id].icon }}"></span>
  653. {% else %}
  654. <span class="{{ item.logo }}"></span>
  655. {% endif %}
  656. </a>
  657. <p style="display: inline-block;">{{ os_templates_profile_mapping_by_id[item.os_template_profile_id].os_product_name }}</p>
  658. </div>
  659. </td>
  660. <td>
  661. <div class="dropdown inline-block">
  662. <a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown">
  663. 更多
  664. </a>
  665. <ul class="dropdown-menu">
  666. <li class="{% if item.active == true %} disabled {% endif %}" style="{% if item.sequence == 0 %} display: none; {% endif %}">
  667. <a href="javascript:;" onclick="enable_at(this);">
  668. 启用
  669. </a>
  670. </li>
  671. <li class="{% if item.active != true %} disabled {% endif %}" style="{% if item.sequence == 0 %} display: none; {% endif %}">
  672. <a href="javascript:;" onclick="disable_at(this);">
  673. 禁用
  674. </a>
  675. </li>
  676. <li class="divider" style="{% if item.sequence == 0 %} display: none; {% endif %}"></li>
  677. <li>
  678. <a href="javascript:;" data-toggle="modal" data-target="#update_os_template_image_profile_id_modal"
  679. onclick="$('#os_template_image_id').val($(this).parent().parent().parent().parent().parent().children()[0].textContent);
  680. $('#update_os_template_image_profile_id_instance_desc').text($(this).parent().parent().parent().parent().parent().children()[2].textContent)">
  681. 变更发行版本
  682. </a>
  683. </li>
  684. <li class="divider" style="{% if item.sequence == 0 %} display: none; {% endif %}"></li>
  685. <li class="{% if item.progress != 100 or 'guests' in item %} disabled {% endif %}">
  686. <a href="javascript:;" data-toggle="modal" data-target="#delete_modal"
  687. onclick="$('#os_template_image_id').val($(this).parent().parent().parent().parent().parent().children()[0].textContent);
  688. $('#delete_instance_desc').text($(this).parent().parent().parent().parent().parent().children()[2].textContent)">
  689. 删除
  690. </a>
  691. </li>
  692. </ul>
  693. </div>
  694. </td>
  695. </tr>
  696. {% endfor %}
  697. </tbody>
  698. </table>
  699. <table class="table table-bordered" style="border-top-width: 0; z-index: 99; position: sticky; bottom: 0;">
  700. <tfoot>
  701. <tr style="height: 70px;">
  702. <th><input type="checkbox" title="选取所有" class="all_selector"></th>
  703. <th>
  704. <div class="row">
  705. <div class="col-sm-6">
  706. </div>
  707. <div class="col-sm-3" style="font-size: 12px; padding-top: 5px; text-align: right;">
  708. 共有{{ custom_count }}条
  709. </div>
  710. <div class="col-sm-3" style="text-align: left;">
  711. </div>
  712. </div>
  713. </th>
  714. </tr>
  715. </tfoot>
  716. </table>
  717. </div>
  718. </div>
  719. </div>
  720. <input id="os_template_image_id" title="模板 ID" class="form-control" name="os_template_image_id" hidden>
  721. <div class="modal" id="edit_label_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="edit_label" title="系统模板镜像名称" class="form-control" name="os_template_image_label">
  729. </div>
  730. <div class="modal-footer">
  731. <button type="button" class="btn btn-sm btn-primary" onclick="label_update();">确定</button>
  732. <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">取消</button>
  733. </div>
  734. </div>
  735. </div>
  736. </div>
  737. <div class="modal" id="edit_path_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
  738. <div class="modal-dialog">
  739. <div class="modal-content">
  740. <div class="modal-header">
  741. <h4 class="modal-title">编辑模板镜像路径:</h4>
  742. </div>
  743. <div class="modal-body">
  744. <input id="edit_path" title="系统模板镜像路径" class="form-control" name="os_template_image_path">
  745. </div>
  746. <div class="modal-footer">
  747. <button type="button" class="btn btn-sm btn-primary" onclick="path_update();">确定</button>
  748. <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">取消</button>
  749. </div>
  750. </div>
  751. </div>
  752. </div>
  753. <div class="modal" id="delete_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
  754. <div class="modal-dialog">
  755. <div class="modal-content">
  756. <div class="modal-header">
  757. <h4 class="modal-title">删除模板:</h4>
  758. </div>
  759. <div class="modal-body">
  760. <p>您确定要删除该模板镜像吗?</p>
  761. <h3 style="color: orangered;" id="delete_instance_desc"></h3>
  762. </div>
  763. <div class="modal-footer">
  764. <button type="button" class="btn btn-sm btn-primary" onclick="delete_at();">确定</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_os_template_image_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 id="add_os_template_image_form" class="form-horizontal bordered-row" action="/os_template_image" method="post">
  779. <input id="active" name="active" value="1" type="hidden" title="激活" class="form-control">
  780. <div class="form-group">
  781. <div class="col-sm-2"></div>
  782. <label class="col-sm-2 control-label"><span class="glyph-icon icon-elusive-compass-circled"></span>&nbsp;&nbsp;模板镜像名称</label>
  783. <div class="col-sm-6">
  784. <input id="label" name="label" type="text" title="模板镜像名称" class="form-control">
  785. </div>
  786. </div>
  787. <div class="form-group">
  788. <div class="col-sm-2"></div>
  789. <label class="col-sm-2 control-label"><span class="glyph-icon icon-elusive-stumbleupon"></span>&nbsp;&nbsp;模板路径</label>
  790. <div class="col-sm-6">
  791. <input id="path" name="path" type="text" title="模板路径" class="form-control">
  792. </div>
  793. </div>
  794. <div class="form-group">
  795. <div class="col-sm-2"></div>
  796. <label class="col-sm-2 control-label"><span class="glyph-icon icon-child"></span>&nbsp;&nbsp;LOGO</label>
  797. <div class="col-sm-6">
  798. <select id="logo" name="logo" title="请选择 LOGO" class="selectpicker">
  799. <option value="icon-os icon-os-centos" data-icon="icon-os icon-os-centos">CentOS</option>
  800. <option value="icon-os icon-os-linux" data-icon="icon-os icon-os-linux">Linux</option>
  801. <option value="icon-os icon-os-ubuntu" data-icon="icon-os icon-os-ubuntu">Ubuntu</option>
  802. <option value="icon-os icon-os-suse" data-icon="icon-os icon-os-suse">Suse</option>
  803. <option value="icon-os icon-os-gentoo" data-icon="icon-os icon-os-gentoo">Gentoo</option>
  804. <option value="icon-os icon-os-debian" data-icon="icon-os icon-os-debian">Debian</option>
  805. <option value="icon-os icon-os-redhat" data-icon="icon-os icon-os-redhat">Redhat</option>
  806. <option value="icon-os icon-os-bsd" data-icon="icon-os icon-os-bsd">BSD</option>
  807. <option value="icon-os icon-os-windows" data-icon="icon-os icon-os-windows">Windows</option>
  808. </select>
  809. </div>
  810. </div>
  811. <div class="form-group">
  812. <div class="col-sm-2"></div>
  813. <label class="col-sm-2 control-label"><span class="glyph-icon icon-bookmark-o"></span>&nbsp;&nbsp;发行版本</label>
  814. <div class="col-sm-8">
  815. <select id="os_distro" name="os_distro" title="请选择发行版" class="selectpicker" data-width="140px">
  816. </select>
  817. <select id="os_template_profile_id" name="os_template_profile_id" title="请选择版本" class="selectpicker" data-width="237px" disabled>
  818. </select>
  819. </div>
  820. </div>
  821. <div class="form-group">
  822. <div class="col-sm-2"></div>
  823. <label class="col-sm-2 control-label"><span class="glyph-icon icon-newspaper-o"></span>&nbsp;&nbsp;模板镜像描述</label>
  824. <div class="col-sm-6">
  825. <textarea id="description" name="description" title="模板镜像描述" class="form-control"></textarea>
  826. </div>
  827. </div>
  828. <div class="form-group">
  829. <div class="col-sm-4"></div>
  830. <div class="col-sm-6 pull-right">
  831. <button type="submit" class="btn btn-blue-alt" style="width: 180px; height: 40px; font-size: 16px;" disabled>创建</button>
  832. <button class="btn btn-default" style="width: 64px; height: 40px; font-size: 16px;" data-dismiss="modal">取消</button>
  833. </div>
  834. </div>
  835. </form>
  836. </div>
  837. </div>
  838. </div>
  839. </div>
  840. </div>
  841. <div class="modal" id="update_os_template_image_profile_id_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
  842. <div class="modal-dialog modal-lg">
  843. <div class="modal-content">
  844. <div class="modal-header">
  845. <h4 class="modal-title">变更模板系统发行版:</h4>
  846. </div>
  847. <div class="modal-body" style="padding-top: 0;">
  848. <form class="form-horizontal bordered-row">
  849. <div class="form-group">
  850. <div class="col-sm-1"></div>
  851. <label class="col-sm-3 control-label"><span class="glyph-icon icon-elusive-compass-circled"></span>&nbsp;&nbsp;模板镜像名称</label>
  852. <div class="col-sm-8">
  853. <h3 style="color: orangered;" id="update_os_template_image_profile_id_instance_desc"></h3>
  854. </div>
  855. </div>
  856. <div class="form-group">
  857. <div class="col-sm-1"></div>
  858. <label class="col-sm-3 control-label"><span class="glyph-icon icon-bookmark-o"></span>&nbsp;&nbsp;发行版本</label>
  859. <div class="col-sm-8">
  860. <select id="update_os_distro" name="os_distro" title="请选择发行版" class="selectpicker" data-width="140px">
  861. </select>
  862. <select id="update_os_template_profile_id" name="os_template_profile_id" title="请选择版本" class="selectpicker" data-width="237px" disabled>
  863. </select>
  864. </div>
  865. </div>
  866. </form>
  867. </div>
  868. <div class="modal-footer">
  869. <button type="button" class="btn btn-sm btn-primary" onclick="update_os_template_image_profile_id_at();">确定</button>
  870. <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">取消</button>
  871. </div>
  872. </div>
  873. </div>
  874. </div>
  875. <div class="modal" id="update_logo_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
  876. <div class="modal-dialog">
  877. <div class="modal-content">
  878. <div class="modal-header">
  879. <h4 class="modal-title">变更 LOGO:</h4>
  880. </div>
  881. <div class="modal-body" style="padding-top: 0;">
  882. <form class="form-horizontal bordered-row">
  883. <div class="form-group">
  884. <div class="col-sm-1"></div>
  885. <label class="col-sm-3 control-label"><span class="glyph-icon icon-elusive-compass-circled"></span>&nbsp;&nbsp;模板镜像名称</label>
  886. <div class="col-sm-8">
  887. <h3 style="color: orangered;" id="update_logo_instance_desc"></h3>
  888. </div>
  889. </div>
  890. <div class="form-group">
  891. <div class="col-sm-1"></div>
  892. <label class="col-sm-3 control-label"><span class="glyph-icon icon-child"></span>&nbsp;&nbsp;LOGO</label>
  893. <div class="col-sm-8">
  894. <select id="update_logo" name="logo" title="模板 LOGO" class="selectpicker">
  895. <option value="icon-os icon-os-centos" data-icon="icon-os icon-os-centos" selected>CentOS</option>
  896. <option value="icon-os icon-os-linux" data-icon="icon-os icon-os-linux">Linux</option>
  897. <option value="icon-os icon-os-ubuntu" data-icon="icon-os icon-os-ubuntu">Ubuntu</option>
  898. <option value="icon-os icon-os-suse" data-icon="icon-os icon-os-suse">Suse</option>
  899. <option value="icon-os icon-os-gentoo" data-icon="icon-os icon-os-gentoo">Gentoo</option>
  900. <option value="icon-os icon-os-debian" data-icon="icon-os icon-os-debian">Debian</option>
  901. <option value="icon-os icon-os-redhat" data-icon="icon-os icon-os-redhat">Redhat</option>
  902. <option value="icon-os icon-os-bsd" data-icon="icon-os icon-os-bsd">BSD</option>
  903. <option value="icon-os icon-os-windows" data-icon="icon-os icon-os-windows">Windows</option>
  904. </select>
  905. </div>
  906. </div>
  907. </form>
  908. </div>
  909. <div class="modal-footer">
  910. <button type="button" class="btn btn-sm btn-primary" onclick="update_logo_at();">确定</button>
  911. <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">取消</button>
  912. </div>
  913. </div>
  914. </div>
  915. </div>
  916. {% endblock content %}