index.blade.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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. <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. @can('admin.node.edit')
  83. <a class="dropdown-item" href="{{route('admin.node.edit', [$node->id, 'page' => Request::query('page', 1)])}}" role="menuitem">
  84. <i class="icon wb-edit" aria-hidden="true"></i> 编辑
  85. </a>
  86. @endcan
  87. @can('admin.node.destroy')
  88. <a class="dropdown-item" href="javascript:delNode('{{$node->id}}', '{{$node->name}}')" role="menuitem">
  89. <i class="icon wb-trash" aria-hidden="true"></i> 删除
  90. </a>
  91. @endcan
  92. @can('admin.node.monitor')
  93. <a class="dropdown-item" href="{{route('admin.node.monitor', $node)}}" role="menuitem">
  94. <i class="icon wb-stats-bars" aria-hidden="true"></i> 流量统计
  95. </a>
  96. @endcan
  97. <hr/>
  98. @can('admin.node.geo')
  99. <a class="dropdown-item" href="javascript:refreshGeo('{{$node->id}}')" role="menuitem">
  100. <i id="geo{{$node->id}}" class="icon wb-map" aria-hidden="true"></i> 刷新地理
  101. </a>
  102. @endcan
  103. @can('admin.node.ping')
  104. <a class="dropdown-item" href="javascript:pingNode('{{$node->id}}')" role="menuitem">
  105. <i id="ping{{$node->id}}" class="icon wb-order" aria-hidden="true"></i> 检测延迟
  106. </a>
  107. @endcan
  108. @can('admin.node.check')
  109. <a class="dropdown-item" href="javascript:checkNode('{{$node->id}}')" role="menuitem">
  110. <i id="node{{$node->id}}" class="icon wb-signal" aria-hidden="true"></i> 连通性检测
  111. </a>
  112. @endcan
  113. @if($node->type === 4)
  114. @can('admin.node.reload')
  115. <hr/>
  116. <a class="dropdown-item" href="javascript:reload('{{$node->id}}')" role="menuitem">
  117. <i id="reload{{$node->id}}" class="icon wb-reload" aria-hidden="true"></i> 重载后端
  118. </a>
  119. @endcan
  120. @endif
  121. </div>
  122. </div>
  123. @endcan
  124. </td>
  125. </tr>
  126. @endforeach
  127. </tbody>
  128. </table>
  129. </div>
  130. <div class="panel-footer">
  131. <div class="row">
  132. <div class="col-sm-4">
  133. 共 <code>{{$nodeList->total()}}</code> 条线路
  134. </div>
  135. <div class="col-sm-8">
  136. <nav class="Page navigation float-right">
  137. {{$nodeList->links()}}
  138. </nav>
  139. </div>
  140. </div>
  141. </div>
  142. </div>
  143. </div>
  144. @endsection
  145. @section('javascript')
  146. <script src="/assets/global/vendor/bootstrap-table/bootstrap-table.min.js"></script>
  147. <script src="/assets/global/vendor/bootstrap-table/extensions/mobile/bootstrap-table-mobile.min.js"></script>
  148. <script>
  149. @can('admin.node.check')
  150. // 节点连通性测试
  151. function checkNode(id) {
  152. $.ajax({
  153. method: 'POST',
  154. url: '{{route('admin.node.check', '')}}/' + id,
  155. data: {_token: '{{csrf_token()}}'},
  156. beforeSend: function() {
  157. $('#node' + id).removeClass('wb-signal').addClass('wb-loop icon-spin');
  158. },
  159. success: function(ret) {
  160. if (ret.status === 'success') {
  161. let str = '';
  162. for (let i in ret.message) {
  163. str += '<tr><td>' + i + '</td><td>' + ret.message[i][0] + '</td><td>' + ret.message[i][1] + '</td></tr>';
  164. }
  165. swal.fire({
  166. title: ret.title,
  167. icon: 'info',
  168. html: '<table class="my-20"><thead class="thead-default"><tr><th> IP </th><th> ICMP </th> <th> TCP </th></thead><tbody>' + str + '</tbody></table>',
  169. showConfirmButton: false,
  170. });
  171. } else {
  172. swal.fire({title: ret.title, text: ret.message, icon: 'error'});
  173. }
  174. },
  175. complete: function() {
  176. $('#node' + id).removeClass('wb-loop icon-spin').addClass('wb-signal');
  177. },
  178. });
  179. }
  180. @endcan
  181. @can('admin.node.ping')
  182. // Ping节点获取延迟
  183. function pingNode(id) {
  184. $.ajax({
  185. method: 'POST',
  186. url: '{{route('admin.node.ping', '')}}/' + id,
  187. data: {_token: '{{csrf_token()}}'},
  188. beforeSend: function() {
  189. $('#ping' + id).removeClass('wb-order').addClass('wb-loop icon-spin');
  190. },
  191. success: function(ret) {
  192. if (ret.status === 'success') {
  193. swal.fire({
  194. icon: 'info',
  195. html: ret.message,
  196. showConfirmButton: false,
  197. });
  198. } else {
  199. swal.fire({title: ret.message, icon: 'error'});
  200. }
  201. },
  202. complete: function() {
  203. $('#ping' + id).removeClass('wb-loop icon-spin').addClass('wb-order');
  204. },
  205. });
  206. }
  207. @endcan
  208. @can('admin.node.reload')
  209. // 发送节点重载请求
  210. function reload(id) {
  211. swal.fire({
  212. text: '确定重载节点?',
  213. icon: 'question',
  214. showCancelButton: true,
  215. cancelButtonText: '{{trans('common.close')}}',
  216. confirmButtonText: '{{trans('common.confirm')}}',
  217. }).then((result) => {
  218. if (result.value) {
  219. $.ajax({
  220. method: 'POST',
  221. url: '{{route('admin.node.reload', '')}}/' + id,
  222. data: {_token: '{{csrf_token()}}'},
  223. beforeSend: function() {
  224. $('#reload' + id).removeClass('wb-reload').addClass('wb-loop icon-spin');
  225. },
  226. success: function(ret) {
  227. if (ret.status === 'success') {
  228. swal.fire({title: ret.message, icon: 'info', showConfirmButton: false});
  229. } else {
  230. swal.fire({title: ret.message, icon: 'error'});
  231. }
  232. },
  233. complete: function() {
  234. $('#reload' + id).removeClass('wb-loop icon-spin').addClass('wb-reload');
  235. },
  236. });
  237. }
  238. });
  239. }
  240. @endcan
  241. @can('admin.node.geo')
  242. // 刷新节点地理信息
  243. function refreshGeo(id = 0) {
  244. $.ajax({
  245. method: 'GET',
  246. url: '{{route('admin.node.geo', '')}}/' + id,
  247. data: {_token: '{{csrf_token()}}'},
  248. beforeSend: function() {
  249. $('#geo' + id).removeClass('wb-map').addClass('wb-loop icon-spin');
  250. },
  251. success: function(ret) {
  252. if (ret.status === 'success') {
  253. swal.fire({title: ret.message, icon: 'info', showConfirmButton: false});
  254. } else {
  255. swal.fire({title: ret.message, icon: 'error'});
  256. }
  257. },
  258. complete: function() {
  259. $('#geo' + id).removeClass('wb-loop icon-spin').addClass('wb-map');
  260. },
  261. });
  262. }
  263. @endcan
  264. @can('admin.node.destroy')
  265. // 删除节点
  266. function delNode(id, name) {
  267. swal.fire({
  268. title: '{{trans('common.warning')}}',
  269. text: '确定删除节点 【' + name + '】 ?',
  270. icon: 'warning',
  271. showCancelButton: true,
  272. cancelButtonText: '{{trans('common.close')}}',
  273. confirmButtonText: '{{trans('common.confirm')}}',
  274. }).then((result) => {
  275. if (result.value) {
  276. $.ajax({
  277. method: 'DELETE',
  278. url: '{{route('admin.node.destroy', '')}}/' + id,
  279. data: {_token: '{{csrf_token()}}'},
  280. dataType: 'json',
  281. success: function(ret) {
  282. if (ret.status === 'success') {
  283. swal.fire({title: ret.message, icon: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  284. } else {
  285. swal.fire({title: ret.message, icon: 'error'}).then(() => window.location.reload());
  286. }
  287. },
  288. });
  289. }
  290. });
  291. }
  292. @endcan
  293. </script>
  294. @endsection