|
@@ -2,11 +2,24 @@
|
|
|
|
|
|
@section('section')
|
|
|
<div class="title">
|
|
|
- <h3 class="font-weight-bold">Instances</h3>
|
|
|
+ <h3 class="font-weight-bold d-inline-block">Instances</h3>
|
|
|
+ <span class="float-right">
|
|
|
+ <div class="dropdown">
|
|
|
+ <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">
|
|
|
+ <i class="fas fa-filter"></i>
|
|
|
+ </button>
|
|
|
+ <div class="dropdown-menu dropdown-menu-right" aria-labelledby="filterDropdown">
|
|
|
+ <a class="dropdown-item font-weight-light" href="{{route('admin.instances')}}?filter=unlisted">Show only Unlisted</a>
|
|
|
+ <a class="dropdown-item font-weight-light" href="{{route('admin.instances')}}?filter=autocw">Show only Auto CW</a>
|
|
|
+ <a class="dropdown-item font-weight-light" href="{{route('admin.instances')}}?filter=banned">Show only Banned</a>
|
|
|
+ <a class="dropdown-item font-weight-light" href="{{route('admin.instances')}}">Show all</a>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </span>
|
|
|
</div>
|
|
|
|
|
|
<hr>
|
|
|
-@if($instances->count() == 0)
|
|
|
+@if($instances->count() == 0 && request()->has('filter') == false)
|
|
|
<div class="alert alert-warning mb-3">
|
|
|
<p class="lead font-weight-bold mb-0">Warning</p>
|
|
|
<p class="font-weight-lighter mb-0">No instances were found.</p>
|
|
@@ -22,14 +35,29 @@
|
|
|
<ul class="list-group">
|
|
|
@foreach($instances as $instance)
|
|
|
<li class="list-group-item">
|
|
|
- <div class="d-flex justify-content-between">
|
|
|
+ <div class="d-flex justify-content-between align-items-center">
|
|
|
<div>
|
|
|
<p class="h4 font-weight-normal mb-1">
|
|
|
{{$instance->domain}}
|
|
|
</p>
|
|
|
<p class="mb-0">
|
|
|
- <a class="btn btn-primary btn-sm py-0 font-weight-normal" href="#">Overview</a>
|
|
|
- <a class="btn btn-secondary btn-sm py-0 font-weight-normal" href="#">Actions</a>
|
|
|
+ <a class="btn btn-outline-primary btn-sm py-0 font-weight-normal" href="{{$instance->getUrl()}}">Overview</a>
|
|
|
+ <button class="btn btn-outline-secondary btn-sm py-0 font-weight-normal btn-action mr-3"
|
|
|
+ data-instance-id="{{$instance->id}}"
|
|
|
+ data-instance-domain="{{$instance->domain}}"
|
|
|
+ data-instance-unlisted="{{$instance->unlisted}}"
|
|
|
+ data-instance-autocw="{{$instance->auto_cw}}"
|
|
|
+ data-instance-banned="{{$instance->banned}}"
|
|
|
+ >Actions</button>
|
|
|
+ @if($instance->unlisted)
|
|
|
+ <i class="fas fa-minus-circle text-danger" data-toggle="tooltip" title="Unlisted from timelines"></i>
|
|
|
+ @endif
|
|
|
+ @if($instance->auto_cw)
|
|
|
+ <i class="fas fa-eye-slash text-danger" data-toggle="tooltip" title="CW applied to all media"></i>
|
|
|
+ @endif
|
|
|
+ @if($instance->banned)
|
|
|
+ <i class="fas fa-shield-alt text-danger" data-toggle="tooltip" title="Instance is banned"></i>
|
|
|
+ @endif
|
|
|
</p>
|
|
|
</div>
|
|
|
<div>
|
|
@@ -66,6 +94,130 @@
|
|
|
$('.filesize').each(function(k,v) {
|
|
|
$(this).text(filesize(v.getAttribute('data-size')))
|
|
|
});
|
|
|
+
|
|
|
+ $('.btn-action').on('click', function(e) {
|
|
|
+ let id = this.getAttribute('data-instance-id');
|
|
|
+ let instanceDomain = this.getAttribute('data-instance-domain');
|
|
|
+ let text = 'Domain: ' + instanceDomain;
|
|
|
+ let unlisted = this.getAttribute('data-instance-unlisted');
|
|
|
+ let autocw = this.getAttribute('data-instance-autocw');
|
|
|
+ let banned = this.getAttribute('data-instance-banned');
|
|
|
+ swal({
|
|
|
+ title: 'Instance Actions',
|
|
|
+ text: text,
|
|
|
+ icon: 'warning',
|
|
|
+ buttons: {
|
|
|
+ unlist: {
|
|
|
+ text: unlisted == 0 ? "Unlist" : "Re-list",
|
|
|
+ className: "bg-warning",
|
|
|
+ value: "unlisted",
|
|
|
+ },
|
|
|
+ cw: {
|
|
|
+ text: autocw == 0 ? "CW Media" : "Remove AutoCW",
|
|
|
+ text: autocw == 0 ? "CW Media" : "Remove AutoCW",
|
|
|
+ className: "bg-warning",
|
|
|
+ value: "autocw",
|
|
|
+ },
|
|
|
+ ban: {
|
|
|
+ text: banned == 0 ? "Ban" : "Unban",
|
|
|
+ className: "bg-danger",
|
|
|
+ value: "ban",
|
|
|
+ },
|
|
|
+ },
|
|
|
+ })
|
|
|
+ .then((value) => {
|
|
|
+ switch (value) {
|
|
|
+ case "unlisted":
|
|
|
+ swal({
|
|
|
+ title: "Are you sure?",
|
|
|
+ text: unlisted == 0 ?
|
|
|
+ "Are you sure you want to unlist " + instanceDomain + " ?" :
|
|
|
+ "Are you sure you want to remove the unlisted rule of " + instanceDomain + " ?",
|
|
|
+ icon: "warning",
|
|
|
+ buttons: true,
|
|
|
+ dangerMode: true,
|
|
|
+ })
|
|
|
+ .then((unlist) => {
|
|
|
+ if (unlist) {
|
|
|
+ axios.post('/i/admin/instances/edit/' + id, {
|
|
|
+ action: 'unlist'
|
|
|
+ }).then((res) => {
|
|
|
+ swal("Domain action was successful! The page will now refresh.", {
|
|
|
+ icon: "success",
|
|
|
+ });
|
|
|
+ setTimeout(function() {
|
|
|
+ window.location.href = window.location.href;
|
|
|
+ }, 5000);
|
|
|
+ }).catch((err) => {
|
|
|
+ swal("Something went wrong!", "Please try again later.", "error");
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ swal("Action Cancelled", "You successfully cancelled this action.", "error");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ case "autocw":
|
|
|
+ swal({
|
|
|
+ title: "Are you sure?",
|
|
|
+ text: autocw == 0 ?
|
|
|
+ "Are you sure you want to auto CW all media from " + instanceDomain + " ?" :
|
|
|
+ "Are you sure you want to remove the auto cw rule for " + instanceDomain + " ?",
|
|
|
+ icon: "warning",
|
|
|
+ buttons: true,
|
|
|
+ dangerMode: true,
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ if (res) {
|
|
|
+ axios.post('/i/admin/instances/edit/' + id, {
|
|
|
+ action: 'autocw'
|
|
|
+ }).then((res) => {
|
|
|
+ swal("Domain action was successful! The page will now refresh.", {
|
|
|
+ icon: "success",
|
|
|
+ });
|
|
|
+ setTimeout(function() {
|
|
|
+ window.location.href = window.location.href;
|
|
|
+ }, 5000);
|
|
|
+ }).catch((err) => {
|
|
|
+ swal("Something went wrong!", "Please try again later.", "error");
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ swal("Action Cancelled", "You successfully cancelled this action.", "error");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ case "ban":
|
|
|
+ swal({
|
|
|
+ title: "Are you sure?",
|
|
|
+ text: autocw == 0 ?
|
|
|
+ "Are you sure you want to ban " + instanceDomain + " ?" :
|
|
|
+ "Are you sure you want unban " + instanceDomain + " ?",
|
|
|
+ icon: "warning",
|
|
|
+ buttons: true,
|
|
|
+ dangerMode: true,
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ if (res) {
|
|
|
+ axios.post('/i/admin/instances/edit/' + id, {
|
|
|
+ action: 'ban'
|
|
|
+ }).then((res) => {
|
|
|
+ swal("Domain action was successful! The page will now refresh.", {
|
|
|
+ icon: "success",
|
|
|
+ });
|
|
|
+ setTimeout(function() {
|
|
|
+ window.location.href = window.location.href;
|
|
|
+ }, 5000);
|
|
|
+ }).catch((err) => {
|
|
|
+ swal("Something went wrong!", "Please try again later.", "error");
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ swal("Action Cancelled", "You successfully cancelled this action.", "error");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ break;
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ })
|
|
|
});
|
|
|
</script>
|
|
|
@endpush
|