os_templates_image_show.html 50 KB

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