list.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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: 'Version',//域值
  142. title: 'version',//标题
  143. visible: true,//false表示不显示
  144. },
  145. {
  146. field: 'VerifyKey',//域值
  147. title: 'vkey',//标题
  148. visible: true,//false表示不显示
  149. formatter: function (value, row, index) {
  150. if (!row.NoStore) {
  151. return value
  152. } else {
  153. return "public vkey"
  154. }
  155. }
  156. },
  157. {
  158. field: 'Addr',//域值
  159. title: 'client addr',//标题
  160. visible: true,//false表示不显示
  161. },
  162. {
  163. field: 'InletFlow',//域值
  164. title: 'in flow',//标题
  165. visible: true,//false表示不显示
  166. sortable: true,//启用排序
  167. formatter: function (value, row, index) {
  168. return change(row.Flow.InletFlow)
  169. }
  170. },
  171. {
  172. field: 'ExportFlow',//域值
  173. title: 'out flow',//标题
  174. visible: true,//false表示不显示
  175. sortable: true,//启用排序
  176. formatter: function (value, row, index) {
  177. return change(row.Flow.ExportFlow)
  178. }
  179. },
  180. {
  181. field: 'IsConnect',//域值
  182. title: 'speed',//内容
  183. visible: true,//false表示不显示
  184. formatter: function (value, row, index) {
  185. return change(row.Rate.NowRate) + "/S"
  186. }
  187. },
  188. {
  189. field: 'Status',//域值
  190. title: 'run',//内容
  191. visible: true,//false表示不显示
  192. formatter: function (value, row, index) {
  193. if (value) {
  194. return '<span class="badge badge-primary">open</span>'
  195. } else {
  196. return '<span class="badge badge-badge">close</span>'
  197. }
  198. }
  199. },
  200. {
  201. field: 'IsConnect',//域值
  202. title: 'status',//内容
  203. visible: true,//false表示不显示
  204. formatter: function (value, row, index) {
  205. if (value) {
  206. return '<span class="badge badge-primary">online</span>'
  207. } else {
  208. return '<span class="badge badge-badge">offline</span>'
  209. }
  210. }
  211. },
  212. {
  213. field: 'option',//域值
  214. title: 'option',//内容
  215. visible: true,//false表示不显示
  216. formatter: function (value, row, index) {
  217. btn_group = '<div class="btn-group">'
  218. 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>`
  219. if (row.Status) {
  220. return btn_group {{if eq true .isAdmin}}+ `<button onclick="stop(` + row.Id + `)" class="btn-warning"><i class="fa fa-close"></i></button>`{{end}}+ btn
  221. } else {
  222. return btn_group {{if eq true .isAdmin}}+ `<button onclick="start(` + row.Id + `)" class="btn-warning"><i class="fa fa-check"></i></button>`{{end}}+ btn
  223. }
  224. }
  225. },
  226. {
  227. field: 'show',//域值
  228. title: 'show',//内容
  229. visible: true,//false表示不显示
  230. formatter: function (value, row, index) {
  231. return `<button onclick="tunnel(` + row.Id + `)" class="btn-info">tunnel</button><button onclick="host(` + row.Id + `)" class="btn-primary">host</button>`
  232. }
  233. }
  234. ]
  235. });
  236. </script>