index.blade.php 13 KB

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