users.blade.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. @extends('admin.index')
  2. @section('styles')
  3. @parent
  4. <link href="{{ asset('css/admin_users.css') }}" rel="stylesheet">
  5. @endsection
  6. @section('content')
  7. @parent
  8. <div class="container">
  9. <div class="table-users card">
  10. <div class="card-header">
  11. <h4>Администрирование пользователей</h4>
  12. </div>
  13. <table class="table table-striped table-hover">
  14. <thead class="table-dark">
  15. <tr>
  16. <th>action</th>
  17. <th>id</th>
  18. <th>nickname</th>
  19. <th>email</th>
  20. <th>password</th>
  21. <th>role</th>
  22. <th>created</th>
  23. <th>updated</th>
  24. </tr>
  25. </thead>
  26. <tbody>
  27. @foreach ( $users as $user)
  28. <tr>
  29. <td>
  30. {{--<i class="fas fa-check"></i>--}}
  31. <i class="glyphicon glyphicon-remove" title="отклонить" data-status="delete"
  32. style="color: red"></i>
  33. <i class="glyphicon glyphicon-edit" title="редактировать" data-status="edit"></i>
  34. </td>
  35. <td data-id>{{ $user->id }} </td>
  36. <td>{{ $user->nickname }} </td>
  37. <td>{{ $user->email }} </td>
  38. <td> reset</td>
  39. <td>{{ $user->role }} </td>
  40. <td>{{ $user->updated_at->format('F j, Y') }} </td>
  41. <td>{{ $user->created_at->format('F j, Y') }} </td>
  42. </tr>
  43. @endforeach
  44. </table>
  45. </div>
  46. <div class="card-footer" style="height:60px;position:relative;">
  47. <div class="row">
  48. <div class="col-md-offset-1 col-md-10">{{ $users->links() }}</div>
  49. </div>
  50. </div>
  51. </div>
  52. {{----------------- MODAL USER -----------------------------}}
  53. <div id="myModal" class="modal animate" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
  54. aria-hidden="true" data-backdrop="true">
  55. <div class="modal-dialog a-zoomRight" role="document">
  56. <div class="modal-content">
  57. <div class="modal-header">
  58. <h5 class="modal-title" id="exampleModalLabel">Редактирование итемки</h5>
  59. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  60. <span aria-hidden="true">×</span>
  61. </button>
  62. </div>
  63. <div class="modal-body text-center p-lg">
  64. <p style="font-size: 1.2em">Содержимое отсутствует!</p>
  65. </div>
  66. <div class="modal-footer">
  67. <button type="button" class="btn btn-danger" data-action="DELETE" onclick="changeMethod(this)">Удалить
  68. </button>
  69. <button type="button" class="btn btn-primary" data-action="PUT" onclick="changeMethod(this)">Изменить
  70. </button>
  71. <button type="button" class="btn btn-secondary" data-dismiss="modal">Закрыть</button>
  72. </div>
  73. </div>
  74. </div>
  75. </div>
  76. @endsection
  77. @section('scripts')
  78. @parent
  79. <script>
  80. $(function () {
  81. $('i.glyphicon').on('click', function (element) {
  82. let action = $(this).data('status');
  83. if (action === 'delete') {
  84. console.log($(this).closest('tr').find('[data-id]').text());
  85. ajaxUserEditRequest(1);
  86. }
  87. });
  88. });
  89. function ajaxUserEditRequest($id) {
  90. $.ajax({
  91. headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')},
  92. url: '{{ route("admin.users.ajax", ["id"=> '0'])}}' + $id,
  93. type: 'POST',
  94. data: ( '{ "user": ' + $id + ' }' ),
  95. contentType: 'json',
  96. success: function (response) {
  97. $("#myModal .modal-body").html(response);
  98. //console.log(response);
  99. // let item = document.querySelector('#myModal input[name="id"]');
  100. // let title = document.querySelector('#myModal .modal-title');
  101. // title.innerHTML = "Редактирование итемки № <b>" + item.value + "</b>";
  102. }
  103. });
  104. }
  105. function optionShow($element) {
  106. var $id = $element.getAttribute('value')
  107. $.ajax({
  108. headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')},
  109. url: '{{ route("admin.users.ajax", ["id"=> '0'])}}' + $id,
  110. type: 'POST',
  111. data: ( '{ "user": ' + $id + ' }' ),
  112. contentType: 'json',
  113. success: function (response) {
  114. $("#myModal .modal-body").html(response);
  115. let item = document.querySelector('#myModal input[name="id"]');
  116. let title = document.querySelector('#myModal .modal-title');
  117. title.innerHTML = "Редактирование итемки № <b>" + item.value + "</b>";
  118. }
  119. });
  120. $("#myModal").modal('show');
  121. $("#myModal").attr('style', 'margin-top: 5%; transition: all 600ms ease-in-out;');
  122. }
  123. function changeMethod(element) {
  124. let method = $(element).data('action');
  125. $('#item-form').find('[name="_method"]').val(method);
  126. $('#item-form').submit();
  127. }
  128. </script>
  129. @endsection