Update admin modlogs

This commit is contained in:
Daniel Supernault 2020-02-20 00:41:19 -07:00
parent e07bd934ac
commit 77778d3e41
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
4 changed files with 56 additions and 13 deletions

View file

@ -267,4 +267,18 @@ trait AdminUserController
$request->session()->flash('status', $msg); $request->session()->flash('status', $msg);
return redirect('/i/admin/users/modtools/' . $profile->user_id); return redirect('/i/admin/users/modtools/' . $profile->user_id);
} }
public function userModLogDelete(Request $request, $id)
{
$this->validate($request, [
'mid' => 'required|integer|exists:mod_logs,id'
]);
$user = User::findOrFail($id);
$uid = $request->user()->id;
$mid = $request->input('mid');
$ml = ModLog::whereUserId($uid)->findOrFail($mid)->delete();
$msg = "Successfully deleted modlog comment!";
$request->session()->flash('status', $msg);
return redirect('/i/admin/users/modlogs/' . $user->id);
}
} }

View file

@ -18,13 +18,25 @@ class ModLog extends Model
$msg = 'Unknown action'; $msg = 'Unknown action';
switch ($this->action) { switch ($this->action) {
case 'admin.user.message': case 'admin.user.mail':
$msg = "Sent Email Message"; $msg = "Sent Message";
break; break;
case 'admin.user.action.cw.warn': case 'admin.user.action.cw.warn':
$msg = "Sent CW reminder"; $msg = "Sent CW reminder";
break; break;
case 'admin.user.edit':
$msg = "Changed Profile";
break;
case 'admin.user.moderate':
$msg = "Moderation";
break;
case 'admin.user.delete':
$msg = "Deleted Account";
break;
default: default:
$msg = 'Unknown action'; $msg = 'Unknown action';

View file

@ -78,13 +78,13 @@
@if($logs->count() > 0) @if($logs->count() > 0)
<div class="list-group"> <div class="list-group">
@foreach($logs as $log) @foreach($logs as $log)
<div class="list-group-item d-flex justify-content-between align-items-center"> <div class="list-group-item">
@if($log->message != null) @if($log->message != null)
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">
<div class="mr-3"> <div class="mr-3">
<img src="{{$log->admin->profile->avatarUrl()}}" width="40px" height="40px" class="border p-1 rounded-circle"> <img src="{{$log->admin->profile->avatarUrl()}}" width="40px" height="40px" class="border p-1 rounded-circle">
</div> </div>
<div style="min-width: 400px;"> <div style="flex-grow: 1;">
@if($log->user_id != Auth::id()) @if($log->user_id != Auth::id())
<div class="p-3 bg-primary rounded"> <div class="p-3 bg-primary rounded">
<p class="mb-0 text-white" style="font-weight: 500;">{{$log->message}}</p> <p class="mb-0 text-white" style="font-weight: 500;">{{$log->message}}</p>
@ -103,17 +103,33 @@
</span> </span>
</div> </div>
</div> </div>
@if($log->user_id == Auth::id())
<div class="align-self-top ml-2">
<form method="post" action="/i/admin/users/modlogs/{{$user->id}}/delete">
@csrf
<input type="hidden" name="mid" value="{{$log->id}}">
<button type="submit" class="btn btn-text">
<i class="fas fa-times text-lighter"></i>
</button>
</form>
</div>
@endif
</div> </div>
@else @else
<div> <div class="d-flex justify-content-between align-items-center">
<p class="small text-muted font-weight-bold mb-0">{{$log->created_at->diffForHumans()}}</p> <div class="mr-3">
<p class="lead mb-0">{{$log->actionToText()}}</p> <img src="{{$log->admin->profile->avatarUrl()}}" width="40px" height="40px" class="border p-1 rounded-circle">
<p class="small text-muted font-weight-bold mb-0"> </div>
by: {{$log->user_username}} <div style="flex-grow: 1;">
</p> <p class="small text-muted font-weight-bold mb-0">{{$log->created_at->diffForHumans()}}</p>
</div> <p class="lead mb-0">{{$log->actionToText()}}</p>
<div> <p class="small text-muted font-weight-bold mb-0">
<i class="fas fa-chevron-right fa-lg text-lighter"></i> by: {{$log->user_username}}
</p>
</div>
<div>
<i class="fas fa-chevron-right fa-lg text-lighter"></i>
</div>
</div> </div>
@endif @endif
</div> </div>

View file

@ -25,6 +25,7 @@ Route::domain(config('pixelfed.domain.admin'))->prefix('i/admin')->group(functio
Route::get('users/modtools/{id}', 'AdminController@userModTools'); Route::get('users/modtools/{id}', 'AdminController@userModTools');
Route::get('users/modlogs/{id}', 'AdminController@userModLogs'); Route::get('users/modlogs/{id}', 'AdminController@userModLogs');
Route::post('users/modlogs/{id}', 'AdminController@userModLogsMessage'); Route::post('users/modlogs/{id}', 'AdminController@userModLogsMessage');
Route::post('users/modlogs/{id}/delete', 'AdminController@userModLogDelete');
Route::get('users/delete/{id}', 'AdminController@userDelete'); Route::get('users/delete/{id}', 'AdminController@userDelete');
Route::post('users/delete/{id}', 'AdminController@userDeleteProcess'); Route::post('users/delete/{id}', 'AdminController@userDeleteProcess');
Route::post('users/moderation/update', 'AdminController@userModerate'); Route::post('users/moderation/update', 'AdminController@userModerate');