hlist.html 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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>host 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. <div class="table-responsive">
  18. <div id="toolbar">
  19. <a href="{{.web_base_url}}/index/addhost?vkey={{.task_id}}&client_id={{.client_id}}"
  20. class="btn btn-primary dim"
  21. type="button" langtag="info-new">新增</a>
  22. </div>
  23. <table id="taskList_table" class="table-striped table-hover"
  24. data-mobile-responsive="true"></table>
  25. </div>
  26. </div>
  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: window.location, // 服务器数据的加载地址
  40. queryParams: function (params) {
  41. return {
  42. "offset": params.offset,
  43. "limit": params.limit,
  44. "search": params.search
  45. }
  46. },
  47. search: true,
  48. contentType: "application/x-www-form-urlencoded",
  49. striped: true, // 设置为true会有隔行变色效果
  50. showHeader: true,
  51. showColumns: true,
  52. showRefresh: true,
  53. pagination: true,//分页
  54. sidePagination: 'server',//服务器端分页
  55. pageNumber: 1,
  56. pageList: [5, 10, 20, 50],//分页步进值
  57. detailView: true,
  58. smartDisplay: true, // 智能显示 pagination 和 cardview 等
  59. detailFormatter: function (index, row, element) {
  60. return '<b langtag="info-export-flow">出口流量</b>:' + change(row.Flow.ExportFlow) + `&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp`
  61. + '<b langtag="info-inlet-flow">入口流量</b>:' + change(row.Flow.InletFlow) + `&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp`
  62. + '<b langtag="info-crypt">加密</b>:' + row.Client.Cnf.Crypt + `&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp`
  63. + '<b langtag="info-compress">压缩</b>:' + row.Client.Cnf.Compress + `&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp` + "<br/><br>"
  64. + '<b langtag="info-web-auth-username">basic权限认证用户名</b>:' + row.Client.Cnf.U + `&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp`
  65. + '<b langtag="info-web-auth-password">basic权限认证密码</b>:' + row.Client.Cnf.P + `&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp` + "<br/><br>"
  66. + '<b langtag="info-https-cert">cert file路径</b>:' + row.CertFilePath + `&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp`
  67. + '<b langtag="info-https-key">key file路径</b>:' + row.KeyFilePath + `&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp` + "<br/><br>"
  68. + '<b langtag="info-header-change">request header修改</b>:' + row.HeaderChange + `&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp` + "<br/><br>"
  69. + '<b langtag="info-host-change">request host 修改</b>:' + row.HostChange + `&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp`
  70. },
  71. //表格的列
  72. columns: [
  73. {
  74. field: 'Id',//域值
  75. title: 'id',//标题
  76. visible: true,//false表示不显示
  77. },
  78. {
  79. field: 'Id',//域值
  80. title: 'client id',//标题
  81. visible: true,//false表示不显示
  82. formatter: function (value, row, index) {
  83. return row.Client.Id
  84. }
  85. },
  86. {
  87. field: 'Remark',//域值
  88. title: 'remark',//标题
  89. visible: true,//false表示不显示
  90. },
  91. {
  92. field: 'Host',//域值
  93. title: 'host',//标题
  94. visible: true,//false表示不显示
  95. },
  96. {
  97. field: 'Scheme',//域值
  98. title: 'scheme',//标题
  99. visible: true,//false表示不显示
  100. },
  101. {
  102. field: 'Target',//域值
  103. title: 'target',//标题
  104. visible: true,//false表示不显示
  105. formatter: function (value, row, index) {
  106. return row.Target.TargetStr
  107. }
  108. },
  109. {
  110. field: 'Location',//域值
  111. title: 'location',//标题
  112. visible: true,//false表示不显示
  113. },
  114. {
  115. field: '',//域值
  116. title: 'client status',//内容
  117. visible: true,//false表示不显示
  118. formatter: function (value, row, index) {
  119. if (row.Client.IsConnect) {
  120. return '<span class="badge badge-primary">online</span>'
  121. } else {
  122. return '<span class="badge badge-badge">offline</span>'
  123. }
  124. }
  125. },
  126. {
  127. field: 'option',//域值
  128. title: 'option',//内容
  129. visible: true,//false表示不显示
  130. formatter: function (value, row, index) {
  131. btn_group = '<div class="btn-group">'
  132. 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>`
  133. return btn_group + btn
  134. }
  135. }
  136. ]
  137. });
  138. </script>
  139. <script type="text/javascript">
  140. function del(id) {
  141. if (confirm("Are you sure you want to delete it??")) {
  142. $.ajax({
  143. type: "POST",
  144. url: "{{.web_base_url}}/index/delhost",
  145. data: {"id": id},
  146. success: function (res) {
  147. alert(res.msg)
  148. if (res.status) {
  149. document.location.reload();
  150. }
  151. }
  152. })
  153. }
  154. }
  155. function edit(id) {
  156. window.location.href = "{{.web_base_url}}/index/edithost?id=" + id
  157. }
  158. </script>