Skip to content

Commit

Permalink
Made type searchable in action logs
Browse files Browse the repository at this point in the history
Signed-off-by: snipe <[email protected]>
  • Loading branch information
snipe committed Oct 30, 2024
1 parent f0813e0 commit f68df1f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 20 deletions.
17 changes: 2 additions & 15 deletions app/Http/Controllers/Api/ReportsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,6 @@ public function index(Request $request) : JsonResponse | array
});
}

if ($request->filled('action_type')) {
$actionlogs = $actionlogs->where('action_type', '=', $request->input('action_type'))->orderBy('created_at', 'desc');
}

if ($request->filled('created_by')) {
$actionlogs = $actionlogs->where('created_by', '=', $request->input('created_by'));
}

if ($request->filled('action_source')) {
$actionlogs = $actionlogs->where('action_source', '=', $request->input('action_source'))->orderBy('created_at', 'desc');
}

if ($request->filled('remote_ip')) {
$actionlogs = $actionlogs->where('remote_ip', '=', $request->input('remote_ip'))->orderBy('created_at', 'desc');
}

if ($request->filled('uploads')) {
$actionlogs = $actionlogs->whereNotNull('filename')->orderBy('created_at', 'desc');
Expand All @@ -74,6 +59,8 @@ public function index(Request $request) : JsonResponse | array
'note',
'remote_ip',
'user_agent',
'target_type',
'item_type',
'action_source',
'action_date',
];
Expand Down
10 changes: 6 additions & 4 deletions app/Models/Actionlog.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class Actionlog extends SnipeModel
'created_by',
'remote_ip',
'user_agent',
'item_type',
'target_type',
'action_source'
];

Expand All @@ -64,10 +66,10 @@ class Actionlog extends SnipeModel
* @var array
*/
protected $searchableRelations = [
'company' => ['name'],
'adminuser' => ['first_name','last_name','username', 'email'],
'user' => ['first_name','last_name','username', 'email'],
'assets' => ['asset_tag','name'],
'company' => ['name'],
'adminuser' => ['first_name','last_name','username', 'email'],
'user' => ['first_name','last_name','username', 'email'],
'assets' => ['asset_tag','name'],
];

/**
Expand Down
2 changes: 1 addition & 1 deletion resources/views/reports/activity.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class="table table-striped snipe-table"
<th class="col-sm-2" data-field="file" data-visible="false" data-formatter="fileUploadNameFormatter">
{{ trans('general.file_name') }}
</th>
<th class="col-sm-1" data-field="type" data-formatter="itemTypeFormatter">
<th class="col-sm-1" data-field="item_type" data-searchable="true" data-formatter="itemTypeFormatter">
{{ trans('general.type') }}
</th>
<th class="col-sm-3" data-field="item.serial" data-visible="false">
Expand Down

0 comments on commit f68df1f

Please sign in to comment.