os_templates_image_show.html 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029
  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-coreos" data-icon="icon-os icon-os-coreos">CoreOS</option>
  840. <option value="icon-os icon-os-windows" data-icon="icon-os icon-os-windows">Windows</option>
  841. </select>
  842. </div>
  843. </div>
  844. <div class="form-group">
  845. <div class="col-sm-2"></div>
  846. <label class="col-sm-2 control-label"><span class="glyph-icon icon-bookmark-o"></span>&nbsp;&nbsp;发行版本</label>
  847. <div class="col-sm-8">
  848. <select id="os_distro" name="os_distro" title="请选择发行版" class="selectpicker" data-width="140px">
  849. </select>
  850. <select id="os_template_profile_id" name="os_template_profile_id" title="请选择版本" class="selectpicker" data-width="237px" disabled>
  851. </select>
  852. </div>
  853. </div>
  854. <div class="form-group">
  855. <div class="col-sm-2"></div>
  856. <label class="col-sm-2 control-label"><span class="glyph-icon icon-newspaper-o"></span>&nbsp;&nbsp;模板镜像描述</label>
  857. <div class="col-sm-6">
  858. <textarea id="description" name="description" title="模板镜像描述" class="form-control"></textarea>
  859. </div>
  860. </div>
  861. <div class="form-group">
  862. <div class="col-sm-4"></div>
  863. <div class="col-sm-6 pull-right">
  864. <button type="submit" class="btn btn-blue-alt" style="width: 180px; height: 40px; font-size: 16px;" disabled>创建</button>
  865. <button class="btn btn-default" style="width: 64px; height: 40px; font-size: 16px;" data-dismiss="modal">取消</button>
  866. </div>
  867. </div>
  868. </form>
  869. </div>
  870. </div>
  871. </div>
  872. </div>
  873. </div>
  874. <div class="modal" id="update_os_template_image_profile_id_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
  875. <div class="modal-dialog modal-lg">
  876. <div class="modal-content">
  877. <div class="modal-header">
  878. <h4 class="modal-title">变更模板系统发行版:</h4>
  879. </div>
  880. <div class="modal-body" style="padding-top: 0;">
  881. <form class="form-horizontal bordered-row">
  882. <div class="form-group">
  883. <div class="col-sm-1"></div>
  884. <label class="col-sm-3 control-label"><span class="glyph-icon icon-elusive-compass-circled"></span>&nbsp;&nbsp;模板镜像名称</label>
  885. <div class="col-sm-8">
  886. <h3 style="color: orangered;" id="update_os_template_image_profile_id_instance_desc"></h3>
  887. </div>
  888. </div>
  889. <div class="form-group">
  890. <div class="col-sm-1"></div>
  891. <label class="col-sm-3 control-label"><span class="glyph-icon icon-bookmark-o"></span>&nbsp;&nbsp;发行版本</label>
  892. <div class="col-sm-8">
  893. <select id="update_os_distro" name="os_distro" title="请选择发行版" class="selectpicker" data-width="140px">
  894. </select>
  895. <select id="update_os_template_profile_id" name="os_template_profile_id" title="请选择版本" class="selectpicker" data-width="237px" disabled>
  896. </select>
  897. </div>
  898. </div>
  899. </form>
  900. </div>
  901. <div class="modal-footer">
  902. <button type="button" class="btn btn-sm btn-primary" onclick="update_os_template_image_profile_id_at();">确定</button>
  903. <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">取消</button>
  904. </div>
  905. </div>
  906. </div>
  907. </div>
  908. <div class="modal" id="update_logo_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
  909. <div class="modal-dialog">
  910. <div class="modal-content">
  911. <div class="modal-header">
  912. <h4 class="modal-title">变更 LOGO:</h4>
  913. </div>
  914. <div class="modal-body" style="padding-top: 0;">
  915. <form class="form-horizontal bordered-row">
  916. <div class="form-group">
  917. <div class="col-sm-1"></div>
  918. <label class="col-sm-3 control-label"><span class="glyph-icon icon-elusive-compass-circled"></span>&nbsp;&nbsp;模板镜像名称</label>
  919. <div class="col-sm-8">
  920. <h3 style="color: orangered;" id="update_logo_instance_desc"></h3>
  921. </div>
  922. </div>
  923. <div class="form-group">
  924. <div class="col-sm-1"></div>
  925. <label class="col-sm-3 control-label"><span class="glyph-icon icon-child"></span>&nbsp;&nbsp;LOGO</label>
  926. <div class="col-sm-8">
  927. <select id="update_logo" name="logo" title="模板 LOGO" class="selectpicker">
  928. <option value="icon-os icon-os-centos" data-icon="icon-os icon-os-centos" selected>CentOS</option>
  929. <option value="icon-os icon-os-linux" data-icon="icon-os icon-os-linux">Linux</option>
  930. <option value="icon-os icon-os-ubuntu" data-icon="icon-os icon-os-ubuntu">Ubuntu</option>
  931. <option value="icon-os icon-os-suse" data-icon="icon-os icon-os-suse">Suse</option>
  932. <option value="icon-os icon-os-gentoo" data-icon="icon-os icon-os-gentoo">Gentoo</option>
  933. <option value="icon-os icon-os-debian" data-icon="icon-os icon-os-debian">Debian</option>
  934. <option value="icon-os icon-os-redhat" data-icon="icon-os icon-os-redhat">Redhat</option>
  935. <option value="icon-os icon-os-bsd" data-icon="icon-os icon-os-bsd">BSD</option>
  936. <option value="icon-os icon-os-coreos" data-icon="icon-os icon-os-coreos">CoreOS</option>
  937. <option value="icon-os icon-os-windows" data-icon="icon-os icon-os-windows">Windows</option>
  938. </select>
  939. </div>
  940. </div>
  941. </form>
  942. </div>
  943. <div class="modal-footer">
  944. <button type="button" class="btn btn-sm btn-primary" onclick="update_logo_at();">确定</button>
  945. <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">取消</button>
  946. </div>
  947. </div>
  948. </div>
  949. </div>
  950. {% endblock content %}