home.blade.php 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. @extends('admin.partial.template-full')
  2. @section('section')
  3. <div class="title">
  4. <h3 class="font-weight-bold d-inline-block">Instances</h3>
  5. <span class="float-right">
  6. <div class="dropdown">
  7. <button class="btn btn-light btn-sm dropdown-toggle font-weight-bold" type="button" id="filterDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  8. <i class="fas fa-filter"></i>
  9. </button>
  10. <div class="dropdown-menu dropdown-menu-right" aria-labelledby="filterDropdown">
  11. <a class="dropdown-item font-weight-light" href="{{route('admin.instances')}}?filter=unlisted">Show only Unlisted</a>
  12. <a class="dropdown-item font-weight-light" href="{{route('admin.instances')}}?filter=autocw">Show only Auto CW</a>
  13. <a class="dropdown-item font-weight-light" href="{{route('admin.instances')}}?filter=banned">Show only Banned</a>
  14. <a class="dropdown-item font-weight-light" href="{{route('admin.instances')}}">Show all</a>
  15. <div class="dropdown-divider"></div>
  16. <form class="" method="post">
  17. @csrf
  18. <button type="submit" class="btn btn-primary py-1 font-weight-bold btn-sm btn-block">Run Scan</button>
  19. </form>
  20. </div>
  21. </div>
  22. </span>
  23. </div>
  24. <hr>
  25. @if($instances->count() == 0 && request()->has('filter') == false)
  26. <div class="alert alert-warning mb-3">
  27. <p class="lead font-weight-bold mb-0">Warning</p>
  28. <p class="font-weight-lighter mb-0">No instances were found.</p>
  29. </div>
  30. <p class="font-weight-lighter">Do you want to scan and populate instances from Profiles and Statuses?</p>
  31. <p>
  32. <form method="post">
  33. @csrf
  34. <button type="submit" class="btn btn-primary py-1 font-weight-bold">Run Scan</button>
  35. </form>
  36. </p>
  37. @else
  38. <ul class="list-group">
  39. @foreach($instances as $instance)
  40. <li class="list-group-item">
  41. <div class="d-flex justify-content-between align-items-center">
  42. <div>
  43. <p class="h4 font-weight-normal mb-1">
  44. {{$instance->domain}}
  45. </p>
  46. <p class="mb-0">
  47. <a class="btn btn-outline-primary btn-sm py-0 font-weight-normal" href="{{$instance->getUrl()}}">Overview</a>
  48. <button class="btn btn-outline-secondary btn-sm py-0 font-weight-normal btn-action mr-3"
  49. data-instance-id="{{$instance->id}}"
  50. data-instance-domain="{{$instance->domain}}"
  51. data-instance-unlisted="{{$instance->unlisted}}"
  52. data-instance-autocw="{{$instance->auto_cw}}"
  53. data-instance-banned="{{$instance->banned}}"
  54. >Actions</button>
  55. @if($instance->unlisted)
  56. <i class="fas fa-minus-circle text-danger" data-toggle="tooltip" title="Unlisted from timelines"></i>
  57. @endif
  58. @if($instance->auto_cw)
  59. <i class="fas fa-eye-slash text-danger" data-toggle="tooltip" title="CW applied to all media"></i>
  60. @endif
  61. @if($instance->banned)
  62. <i class="fas fa-shield-alt text-danger" data-toggle="tooltip" title="Instance is banned"></i>
  63. @endif
  64. </p>
  65. </div>
  66. <div>
  67. <div class="d-inline-block pr-4">
  68. <p class="h4 font-weight-light text-center">{{$instance->profiles()->count()}}</p>
  69. <p class="mb-0 small font-weight-normal text-muted">Profiles</p>
  70. </div>
  71. <div class="d-inline-block pr-4">
  72. <p class="h4 font-weight-light text-center">{{$instance->statuses()->count()}}</p>
  73. <p class="mb-0 small font-weight-normal text-muted">Statuses</p>
  74. </div>
  75. <div class="d-inline-block pr-4">
  76. <p class="h4 font-weight-light text-center text-muted">{{$instance->reported()->count()}}</p>
  77. <p class="mb-0 small font-weight-normal text-muted">Reports</p>
  78. </div>
  79. <div class="d-inline-block">
  80. <p class="h4 font-weight-light text-center text-muted filesize" data-size="{{$instance->media()->sum('size')}}">0</p>
  81. <p class="mb-0 small font-weight-normal text-muted">Storage Used</p>
  82. </div>
  83. </div>
  84. </div>
  85. </li>
  86. @endforeach
  87. </ul>
  88. <div class="d-flex justify-content-center mt-5 small">
  89. {{$instances->links()}}
  90. </div>
  91. @endif
  92. @endsection
  93. @push('scripts')
  94. <script type="text/javascript">
  95. $(document).ready(function() {
  96. $('.filesize').each(function(k,v) {
  97. $(this).text(filesize(v.getAttribute('data-size')))
  98. });
  99. $('.btn-action').on('click', function(e) {
  100. let id = this.getAttribute('data-instance-id');
  101. let instanceDomain = this.getAttribute('data-instance-domain');
  102. let text = 'Domain: ' + instanceDomain;
  103. let unlisted = this.getAttribute('data-instance-unlisted');
  104. let autocw = this.getAttribute('data-instance-autocw');
  105. let banned = this.getAttribute('data-instance-banned');
  106. swal({
  107. title: 'Instance Actions',
  108. text: text,
  109. icon: 'warning',
  110. buttons: {
  111. unlist: {
  112. text: unlisted == 0 ? "Unlist" : "Re-list",
  113. className: "bg-warning",
  114. value: "unlisted",
  115. },
  116. cw: {
  117. text: autocw == 0 ? "CW Media" : "Remove AutoCW",
  118. className: "bg-warning",
  119. value: "autocw",
  120. },
  121. ban: {
  122. text: banned == 0 ? "Ban" : "Unban",
  123. className: "bg-danger",
  124. value: "ban",
  125. },
  126. },
  127. })
  128. .then((value) => {
  129. switch (value) {
  130. case "unlisted":
  131. swal({
  132. title: "Are you sure?",
  133. text: unlisted == 0 ?
  134. "Are you sure you want to unlist " + instanceDomain + " ?" :
  135. "Are you sure you want to remove the unlisted rule of " + instanceDomain + " ?",
  136. icon: "warning",
  137. buttons: true,
  138. dangerMode: true,
  139. })
  140. .then((unlist) => {
  141. if (unlist) {
  142. axios.post('/i/admin/instances/edit/' + id, {
  143. action: 'unlist'
  144. }).then((res) => {
  145. swal("Domain action was successful! The page will now refresh.", {
  146. icon: "success",
  147. });
  148. setTimeout(function() {
  149. window.location.href = window.location.href;
  150. }, 5000);
  151. }).catch((err) => {
  152. swal("Something went wrong!", "Please try again later.", "error");
  153. })
  154. } else {
  155. swal("Action Cancelled", "You successfully cancelled this action.", "error");
  156. }
  157. });
  158. break;
  159. case "autocw":
  160. swal({
  161. title: "Are you sure?",
  162. text: autocw == 0 ?
  163. "Are you sure you want to auto CW all media from " + instanceDomain + " ?" :
  164. "Are you sure you want to remove the auto cw rule for " + instanceDomain + " ?",
  165. icon: "warning",
  166. buttons: true,
  167. dangerMode: true,
  168. })
  169. .then((res) => {
  170. if (res) {
  171. axios.post('/i/admin/instances/edit/' + id, {
  172. action: 'autocw'
  173. }).then((res) => {
  174. swal("Domain action was successful! The page will now refresh.", {
  175. icon: "success",
  176. });
  177. setTimeout(function() {
  178. window.location.href = window.location.href;
  179. }, 5000);
  180. }).catch((err) => {
  181. swal("Something went wrong!", "Please try again later.", "error");
  182. })
  183. } else {
  184. swal("Action Cancelled", "You successfully cancelled this action.", "error");
  185. }
  186. });
  187. break;
  188. case "ban":
  189. swal({
  190. title: "Are you sure?",
  191. text: autocw == 0 ?
  192. "Are you sure you want to ban " + instanceDomain + " ?" :
  193. "Are you sure you want unban " + instanceDomain + " ?",
  194. icon: "warning",
  195. buttons: true,
  196. dangerMode: true,
  197. })
  198. .then((res) => {
  199. if (res) {
  200. axios.post('/i/admin/instances/edit/' + id, {
  201. action: 'ban'
  202. }).then((res) => {
  203. swal("Domain action was successful! The page will now refresh.", {
  204. icon: "success",
  205. });
  206. setTimeout(function() {
  207. window.location.href = window.location.href;
  208. }, 5000);
  209. }).catch((err) => {
  210. swal("Something went wrong!", "Please try again later.", "error");
  211. })
  212. } else {
  213. swal("Action Cancelled", "You successfully cancelled this action.", "error");
  214. }
  215. });
  216. break;
  217. }
  218. });
  219. })
  220. });
  221. </script>
  222. @endpush