nodeList.blade.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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>' +
  133. ret.message[0] + '</td><td>' + ret.message[1] + '</td></tr></tbody></table>',
  134. showConfirmButton: false,
  135. });
  136. }
  137. else {
  138. swal.fire({title: ret.title, text: ret.message, type: 'error'});
  139. }
  140. },
  141. complete: function() {
  142. $('#node' + id).removeClass('wb-loop icon-spin').addClass('wb-signal');
  143. },
  144. });
  145. }
  146. // Ping节点获取延迟
  147. function pingNode(id) {
  148. $.ajax({
  149. type: 'POST',
  150. url: '/node/ping/' + id,
  151. data: {_token: '{{csrf_token()}}'},
  152. beforeSend: function() {
  153. $('#ping' + id).removeClass('wb-order').addClass('wb-loop icon-spin');
  154. },
  155. success: function(ret) {
  156. if (ret.status === 'success') {
  157. swal.fire({
  158. type: 'info',
  159. html: '<table class="my-20"><thead class="thead-default"><tr><th> 电信 </th> <th> 联通 </th> <th> 移动 </th> <th> 香港 </th></thead><tbody><tr><td>' +
  160. ret.message[0] + '</td><td>' + ret.message[1] + '</td><td>' + ret.message[2] + '</td><td>' +
  161. ret.message[3] + '</td></tr></tbody></table>',
  162. showConfirmButton: false,
  163. });
  164. }
  165. else {
  166. swal.fire({title: ret.message, type: 'error'});
  167. }
  168. },
  169. complete: function() {
  170. $('#ping' + id).removeClass('wb-loop icon-spin').addClass('wb-order');
  171. },
  172. });
  173. }
  174. // 发送节点重载请求
  175. function reload(id) {
  176. swal.fire({
  177. text: '确定重载节点?',
  178. type: 'question',
  179. showCancelButton: true,
  180. cancelButtonText: '{{trans('home.ticket_close')}}',
  181. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  182. }).then((result) => {
  183. if (result.value) {
  184. $.ajax({
  185. type: 'post',
  186. url: '/node/reload/' + id,
  187. data: {_token: '{{csrf_token()}}'},
  188. beforeSend: function() {
  189. $('#reload' + id).removeClass('wb-reload').addClass('wb-loop icon-spin');
  190. },
  191. success: function(ret) {
  192. if (ret.status === 'success') {
  193. swal.fire({type: 'info', title: ret.message, showConfirmButton: false});
  194. }
  195. else {
  196. swal.fire({title: ret.message, type: 'error'});
  197. }
  198. },
  199. complete: function() {
  200. $('#reload' + id).removeClass('wb-loop icon-spin').addClass('wb-reload');
  201. },
  202. });
  203. }
  204. });
  205. }
  206. // 刷新节点地理信息
  207. function refreshGeo(id) {
  208. $.ajax({
  209. type: 'GET',
  210. url: '/node/refreshGeo',
  211. data: {_token: '{{csrf_token()}}', id: id},
  212. beforeSend: function() {
  213. $('#geo' + id).removeClass('wb-map').addClass('wb-loop icon-spin');
  214. },
  215. success: function(ret) {
  216. if (ret.status === 'success') {
  217. swal.fire({type: 'info', title: ret.message, showConfirmButton: false});
  218. }
  219. else {
  220. swal.fire({title: ret.message, type: 'error'});
  221. }
  222. },
  223. complete: function() {
  224. $('#geo' + id).removeClass('wb-loop icon-spin').addClass('wb-map');
  225. },
  226. });
  227. }
  228. // 删除节点
  229. function delNode(id, name) {
  230. swal.fire({
  231. title: '警告',
  232. text: '确定删除节点 【' + name + '】 ?',
  233. type: 'warning',
  234. showCancelButton: true,
  235. cancelButtonText: '{{trans('home.ticket_close')}}',
  236. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  237. }).then((result) => {
  238. if (result.value) {
  239. $.post('/node/delete', {id: id, _token: '{{csrf_token()}}'}, function(ret) {
  240. if (ret.status === 'success') {
  241. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false}).
  242. then(() => window.location.reload());
  243. }
  244. else {
  245. swal.fire({title: ret.message, type: 'error'}).then(() => window.location.reload());
  246. }
  247. });
  248. }
  249. });
  250. }
  251. // 显示提示
  252. function showIdTips() {
  253. swal.fire({
  254. title: '复制成功',
  255. type: 'success',
  256. timer: 1300,
  257. showConfirmButton: false,
  258. });
  259. }
  260. </script>
  261. @endsection