log.blade.php 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. @extends('admin.table_layouts')
  2. @section('content')
  3. <div class="page-content container-fluid">
  4. <div class="panel">
  5. <div class="panel-heading">
  6. <h2 class="panel-title">{{ trans('admin.logs.rule.title') }}</h2>
  7. @can('admin.rule.clear')
  8. <div class="panel-actions">
  9. <button class="btn btn-outline-primary" onclick="clearLog()">
  10. <i class="icon wb-rubber" aria-hidden="true"></i>{{ trans('admin.logs.rule.clear_all') }}
  11. </button>
  12. </div>
  13. @endcan
  14. </div>
  15. <div class="panel-body">
  16. <form class="form-row">
  17. <div class="form-group col-xxl-1 col-lg-2 col-md-1 col-sm-4">
  18. <input class="form-control" name="user_id" type="number" value="{{ Request::query('user_id') }}"
  19. placeholder="{{ trans('model.user.id') }}" />
  20. </div>
  21. <div class="form-group col-xxl-2 col-lg-3 col-md-3 col-sm-4">
  22. <input class="form-control" name="username" type="text" value="{{ Request::query('username') }}"
  23. placeholder="{{ trans('model.user.username') }}" />
  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" data-plugin="selectpicker" data-style="btn-outline btn-primary"
  27. title="{{ trans('model.node.attribute') }}">
  28. @foreach ($nodes as $node)
  29. <option value="{{ $node->id }}">{{ $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" data-plugin="selectpicker" data-style="btn-outline btn-primary"
  35. title="{{ trans('model.rule.attribute') }}">
  36. @foreach ($rules as $rule)
  37. <option value="{{ $rule->id }}">{{ $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" type="submit">{{ trans('common.search') }}</button>
  43. <a class="btn btn-danger" href="{{ route('admin.rule.log') }}">{{ trans('common.reset') }}</a>
  44. </div>
  45. </form>
  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> UID</th>
  51. <th> {{ trans('model.user.username') }}</th>
  52. <th> {{ trans('model.node.attribute') }}</th>
  53. <th> {{ trans('admin.logs.rule.name') }}</th>
  54. <th> {{ trans('admin.logs.rule.reason') }}</th>
  55. <th> {{ trans('admin.logs.rule.created_at') }}</th>
  56. </tr>
  57. </thead>
  58. <tbody>
  59. @foreach ($ruleLogs as $ruleLog)
  60. <tr>
  61. <td> {{ $ruleLog->id }} </td>
  62. <td> {{ $ruleLog->user->id ?? '【' . trans('common.deleted_item', ['attribute' => trans('common.account')]) . '】' }} </td>
  63. <td> {{ $ruleLog->user->username ?? '【' . trans('common.deleted_item', ['attribute' => trans('common.account')]) . '】' }} </td>
  64. <td> {{ empty($ruleLog->node) ? '【' . trans('common.deleted_item', ['attribute' => trans('model.node.attribute')]) . '】' : '【' . trans('model.node.attribute') . '#: ' . $ruleLog->node_id . '】' . $ruleLog->node->name }}
  65. </td>
  66. <td> {{ $ruleLog->rule_id ? '⛔ ' . ($ruleLog->rule->name ?? '【' . trans('common.deleted_item', ['attribute' => trans('model.rule.attribute')]) . '】') : trans('admin.logs.rule.tag') }}
  67. </td>
  68. <td> {{ $ruleLog->reason }} </td>
  69. <td> {{ $ruleLog->created_at }} </td>
  70. </tr>
  71. @endforeach
  72. </tbody>
  73. </table>
  74. </div>
  75. <div class="panel-footer">
  76. <div class="row">
  77. <div class="col-sm-4">
  78. {!! trans('admin.logs.counts', ['num' => $ruleLogs->total()]) !!}
  79. </div>
  80. <div class="col-sm-8">
  81. <nav class="Page navigation float-right">
  82. {{ $ruleLogs->links() }}
  83. </nav>
  84. </div>
  85. </div>
  86. </div>
  87. </div>
  88. </div>
  89. @endsection
  90. @push('javascript')
  91. <script>
  92. $(document).ready(function() {
  93. $('#node_id').selectpicker('val', @json(Request::query('node_id')));
  94. $('#rule_id').selectpicker('val', @json(Request::query('rule_id')));
  95. });
  96. @can('admin.rule.clear')
  97. // 清除所有记录
  98. function clearLog() {
  99. swal.fire({
  100. title: '{{ trans('common.warning') }}',
  101. text: '{{ trans('admin.logs.rule.clear_confirm') }}',
  102. icon: 'warning',
  103. showCancelButton: true,
  104. cancelButtonText: '{{ trans('common.close') }}',
  105. confirmButtonText: '{{ trans('common.confirm') }}',
  106. }).then((result) => {
  107. if (result.value) {
  108. $.post("{{ route('admin.rule.clear') }}", {
  109. _token: '{{ csrf_token() }}'
  110. }, function(ret) {
  111. if (ret.status === 'success') {
  112. swal.fire({
  113. title: ret.message,
  114. icon: 'success',
  115. timer: 1000,
  116. showConfirmButton: false,
  117. }).then(() => window.location.reload());
  118. } else {
  119. swal.fire({
  120. title: ret.message,
  121. icon: 'error'
  122. });
  123. }
  124. });
  125. }
  126. });
  127. }
  128. @endcan
  129. </script>
  130. @endpush