hlist.html 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <div class="wrapper wrapper-content animated fadeInRight">
  2. <div class="row">
  3. <div class="col-lg-12">
  4. <div class="ibox float-e-margins">
  5. <div class="ibox-title">
  6. <h5>host list</h5>
  7. <div class="ibox-tools">
  8. <a class="collapse-link">
  9. <i class="fa fa-chevron-up"></i>
  10. </a>
  11. <a class="close-link">
  12. <i class="fa fa-times"></i>
  13. </a>
  14. </div>
  15. </div>
  16. <div class="content">
  17. <div class="table-responsive">
  18. <div id="toolbar">
  19. <a href="/index/addhost?vkey={{.task_id}}&client_id={{.client_id}}"
  20. class="btn btn-primary dim"
  21. type="button">new</a>
  22. </div>
  23. <table id="taskList_table" class="table-striped table-hover"
  24. data-mobile-responsive="true"></table>
  25. </div>
  26. </div>
  27. <div class="ibox-content">
  28. <table id="table"></table>
  29. </div>
  30. </div>
  31. </div>
  32. </div>
  33. </div>
  34. <script>
  35. /*bootstrap table*/
  36. $('#table').bootstrapTable({
  37. toolbar: "#toolbar",
  38. method: 'post', // 服务器数据的请求方式 get or post
  39. url: window.location, // 服务器数据的加载地址
  40. queryParams: function (params) {
  41. return {
  42. "offset": params.offset,
  43. "limit": params.limit,
  44. }
  45. },
  46. contentType: "application/x-www-form-urlencoded",
  47. striped: true, // 设置为true会有隔行变色效果
  48. showHeader: true,
  49. showColumns: true,
  50. showRefresh: true,
  51. pagination: true,//分页
  52. sidePagination: 'server',//服务器端分页
  53. pageNumber: 1,
  54. pageList: [5, 10, 20, 50],//分页步进值
  55. detailView: true,
  56. smartDisplay: true, // 智能显示 pagination 和 cardview 等
  57. detailFormatter: function (index, row, element) {
  58. return '<b>export flow: </b>' + change(row.Flow.ExportFlow) + `&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp`
  59. + '<b>inlet flow: </b>' + change(row.Flow.InletFlow) + `&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp`
  60. + '<b>crypt: </b>' + row.Client.Cnf.Crypt + `&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp`
  61. + '<b>compress: </b>' + row.Client.Cnf.Compress + `&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp` + "<br/><br>"
  62. + '<b>username: </b>' + row.Client.Cnf.U + `&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp`
  63. + '<b>password: </b>' + row.Client.Cnf.P + `&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp` + "<br/><br>"
  64. + '<b>header_change: </b>' + row.HeaderChange + `&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp`
  65. },
  66. //表格的列
  67. columns: [
  68. {
  69. field: 'Id',//域值
  70. title: 'id',//标题
  71. visible: true,//false表示不显示
  72. sortable: true,//启用排序
  73. },
  74. {
  75. field: 'Id',//域值
  76. title: 'client id',//标题
  77. visible: true,//false表示不显示
  78. sortable: true,//启用排序
  79. formatter: function (value, row, index) {
  80. return row.Client.Id
  81. }
  82. },
  83. {
  84. field: 'Remark',//域值
  85. title: 'remark',//标题
  86. visible: true,//false表示不显示
  87. sortable: true,//启用排序
  88. },
  89. {
  90. field: 'Host',//域值
  91. title: 'host',//标题
  92. visible: true,//false表示不显示
  93. sortable: true,//启用排序
  94. },
  95. {
  96. field: 'Scheme',//域值
  97. title: 'scheme',//标题
  98. visible: true,//false表示不显示
  99. sortable: true,//启用排序
  100. },
  101. {
  102. field: 'Target',//域值
  103. title: 'target',//标题
  104. visible: true,//false表示不显示
  105. sortable: true,//启用排序
  106. },
  107. {
  108. field: 'Location',//域值
  109. title: 'location',//标题
  110. visible: true,//false表示不显示
  111. sortable: true,//启用排序
  112. },
  113. {
  114. field: '',//域值
  115. title: 'client status',//内容
  116. visible: true,//false表示不显示
  117. sortable: true,//启用排序
  118. formatter: function (value, row, index) {
  119. if (row.Client.IsConnect) {
  120. return '<span class="badge badge-primary">online</span>'
  121. } else {
  122. return '<span class="badge badge-badge">offline</span>'
  123. }
  124. }
  125. },
  126. {
  127. field: 'option',//域值
  128. title: 'option',//内容
  129. visible: true,//false表示不显示
  130. sortable: true,//启用排序
  131. formatter: function (value, row, index) {
  132. btn_group = '<div class="btn-group">'
  133. btn = `<button onclick="del(` + row.Id + `)" class="btn-danger"><i class="fa fa-trash"></i></button><button onclick="edit(` + row.Id + `)" class="btn-primary"><i class="fa fa-edit"></i></button></div>`
  134. return btn_group + btn
  135. }
  136. }
  137. ]
  138. });
  139. </script>
  140. <script type="text/javascript">
  141. function del(id) {
  142. if (confirm("Are you sure you want to delete it??")) {
  143. $.ajax({
  144. type: "POST",
  145. url: "/index/delhost",
  146. data: {"id": id},
  147. success: function (res) {
  148. alert(res.msg)
  149. if (res.status) {
  150. document.location.reload();
  151. }
  152. }
  153. })
  154. }
  155. }
  156. function edit(id) {
  157. window.location.href = "/index/edithost?id=" + id
  158. }
  159. </script>