home.blade.php 5.7 KB

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