mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04:00
parent
c548c06086
commit
06706a2d9c
@ -20,6 +20,7 @@ class AuditLogController extends Controller
|
||||
'sort' => $request->get('sort', 'created_at'),
|
||||
'date_from' => $request->get('date_from', ''),
|
||||
'date_to' => $request->get('date_to', ''),
|
||||
'user' => $request->get('user', ''),
|
||||
];
|
||||
|
||||
$query = Activity::query()
|
||||
@ -34,6 +35,9 @@ class AuditLogController extends Controller
|
||||
if ($listDetails['event']) {
|
||||
$query->where('type', '=', $listDetails['event']);
|
||||
}
|
||||
if ($listDetails['user']) {
|
||||
$query->where('user_id', '=', $listDetails['user']);
|
||||
}
|
||||
|
||||
if ($listDetails['date_from']) {
|
||||
$query->where('created_at', '>=', $listDetails['date_from']);
|
||||
|
@ -13,9 +13,11 @@ class UserSelect {
|
||||
}
|
||||
|
||||
selectUser(event, userEl) {
|
||||
event.preventDefault();
|
||||
const id = userEl.getAttribute('data-id');
|
||||
this.input.value = id;
|
||||
this.userInfoContainer.innerHTML = userEl.innerHTML;
|
||||
this.input.dispatchEvent(new Event('change', {bubbles: true}));
|
||||
this.hide();
|
||||
}
|
||||
|
||||
|
@ -783,6 +783,6 @@ body.flexbox-support #entity-selector-wrap .popup-body .form-group {
|
||||
|
||||
.custom-select-input {
|
||||
max-width: 280px;
|
||||
border: 1px solid #DDD;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #D4D4D4;
|
||||
border-radius: 3px;
|
||||
}
|
@ -269,7 +269,7 @@ header .search-box {
|
||||
.dropdown-search {
|
||||
position: relative;
|
||||
.dropdown-search-toggle {
|
||||
padding: 6px;
|
||||
padding: $-xs;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 4px;
|
||||
&:hover {
|
||||
@ -281,6 +281,14 @@ header .search-box {
|
||||
}
|
||||
}
|
||||
|
||||
.dropdown-search-toggle.compact {
|
||||
padding: $-xxs $-xs;
|
||||
.avatar {
|
||||
height: 22px;
|
||||
width: 22px;
|
||||
}
|
||||
}
|
||||
|
||||
.faded {
|
||||
a, button, span, span > div {
|
||||
color: #666;
|
||||
|
@ -28,7 +28,7 @@ $-xs: 6px;
|
||||
$-xxs: 3px;
|
||||
|
||||
// List of our spacing sizes
|
||||
$spacing: (('none', 0), ('xxs', $-xxs), ('xs', $-xs), ('s', $-s), ('m', $-m), ('l', $-l), ('xl', $-xl), ('xxl', $-xxl));
|
||||
$spacing: (('none', 0), ('xxs', $-xxs), ('xs', $-xs), ('s', $-s), ('m', $-m), ('l', $-l), ('xl', $-xl), ('xxl', $-xxl), ('auto', auto));
|
||||
|
||||
// Fonts
|
||||
$text: -apple-system, BlinkMacSystemFont,
|
||||
|
@ -1,3 +1,6 @@
|
||||
<a href="#" class="flex-container-row items-center dropdown-search-item" data-id="">
|
||||
<span>{{ trans('settings.users_none_selected') }}</span>
|
||||
</a>
|
||||
@foreach($users as $user)
|
||||
<a href="#" class="flex-container-row items-center dropdown-search-item" data-id="{{ $user->id }}">
|
||||
<img class="avatar mr-m" src="{{ $user->getAvatar(30) }}" alt="{{ $user->name }}">
|
||||
|
@ -3,17 +3,17 @@
|
||||
>
|
||||
<input refs="user-select@input" type="hidden" name="{{ $name }}" value="{{ $user->id ?? '' }}">
|
||||
<div refs="dropdown@toggle"
|
||||
class="dropdown-search-toggle flex-container-row items-center"
|
||||
class="dropdown-search-toggle {{ $compact ? 'compact' : '' }} flex-container-row items-center"
|
||||
aria-haspopup="true" aria-expanded="false" tabindex="0">
|
||||
<div refs="user-select@user-info" class="flex-container-row items-center px-s">
|
||||
@if($user)
|
||||
<img class="avatar mr-m" src="{{ $user->getAvatar(30) }}" alt="{{ $user->name }}">
|
||||
<img class="avatar small mr-m" src="{{ $user->getAvatar($compact ? 22 : 30) }}" alt="{{ $user->name }}">
|
||||
<span>{{ $user->name }}</span>
|
||||
@else
|
||||
<span>{{ trans('settings.users_none_selected') }}</span>
|
||||
@endif
|
||||
</div>
|
||||
<span style="font-size: 1.5rem; margin-left: auto;">
|
||||
<span style="font-size: {{ $compact ? '1.15rem' : '1.5rem' }}; margin-left: auto;">
|
||||
@icon('caret-down')
|
||||
</span>
|
||||
</div>
|
||||
|
@ -15,7 +15,7 @@
|
||||
<div>
|
||||
<div class="form-group">
|
||||
<label for="owner">{{ trans('entities.permissions_owner') }}</label>
|
||||
@include('components.user-select', ['user' => $model->ownedBy, 'name' => 'owned_by'])
|
||||
@include('components.user-select', ['user' => $model->ownedBy, 'name' => 'owned_by', 'compact' => false])
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -25,21 +25,27 @@
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@foreach(['date_from', 'date_to'] as $filterKey)
|
||||
<form action="{{ url('/settings/audit') }}" method="get" class="block mr-m">
|
||||
@foreach($listDetails as $param => $val)
|
||||
@if(!empty($val) && $param !== $filterKey)
|
||||
<input type="hidden" name="{{ $param }}" value="{{ $val }}">
|
||||
@endif
|
||||
@endforeach
|
||||
<label for="audit_filter_{{ $filterKey }}">{{ trans('settings.audit_' . $filterKey) }}</label>
|
||||
<input id="audit_filter_{{ $filterKey }}"
|
||||
component="submit-on-change"
|
||||
type="date"
|
||||
name="{{ $filterKey }}"
|
||||
value="{{ $listDetails[$filterKey] ?? '' }}">
|
||||
</form>
|
||||
@endforeach
|
||||
<form action="{{ url('/settings/audit') }}" method="get" class="flex-container-row mr-m">
|
||||
@if(!empty($listDetails['event']))
|
||||
<input type="hidden" name="event" value="{{ $listDetails['event'] }}">
|
||||
@endif
|
||||
|
||||
@foreach(['date_from', 'date_to'] as $filterKey)
|
||||
<div class="mr-m">
|
||||
<label for="audit_filter_{{ $filterKey }}">{{ trans('settings.audit_' . $filterKey) }}</label>
|
||||
<input id="audit_filter_{{ $filterKey }}"
|
||||
component="submit-on-change"
|
||||
type="date"
|
||||
name="{{ $filterKey }}"
|
||||
value="{{ $listDetails[$filterKey] ?? '' }}">
|
||||
</div>
|
||||
@endforeach
|
||||
|
||||
<div class="form-group ml-auto" component="submit-on-change">
|
||||
<label for="owner">{{ trans('settings.audit_table_user') }}</label>
|
||||
@include('components.user-select', ['user' => $listDetails['user'] ? \BookStack\Auth\User::query()->find($listDetails['user']) : null, 'name' => 'user', 'compact' => true])
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<hr class="mt-l mb-s">
|
||||
|
@ -20,7 +20,7 @@
|
||||
<p class="small">{{ trans('settings.users_migrate_ownership_desc') }}</p>
|
||||
</div>
|
||||
<div>
|
||||
@include('components.user-select', ['name' => 'new_owner_id', 'user' => null])
|
||||
@include('components.user-select', ['name' => 'new_owner_id', 'user' => null, 'compact' => false])
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -4,6 +4,7 @@ use BookStack\Actions\Activity;
|
||||
use BookStack\Actions\ActivityService;
|
||||
use BookStack\Actions\ActivityType;
|
||||
use BookStack\Auth\UserRepo;
|
||||
use BookStack\Entities\Models\Chapter;
|
||||
use BookStack\Entities\Tools\TrashCan;
|
||||
use BookStack\Entities\Models\Page;
|
||||
use BookStack\Entities\Repos\PageRepo;
|
||||
@ -117,4 +118,26 @@ class AuditLogTest extends TestCase
|
||||
$resp->assertDontSeeText($page->name);
|
||||
}
|
||||
|
||||
public function test_user_filter()
|
||||
{
|
||||
$admin = $this->getAdmin();
|
||||
$editor = $this->getEditor();
|
||||
$this->actingAs($admin);
|
||||
$page = Page::query()->first();
|
||||
$this->activityService->addForEntity($page, ActivityType::PAGE_CREATE);
|
||||
|
||||
$this->actingAs($editor);
|
||||
$chapter = Chapter::query()->first();
|
||||
$this->activityService->addForEntity($chapter, ActivityType::CHAPTER_UPDATE);
|
||||
|
||||
$resp = $this->actingAs($admin)->get('settings/audit?user=' . $admin->id);
|
||||
$resp->assertSeeText($page->name);
|
||||
$resp->assertDontSeeText($chapter->name);
|
||||
|
||||
$resp = $this->actingAs($admin)->get('settings/audit?user=' . $editor->id);
|
||||
$resp->assertSeeText($chapter->name);
|
||||
$resp->assertDontSeeText($page->name);
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user