list.html 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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>模式</th>*/}}
  9. <th>监听端口</th>
  10. <th>内网目标</th>
  11. <th>多客户端模式客户端执行命令</th>
  12. <th>压缩方式</th>
  13. <th>加密传输</th>
  14. <th>TCP多路复用</th>
  15. <th>用户名</th>
  16. <th>密码</th>
  17. <th>客户端状态</th>
  18. <th>状态</th>
  19. <th>操作</th>
  20. </tr>
  21. </thead>
  22. <tbody>
  23. </tbody>
  24. </table>
  25. </div>
  26. </div>
  27. </div>
  28. </div>
  29. </main>
  30. <script type="text/javascript">
  31. function del(vKey) {
  32. if (confirm("确定要删除数据吗?")) {
  33. $.ajax({
  34. type: "POST",
  35. url: "/index/del",
  36. data: {"vKey": vKey},
  37. success: function (res) {
  38. alert(res.msg)
  39. if (res.status) {
  40. document.location.reload();
  41. }
  42. }
  43. })
  44. }
  45. }
  46. function start(vKey) {
  47. if (confirm("确定要开始任务吗?")) {
  48. $.ajax({
  49. type: "POST",
  50. url: "/index/start",
  51. data: {"vKey": vKey},
  52. success: function (res) {
  53. alert(res.msg)
  54. if (res.status) {
  55. document.location.reload();
  56. }
  57. }
  58. })
  59. }
  60. }
  61. function stop(vKey) {
  62. if (confirm("确定要暂停吗?")) {
  63. $.ajax({
  64. type: "POST",
  65. url: "/index/stop",
  66. data: {"vKey": vKey},
  67. success: function (res) {
  68. alert(res.msg)
  69. if (res.status) {
  70. document.location.reload();
  71. }
  72. }
  73. })
  74. }
  75. }
  76. function edit(vKey) {
  77. window.location.href = "/index/edit?vKey=" + vKey
  78. }
  79. function add() {
  80. window.location.href = "/index/add?type=" +{{.type}}
  81. }
  82. function hostList(vkey) {
  83. window.location.href = "/index/hostlist?vkey=" + vkey
  84. }
  85. $(document).ready(function () {
  86. var table = $('#sampleTable').DataTable({
  87. dom: 'Bfrtip',
  88. processing: true,
  89. serverSide: true,
  90. autoWidth: false,
  91. ordering: false,
  92. ajax: {
  93. url: '/index/getserverconfig?type={{.type}}',
  94. type: 'POST'
  95. },
  96. dom: '<"top"fl><"toolbar">rt<"bottom"ip><"clear">',
  97. columns: [ //这个是显示到界面上的个数据 格式为 {data:'显示的字段名'}
  98. // {data: 'Mode'},
  99. {data: 'TcpPort'},
  100. {data: 'Target'},
  101. {data: 'VerifyKey'},
  102. {data: 'Compress'},
  103. {data: 'Crypt'},
  104. {data: 'Mux'},
  105. {data: 'U'},
  106. {data: 'P'},
  107. {data: 'ClientStatus'},
  108. {data: 'IsRun'},
  109. {data: "Id"}
  110. ],
  111. bFilter: false,
  112. columnDefs: [{
  113. targets: -1,
  114. render: function (data, type, row, meta) {
  115. if (row.IsRun == 1) {
  116. btn = "<button onclick=\"stop('" + row.VerifyKey + "')\" class=\"btn btn-secondary btn-sm\" type=\"button\">关闭</button>"
  117. } else {
  118. btn = "<button onclick=\"start('" + row.VerifyKey + "')\" class=\"btn btn-success btn-sm\" type=\"button\">打开</button>"
  119. }
  120. btn_edit = '<button onclick="edit(\'' + row.VerifyKey + '\')" type="button" class="btn btn-primary btn-sm">查看编辑</button> '
  121. if ({{.type}} == "hostServer"
  122. )
  123. {
  124. btn_host = '<button onclick="hostList(\'' + row.VerifyKey + '\')" type="button" class="btn btn-info btn-sm">域名管理</button> '
  125. }
  126. else
  127. {
  128. btn_host = ""
  129. }
  130. return '<div class="btn-group" role="group" aria-label="..."> ' +
  131. '<button onclick="del(\'' + row.VerifyKey + '\')" type="button" class="btn btn-danger btn-sm">删除</button>' +
  132. btn_edit + btn + btn_host + ' </div>'
  133. }
  134. },
  135. {
  136. targets: -2,
  137. render: function (data, type, row, meta) {
  138. if (data == 0) {
  139. return "<span class=\"badge badge-pill badge-secondary\">暂停</span>"
  140. } else {
  141. return "<span class=\"badge badge-pill badge-success\">正常</span>"
  142. }
  143. }
  144. },
  145. {
  146. targets: -7,
  147. render: function (data, type, row, meta) {
  148. if (data == "0") {
  149. return "不加密"
  150. } else {
  151. return "加密"
  152. }
  153. }
  154. },
  155. {
  156. targets: -6,
  157. render: function (data, type, row, meta) {
  158. if (data == "0") {
  159. return "不启用"
  160. } else {
  161. return "启用"
  162. }
  163. }
  164. }
  165. ,
  166. {
  167. targets: 2,
  168. render: function (data, type, row, meta) {
  169. return "./proxy_client -server={{.ip}}:{{.p}} -vkey=" + data
  170. // return data
  171. }
  172. },
  173. {
  174. targets: -3,
  175. render: function (data, type, row, meta) {
  176. if (data == 0) {
  177. return "<span class=\"badge badge-pill badge-secondary\">离线</span>"
  178. } else {
  179. return "<span class=\"badge badge-pill badge-success\">在线</span>"
  180. }
  181. }
  182. }
  183. ],
  184. buttons: []
  185. });
  186. $("#sampleTable_length").html('<button class="btn btn-primary" onclick="add()" type="button">新增</button>')
  187. })
  188. ;
  189. </script>