index.blade.php 14 KB

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