index.blade.php 13 KB

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