log.blade.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. @endsection
  5. @section('content')
  6. <div class="page-content container-fluid">
  7. <div class="panel">
  8. <div class="panel-heading">
  9. <h2 class="panel-title">触发记录</h2>
  10. <div class="panel-actions">
  11. <a href="javascript:clearLog();" class="btn btn-outline-primary">
  12. <i class="icon wb-rubber" aria-hidden="true"></i>清空记录
  13. </a>
  14. </div>
  15. </div>
  16. <div class="panel-body">
  17. <div class="form-row">
  18. <div class="form-group col-xxl-1 col-lg-2 col-md-1 col-sm-4">
  19. <input type="number" class="form-control" name="uid" value="{{Request::input('uid')}}" id="uid" placeholder="用户ID"/>
  20. </div>
  21. <div class="form-group col-xxl-2 col-lg-3 col-md-3 col-sm-4">
  22. <input type="text" class="form-control" id="email" name="email"
  23. value="{{Request::input('email')}}" placeholder="用户名"/>
  24. </div>
  25. <div class="form-group col-xxl-1 col-lg-3 col-md-3 col-4">
  26. <select class="form-control" id="node_id" name="node_id" onChange="Search()">
  27. <option value="" @if(Request::input('node_id') == '') selected @endif>节点</option>
  28. @foreach($nodeList as $node)
  29. <option value="{{$node->id}}" @if(Request::input('node_id') == $node->id) selected @endif>{{$node->id . ' - ' . $node->name}}</option>
  30. @endforeach
  31. </select>
  32. </div>
  33. <div class="form-group col-xxl-1 col-lg-3 col-md-3 col-4">
  34. <select class="form-control" id="rule_id" name="rule_id" onChange="Search()">
  35. <option value="" @if(Request::input('rule_id') == '') selected @endif>规则</option>
  36. @foreach($ruleList as $rule)
  37. <option value="{{$rule->id}}" @if(Request::input('rule_id') == $rule->id) selected @endif>{{$rule->name}}</option>
  38. @endforeach
  39. </select>
  40. </div>
  41. <div class="form-group col-xxl-1 col-lg-3 col-md-3 col-4 btn-group">
  42. <button class="btn btn-primary" onclick="Search()">搜 索</button>
  43. <a href="{{route('admin.rule.log')}}" class="btn btn-danger">重 置</a>
  44. </div>
  45. </div>
  46. <table class="text-md-center" data-toggle="table" data-mobile-responsive="true">
  47. <thead class="thead-default">
  48. <tr>
  49. <th> #</th>
  50. <th> 用户ID</th>
  51. <th> 用户名</th>
  52. <th> 节点</th>
  53. <th> 触发规则</th>
  54. <th> 触发原因</th>
  55. <th> 触发时间</th>
  56. </tr>
  57. </thead>
  58. <tbody>
  59. @foreach($ruleLogs as $ruleLog)
  60. <tr>
  61. <td> {{$ruleLog->id}} </td>
  62. <td> {{$ruleLog->user->id ?? '【账号已删除】'}} </td>
  63. <td> {{$ruleLog->user->username ?? '【账号已删除】'}} </td>
  64. <td> {{empty($ruleLog->node) ? '【节点已删除】' : '【节点ID:' . $ruleLog->node_id . '】' . $ruleLog->node->name}} </td>
  65. <td> {{$ruleLog->rule_id ? '⛔ ' . ($ruleLog->rule->name ?? '【规则已删除】') : '✅ 访问非规则允许内容'}} </td>
  66. <td> {{$ruleLog->reason}} </td>
  67. <td> {{$ruleLog->created_at}} </td>
  68. </tr>
  69. @endforeach
  70. </tbody>
  71. </table>
  72. </div>
  73. <div class="panel-footer">
  74. <div class="row">
  75. <div class="col-sm-4">
  76. 共 <code>{{$ruleLogs->total()}}</code> 条记录
  77. </div>
  78. <div class="col-sm-8">
  79. <nav class="Page navigation float-right">
  80. {{$ruleLogs->links()}}
  81. </nav>
  82. </div>
  83. </div>
  84. </div>
  85. </div>
  86. </div>
  87. @endsection
  88. @section('script')
  89. <script src="/assets/global/vendor/bootstrap-table/bootstrap-table.min.js" type="text/javascript"></script>
  90. <script src="/assets/global/vendor/bootstrap-table/extensions/mobile/bootstrap-table-mobile.min.js" type="text/javascript"></script>
  91. <script type="text/javascript">
  92. // 搜索
  93. function Search() {
  94. window.location.href = '{{route('admin.rule.log')}}?uid=' + $('#uid').val() + '&email=' + $('#email').val() +
  95. '&node_id=' + $('#node_id option:selected').val() + '&rule_id=' + $('#rule_id option:selected').val();
  96. }
  97. // 清除所有记录
  98. function clearLog() {
  99. swal.fire({
  100. title: '警告',
  101. text: '确定清空所有记录吗?',
  102. type: 'warning',
  103. showCancelButton: true,
  104. cancelButtonText: '{{trans('home.ticket_close')}}',
  105. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  106. }).then((result) => {
  107. if (result.value) {
  108. $.post("{{route('admin.rule.clear')}}", {_token: '{{csrf_token()}}'}, function(ret) {
  109. if (ret.status === 'success') {
  110. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false}).
  111. then(() => window.location.reload());
  112. }
  113. else {
  114. swal.fire({title: ret.message, type: 'error'});
  115. }
  116. });
  117. }
  118. });
  119. }
  120. </script>
  121. @endsection