list.html 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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>{{.name}}</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/add?type={{.type}}&client_id={{.client_id}}" class="btn btn-primary dim"
  20. type="button">new</a>
  21. </div>
  22. <table id="taskList_table" class="table-striped table-hover"
  23. data-mobile-responsive="true"></table>
  24. </div>
  25. </div>
  26. <div class="ibox-content">
  27. <table id="table"></table>
  28. </div>
  29. </div>
  30. </div>
  31. </div>
  32. </div>
  33. <script>
  34. /*bootstrap table*/
  35. $('#table').bootstrapTable({
  36. toolbar: "#toolbar",
  37. method: 'post', // 服务器数据的请求方式 get or post
  38. url: "/index/gettunnel", // 服务器数据的加载地址
  39. queryParams: function (params) {
  40. return {
  41. "offset": params.offset,
  42. "limit": params.limit,
  43. "type":{{.type}},
  44. "client_id":{{.client_id}},
  45. }
  46. },
  47. contentType: "application/x-www-form-urlencoded",
  48. striped: true, // 设置为true会有隔行变色效果
  49. showHeader: true,
  50. showColumns: true,
  51. showRefresh: true,
  52. pagination: true,//分页
  53. sidePagination: 'server',//服务器端分页
  54. pageNumber: 1,
  55. pageList: [5, 10, 20, 50],//分页步进值
  56. detailView: true,
  57. smartDisplay: true, // 智能显示 pagination 和 cardview 等
  58. detailFormatter: function (index, row, element) {
  59. return '<b>export flow: </b>' + change(row.Flow.ExportFlow) + `&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp`
  60. + '<b>inlet flow: </b>' + change(row.Flow.InletFlow) + `&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp` + "<br/><br>"
  61. + '<b>crypt: </b>' + row.Client.Cnf.Crypt + `&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp`
  62. + '<b>compress: </b>' + row.Client.Cnf.Compress + `&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp`
  63. + '<b>username: </b>' + row.Client.Cnf.U + `&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp`
  64. + '<b>password: </b>' + row.Client.Cnf.P + `&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: 'Mode',//域值
  91. title: 'mode',//标题
  92. visible: true,//false表示不显示
  93. sortable: true,//启用排序
  94. },
  95. {
  96. field: 'Port',//域值
  97. title: 'port',//标题
  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: 'Password',//域值
  109. title: 'secret',//标题
  110. visible: true,//false表示不显示
  111. sortable: true,//启用排序
  112. },
  113. {
  114. field: 'Status',//域值
  115. title: 'setting',//内容
  116. visible: true,//false表示不显示
  117. sortable: true,//启用排序
  118. formatter: function (value, row, index) {
  119. if (value) {
  120. return '<span class="badge badge-primary">open</span>'
  121. } else {
  122. return '<span class="badge badge-badge">close</span>'
  123. }
  124. }
  125. },
  126. {
  127. field: 'RunStatus',//域值
  128. title: 'run',//内容
  129. visible: true,//false表示不显示
  130. sortable: true,//启用排序
  131. formatter: function (value, row, index) {
  132. if (value) {
  133. return '<span class="badge badge-primary">open</span>'
  134. } else {
  135. return '<span class="badge badge-badge">close</span>'
  136. }
  137. }
  138. },
  139. {
  140. field: '',//域值
  141. title: 'client',//内容
  142. visible: true,//false表示不显示
  143. sortable: true,//启用排序
  144. formatter: function (value, row, index) {
  145. if (row.Client.IsConnect) {
  146. return '<span class="badge badge-primary">online</span>'
  147. } else {
  148. return '<span class="badge badge-badge">offline</span>'
  149. }
  150. }
  151. },
  152. {
  153. field: 'option',//域值
  154. title: 'option',//内容
  155. visible: true,//false表示不显示
  156. sortable: true,//启用排序
  157. formatter: function (value, row, index) {
  158. btn_group = '<div class="btn-group">'
  159. 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>`
  160. if (row.Status) {
  161. return btn_group + `<button onclick="stop(` + row.Id + `)" class="btn-dark"><i class="fa fa-close"></i></button>` + btn
  162. } else {
  163. return btn_group + `<button onclick="start(` + row.Id + `)" class="btn-outline-primary"><i class="fa fa-check"></i></button>` + btn
  164. }
  165. }
  166. }
  167. ]
  168. });
  169. </script>
  170. <script type="text/javascript">
  171. function del(id) {
  172. if (confirm("Are you sure you want to delete it??")) {
  173. $.ajax({
  174. type: "POST",
  175. url: "/index/del",
  176. data: {"id": id},
  177. success: function (res) {
  178. alert(res.msg)
  179. if (res.status) {
  180. document.location.reload();
  181. }
  182. }
  183. })
  184. }
  185. }
  186. function start(id) {
  187. if (confirm("Are you sure you want to start it??")) {
  188. $.ajax({
  189. type: "POST",
  190. url: "/index/start",
  191. data: {"id": id},
  192. success: function (res) {
  193. alert(res.msg)
  194. if (res.status) {
  195. document.location.reload();
  196. }
  197. }
  198. })
  199. }
  200. }
  201. function stop(id) {
  202. if (confirm("Are you sure you want to stop it??")) {
  203. $.ajax({
  204. type: "POST",
  205. url: "/index/stop",
  206. data: {"id": id},
  207. success: function (res) {
  208. alert(res.msg)
  209. if (res.status) {
  210. document.location.reload();
  211. }
  212. }
  213. })
  214. }
  215. }
  216. function edit(id) {
  217. window.location.href = "/index/edit?id=" + id
  218. }
  219. </script>