index.blade.php 14 KB

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