mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-01 18:53:16 +00:00
Update admin instance views
This commit is contained in:
parent
9a7245d12e
commit
cd6b66b8e6
2 changed files with 270 additions and 5 deletions
|
@ -2,11 +2,24 @@
|
||||||
|
|
||||||
@section('section')
|
@section('section')
|
||||||
<div class="title">
|
<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>
|
</div>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
@if($instances->count() == 0)
|
@if($instances->count() == 0 && request()->has('filter') == false)
|
||||||
<div class="alert alert-warning mb-3">
|
<div class="alert alert-warning mb-3">
|
||||||
<p class="lead font-weight-bold mb-0">Warning</p>
|
<p class="lead font-weight-bold mb-0">Warning</p>
|
||||||
<p class="font-weight-lighter mb-0">No instances were found.</p>
|
<p class="font-weight-lighter mb-0">No instances were found.</p>
|
||||||
|
@ -22,14 +35,29 @@
|
||||||
<ul class="list-group">
|
<ul class="list-group">
|
||||||
@foreach($instances as $instance)
|
@foreach($instances as $instance)
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<div class="d-flex justify-content-between">
|
<div class="d-flex justify-content-between align-items-center">
|
||||||
<div>
|
<div>
|
||||||
<p class="h4 font-weight-normal mb-1">
|
<p class="h4 font-weight-normal mb-1">
|
||||||
{{$instance->domain}}
|
{{$instance->domain}}
|
||||||
</p>
|
</p>
|
||||||
<p class="mb-0">
|
<p class="mb-0">
|
||||||
<a class="btn btn-primary btn-sm py-0 font-weight-normal" href="#">Overview</a>
|
<a class="btn btn-outline-primary btn-sm py-0 font-weight-normal" href="{{$instance->getUrl()}}">Overview</a>
|
||||||
<a class="btn btn-secondary btn-sm py-0 font-weight-normal" href="#">Actions</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>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
@ -66,6 +94,130 @@
|
||||||
$('.filesize').each(function(k,v) {
|
$('.filesize').each(function(k,v) {
|
||||||
$(this).text(filesize(v.getAttribute('data-size')))
|
$(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>
|
</script>
|
||||||
@endpush
|
@endpush
|
113
resources/views/admin/instances/show.blade.php
Normal file
113
resources/views/admin/instances/show.blade.php
Normal file
|
@ -0,0 +1,113 @@
|
||||||
|
@extends('admin.partial.template')
|
||||||
|
|
||||||
|
@section('section')
|
||||||
|
<div class="title">
|
||||||
|
<div class="d-flex justify-content-between">
|
||||||
|
<div>
|
||||||
|
<h3 class="font-weight-bold mb-0">Instance Overview</h3>
|
||||||
|
<p class="font-weight-lighter mb-0">domain: {{$instance->domain}}</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<a class="btn btn-outline-primary btn-sm py-1" href="{{route('admin.instances')}}">Back</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<hr>
|
||||||
|
<div class="d-flex justify-content-between">
|
||||||
|
<div>
|
||||||
|
<p class="font-weight-lighter mb-0">unlisted: {{$instance->unlisted ? 'true' : 'false'}}</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p class="font-weight-lighter mb-0">CW media: {{$instance->auto_cw ? 'true' : 'false'}}</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p class="font-weight-lighter mb-0">banned: {{$instance->banned ? 'true' : 'false'}}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<hr>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12 col-md-6">
|
||||||
|
<div class="card mb-3">
|
||||||
|
<div class="card-body text-center">
|
||||||
|
<p class="mb-0 font-weight-lighter display-4">
|
||||||
|
{{$instance->profiles->count()}}
|
||||||
|
</p>
|
||||||
|
<p class="mb-0 text-muted">Profiles</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="card mb-3">
|
||||||
|
<div class="card-body text-center">
|
||||||
|
<p class="mb-0 font-weight-lighter display-4">
|
||||||
|
{{$instance->reports->count()}}
|
||||||
|
</p>
|
||||||
|
<p class="mb-0 text-muted">Reports</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-12 col-md-6">
|
||||||
|
<div class="card mb-3">
|
||||||
|
<div class="card-body text-center">
|
||||||
|
<p class="mb-0 font-weight-lighter display-4">
|
||||||
|
{{$instance->statuses->count()}}
|
||||||
|
</p>
|
||||||
|
<p class="mb-0 text-muted">Statuses</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="card mb-3">
|
||||||
|
<div class="card-body text-center">
|
||||||
|
<p class="mb-0 font-weight-lighter display-4 filesize" data-size="{{$instance->media()->sum('size')}}">
|
||||||
|
0
|
||||||
|
</p>
|
||||||
|
<p class="mb-0 text-muted">Storage Used</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header bg-light h4 font-weight-lighter">
|
||||||
|
Profiles
|
||||||
|
<span class="float-right">
|
||||||
|
<a class="btn btn-outline-secondary btn-sm py-0" href="#">View All</a>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<ul class="list-group list-group-flush">
|
||||||
|
@foreach($instance->profiles()->latest()->take(5)->get() as $profile)
|
||||||
|
<li class="list-group-item">
|
||||||
|
<a class="btn btn-outline-primary btn-block btn-sm" href="{{$profile->url()}}">{{$profile->emailUrl()}}</a>
|
||||||
|
</li>
|
||||||
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header bg-light h4 font-weight-lighter">
|
||||||
|
Statuses
|
||||||
|
<span class="float-right">
|
||||||
|
<a class="btn btn-outline-secondary btn-sm py-0" href="#">View All</a>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<ul class="list-group list-group-flush">
|
||||||
|
@foreach($instance->statuses()->latest()->take(5)->get() as $status)
|
||||||
|
<li class="list-group-item">
|
||||||
|
<a class="btn btn-outline-primary btn-block btn-sm" href="{{$status->url()}}">Status ID: {{$status->id}}</a>
|
||||||
|
</li>
|
||||||
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@push('scripts')
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('.filesize').each(function(k,v) {
|
||||||
|
$(this).text(filesize(v.getAttribute('data-size')))
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@endpush
|
Loading…
Reference in a new issue