blocked-instances.blade.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. @extends('settings.template')
  2. @section('section')
  3. <div class="title">
  4. <h3 class="font-weight-bold">Blocked Instances</h3>
  5. </div>
  6. <hr>
  7. <div class="form-group pb-1">
  8. <p>
  9. <a class="btn btn-outline-secondary py-0 font-weight-bold" href="{{route('settings.privacy.muted-users')}}">Muted Users</a>
  10. <a class="btn btn-outline-secondary py-0 font-weight-bold" href="{{route('settings.privacy.blocked-users')}}">Blocked Users</a>
  11. <a class="btn btn-outline-secondary py-0 font-weight-bold" href="{{route('settings.privacy.blocked-keywords')}}">Blocked keywords</a>
  12. <a class="btn btn-outline-primary py-0 font-weight-bold" href="{{route('settings.privacy.blocked-instances')}}">Blocked instances</a>
  13. </p>
  14. </div>
  15. @if($filters->count() > 0)
  16. <ul class="list-group list-group-flush">
  17. @foreach($filters as $filter)
  18. <li class="list-group-item">
  19. <div class="d-flex justify-content-between align-items-center font-weight-bold">
  20. <span>
  21. <span class="pr-5">{{$filter->id}}</span>
  22. <span>{{$filter->instance->domain}}</span>
  23. </span>
  24. <span class="btn-group">
  25. <form action="{{route('settings.privacy.blocked-instances.unblock')}}" method="POST">
  26. @csrf
  27. <input type="hidden" name="id" value="{{$filter->id}}">
  28. <button type="submit" class="btn btn-outline-secondary btn-sm px-3 font-weight-bold">Unblock</button>
  29. </form>
  30. </span>
  31. </div>
  32. </li>
  33. @endforeach
  34. </ul>
  35. <div class="d-flex justify-content-center mt-3 font-weight-bold">
  36. {{$filters->links()}}
  37. </div>
  38. <p>
  39. <button type="button" class="btn btn-primary font-weight-bold px-3 blockInstance">Block Instance</button>
  40. </p>
  41. @else
  42. <p>You can block entire instances, this prevents users on that instance from interacting with your content. To understand how blocking works, <a href="#">read more</a> in the Help Center.</p>
  43. <p class="lead mb-4">You are not blocking any instances. For a list of instances banned by the admin, click <a href="#">here</a>.</p>
  44. <p>
  45. <button type="button" class="btn btn-primary font-weight-bold px-3 blockInstance">Block Instance</button>
  46. </p>
  47. @endif
  48. @endsection
  49. @push('scripts')
  50. <script type="text/javascript">
  51. $(document).ready(function() {
  52. $('.blockInstance').on('click', function() {
  53. swal({
  54. text: 'Add domain to block.',
  55. content: "input",
  56. button: {
  57. text: "Block",
  58. closeModal: false,
  59. },
  60. })
  61. .then(val => {
  62. if (!val) {
  63. swal.stopLoading();
  64. swal.close();
  65. return;
  66. }
  67. let msg = 'The URL you have entered is not valid, please try again.'
  68. try {
  69. let validator = new URL(val);
  70. if(!validator.hostname || validator.protocol != 'https:') {
  71. swal.stopLoading();
  72. swal.close();
  73. swal('Invalid URL', msg, 'error');
  74. return;
  75. }
  76. axios.post(window.location.href, {
  77. domain: validator.href
  78. }).then(res => {
  79. window.location.href = window.location.href;
  80. }).catch(err => {
  81. swal.stopLoading();
  82. swal.close();
  83. swal('Invalid URL', msg, 'error');
  84. return;
  85. });
  86. } catch(e) {
  87. swal.stopLoading();
  88. swal.close();
  89. swal('Invalid URL', msg, 'error');
  90. }
  91. })
  92. });
  93. });
  94. </script>
  95. @endpush