boot_job_show.html 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  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. </style>
  47. {% endblock head %}
  48. {% block content %}
  49. <script type="text/javascript">
  50. var page = 1;
  51. var page_size = 10;
  52. var keyword = '';
  53. var resource_path = window.location.pathname;
  54. var cur_url = resource_path;
  55. $(document).ready(function() {
  56. page_size = $('#page_size').val();
  57. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size;
  58. var last_ready = null;
  59. $('#content_search').keydown(function() {
  60. if (last_ready !== null) {
  61. clearTimeout(last_ready);
  62. }
  63. last_ready = setTimeout(function () {
  64. keyword = $('#content_search').val();
  65. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size;
  66. if (keyword.length > 0) {
  67. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size + '&keyword=' + keyword;
  68. }
  69. window.location.href=cur_url;
  70. }, 1000);
  71. });
  72. $('#page_size').change(function () {
  73. keyword = $('#content_search').val();
  74. page_size = $('#page_size').val();
  75. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size;
  76. if (keyword.length > 0) {
  77. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size + '&keyword=' + keyword;
  78. }
  79. window.location.href=cur_url;
  80. });
  81. $('#edit_name_modal').on('show.bs.modal', function (me) {
  82. $('#boot_job_id').val($(me.relatedTarget).parent().parent().prev().text());
  83. $('#edit_name').val($(me.relatedTarget).prev().text());
  84. });
  85. $('#edit_remark_modal').on('show.bs.modal', function (me) {
  86. $('#boot_job_id').val($(me.relatedTarget).parent().parent().prev().prev().prev().text());
  87. $('#edit_remark').val($(me.relatedTarget).prev().text());
  88. });
  89. $('#add_boot_job_modal').on('show.bs.modal', function (me) {
  90. });
  91. $('#update_use_for_modal').on('show.bs.modal', function (me) {
  92. $('#boot_job_id').val($(me.relatedTarget).parent().prev().prev().text());
  93. $('#update_use_for_instance_desc').text($(me.relatedTarget).parent().prev().text());
  94. });
  95. });
  96. function refresh() {
  97. keyword = $('#content_search').val();
  98. page = $('#pagination li.active a').text();
  99. page_size = $('#page_size').val();
  100. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size;
  101. if (keyword.length > 0) {
  102. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size + '&keyword=' + keyword;
  103. }
  104. window.location.href=cur_url;
  105. }
  106. function row_onmouseover(me) {
  107. $(me).find(".edit_name_trigger, .edit_remark_trigger").css('display','inline-flex');
  108. }
  109. function row_onmouseout(me) {
  110. $(me).find(".edit_name_trigger, .edit_remark_trigger").css('display','none');
  111. }
  112. function name_update(me) {
  113. var boot_job_id = $('#boot_job_id').val();
  114. var name = $('#edit_name').val();
  115. $('#edit_name_modal').modal('hide');
  116. $.ajax({
  117. url : '/api/boot_job/' + boot_job_id,
  118. type : 'PATCH',
  119. contentType: "application/json; charset=utf-8",
  120. data : JSON.stringify({
  121. name: name
  122. }),
  123. error : function() {
  124. alter_danger('启动作业名称更新失败!');
  125. },
  126. success : function() {
  127. alter_success('启动作业名称更新成功!');
  128. refresh()
  129. }
  130. });
  131. }
  132. function remark_update(me) {
  133. var boot_job_id = $('#boot_job_id').val();
  134. var remark = $('#edit_remark').val();
  135. $('#edit_remark_modal').modal('hide');
  136. $.ajax({
  137. url : '/api/boot_job/' + boot_job_id,
  138. type : 'PATCH',
  139. contentType: "application/json; charset=utf-8",
  140. data : JSON.stringify({
  141. remark: remark
  142. }),
  143. error : function() {
  144. alter_danger('启动作业备注更新失败!');
  145. },
  146. success : function() {
  147. alter_success('启动作业备注路径更新成功!');
  148. refresh()
  149. }
  150. });
  151. }
  152. function update_use_for(id) {
  153. $.ajax({
  154. url : '/api/boot_job/' + id,
  155. type : 'PATCH',
  156. contentType: "application/json; charset=utf-8",
  157. data : JSON.stringify({
  158. use_for: parseInt($('#update_use_for').val())
  159. }),
  160. error : function() {
  161. alter_danger('变更启动作业作用域指令发送失败!');
  162. },
  163. success : function() {
  164. alter_success('变更启动作业作用域指令发送成功!');
  165. refresh();
  166. }
  167. });
  168. }
  169. function remove(id) {
  170. $.ajax({
  171. url : '/api/boot_jobs/' + id,
  172. type : 'DELETE',
  173. contentType: "application/json; charset=utf-8",
  174. error : function() {
  175. alter_danger('启动作业删除指令发送失败!');
  176. },
  177. success : function() {
  178. alter_success('启动作业删除指令发送成功!');
  179. refresh();
  180. }
  181. });
  182. }
  183. function delete_at(me) {
  184. var id = $('#boot_job_id').val();
  185. remove(id);
  186. $('#delete_modal').modal('hide');
  187. }
  188. function update_use_for_at(me) {
  189. var id = $('#boot_job_id').val();
  190. update_use_for(id);
  191. $('#update_use_for_modal').modal('hide');
  192. }
  193. </script>
  194. <div class="panel">
  195. <div class="panel-body">
  196. <h3 class="title-hero" style="font-size: 24px;">
  197. 启动作业
  198. </h3>
  199. <div>
  200. <div id="datatable-row-highlight_wrapper" class="dataTables_wrapper form-inline">
  201. <div class="row" style="padding: 10px 10px 10px 0; width: 100%;">
  202. <div class="col-sm-12" style="padding-right: 0;">
  203. <div id="datatable-row-highlight_filter" class="dataTables_filter" style="display: inline-block;">
  204. <input id="content_search" type="search" class="form-control" placeholder="模糊搜索..." value="{%- if keyword -%} {{ keyword }} {%- endif -%}" style="margin-left: 0; border-radius: 0;">
  205. </div>
  206. <div class="pull-right">
  207. <button class="btn btn-default" onclick="refresh()" style="border-radius: 0;"><span class="glyph-icon icon-elusive-arrows-cw"></span></button>
  208. <a class="btn btn-info" href="javascript:;" data-toggle="modal" data-target="#add_boot_job_modal" style="border-radius: 0; padding-left: 40px; padding-right: 40px;">添加启动作业</a>
  209. </div>
  210. </div>
  211. </div>
  212. <table id="boot_job_list" class="table table-bordered table-hover" cellspacing="0" width="100%" role="grid"
  213. style="width: 100%; margin-bottom: 0; border-bottom-width: 0;">
  214. <thead>
  215. <tr role="row">
  216. <th style="display: none;">ID</th>
  217. <th width="280px;">名称</th>
  218. <th>作用域</th>
  219. <th width="600px;">备注</th>
  220. <th>操作</th>
  221. </tr>
  222. </thead>
  223. <tbody>
  224. {% for item in boot_jobs_ret.data %}
  225. <tr role="row" class="odd" onmouseover="row_onmouseover(this);" onmouseout="row_onmouseout(this);">
  226. <td style="display: none;">{{ item.id }}</td>
  227. <td>
  228. <div>
  229. <p style="display: inline-block;">{{ item.name }}</p>
  230. <a href="javascript:;" class="edit_name_trigger" data-toggle="modal" data-target="#edit_name_modal" style="display: none; float: right;">
  231. <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>
  232. </a>
  233. </div>
  234. </td>
  235. <td>
  236. <a href="javascript:;" data-toggle="modal" data-target="#update_use_for_modal">
  237. {% if item.use_for == 0 %}
  238. <span style="color: #8800FF;">模板</span>
  239. {% elif item.use_for == 1 %}
  240. <span style="color: #3333FF;">系统</span>
  241. {% elif item.use_for == 2 %}
  242. <span style="color: #00BB00;">用户</span>
  243. {% else %}
  244. <span style="color: #990000;">未知</span>
  245. {% endif %}
  246. </a>
  247. </td>
  248. <td>
  249. <div>
  250. <p style="display: inline-block;">{{ item.remark }}</p>
  251. <a href="javascript:;" class="edit_remark_trigger" data-toggle="modal" data-target="#edit_remark_modal" style="display: none; float: right;">
  252. <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>
  253. </a>
  254. </div>
  255. </td>
  256. <td>
  257. <div class="dropdown inline-block">
  258. <a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown">
  259. 更多
  260. </a>
  261. <ul class="dropdown-menu">
  262. <li>
  263. <a href="javascript:;" data-toggle="modal" data-target="#delete_modal"
  264. onclick="$('#boot_job_id').val($(this).parent().parent().parent().parent().parent().children()[0].textContent);
  265. $('#delete_instance_desc').text($(this).parent().parent().parent().parent().parent().children()[1].textContent)">
  266. 删除
  267. </a>
  268. </li>
  269. </ul>
  270. </div>
  271. </td>
  272. </tr>
  273. {% endfor %}
  274. </tbody>
  275. </table>
  276. <table class="table table-bordered" style="border-top-width: 0; z-index: 99; position: sticky; bottom: 0;">
  277. <tfoot>
  278. <tr style="height: 70px;">
  279. <th>
  280. <div class="row">
  281. <div class="col-sm-6">
  282. </div>
  283. <div class="col-sm-3" style="font-size: 12px; padding-top: 5px; text-align: right;">
  284. 共有{{ boot_jobs_ret.paging.total }}条,每页显示:
  285. <select id="page_size" name="datatable-row-highlight_length" title="page_size" class="form-control" style="height: 22px; vertical-align: baseline;">
  286. <option value="10" {% if page_size == 10 %} selected {% endif %}>10</option>
  287. <option value="20" {% if page_size == 20 %} selected {% endif %}>20</option>
  288. <option value="50" {% if page_size == 50 %} selected {% endif %}>50</option>
  289. </select>&nbsp;&nbsp;条
  290. </div>
  291. <div class="col-sm-3" style="text-align: left;">
  292. <div class="dataTables_paginate paging_bootstrap" id="datatable-row-highlight_paginate">
  293. <ul id="pagination" class="pagination">
  294. <li class="{% if page == 1 %} disabled {% endif %}">
  295. <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>
  296. </li>
  297. {% for item in pages %}
  298. <li class="{% if item == page %} active {% endif %}">
  299. <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>
  300. </li>
  301. {% endfor %}
  302. <li class="{% if page == last_page %} disabled {% endif %}">
  303. <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>
  304. </li>
  305. </ul>
  306. </div>
  307. </div>
  308. </div>
  309. </th>
  310. </tr>
  311. </tfoot>
  312. </table>
  313. </div>
  314. </div>
  315. </div>
  316. </div>
  317. <input id="boot_job_id" title="启动作业 ID" class="form-control" name="boot_job_id" hidden>
  318. <div class="modal" id="edit_name_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
  319. <div class="modal-dialog modal-sm">
  320. <div class="modal-content">
  321. <div class="modal-header">
  322. <h4 class="modal-title">编辑启动作业名称:</h4>
  323. </div>
  324. <div class="modal-body">
  325. <input id="edit_name" title="启动作业名称" class="form-control" name="boot_job_name">
  326. </div>
  327. <div class="modal-footer">
  328. <button type="button" class="btn btn-sm btn-primary" onclick="name_update();">确定</button>
  329. <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">取消</button>
  330. </div>
  331. </div>
  332. </div>
  333. </div>
  334. <div class="modal" id="edit_remark_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
  335. <div class="modal-dialog">
  336. <div class="modal-content">
  337. <div class="modal-header">
  338. <h4 class="modal-title">编辑模板路径:</h4>
  339. </div>
  340. <div class="modal-body">
  341. <input id="edit_remark" title="启动作业备注" class="form-control" name="boot_job_remark">
  342. </div>
  343. <div class="modal-footer">
  344. <button type="button" class="btn btn-sm btn-primary" onclick="remark_update();">确定</button>
  345. <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">取消</button>
  346. </div>
  347. </div>
  348. </div>
  349. </div>
  350. <div class="modal" id="delete_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
  351. <div class="modal-dialog">
  352. <div class="modal-content">
  353. <div class="modal-header">
  354. <h4 class="modal-title">删除启动作业:</h4>
  355. </div>
  356. <div class="modal-body">
  357. <p>你确定要删除该启动作业吗?</p>
  358. <h3 style="color: orangered;" id="delete_instance_desc"></h3>
  359. </div>
  360. <div class="modal-footer">
  361. <button type="button" class="btn btn-sm btn-primary" onclick="delete_at();">确定</button>
  362. <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">取消</button>
  363. </div>
  364. </div>
  365. </div>
  366. </div>
  367. <div class="modal" id="add_boot_job_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
  368. <div class="modal-dialog modal-lg">
  369. <div class="modal-content">
  370. <div class="modal-header">
  371. <h4 class="modal-title">添加启动作业:</h4>
  372. </div>
  373. <div class="modal-body" style="padding-top: 0; padding-bottom: 0;">
  374. <div class="example-box-wrapper">
  375. <form class="form-horizontal bordered-row" action="/boot_job" method="post">
  376. <div class="form-group">
  377. <div class="col-sm-2"></div>
  378. <label class="col-sm-2 control-label"><span class="glyph-icon icon-elusive-compass-circled"></span>&nbsp;&nbsp;启动作业名称</label>
  379. <div class="col-sm-6">
  380. <input id="name" name="name" type="text" title="启动作业名称" class="form-control">
  381. </div>
  382. </div>
  383. <div class="form-group">
  384. <div class="col-sm-2"></div>
  385. <label class="col-sm-2 control-label"><span class="glyph-icon icon-pie-chart"></span>&nbsp;&nbsp;作用域</label>
  386. <div class="col-sm-6">
  387. <select id="use_for" name="use_for" title="作用域" class="selectpicker">
  388. <option value="0" data-subtext="从模板克隆的虚拟机,首次启动时初始化系统使用" selected>模板</option>
  389. <option value="1" data-subtext="JimV系统平台内置的功能,如重置系统密码,更换IP等操作">系统</option>
  390. <option value="2" data-subtext="通过重启系统,批量执行用户预定的操作">用户</option>
  391. </select>
  392. </div>
  393. </div>
  394. <div class="form-group">
  395. <div class="col-sm-2"></div>
  396. <label class="col-sm-2 control-label"><span class="glyph-icon icon-newspaper-o"></span>&nbsp;&nbsp;备注</label>
  397. <div class="col-sm-6">
  398. <input id="remark" name="remark" type="text" title="备注" class="form-control">
  399. </div>
  400. </div>
  401. <div class="form-group">
  402. <div class="col-sm-4"></div>
  403. <div class="col-sm-6 pull-right">
  404. <button class="btn btn-blue-alt" style="width: 180px; height: 40px; font-size: 16px;">创建</button>
  405. <button class="btn btn-default" style="width: 64px; height: 40px; font-size: 16px;" data-dismiss="modal">取消</button>
  406. </div>
  407. </div>
  408. </form>
  409. </div>
  410. </div>
  411. </div>
  412. </div>
  413. </div>
  414. <div class="modal" id="update_use_for_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
  415. <div class="modal-dialog">
  416. <div class="modal-content">
  417. <div class="modal-header">
  418. <h4 class="modal-title">变更作用域:</h4>
  419. </div>
  420. <div class="modal-body" style="padding-top: 0;">
  421. <form class="form-horizontal bordered-row">
  422. <div class="form-group">
  423. <div class="col-sm-1"></div>
  424. <label class="col-sm-3 control-label"><span class="glyph-icon icon-elusive-compass-circled"></span>&nbsp;&nbsp;启动作业名称</label>
  425. <div class="col-sm-8">
  426. <h3 style="color: orangered;" id="update_use_for_instance_desc"></h3>
  427. </div>
  428. </div>
  429. <div class="form-group">
  430. <div class="col-sm-1"></div>
  431. <label class="col-sm-3 control-label"><span class="glyph-icon icon-pie-chart"></span>&nbsp;&nbsp;作用域</label>
  432. <div class="col-sm-8">
  433. <select id="update_use_for" name="use_for" title="作用域" class="selectpicker">
  434. <option value="0" data-subtext="从模板克隆的虚拟机,首次启动时初始化系统使用" selected>模板</option>
  435. <option value="1" data-subtext="JimV系统平台内置的功能,如重置系统密码,更换IP等操作">系统</option>
  436. <option value="2" data-subtext="通过重启系统,批量执行用户预定的操作">用户</option>
  437. </select>
  438. </div>
  439. </div>
  440. </form>
  441. </div>
  442. <div class="modal-footer">
  443. <button type="button" class="btn btn-sm btn-primary" onclick="update_use_for_at();">确定</button>
  444. <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">取消</button>
  445. </div>
  446. </div>
  447. </div>
  448. </div>
  449. {% endblock content %}