2019-04-07 01:25:30 +00:00
@ extends ( 'admin.partial.template-full' )
2018-05-20 21:50:11 +00:00
@ section ( 'section' )
2021-02-23 06:03:49 +00:00
< div class = " title d-flex justify-content-between align-items-center " >
2020-02-20 02:42:49 +00:00
< h3 class = " font-weight-bold " > Users </ h3 >
2021-02-23 06:03:49 +00:00
< form method = " get " >
< input type = " hidden " name = " a " value = " search " >
< div class = " input-group " >
< input class = " form-control " name = " q " placeholder = " Search usernames " value = " { { request()->input('q')}} " >
< div class = " input-group-append " >
< button type = " submit " class = " btn btn-primary " >
< i class = " fas fa-search " ></ i >
</ button >
</ div >
</ div >
</ form >
2020-02-20 02:42:49 +00:00
</ div >
< hr >
2023-06-10 11:08:16 +00:00
< div v - if = " selectedAll " >
< button class = " btn btn-danger font-weight-bold mb-3 " id = " selectedAllInput " @@ click = " deleteSelected " > Delete selected accounts </ button >
</ div >
2020-02-20 02:42:49 +00:00
< div class = " table-responsive " >
< table class = " table " >
< thead class = " bg-light " >
< tr class = " text-center " >
2023-06-10 11:08:16 +00:00
< th scope = " col " class = " border-0 " width = " 1% " >
< div class = " custom-control custom-checkbox account-select-check " >
< input type = " checkbox " class = " custom-control-input " id = " allCheck " v - model = " selectedAll " >
< label class = " custom-control-label " for = " allCheck " ></ label >
</ div >
</ th >
< th scope = " col " class = " border-0 " width = " 5% " >
2020-02-20 02:42:49 +00:00
< span > ID </ span >
</ th >
2023-06-10 09:40:31 +00:00
< th scope = " col " class = " border-0 " width = " 40% " >
2020-02-20 02:42:49 +00:00
< span > Username </ span >
</ th >
2023-06-10 09:40:31 +00:00
< th scope = " col " class = " border-0 " width = " 5% " >
2023-06-10 11:08:16 +00:00
< span > Statuses </ span >
2023-06-10 09:40:31 +00:00
</ th >
< th scope = " col " class = " border-0 " width = " 5% " >
2023-06-10 11:08:16 +00:00
< span > Followers </ span >
2023-06-10 09:40:31 +00:00
</ th >
< th scope = " col " class = " border-0 " width = " 5% " >
2023-06-10 11:08:16 +00:00
< span > Following </ span >
2023-06-10 09:40:31 +00:00
</ th >
2020-02-20 02:42:49 +00:00
< th scope = " col " class = " border-0 " width = " 30% " >
< span > Actions </ span >
</ th >
</ tr >
</ thead >
< tbody >
2023-06-10 09:40:31 +00:00
@ foreach ( $users as $key => $user )
2020-02-20 02:42:49 +00:00
@ if ( $user -> status == 'deleted' )
< tr class = " font-weight-bold text-center user-row " >
2023-06-10 11:08:16 +00:00
< th scope = " row " >
2023-06-10 09:40:31 +00:00
< div class = " custom-control custom-checkbox account-select-check " >
< input type = " checkbox " class = " custom-control-input " disabled >
< label class = " custom-control-label " ></ label >
</ div >
2020-02-20 02:42:49 +00:00
</ th >
2023-06-10 11:08:16 +00:00
< td >
< span class = " text-danger " class = " text-monospace " > {{ $user -> id }} </ span >
</ td >
2020-02-20 02:42:49 +00:00
< td class = " text-left " >
2023-06-10 09:40:31 +00:00
< img src = " /storage/avatars/default.jpg " width = " 20 " height = " 20 " class = " rounded-circle mr-1 " />
2020-02-20 02:42:49 +00:00
< span title = " { { $user -> username } } " data - toggle = " tooltip " data - placement = " bottom " >
< span class = " text-danger " > {{ $user -> username }} </ span >
</ span >
</ td >
2023-06-10 09:40:31 +00:00
< td > 0 </ td >
< td > 0 </ td >
< td > 0 </ td >
2020-02-20 02:42:49 +00:00
< td >
< span class = " font-weight-bold small " >
< span class = " text-danger " > Account Deleted </ span >
</ span >
</ td >
</ tr >
@ else
< tr class = " font-weight-bold text-center user-row " >
2023-06-10 11:08:16 +00:00
< th scope = " row " >
2023-06-10 09:40:31 +00:00
< div class = " custom-control custom-checkbox account-select-check " >
2023-06-10 11:08:16 +00:00
< input type = " checkbox " id = " { { $key } } " class = " custom-control-input action-check " data - id = " { { $user -> id } } " data - username = " { { $user -> username } } " >
< label class = " custom-control-label " for = " { { $key } } " ></ label >
2023-06-10 09:40:31 +00:00
</ div >
2020-02-20 02:42:49 +00:00
</ th >
2023-06-10 11:08:16 +00:00
< td >
< span class = " text-monospace " > {{ $user -> id }} </ span >
</ td >
< td class = " d-flex align-items-center " >
2023-06-10 09:40:31 +00:00
@ if ( $user -> account )
2023-06-10 11:08:16 +00:00
< img src = " { { $user -> account [ 'avatar' ] } } " width = " 20 " height = " 20 " class = " rounded-circle mr-2 " onerror = " this.src='/storage/avatars/default.jpg';this.onerror=null; " />
2023-06-10 09:40:31 +00:00
@ endif
2020-02-20 02:42:49 +00:00
< span title = " { { $user -> username } } " data - toggle = " tooltip " data - placement = " bottom " >
< span > {{ $user -> username }} </ span >
@ if ( $user -> is_admin )
< i class = " text-danger fas fa-certificate " title = " Admin " ></ i >
@ endif
</ span >
</ td >
2023-06-10 09:40:31 +00:00
< td >
@ if ( $user -> account )
{{ $user -> account [ 'statuses_count' ]}}
@ else
0
@ endif
</ td >
< td >
@ if ( $user -> account )
{{ $user -> account [ 'followers_count' ]}}
@ else
0
@ endif
</ td >
< td >
@ if ( $user -> account )
{{ $user -> account [ 'following_count' ]}}
@ else
0
@ endif
</ td >
2020-02-20 02:42:49 +00:00
< td >
< span class = " action-row font-weight-lighter " >
2021-02-23 06:03:49 +00:00
< a href = " / { { $user -> username } } " class = " pr-2 text-muted small font-weight-bold " title = " View Profile " data - toggle = " tooltip " data - placement = " bottom " >
2020-02-20 02:42:49 +00:00
Profile
</ a >
2019-04-07 01:25:30 +00:00
2020-02-20 02:42:49 +00:00
< a href = " /i/admin/users/show/ { { $user -> id } } " class = " pr-2 text-muted small font-weight-bold " title = " Profile Review " data - toggle = " tooltip " data - placement = " bottom " >
Review
</ a >
2019-04-07 01:25:30 +00:00
2021-02-23 06:03:49 +00:00
< a href = " /i/admin/users/modtools/ { { $user -> id } } " class = " pr-2 text-muted small font-weight-bold " title = " Moderation Logs " data - toggle = " tooltip " data - placement = " bottom " >
Mod Tools
2020-02-20 02:42:49 +00:00
</ a >
2023-06-10 09:40:31 +00:00
@ if ( $user -> status !== 'deleted' && ! $user -> is_admin )
< a href = " /i/admin/users/delete/ { { $user -> id } } " class = " pr-2 text-muted small font-weight-bold " title = " Delete account " data - toggle = " tooltip " data - placement = " bottom " onclick = " deleteAccount( { { $user -> id } }) " >
Delete
</ a >
@ endif
2020-02-20 02:42:49 +00:00
</ span >
</ td >
</ tr >
@ endif
@ endforeach
</ tbody >
</ table >
</ div >
< div class = " d-flex justify-content-center mt-5 small " >
2021-02-23 06:03:49 +00:00
< ul class = " pagination " >
2021-02-23 07:31:12 +00:00
@ if ( $pagination [ 'prev' ] !== null || $pagination [ 'prev' ] == 1 )
2021-02-23 06:03:49 +00:00
< li class = " page-item " >< a class = " page-link pagination__prev " href = " ?page= { { $pagination [ 'prev' ] } } { { $pagination [ 'query' ] } } " rel = " prev " > « Previous </ a ></ li >
@ else
< li class = " page-item disabled " >< span class = " page-link " > « Previous </ span ></ li >
@ endif
< li class = " page-item " >< a class = " page-link pagination__next " href = " ?page= { { $pagination [ 'next' ] } } { { $pagination [ 'query' ] } } " rel = " next " > Next » </ a ></ li >
</ ul >
2020-02-20 02:42:49 +00:00
</ div >
2018-05-20 21:50:11 +00:00
@ endsection
2018-09-03 01:23:59 +00:00
@ push ( 'styles' )
< style type = " text/css " >
2020-02-20 02:42:49 +00:00
. user - row : hover {
background - color : #eff8ff;
}
. user - row : hover . action - row {
display : block ;
}
. user - row : hover . last - active {
display : none ;
}
2018-09-03 01:23:59 +00:00
</ style >
@ endpush
2018-05-20 21:50:11 +00:00
@ push ( 'scripts' )
2020-02-20 02:42:49 +00:00
< script type = " text/javascript " >
$ ( document ) . ready ( function () {
$ ( '.human-size' ) . each ( function ( d , a ) {
let el = $ ( a );
let size = el . data ( 'bytes' );
el . text ( filesize ( size , { round : 0 }));
});
});
2023-06-10 09:40:31 +00:00
function deleteAccount ( id ) {
event . preventDefault ();
if ( ! window . confirm ( 'Are you sure you want to delete this account?' )) {
return ;
}
axios . post ( '/i/admin/users/delete/' + id )
. then ( res => {
swal ( 'Account Deleted' , 'Successfully deleted this account! This page will refresh once you press OK.' , 'success' )
. then ( res => {
window . location . reload ();
});
})
}
2023-06-10 11:08:16 +00:00
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 )
}
}
});
2020-02-20 02:42:49 +00:00
</ script >
2018-06-01 21:12:53 +00:00
@ endpush