list.html 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <div class="row">
  2. <div class="col-md-12">
  3. <div class="tile">
  4. <div class="tile-body">
  5. <table class="table table-hover table-bordered" id="sampleTable">
  6. <thead>
  7. <tr>
  8. <th>Id</th>
  9. <th>验证密钥</th>
  10. <th>客户端地址</th>
  11. <th>备注</th>
  12. <th>压缩方式</th>
  13. <th>加密</th>
  14. <th>多路复用</th>
  15. <th>用户名</th>
  16. <th>密码</th>
  17. <th>状态</th>
  18. <th>客户端连接状态</th>
  19. <th>出口流量</th>
  20. <th>入口流量</th>
  21. <th>操作</th>
  22. </tr>
  23. </thead>
  24. <tbody>
  25. </tbody>
  26. </table>
  27. </div>
  28. </div>
  29. </div>
  30. </div>
  31. </main>
  32. <script type="text/javascript">
  33. function del(id) {
  34. if (confirm("确定要删除数据吗?")) {
  35. $.ajax({
  36. type: "POST",
  37. url: "/client/del",
  38. data: {"id": id},
  39. success: function (res) {
  40. alert(res.msg)
  41. if (res.status) {
  42. document.location.reload();
  43. }
  44. }
  45. })
  46. }
  47. }
  48. function start(id) {
  49. if (confirm("确定要开始任务吗?")) {
  50. $.ajax({
  51. type: "POST",
  52. url: "/client/changestatus",
  53. data: {"id": id, "status": 1},
  54. success: function (res) {
  55. alert(res.msg)
  56. if (res.status) {
  57. document.location.reload();
  58. }
  59. }
  60. })
  61. }
  62. }
  63. function stop(id) {
  64. if (confirm("确定要暂停吗?")) {
  65. $.ajax({
  66. type: "POST",
  67. url: "/client/changestatus",
  68. data: {
  69. "id": id, "status": 0
  70. },
  71. success:
  72. function (res) {
  73. alert(res.msg)
  74. if (res.status) {
  75. document.location.reload();
  76. }
  77. }
  78. })
  79. }
  80. }
  81. function edit(id) {
  82. window.location.href = "/client/edit?id=" + id
  83. }
  84. function add() {
  85. window.location.href = "/client/add"
  86. }
  87. function show_tunnel_list(id) {
  88. window.location.href = "/index/all?client_id=" + id
  89. }
  90. function show_host_list(id) {
  91. window.location.href = "/index/hostlist?client_id=" + id
  92. }
  93. $(document)
  94. .ready(function () {
  95. var table = $('#sampleTable').DataTable({
  96. responsive: {
  97. details: {
  98. display: $.fn.dataTable.Responsive.display.childRowImmediate
  99. }
  100. },
  101. dom: 'Bfrtip',
  102. processing: true,
  103. serverSide: true,
  104. autoWidth: false,
  105. ordering: false,
  106. ajax: {
  107. url: '/client/client',
  108. type: 'POST'
  109. },
  110. dom: '<"top"fl><"toolbar">rt<"bottom"ip><"clear">',
  111. columns: [ //这个是显示到界面上的个数据 格式为 {data:'显示的字段名'}
  112. {data: 'Id'},
  113. {data: 'VerifyKey'},
  114. {data: "Addr"},
  115. {data: "Remark"},
  116. {data: "Addr"},
  117. {data: "Addr"},
  118. {data: "Addr"},
  119. {data: "Addr"},
  120. {data: "Remark"},
  121. {data: "Status"},
  122. {data: "IsConnect"},
  123. {data: "Addr"},
  124. {data: "Addr"},
  125. {data: ""},
  126. ],
  127. bFilter: false,
  128. columnDefs: [{
  129. targets: -1,
  130. render: function (data, type, row, meta) {
  131. if (row.Status == true) {
  132. btn = "<button onclick=\"stop('" + row.Id + "')\" class=\"btn btn-secondary btn-sm\" type=\"button\">关闭</button>"
  133. } else {
  134. btn = "<button onclick=\"start('" + row.Id + "')\" class=\"btn btn-success btn-sm\" type=\"button\">打开</button>"
  135. }
  136. btn_del = '<button onclick="del(\'' + row.Id + '\')" class="btn btn-danger btn-sm">删除</button> '
  137. btn_edit = '<button onclick="edit(\'' + row.Id + '\')" class="btn btn-primary btn-sm">查看编辑</button> '
  138. btn_list = '<button onclick="show_tunnel_list(\'' + row.Id + '\')" class="btn btn-info btn-sm">隧道</button> '
  139. btn_host = '<button onclick="show_host_list(\'' + row.Id + '\')" class="btn btn-info btn-sm">域名</button> '
  140. return '<div class="btn-group" role="group" aria-label="..."> ' + btn + btn_del + btn_edit + btn_host + btn_list + '</div>'
  141. }
  142. },
  143. {
  144. targets: -5,
  145. render: function (data, type, row, meta) {
  146. if (data == false) {
  147. return "<span class=\"badge badge-pill badge-secondary\">暂停</span>"
  148. } else {
  149. return "<span class=\"badge badge-pill badge-success\">正常</span>"
  150. }
  151. }
  152. },
  153. {
  154. targets: -4,
  155. render: function (data, type, row, meta) {
  156. if (data == false) {
  157. return "<span class=\"badge badge-pill badge-secondary\">未连接</span>"
  158. } else {
  159. return "<span class=\"badge badge-pill badge-success\">已连接</span>"
  160. }
  161. }
  162. },
  163. {
  164. targets: -2,
  165. render: function (data, type, row, meta) {
  166. return change(row.Flow.InletFlow)
  167. }
  168. },
  169. {
  170. targets: -3,
  171. render: function (data, type, row, meta) {
  172. return change(row.Flow.ExportFlow)
  173. }
  174. },
  175. {
  176. targets: -6,
  177. render: function (data, type, row, meta) {
  178. return row.Cnf.P
  179. }
  180. },
  181. {
  182. targets: -7,
  183. render: function (data, type, row, meta) {
  184. return row.Cnf.U
  185. }
  186. },
  187. {
  188. targets: -8,
  189. render: function (data, type, row, meta) {
  190. if (row.Cnf.Mux == "0") {
  191. return "不启用"
  192. } else {
  193. return "启用"
  194. }
  195. }
  196. }
  197. ,
  198. {
  199. targets: -9,
  200. render: function (data, type, row, meta) {
  201. if (row.Cnf.Crypt == "0") {
  202. return "不加密"
  203. } else {
  204. return "加密"
  205. }
  206. }
  207. }
  208. ,
  209. {
  210. targets: -10,
  211. render: function (data, type, row, meta) {
  212. return row.Cnf.Compress
  213. }
  214. }
  215. ],
  216. buttons: []
  217. });
  218. $("#sampleTable_length").html('<button class="btn btn-primary" onclick="add()" type="button">新增</button>')
  219. })
  220. ;
  221. </script>