list.html 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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="{{.web_base_url}}/index/add?type={{.type}}&client_id={{.client_id}}" class="btn btn-primary dim"
  20. type="button" langtag="info-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: "{{.web_base_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. "search": params.search
  46. }
  47. },
  48. search: true,
  49. contentType: "application/x-www-form-urlencoded",
  50. striped: true, // 设置为true会有隔行变色效果
  51. showHeader: true,
  52. showColumns: true,
  53. showRefresh: true,
  54. pagination: true,//分页
  55. sidePagination: 'server',//服务器端分页
  56. pageNumber: 1,
  57. pageList: [5, 10, 20, 50],//分页步进值
  58. detailView: true,
  59. smartDisplay: true, // 智能显示 pagination 和 cardview 等
  60. detailFormatter: function (index, row, element) {
  61. tmp = '<b langtag="info-export-flow">出口流量</b>:' + change(row.Flow.ExportFlow) + `&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp`
  62. + '<b langtag="info-inlet-flow">入口流量</b>:' + change(row.Flow.InletFlow) + `&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp`
  63. + '<b langtag="info-crypt">加密</b>:' + row.Client.Cnf.Crypt + `&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp`
  64. + '<b langtag="info-compress">压缩</b>:' + row.Client.Cnf.Compress + `&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp`
  65. + '<b langtag="info-web-auth-username">basic权限认证用户名</b>:' + row.Client.Cnf.U + `&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp`
  66. + '<b langtag="info-web-auth-password">basic权限认证密码</b>:' + row.Client.Cnf.P + `&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp`
  67. if (row.Mode == "p2p") {
  68. return tmp + "<br/><br>"
  69. + '<b langtag="info-command">访问端命令(tcp)</b>:' + "<code>./npc{{.win}} -server={{.ip}}:{{.p}} -vkey=" + row.Client.VerifyKey + " -type=" +{{.bridgeType}} +" -password=" + row.Password + " -target=" + row.Target.TargetStr + "</code>" + "<br/><br>"
  70. + '<b langtag="info-command">访问端命令(socks5)</b>:' + "<code>./npc{{.win}} -server={{.ip}}:{{.p}} -vkey=" + row.Client.VerifyKey + " -type=" +{{.bridgeType}} +" -password=" + row.Password + " -local_type=p2ps" + "</code>" + "<br/><br>"
  71. + '<b langtag="info-command">访问端命令(透明代理)</b>:' + "<code>./npc{{.win}} -server={{.ip}}:{{.p}} -vkey=" + row.Client.VerifyKey + " -type=" +{{.bridgeType}} +" -password=" + row.Password + " -local_type=p2pt" + "</code>"
  72. }
  73. if (row.Mode = "secret") {
  74. return tmp + "<br/><br>" + '<b langtag="info-command">访问端命令</b>:' + "<code>./npc{{.win}} -server={{.ip}}:{{.p}} -vkey=" + row.Client.VerifyKey + " -type=" +{{.bridgeType}} +" -password=" + row.Password + " -local_type=secret" + "</code>"
  75. }
  76. return tmp
  77. },
  78. //表格的列
  79. columns: [
  80. {
  81. field: 'Id',//域值
  82. title: 'id',//标题
  83. visible: true,//false表示不显示
  84. },
  85. {
  86. field: 'Id',//域值
  87. title: 'client id',//标题
  88. visible: true,//false表示不显示
  89. formatter: function (value, row, index) {
  90. return row.Client.Id
  91. }
  92. },
  93. {
  94. field: 'Remark',//域值
  95. title: 'remark',//标题
  96. visible: true,//false表示不显示
  97. },
  98. {
  99. field: 'Mode',//域值
  100. title: 'mode',//标题
  101. visible: true,//false表示不显示
  102. },
  103. {
  104. field: 'Port',//域值
  105. title: 'port',//标题
  106. visible: true,//false表示不显示
  107. },
  108. {
  109. field: 'Target',//域值
  110. title: 'target',//标题
  111. visible: true,//false表示不显示
  112. formatter: function (value, row, index) {
  113. return row.Target.TargetStr
  114. }
  115. },
  116. {
  117. field: 'Password',//域值
  118. title: 'secret',//标题
  119. visible: true,//false表示不显示
  120. },
  121. {
  122. field: 'Status',//域值
  123. title: 'setting',//内容
  124. visible: true,//false表示不显示
  125. formatter: function (value, row, index) {
  126. if (value) {
  127. return '<span class="badge badge-primary">open</span>'
  128. } else {
  129. return '<span class="badge badge-badge">close</span>'
  130. }
  131. }
  132. },
  133. {
  134. field: 'RunStatus',//域值
  135. title: 'run',//内容
  136. visible: true,//false表示不显示
  137. formatter: function (value, row, index) {
  138. if (value) {
  139. return '<span class="badge badge-primary">open</span>'
  140. } else {
  141. return '<span class="badge badge-badge">close</span>'
  142. }
  143. }
  144. },
  145. {
  146. field: '',//域值
  147. title: 'client',//内容
  148. visible: true,//false表示不显示
  149. formatter: function (value, row, index) {
  150. if (row.Client.IsConnect) {
  151. return '<span class="badge badge-primary">online</span>'
  152. } else {
  153. return '<span class="badge badge-badge">offline</span>'
  154. }
  155. }
  156. },
  157. {
  158. field: 'option',//域值
  159. title: 'option',//内容
  160. visible: true,//false表示不显示
  161. formatter: function (value, row, index) {
  162. btn_group = '<div class="btn-group">'
  163. 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>`
  164. if (row.Status) {
  165. return btn_group + `<button onclick="stop(` + row.Id + `)" class="btn-dark"><i class="fa fa-close"></i></button>` + btn
  166. } else {
  167. return btn_group + `<button onclick="start(` + row.Id + `)" class="btn-outline-primary"><i class="fa fa-check"></i></button>` + btn
  168. }
  169. }
  170. }
  171. ]
  172. });
  173. </script>
  174. <script type="text/javascript">
  175. function del(id) {
  176. if (confirm("Are you sure you want to delete it??")) {
  177. $.ajax({
  178. type: "POST",
  179. url: "{{.web_base_url}}/index/del",
  180. data: {"id": id},
  181. success: function (res) {
  182. alert(res.msg)
  183. if (res.status) {
  184. document.location.reload();
  185. }
  186. }
  187. })
  188. }
  189. }
  190. function start(id) {
  191. if (confirm("Are you sure you want to start it??")) {
  192. $.ajax({
  193. type: "POST",
  194. url: "{{.web_base_url}}/index/start",
  195. data: {"id": id},
  196. success: function (res) {
  197. alert(res.msg)
  198. if (res.status) {
  199. document.location.reload();
  200. }
  201. }
  202. })
  203. }
  204. }
  205. function stop(id) {
  206. if (confirm("Are you sure you want to stop it??")) {
  207. $.ajax({
  208. type: "POST",
  209. url: "{{.web_base_url}}/index/stop",
  210. data: {"id": id},
  211. success: function (res) {
  212. alert(res.msg)
  213. if (res.status) {
  214. document.location.reload();
  215. }
  216. }
  217. })
  218. }
  219. }
  220. function edit(id) {
  221. window.location.href = "{{.web_base_url}}/index/edit?id=" + id
  222. }
  223. </script>