home.blade.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. @extends('settings.template')
  2. @section('section')
  3. <div class="title">
  4. <h3 class="font-weight-bold">Relationships</h3>
  5. </div>
  6. <hr>
  7. <ul class="nav nav-pills">
  8. <li class="nav-item">
  9. <a class="nav-link font-weight-bold {{!request()->has('mode') || $mode == 'followers' ? 'active' : ''}}" href="?mode=followers&page=1">Followers</a>
  10. </li>
  11. <li class="nav-item">
  12. <a class="nav-link font-weight-bold {{$mode == 'following' ? 'active' : ''}}" href="?mode=following&page=1">Following</a>
  13. </li>
  14. <li class="nav-item">
  15. <a class="nav-link font-weight-bold {{$mode == 'hashtags' ? 'active' : ''}}" href="?mode=hashtags&page=1">Hashtags</a>
  16. </li>
  17. </ul>
  18. <hr>
  19. @if(empty($data))
  20. <p class="text-center lead pt-5 mt-5">You are not {{$mode == 'hashtags' ? 'following any hashtags.' : ($mode == 'following' ? 'following anyone.' : 'followed by anyone.')}}</p>
  21. @else
  22. <div class="table-responsive">
  23. <table class="table table-bordered table-hover">
  24. @if($mode == 'hashtags')
  25. <thead>
  26. <tr>
  27. {{-- <th scope="col" class="pt-0 pb-1 mt-0">
  28. <input type="checkbox" name="check" class="form-control check-all">
  29. </th> --}}
  30. <th scope="col">Hashtag</th>
  31. <th scope="col">Action</th>
  32. </tr>
  33. </thead>
  34. <tbody>
  35. @foreach($data as $hashtag)
  36. <tr>
  37. <td class="font-weight-bold">
  38. <a href="{{$hashtag->hashtag->url('?src=relset')}}" class="text-decoration-none text-dark">
  39. <p class="mb-0 pb-0">#{{$hashtag->hashtag->name}}</p>
  40. </a>
  41. </td>
  42. <td class="text-center">
  43. <a class="btn btn-outline-danger btn-sm py-0 action-btn" href="#" data-id="{{$hashtag->hashtag->name}}" data-action="unfollowhashtag">Unfollow</a>
  44. </td>
  45. </tr>
  46. @endforeach
  47. @else
  48. <thead>
  49. <tr>
  50. {{-- <th scope="col" class="pt-0 pb-1 mt-0">
  51. <input type="checkbox" name="check" class="form-control check-all">
  52. </th> --}}
  53. <th scope="col">Username</th>
  54. <th scope="col">Action</th>
  55. </tr>
  56. </thead>
  57. <tbody>
  58. @foreach($data as $follower)
  59. <tr>
  60. {{-- <th scope="row" class="pb-0 pt-1 my-0">
  61. <input type="checkbox" class="form-control mr-1 check-row">
  62. </th> --}}
  63. <td class="font-weight-bold">
  64. <a href="{{$follower->url()}}" class="text-decoration-none text-dark">
  65. <p class="mb-0 pb-0 text-truncate" title="{{$follower->username}}">{{$follower->username}}</p>
  66. </a>
  67. </td>
  68. @if($mode == 'following')
  69. <td class="text-center">
  70. <a class="btn btn-outline-danger btn-sm py-0 action-btn" href="#" data-id="{{$follower->id}}" data-action="unfollow">Unfollow</a>
  71. </td>
  72. @else
  73. <td class="text-center">
  74. <a class="btn btn-outline-primary btn-sm py-0 action-btn" href="#" data-id="{{$follower->id}}" data-action="mute">Mute</a>
  75. <a class="btn btn-outline-danger btn-sm py-0 action-btn" href="#" data-id="{{$follower->id}}" data-action="block">Block</a>
  76. </td>
  77. @endif
  78. </tr>
  79. @endforeach
  80. @endif
  81. </tbody>
  82. </table>
  83. </div>
  84. <div class="d-flex justify-content-center">{{$data->appends(['mode' => $mode])->links()}}</div>
  85. @endif
  86. @endsection
  87. @push('styles')
  88. <style type="text/css">
  89. .table-hover tbody tr:hover {
  90. color: #718096;
  91. background-color: #F7FAFC;
  92. }
  93. </style>
  94. @endpush
  95. @push('scripts')
  96. <script type="text/javascript">
  97. $(document).ready(() => {
  98. $('.action-btn').on('click', e => {
  99. e.preventDefault();
  100. let action = e.target.getAttribute('data-action');
  101. let id = e.target.getAttribute('data-id');
  102. switch(action) {
  103. case 'mute':
  104. axios.post('/i/mute', {
  105. type: 'user',
  106. item: id
  107. }).then(res => {
  108. swal(
  109. 'Mute Successful',
  110. 'You have successfully muted that user',
  111. 'success'
  112. );
  113. });
  114. break;
  115. case 'block':
  116. axios.post('/i/block', {
  117. type: 'user',
  118. item: id
  119. }).then(res => {
  120. swal(
  121. 'Block Successful',
  122. 'You have successfully blocked that user',
  123. 'success'
  124. );
  125. });
  126. break;
  127. case 'unfollow':
  128. axios.post('/api/v1/accounts/' + id + '/unfollow')
  129. .then(res => {
  130. swal(
  131. 'Unfollow Successful',
  132. 'You have successfully unfollowed that user',
  133. 'success'
  134. );
  135. })
  136. .catch(err => {
  137. swal(
  138. 'Error',
  139. 'An error occured when attempting to unfollow this user',
  140. 'error'
  141. );
  142. });
  143. break;
  144. case 'unfollowhashtag':
  145. axios.post('/api/local/discover/tag/subscribe', {
  146. name: id
  147. }).then(res => {
  148. swal(
  149. 'Unfollow Successful',
  150. 'You have successfully unfollowed that hashtag',
  151. 'success'
  152. );
  153. });
  154. }
  155. setTimeout(function() {
  156. window.location.href = window.location.href;
  157. }, 3000);
  158. });
  159. $('.check-all').on('click', e => {
  160. })
  161. });
  162. </script>
  163. @endpush