os_templates_image_show.html 48 KB

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