list.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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>client 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. {{if eq true .isAdmin}}
  18. <div class="table-responsive">
  19. <div id="toolbar">
  20. <a href="{{.web_base_url}}/client/add" class="btn btn-primary dim" 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. {{end}}
  27. <div class="ibox-content">
  28. <table id="table"></table>
  29. </div>
  30. </div>
  31. </div>
  32. </div>
  33. </div>
  34. <script>
  35. function del(id) {
  36. if (confirm("Are you sure you want to delete it??")) {
  37. $.ajax({
  38. type: "POST",
  39. url: "{{.web_base_url}}/client/del",
  40. data: {"id": id},
  41. success: function (res) {
  42. alert(res.msg)
  43. if (res.status) {
  44. document.location.reload();
  45. }
  46. }
  47. })
  48. }
  49. }
  50. function start(id) {
  51. if (confirm("Are you sure you want to start it??")) {
  52. $.ajax({
  53. type: "POST",
  54. url: "{{.web_base_url}}/client/changestatus",
  55. data: {"id": id, "status": 1},
  56. success: function (res) {
  57. alert(res.msg)
  58. if (res.status) {
  59. document.location.reload();
  60. }
  61. }
  62. })
  63. }
  64. }
  65. function stop(id) {
  66. if (confirm("Are you sure you want to stop it?")) {
  67. $.ajax({
  68. type: "POST",
  69. url: "{{.web_base_url}}/client/changestatus",
  70. data: {
  71. "id": id, "status": 0
  72. },
  73. success:
  74. function (res) {
  75. alert(res.msg)
  76. if (res.status) {
  77. document.location.reload();
  78. }
  79. }
  80. })
  81. }
  82. }
  83. function edit(id) {
  84. window.location.href = "{{.web_base_url}}/client/edit?id=" + id
  85. }
  86. function add() {
  87. window.location.href = "{{.web_base_url}}/client/add"
  88. }
  89. function tunnel(id) {
  90. window.location.href = "{{.web_base_url}}/index/all?client_id=" + id
  91. }
  92. function host(id) {
  93. window.location.href = "{{.web_base_url}}/index/hostlist?client_id=" + id
  94. }
  95. /*bootstrap table*/
  96. $('#table').bootstrapTable({
  97. toolbar: "#toolbar",
  98. method: 'post', // 服务器数据的请求方式 get or post
  99. url: "{{.web_base_url}}/client/list", // 服务器数据的加载地址
  100. contentType: "application/x-www-form-urlencoded",
  101. striped: true, // 设置为true会有隔行变色效果
  102. search: true,
  103. showHeader: true,
  104. showColumns: true,
  105. showRefresh: true,
  106. pagination: true,//分页
  107. sidePagination: 'server',//服务器端分页
  108. pageNumber: 1,
  109. pageList: [5, 10, 20, 50],//分页步进值
  110. detailView: true,
  111. smartDisplay: true, // 智能显示 pagination 和 cardview 等
  112. detailFormatter: function (index, row, element) {
  113. return '<b langtag="info-max-conn-num">最大连接数</b>:' + row.MaxConn + `&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp`
  114. + '<b langtag="info-now-conn-num">当前连接数</b>:' + row.NowConn + `&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp`
  115. + '<b langtag="info-flow-limit">流量限制</b>:' + row.Flow.FlowLimit + `m&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp`
  116. + '<b langtag="info-rate-limit">带宽限制</b>:' + row.RateLimit + `kb/s&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp`
  117. + '<b langtag="info-max-tunnel-num">隧道数限制</b>:' + row.MaxTunnelNum + `&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp`
  118. + '<b langtag="info-client-web-username">web登陆用户名</b>:' + row.WebUserName + `&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp`
  119. + '<b langtag="info-client-web-password">web登陆密码</b>:' + row.WebPassword + `&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp`
  120. + `&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp` + "<br/><br>"
  121. + '<b langtag="info-crypt">加密</b>:' + row.Cnf.Crypt + `&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp`
  122. + '<b langtag="info-compress">压缩</b>:' + row.Cnf.Compress + `&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp`
  123. + '<b langtag="info-config-conn-allow">是否允许配置文件模式连接</b>:' + row.ConfigConnAllow + `&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp`
  124. + '<b langtag="info-web-auth-username">basic认证用户名</b>:' + row.Cnf.U + `&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp`
  125. + '<b langtag="info-web-auth-password">basic认证密码</b>:' + row.Cnf.P + `&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp` + "<br/><br>"
  126. + '<b langtag="info-command">命令</b>:' + "<code>./npc{{.win}} -server={{.ip}}:{{.p}} -vkey=" + row.VerifyKey + " -type=" +{{.bridgeType}} +"</code>"
  127. },
  128. //表格的列
  129. columns: [
  130. {
  131. field: 'Id',//域值
  132. title: 'id',//标题
  133. visible: true,//false表示不显示
  134. },
  135. {
  136. field: 'Remark',//域值
  137. title: 'remark',//标题
  138. visible: true,//false表示不显示
  139. },
  140. {
  141. field: 'VerifyKey',//域值
  142. title: 'vkey',//标题
  143. visible: true,//false表示不显示
  144. formatter: function (value, row, index) {
  145. if (!row.NoStore) {
  146. return value
  147. } else {
  148. return "public vkey"
  149. }
  150. }
  151. },
  152. {
  153. field: 'Addr',//域值
  154. title: 'client addr',//标题
  155. visible: true,//false表示不显示
  156. },
  157. {
  158. field: 'InletFlow',//域值
  159. title: 'in flow',//标题
  160. visible: true,//false表示不显示
  161. sortable: true,//启用排序
  162. formatter: function (value, row, index) {
  163. return change(row.Flow.InletFlow)
  164. }
  165. },
  166. {
  167. field: 'ExportFlow',//域值
  168. title: 'out flow',//标题
  169. visible: true,//false表示不显示
  170. sortable: true,//启用排序
  171. formatter: function (value, row, index) {
  172. return change(row.Flow.ExportFlow)
  173. }
  174. },
  175. {
  176. field: 'IsConnect',//域值
  177. title: 'speed',//内容
  178. visible: true,//false表示不显示
  179. formatter: function (value, row, index) {
  180. return change(row.Rate.NowRate) + "/S"
  181. }
  182. },
  183. {
  184. field: 'Status',//域值
  185. title: 'run',//内容
  186. visible: true,//false表示不显示
  187. formatter: function (value, row, index) {
  188. if (value) {
  189. return '<span class="badge badge-primary">open</span>'
  190. } else {
  191. return '<span class="badge badge-badge">close</span>'
  192. }
  193. }
  194. },
  195. {
  196. field: 'IsConnect',//域值
  197. title: 'status',//内容
  198. visible: true,//false表示不显示
  199. formatter: function (value, row, index) {
  200. if (value) {
  201. return '<span class="badge badge-primary">online</span>'
  202. } else {
  203. return '<span class="badge badge-badge">offline</span>'
  204. }
  205. }
  206. },
  207. {
  208. field: 'option',//域值
  209. title: 'option',//内容
  210. visible: true,//false表示不显示
  211. formatter: function (value, row, index) {
  212. btn_group = '<div class="btn-group">'
  213. btn = `{{if eq true .isAdmin}}<button onclick="del(` + row.Id + `)" class="btn-danger"><i class="fa fa-trash"></i></button>{{end}}<button onclick="edit(` + row.Id + `)" class="btn-primary"><i class="fa fa-edit"></i></button></div>`
  214. if (row.Status) {
  215. return btn_group {{if eq true .isAdmin}}+ `<button onclick="stop(` + row.Id + `)" class="btn-warning"><i class="fa fa-close"></i></button>`{{end}}+ btn
  216. } else {
  217. return btn_group {{if eq true .isAdmin}}+ `<button onclick="start(` + row.Id + `)" class="btn-warning"><i class="fa fa-check"></i></button>`{{end}}+ btn
  218. }
  219. }
  220. },
  221. {
  222. field: 'show',//域值
  223. title: 'show',//内容
  224. visible: true,//false表示不显示
  225. formatter: function (value, row, index) {
  226. return `<button onclick="tunnel(` + row.Id + `)" class="btn-info">tunnel</button><button onclick="host(` + row.Id + `)" class="btn-primary">host</button>`
  227. }
  228. }
  229. ]
  230. });
  231. </script>