nodeList.blade.php 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. @extends('admin.layouts')
  2. @section('css')
  3. <link href="/assets/global/vendor/bootstrap-table/bootstrap-table.min.css" type="text/css" rel="stylesheet">
  4. <style>
  5. #swal2-content {
  6. display: grid !important;
  7. }
  8. </style>
  9. @endsection
  10. @section('content')
  11. <div class="page-content container-fluid">
  12. <div class="panel">
  13. <div class="panel-heading">
  14. <h3 class="panel-title">节点列表</h3>
  15. <div class="panel-actions btn-group">
  16. <button type="button" onclick="refreshGeo()" class="btn btn-info">
  17. <i class="icon wb-map"></i> 刷新节点地理信息
  18. </button>
  19. <a href="/node/add" class="btn btn-primary"><i class="icon wb-plus"></i> 添加节点</a>
  20. </div>
  21. </div>
  22. <div class="panel-body">
  23. <table class="text-md-center" data-toggle="table" data-mobile-responsive="true">
  24. <thead class="thead-default">
  25. <tr>
  26. <th> ID</th>
  27. <th> 类型</th>
  28. <th> 名称</th>
  29. <th> IP</th>
  30. <th> 域名</th>
  31. <th> 存活</th>
  32. <th> 状态</th>
  33. <th> 在线</th>
  34. <th> 产生流量</th>
  35. <th> 流量比例</th>
  36. <th> 扩展</th>
  37. <th> 操作</th>
  38. </tr>
  39. </thead>
  40. <tbody>
  41. @foreach($nodeList as $node)
  42. <tr class="{{!$node->isOnline && $node->status ? 'table-danger' : ''}}">
  43. <td>
  44. {{$node->id}}
  45. </td>
  46. <td>
  47. @if($node->is_relay)
  48. 中转
  49. @else
  50. {{$node->type_label}}
  51. @endif
  52. </td>
  53. <td> {{$node->name}} </td>
  54. <td> {{$node->is_ddns ? 'DDNS' : $node->ip}} </td>
  55. <td> {{$node->server}} </td>
  56. <td> {{$node->uptime}} </td>
  57. <td> {{$node->status? $node->load : '维护'}} </td>
  58. <td> {{$node->online_users}} </td>
  59. <td> {{$node->transfer}} </td>
  60. <td> {{$node->traffic_rate}} </td>
  61. <td>
  62. @if($node->compatible) <span class="badge badge-lg badge-info">兼</span> @endif
  63. @if($node->single) <span class="badge badge-lg badge-info">单</span> @endif
  64. @if(!$node->is_subscribe)
  65. <span class="badge badge-lg badge-danger"><s>订</s></span> @endif
  66. </td>
  67. <td>
  68. <div class="btn-group">
  69. @if($node->type === 4)
  70. <button type="button" onclick="reload('{{$node->id}}')" class="btn btn-primary">
  71. <i id="reload{{$node->id}}" class="icon wb-reload"></i>
  72. </button>
  73. @endif
  74. <button type="button" onclick="refreshGeo('{{$node->id}}')" class="btn btn-primary">
  75. <i id="geo{{$node->id}}" class="icon wb-map"></i>
  76. </button>
  77. <a href="javascript:pingNode('{{$node->id}}')" class="btn btn-primary">
  78. <i id="ping{{$node->id}}" class="icon wb-order"></i>
  79. </a>
  80. <a href="javascript:checkNode('{{$node->id}}')" class="btn btn-primary">
  81. <i id="node{{$node->id}}" class="icon wb-signal"></i>
  82. </a>
  83. <a href="/node/edit?id={{$node->id}}&page={{Request::get('page', 1)}}" class="btn btn-primary">
  84. <i class="icon wb-edit"></i>
  85. </a>
  86. <a href="javascript:delNode('{{$node->id}}','{{$node->name}}')" class="btn btn-danger">
  87. <i class="icon wb-trash"></i>
  88. </a>
  89. <a href="/node/monitor?id={{$node->id}}" class="btn btn-primary">
  90. <i class="icon wb-stats-bars"></i>
  91. </a>
  92. </div>
  93. </td>
  94. </tr>
  95. @endforeach
  96. </tbody>
  97. </table>
  98. </div>
  99. <div class="panel-footer">
  100. <div class="row">
  101. <div class="col-sm-4">
  102. 共 <code>{{$nodeList->total()}}</code> 条线路
  103. </div>
  104. <div class="col-sm-8">
  105. <nav class="Page navigation float-right">
  106. {{$nodeList->links()}}
  107. </nav>
  108. </div>
  109. </div>
  110. </div>
  111. </div>
  112. </div>
  113. @endsection
  114. @section('script')
  115. <script src="/assets/global/vendor/bootstrap-table/bootstrap-table.min.js" type="text/javascript"></script>
  116. <script src="/assets/global/vendor/bootstrap-table/extensions/mobile/bootstrap-table-mobile.min.js" type="text/javascript"></script>
  117. <script type="text/javascript">
  118. // 节点连通性测试
  119. function checkNode(id) {
  120. $.ajax({
  121. type: "POST",
  122. url: '/node/check/' + id,
  123. data: {_token: '{{csrf_token()}}'},
  124. beforeSend: function () {
  125. $("#node" + id).removeClass("wb-signal").addClass("wb-loop icon-spin");
  126. },
  127. success: function (ret) {
  128. if (ret.status === 'success') {
  129. swal.fire({
  130. title: ret.title,
  131. type: 'info',
  132. html: '<table class="my-20"><thead class="thead-default"><tr><th> ICMP </th> <th> TCP </th></thead><tbody><tr><td>' + ret.message[0] + '</td><td>' + ret.message[1] + '</td></tr></tbody></table>',
  133. showConfirmButton: false
  134. })
  135. } else {
  136. swal.fire({title: ret.title, text: ret.message, type: "error"})
  137. }
  138. },
  139. complete: function () {
  140. $("#node" + id).removeClass("wb-loop icon-spin").addClass("wb-signal");
  141. }
  142. });
  143. }
  144. // Ping节点获取延迟
  145. function pingNode(id) {
  146. $.ajax({
  147. type: "POST",
  148. url: '/node/ping/' + id,
  149. data: {_token: '{{csrf_token()}}'},
  150. beforeSend: function () {
  151. $("#ping" + id).removeClass("wb-order").addClass("wb-loop icon-spin");
  152. },
  153. success: function (ret) {
  154. if (ret.status === 'success') {
  155. swal.fire({
  156. type: 'info',
  157. html: '<table class="my-20"><thead class="thead-default"><tr><th> 电信 </th> <th> 联通 </th> <th> 移动 </th> <th> 香港 </th></thead><tbody><tr><td>' + ret.message[0] + '</td><td>' + ret.message[1] + '</td><td>' + ret.message[2] + '</td><td>' + ret.message[3] + '</td></tr></tbody></table>',
  158. showConfirmButton: false
  159. })
  160. } else {
  161. swal.fire({title: ret.message, type: "error"})
  162. }
  163. },
  164. complete: function () {
  165. $("#ping" + id).removeClass("wb-loop icon-spin").addClass("wb-order");
  166. }
  167. });
  168. }
  169. // 发送节点重载请求
  170. function reload(id) {
  171. swal.fire({
  172. text: '确定重载节点?',
  173. type: 'question',
  174. showCancelButton: true,
  175. cancelButtonText: '{{trans('home.ticket_close')}}',
  176. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  177. }).then((result) => {
  178. if (result.value) {
  179. $.ajax({
  180. type: "post",
  181. url: '/node/reload/' + id,
  182. data: {_token: '{{csrf_token()}}'},
  183. beforeSend: function () {
  184. $("#reload" + id).removeClass("wb-reload").addClass("wb-loop icon-spin");
  185. },
  186. success: function (ret) {
  187. if (ret.status === 'success') {
  188. swal.fire({type: 'info', title: ret.message, showConfirmButton: false})
  189. } else {
  190. swal.fire({title: ret.message, type: "error"})
  191. }
  192. },
  193. complete: function () {
  194. $("#reload" + id).removeClass("wb-loop icon-spin").addClass("wb-reload");
  195. }
  196. });
  197. }
  198. })
  199. }
  200. // 刷新节点地理信息
  201. function refreshGeo(id) {
  202. $.ajax({
  203. type: "GET",
  204. url: '/node/refreshGeo',
  205. data: {_token: '{{csrf_token()}}', id: id},
  206. beforeSend: function () {
  207. $("#geo" + id).removeClass("wb-map").addClass("wb-loop icon-spin");
  208. },
  209. success: function (ret) {
  210. if (ret.status === 'success') {
  211. swal.fire({type: 'info', title: ret.message, showConfirmButton: false})
  212. } else {
  213. swal.fire({title: ret.message, type: "error"})
  214. }
  215. },
  216. complete: function () {
  217. $("#geo" + id).removeClass("wb-loop icon-spin").addClass("wb-map");
  218. }
  219. });
  220. }
  221. // 删除节点
  222. function delNode(id, name) {
  223. swal.fire({
  224. title: '警告',
  225. text: '确定删除节点 【' + name + '】 ?',
  226. type: 'warning',
  227. showCancelButton: true,
  228. cancelButtonText: '{{trans('home.ticket_close')}}',
  229. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  230. }).then((result) => {
  231. if (result.value) {
  232. $.post("/node/delete", {id: id, _token: '{{csrf_token()}}'}, function (ret) {
  233. if (ret.status === 'success') {
  234. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false})
  235. .then(() => window.location.reload())
  236. } else {
  237. swal.fire({title: ret.message, type: "error"}).then(() => window.location.reload())
  238. }
  239. });
  240. }
  241. });
  242. }
  243. // 显示提示
  244. function showIdTips() {
  245. swal.fire({
  246. title: '复制成功',
  247. type: 'success',
  248. timer: 1300,
  249. showConfirmButton: false,
  250. });
  251. }
  252. </script>
  253. @endsection