Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Scroll and Open specific log entry #58

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions src/resources/views/log_item.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
trans('backpack::logmanager.log_manager') => route('log.index'),
trans('backpack::logmanager.preview') => false,
];
$entryID = count($logs);
@endphp

@section('header')
Expand All @@ -21,20 +22,21 @@
<div id="accordion" role="tablist" aria-multiselectable="true">
@forelse($logs as $key => $log)
<div class="card mb-0 pb-0">
<div class="card-header bg-{{ $log['level_class'] }}" role="tab" id="heading{{ $key }}">
<a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse{{ $key }}" aria-expanded="true" aria-controls="collapse{{ $key }}" class="text-white">
<div class="card-header bg-{{ $log['level_class'] }}" role="tab" id="heading{{ $entryID }}">
<a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse{{ $entryID }}" aria-expanded="true" aria-controls="collapse{{ $entryID }}" class="text-white">
<i class="la la-{{ $log['level_img'] }}"></i>
<span>[{{ $log['date'] }}]</span>
{{ Str::limit($log['text'], 150) }}
</a>
</div>
<div id="collapse{{ $key }}" class="panel-collapse collapse p-3" role="tabpanel" aria-labelledby="heading{{ $key }}">
<div id="collapse{{ $entryID }}" class="panel-collapse collapse p-3" role="tabpanel" aria-labelledby="heading{{ $entryID }}">
<div class="panel-body">
<p>{{$log['text']}}</p>
<pre><code class="php">{{ trim($log['stack']) }}</code></pre>
</div>
</div>
</div>
@php($entryID--)
@empty
<h3 class="text-center">No Logs to display.</h3>
@endforelse
Expand All @@ -46,4 +48,13 @@
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.6/styles/default.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.6/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script type="text/javascript">
jQuery(document).ready(function($) {
// Scroll and Open, if #collapse exists
if (location.hash.match(/^#collapse/) && $(location.hash).length > 0) {
$(location.hash).collapse('show');
$('html, body').animate({scrollTop: $(location.hash).closest('.card').offset().top}, 500);
}
});
</script>
@endsection