list.html 9.8 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><span id="langtag"></span><span></span></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. <i class="fa fa-fw fa-lg fa-plus"></i> <span langtag="word-add"></span></a>
  21. </div>
  22. <table id="taskList_table" class="table-striped table-hover" data-mobile-responsive="true"></table>
  23. </div>
  24. </div>
  25. <div class="ibox-content">
  26. <table id="table"></table>
  27. </div>
  28. </div>
  29. </div>
  30. </div>
  31. </div>
  32. <script>
  33. name = '{{.name}}:'.replace(/\s*/g,"")
  34. $('#langtag').attr('langtag','page-list' + name.replace(/:.*/,"")).next().text(name.split(":")[1])
  35. /*bootstrap table*/
  36. $('#table').bootstrapTable({
  37. toolbar: "#toolbar",
  38. method: 'post', // 服务器数据的请求方式 get or post
  39. url: "{{.web_base_url}}/index/gettunnel", // 服务器数据的加载地址
  40. queryParams: function (params) {
  41. return {
  42. "offset": params.offset,
  43. "limit": params.limit,
  44. "type":{{.type}},
  45. "client_id":{{.client_id}},
  46. "search": params.search
  47. }
  48. },
  49. search: true,
  50. contentType: "application/x-www-form-urlencoded",
  51. striped: true, // 设置为true会有隔行变色效果
  52. showHeader: true,
  53. showColumns: true,
  54. showRefresh: true,
  55. pagination: true,//分页
  56. sidePagination: 'server',//服务器端分页
  57. pageNumber: 1,
  58. pageList: [5, 10, 20, 50],//分页步进值
  59. detailView: true,
  60. smartDisplay: true, // 智能显示 pagination 和 cardview 等
  61. onExpandRow: function () {$('body').setLang ('.detail-view');},
  62. onLoadSuccess:function (data) {$('body').setLang ('.detail-view');},
  63. onPostBody: function (data) { if ($(this)[0].locale != undefined ) $('body').setLang ('#table'); },
  64. detailFormatter: function (index, row, element) {
  65. tmp = '<b langtag="word-exportflow"></b>: ' + changeunit(row.Flow.ExportFlow) + '&emsp;'
  66. + '<b langtag="word-inletflow"></b>: ' + changeunit(row.Flow.InletFlow) + '&emsp;'
  67. + '<b langtag="word-crypt"></b>: ' + row.Client.Cnf.Crypt + '&emsp;'
  68. + '<b langtag="word-compress"></b>: ' + row.Client.Cnf.Compress + '&emsp;'
  69. + '<b langtag="word-basicusername"></b>: ' + row.Client.Cnf.U + '&emsp;'
  70. + '<b langtag="word-basicpassword"></b>: ' + row.Client.Cnf.P + '&emsp;'
  71. if (row.Mode == "p2p") {
  72. return tmp + "<br/><br>"
  73. + '<b langtag="word-commandaccessp2p"></b>: ' + "<code>./npc{{.win}} -server={{.ip}}:{{.p}} -vkey=" + row.Client.VerifyKey
  74. + " -type=" +{{.bridgeType}} +" -password=" + row.Password + " -target=" + row.Target.TargetStr + "</code>" + "<br/><br>"
  75. + '<b langtag="word-commandaccessp2ps"></b>: ' + "<code>./npc{{.win}} -server={{.ip}}:{{.p}} -vkey=" + row.Client.VerifyKey
  76. + " -type=" +{{.bridgeType}} +" -password=" + row.Password + " -local_type=p2ps" + "</code>" + "<br/><br>"
  77. + '<b langtag="word-commandaccessp2pt"></b>: ' + "<code>./npc{{.win}} -server={{.ip}}:{{.p}} -vkey=" + row.Client.VerifyKey
  78. + " -type=" +{{.bridgeType}} +" -password=" + row.Password + " -local_type=p2pt" + "</code>"
  79. }
  80. if (row.Mode == "secret") {
  81. return tmp + "<br/><br>" + '<b langtag="word-commandaccess"></b>: ' + "<code>./npc{{.win}} -server={{.ip}}:{{.p}} -vkey=" + row.Client.VerifyKey
  82. + " -type=" +{{.bridgeType}} +" -password=" + row.Password + " -local_type=secret" + "</code>"
  83. }
  84. return tmp
  85. },
  86. //表格的列
  87. columns: [
  88. {
  89. field: 'Id',//域值
  90. title: '<span langtag="word-id"></span>',//标题
  91. halign: 'center',
  92. visible: true//false表示不显示
  93. },
  94. {
  95. field: 'Id',//域值
  96. title: '<span langtag="word-clientid"></span>',//标题
  97. halign: 'center',
  98. visible: true,//false表示不显示
  99. formatter: function (value, row, index) {
  100. return row.Client.Id
  101. }
  102. },
  103. {
  104. field: 'Remark',//域值
  105. title: '<span langtag="word-remark"></span>',//标题
  106. halign: 'center',
  107. visible: true//false表示不显示
  108. },
  109. {
  110. field: 'Mode',//域值
  111. title: '<span langtag="word-scheme"></span>',//标题
  112. halign: 'center',
  113. visible: true,//false表示不显示
  114. formatter: function (value, row, index) {
  115. return '<span langtag="scheme-' + value + '"></span>'
  116. }
  117. },
  118. {
  119. field: 'Port',//域值
  120. title: '<span langtag="word-port"></span>',//标题
  121. halign: 'center',
  122. visible: true//false表示不显示
  123. },
  124. {
  125. field: 'Target',//域值
  126. title: '<span langtag="word-target"></span>',//标题
  127. halign: 'center',
  128. visible: true,//false表示不显示
  129. formatter: function (value, row, index) {
  130. return row.Target.TargetStr
  131. }
  132. },
  133. {
  134. field: 'Password',//域值
  135. title: '<span langtag="word-identificationkey"></span>',//标题
  136. halign: 'center',
  137. visible: true//false表示不显示
  138. },
  139. {
  140. field: 'Status',//域值
  141. title: '<span langtag="word-status"></span>',//内容
  142. align: 'center',
  143. halign: 'center',
  144. visible: true,//false表示不显示
  145. formatter: function (value, row, index) {
  146. if (value) {
  147. return '<span class="badge badge-primary" langtag="word-open"></span>'
  148. } else {
  149. return '<span class="badge badge-badge" langtag="word-close"></span>'
  150. }
  151. }
  152. },
  153. {
  154. field: 'RunStatus',//域值
  155. title: '<span langtag="word-runstatus"></span>',//内容
  156. align: 'center',
  157. halign: 'center',
  158. visible: true,//false表示不显示
  159. formatter: function (value, row, index) {
  160. if (value) {
  161. return '<span class="badge badge-primary" langtag="word-open"></span>'
  162. } else {
  163. return '<span class="badge badge-badge" langtag="word-close"></span>'
  164. }
  165. }
  166. },
  167. {
  168. field: '',//域值
  169. title: '<span langtag="word-clientstatus"></span>',//内容
  170. align: 'center',
  171. halign: 'center',
  172. visible: true,//false表示不显示
  173. formatter: function (value, row, index) {
  174. if (row.Client.IsConnect) {
  175. return '<span class="badge badge-primary" langtag="word-online"></span>'
  176. } else {
  177. return '<span class="badge badge-badge" langtag="word-offline"></span>'
  178. }
  179. }
  180. },
  181. {
  182. field: 'option',//域值
  183. title: '<span langtag="word-option"></span>',//内容
  184. align: 'center',
  185. halign: 'center',
  186. visible: true,//false表示不显示
  187. formatter: function (value, row, index) {
  188. btn_group = '<div class="btn-group">'
  189. if (row.Status) {
  190. btn_group += "<a onclick=\"submitform('stop', '{{.web_base_url}}/index/stop', {'id':" + row.Id
  191. btn_group += '})" class="btn btn-outline btn-warning"><i class="fa fa-pause"></i></a>'
  192. } else {
  193. btn_group += "<a onclick=\"submitform('start', '{{.web_base_url}}/index/start', {\'id\':" + row.Id
  194. btn_group += '})" class="btn btn-outline btn-primary"><i class="fa fa-play"></i></a>'
  195. }
  196. btn_group += "<a onclick=\"submitform('delete', '{{.web_base_url}}/index/del', {'id':" + row.Id
  197. btn_group += '})" class="btn btn-outline btn-danger"><i class="fa fa-trash"></i></a>'
  198. btn_group += '<a href="{{.web_base_url}}/index/edit?id=' + row.Id
  199. btn_group += '" class="btn btn-outline btn-success"><i class="fa fa-edit"></i></a></div>'
  200. return btn_group
  201. }
  202. }
  203. ]
  204. });
  205. </script>