From 7cd59f75e4024ff5e9f4be6e20bc19f989012f8a Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 10 Jun 2023 05:08:16 -0600 Subject: [PATCH] Update admin dashboard, improve users section --- resources/views/admin/users/home.blade.php | 126 +++++++++++++++++---- 1 file changed, 107 insertions(+), 19 deletions(-) diff --git a/resources/views/admin/users/home.blade.php b/resources/views/admin/users/home.blade.php index cd75062a4..70ab654a1 100644 --- a/resources/views/admin/users/home.blade.php +++ b/resources/views/admin/users/home.blade.php @@ -16,26 +16,33 @@
+
+ +
- {{-- --}} - + - {{-- --}} - + @else - {{-- --}} - +
- + + + ID Username - Status
Count
+ Statuses
- Followers
Count
+ Followers
- Following
Count
+ Following
Actions @@ -46,15 +53,15 @@ @foreach($users as $key => $user) @if($user->status == 'deleted')
+ - - {{$user->id}} + {{$user->id}} + @@ -73,18 +80,18 @@
- - - {{$user->id}} + + + {{$user->id}} + @if($user->account) - + @endif {{$user->username}} @@ -189,5 +196,86 @@ }); }) } + + let app = new Vue({ + el: '#panel', + + data() { + return { + selectedAll: false + } + }, + + watch: { + selectedAll(val) { + if(val) { + if(document.querySelectorAll('.action-check').length == 0) { + this.selectedAll = false; + return; + } + document.querySelectorAll('.action-check').forEach(v => v.checked = true) + } else { + document.querySelectorAll('.action-check').forEach(v => v.checked = false) + } + } + }, + + methods: { + async deleteSelected() { + let usernames = [...document.querySelectorAll('.action-check:checked')].map(el => el.dataset.username); + let ids = [...document.querySelectorAll('.action-check:checked')].map(el => el.dataset.id); + + swal({ + title: 'Confirm mass deletion', + text: "Are you sure you want to delete the following accounts: \n\n" + usernames.join(" \n"), + icon: 'warning', + dangerMode: true, + buttons: { + cancel: { + text: "Cancel", + value: false, + closeModal: true, + visible: true, + }, + delete: { + text: "Delete", + value: "delete", + className: "btn-danger" + } + } + }) + .then(async (res) => { + if(res !== 'delete') { + swal('Mass delete cancelled', '', 'success'); + } else { + swal({ + title: 'Processing mass deletes', + text: 'Do not close or navigate away from this page while we process this request', + icon: 'warning', + timer: 4000 + }) + + await axios.all(ids.map((acct) => this.deleteAccountById(acct))) + .finally(() => { + swal({ + title: 'Accounts successfully deleted!', + text: 'This page will refresh shortly!', + icon: 'success', + timer: 1000 + }) + setTimeout(() => { + window.location.reload(); + }, 10000) + }) + } + }) + }, + + async deleteAccountById(id) { + await axios.post('/i/admin/users/delete/' + id) + } + } + }); + @endpush