list.html 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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 langtag="page-clientlist"></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">
  21. <i class="fa fa-fw fa-lg fa-plus"></i> <span langtag="word-add"></span></a>
  22. </div>
  23. <table id="taskList_table" class="table-striped table-hover" 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. /*bootstrap table*/
  36. $('#table').bootstrapTable({
  37. toolbar: "#toolbar",
  38. method: 'post', // 服务器数据的请求方式 get or post
  39. url: "{{.web_base_url}}/client/list", // 服务器数据的加载地址
  40. contentType: "application/x-www-form-urlencoded",
  41. striped: true, // 设置为true会有隔行变色效果
  42. search: true,
  43. showHeader: true,
  44. showColumns: true,
  45. showRefresh: true,
  46. pagination: true,//分页
  47. sidePagination: 'server',//服务器端分页
  48. pageNumber: 1,
  49. pageList: [5, 10, 20, 50],//分页步进值
  50. detailView: true,
  51. smartDisplay: true, // 智能显示 pagination 和 cardview 等
  52. onExpandRow: function () {$('body').setLang ('.detail-view');},
  53. onPostBody: function (data) { if ($(this)[0].locale != undefined ) $('body').setLang ('#table'); },
  54. detailFormatter: function (index, row, element) {
  55. return '<b langtag="word-maxconnections"></b>: ' + row.MaxConn + '&emsp;'
  56. + '<b langtag="word-curconnections"></b>: ' + row.NowConn + '&emsp;'
  57. + '<b langtag="word-flowlimit"></b>: ' + row.Flow.FlowLimit + 'm&emsp;'
  58. + '<b langtag="word-ratelimit"></b>: ' + row.RateLimit + 'kb/s&emsp;'
  59. + '<b langtag="word-maxtunnels"></b>: ' + row.MaxTunnelNum + '&emsp;<br/><br/>'
  60. + '<b langtag="word-webusername"></b>: ' + row.WebUserName + '&emsp;'
  61. + '<b langtag="word-webpassword"></b>: ' + row.WebPassword + '&emsp;'
  62. + '<b langtag="word-basicusername"></b>: ' + row.Cnf.U + '&emsp;'
  63. + '<b langtag="word-basicpassword"></b>: ' + row.Cnf.P + '&emsp;<br/><br/>'
  64. + '<b langtag="word-crypt"></b>: <span langtag="word-' + row.Cnf.Crypt + '"></span>&emsp;'
  65. + '<b langtag="word-compress"></b>: <span langtag="word-' + row.Cnf.Compress + '"></span>&emsp;'
  66. + '<b langtag="word-connectbyconfig"></b>: <span langtag="word-' + row.ConfigConnAllow + '"></span>&emsp;<br/><br/>'
  67. + '<b langtag="word-commandclient"></b>: ' + "<code>./npc{{.win}} -server={{.ip}}:{{.p}} -vkey=" + row.VerifyKey + " -type=" +{{.bridgeType}} +"</code>"
  68. },
  69. //表格的列
  70. columns: [
  71. {
  72. field: 'Id',//域值
  73. title: '<span langtag="word-id"></span>',//标题
  74. halign: 'center',
  75. visible: true//false表示不显示
  76. },
  77. {
  78. field: 'Remark',//域值
  79. title: '<span langtag="word-remark"></span>',//标题
  80. halign: 'center',
  81. visible: true//false表示不显示
  82. },
  83. {
  84. field: 'Version',//域值
  85. title: '<span langtag="word-version"></span>',//标题
  86. halign: 'center',
  87. visible: true//false表示不显示
  88. },
  89. {
  90. field: 'VerifyKey',//域值
  91. title: '<span langtag="word-verifykey"></span>',//标题
  92. halign: 'center',
  93. visible: true,//false表示不显示
  94. formatter: function (value, row, index) {
  95. if (!row.NoStore) {
  96. return value
  97. } else {
  98. return '<span langtag="word-publicvkey"></span>'
  99. }
  100. }
  101. },
  102. {
  103. field: 'Addr',//域值
  104. title: '<span langtag="word-address"></span>',//标题
  105. halign: 'center',
  106. visible: true//false表示不显示
  107. },
  108. {
  109. field: 'InletFlow',//域值
  110. title: '<span langtag="word-inletflow"></span>',//标题
  111. halign: 'center',
  112. visible: true,//false表示不显示
  113. sortable: true,//启用排序
  114. formatter: function (value, row, index) {
  115. return changeunit(row.Flow.InletFlow)
  116. }
  117. },
  118. {
  119. field: 'ExportFlow',//域值
  120. title: '<span langtag="word-exportflow"></span>',//标题
  121. halign: 'center',
  122. visible: true,//false表示不显示
  123. sortable: true,//启用排序
  124. formatter: function (value, row, index) {
  125. return changeunit(row.Flow.ExportFlow)
  126. }
  127. },
  128. {
  129. field: 'IsConnect',//域值
  130. title: '<span langtag="word-speed"></span>',//内容
  131. halign: 'center',
  132. visible: true,//false表示不显示
  133. formatter: function (value, row, index) {
  134. return changeunit(row.Rate.NowRate) + "/S"
  135. }
  136. },
  137. {
  138. field: 'Status',//域值
  139. title: '<span langtag="word-status"></span>',//内容
  140. align: 'center',
  141. halign: 'center',
  142. visible: true,//false表示不显示
  143. formatter: function (value, row, index) {
  144. if (value) {
  145. return '<span class="badge badge-primary" langtag="word-open"></span>'
  146. } else {
  147. return '<span class="badge badge-badge" langtag="word-close"></span>'
  148. }
  149. }
  150. },
  151. {
  152. field: 'IsConnect',//域值
  153. title: '<span langtag="word-connect"></span>',//内容
  154. align: 'center',
  155. halign: 'center',
  156. visible: true,//false表示不显示
  157. formatter: function (value, row, index) {
  158. if (value) {
  159. return '<span class="badge badge-primary" langtag="word-online"></span>'
  160. } else {
  161. return '<span class="badge badge-badge" langtag="word-offline"></span>'
  162. }
  163. }
  164. },
  165. {
  166. field: 'option',//域值
  167. title: '<span langtag="word-option"></span>',//内容
  168. align: 'center',
  169. halign: 'center',
  170. visible: true,//false表示不显示
  171. formatter: function (value, row, index) {
  172. btn_group = '<div class="btn-group">'
  173. {{if eq true .isAdmin}}
  174. if (row.Status) {
  175. btn_group += '<a onclick="submitform(\'stop\', \'{{.web_base_url}}/client/changestatus\', {\'id\':' + row.Id
  176. btn_group += ', \'status\': 0})" class="btn btn-outline btn-warning"><i class="fa fa-pause"></i></a>'
  177. } else {
  178. btn_group += '<a onclick="submitform(\'start\', \'{{.web_base_url}}/client/changestatus\', {\'id\':' + row.Id
  179. btn_group += ', \'status\': 1})" class="btn btn-outline btn-primary"><i class="fa fa-play"></i></a>'
  180. }
  181. btn_group += '<a onclick="submitform(\'delete\', \'{{.web_base_url}}/client/del\', {\'id\':' + row.Id
  182. btn_group += '})" class="btn btn-outline btn-danger"><i class="fa fa-trash"></i></a>'
  183. {{end}}
  184. btn_group += '<a href="{{.web_base_url}}/client/edit?id=' + row.Id
  185. btn_group += '" class="btn btn-outline btn-success"><i class="fa fa-edit"></i></a></div>'
  186. return btn_group
  187. }
  188. },
  189. {
  190. field: 'show',//域值
  191. title: '<span langtag="word-show">',//内容
  192. align: 'center',
  193. halign: 'center',
  194. visible: true,//false表示不显示
  195. formatter: function (value, row, index) {
  196. return '<div class="btn-group"><a href="{{.web_base_url}}/index/all?client_id=' + row.Id
  197. + '" class="btn btn-outline btn-primary" langtag="word-tunnel"></a>'
  198. + '<a href="{{.web_base_url}}/index/hostlist?client_id=' + row.Id
  199. + '" class="btn btn-outline btn-success" langtag="word-host"></a></div>'
  200. }
  201. }
  202. ]
  203. });
  204. </script>