Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
rabol committed Jan 4, 2022
1 parent bbf6a65 commit 8658ccc
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 67 deletions.
40 changes: 40 additions & 0 deletions resources/css/dist/filament-logviewer.css
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,31 @@ Ensure the default browser behavior of the `hidden` attribute.
background-color: rgb(251 191 36 / var(--tw-bg-opacity));
}

.bg-danger-600 {
--tw-bg-opacity: 1;
background-color: rgb(225 29 72 / var(--tw-bg-opacity));
}

.bg-warning-600 {
--tw-bg-opacity: 1;
background-color: rgb(217 119 6 / var(--tw-bg-opacity));
}

.bg-primary-600 {
--tw-bg-opacity: 1;
background-color: rgb(202 138 4 / var(--tw-bg-opacity));
}

.bg-success-400 {
--tw-bg-opacity: 1;
background-color: rgb(74 222 128 / var(--tw-bg-opacity));
}

.bg-success-600 {
--tw-bg-opacity: 1;
background-color: rgb(22 163 74 / var(--tw-bg-opacity));
}

.p-2 {
padding: 0.5rem;
}
Expand Down Expand Up @@ -594,6 +619,21 @@ Ensure the default browser behavior of the `hidden` attribute.
color: rgb(255 255 255 / var(--tw-text-opacity));
}

.text-gray-700 {
--tw-text-opacity: 1;
color: rgb(68 64 60 / var(--tw-text-opacity));
}

.text-gray-400 {
--tw-text-opacity: 1;
color: rgb(168 162 158 / var(--tw-text-opacity));
}

.text-black {
--tw-text-opacity: 1;
color: rgb(0 0 0 / var(--tw-text-opacity));
}

.hover\:shadow-lg:hover {
--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);
Expand Down
86 changes: 46 additions & 40 deletions resources/views/log-viewer-view-details.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,60 @@
<div>
<x-slot name="header">
<h2 class="text-xl font-semibold leading-tight text-gray-800">
Log Files - view
{{ $header }}
</h2>
</x-slot>
<div>

<div class="">
<table class="w-full text-left rtl:text-right divide-y table-auto">

<thead>
<tr class="bg-gray-50">
<td>Date</td>
<td>Environment</td>
<td>Level</td>
{{--<td>File path</td>--}}
<td>Context</td>
<td>Stack trace</td>
</tr>
</thead>


<tbody class="divide-y whitespace-nowrap text-sm">
@if($logEntries)
@foreach ($logEntries as $logEntry)
<tr>
<td><span class="">{{$logEntry->date}}</span></td>
<td>{{$logEntry->environment}}</td>
<td>
@if($logEntry->level == 'error')
<span class="text-xs px-3 bg-red-600 text-white rounded-full">{{$logEntry->level}}</span>
@elseif($logEntry->level == 'debug')
<span class="text-xs px-3 bg-warning-500 text-gray-800 rounded-full">{{$logEntry->level}}</span>
@else
<span class="text-xs px-3 bg-gray-200 text-gray-800 rounded-full">{{$logEntry->level}}</span>
@endif
</td>
{{--<td>{{$logEntry->file_path}}</td>--}}
<td>{{ \Illuminate\Support\Str::limit($logEntry->context, 40, ' (...)')}}</td>
<td>
@if($logEntry->stack_traces && $logEntry->stack_traces->count())
Show stack trace
@else
No stacktrace
@endif
</td>
</tr>
<tr>
<td>Date:</td>
<td>{{$entry->date}}</td>
</tr>
<tr>
<td>Environment:</td>
<td>{{$entry->environment}}</td>
</tr>
<tr>
<td>Level:</td>
<td>{{$entry->level}}</td>
</tr>
<tr>
<td>Context:</td>
<td>{{$entry->context}}</td>
</tr>
<tr>
<td>Stack trace:</td>
<td>
@if($entry->stack_traces && $entry->stack_traces->count())

@foreach ($entry->stack_traces as $st)
<table>
<tr>
<td>Caught at</td>
<td>{{$st->caught_at}}</td>
</tr>
<tr>
<td>In</td>
<td>{{$st->in}}</td>
</tr>
<tr>
<td>Line</td>
<td>{{$st->line}}</td>
</tr>
<tr>
<td>content</td>
<td>{{$st->__toString()}}</td>
</tr>
</table>
@endforeach

@endif
</tbody>
</td>
</tr>



@if ($footer)
<tfoot>
Expand Down
8 changes: 4 additions & 4 deletions resources/views/log-viewer-view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@
<td>{{$logEntry->environment}}</td>
<td>
@if($logEntry->level == 'error')
<span class="text-xs px-3 bg-red-600 text-white rounded-full">{{$logEntry->level}}</span>
<span class="text-xs px-3 bg-danger-600 text-white rounded-full">{{$logEntry->level}}</span>
@elseif($logEntry->level == 'debug')
<span class="text-xs px-3 bg-warning-500 text-gray-800 rounded-full">{{$logEntry->level}}</span>
<span class="text-xs px-3 bg-warning-600 text-gray-800 rounded-full">{{$logEntry->level}}</span>
@else
<span class="text-xs px-3 bg-gray-200 text-gray-800 rounded-full">{{$logEntry->level}}</span>
<span class="text-xs px-3 bg-primary-600 text-gray-800 rounded-full">{{$logEntry->level}}</span>
@endif
</td>
{{--<td>{{$logEntry->file_path}}</td>--}}
<td>{{ \Illuminate\Support\Str::limit($logEntry->context, 40, ' (...)')}}</td>
<td>

<a href="{{ Rabol\FilamentLogviewer\Pages\LogViewerViewDetailsPage::getUrl(['logEntryId' => $logEntry->id])}}" class="bg-amber-400 p-2 text-white rounded-md hover:shadow-lg text-xs font-thin">details</a>
<a href="{{ Rabol\FilamentLogviewer\Pages\LogViewerViewDetailsPage::getUrl(['recordId' => $logEntry->id,'fileName'=> $filename])}}" class="bg-success-600 p-2 text-white rounded-md hover:shadow-lg text-xs font-thin">details</a>

</td>
</tr>
Expand Down
5 changes: 3 additions & 2 deletions src/Pages/LogViewerPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class LogViewerPage extends Page implements Tables\Contracts\HasTable
protected static ?string $navigationIcon = 'heroicon-o-document-text';

protected static string $view = 'filament-log-viewer::log-viewer';

protected static ?string $title = 'Log viewer';
protected static ?string $navigationLabel = 'Log viewer';

protected function getActions(): array
{
Expand Down Expand Up @@ -59,7 +60,7 @@ protected function getTableActions(): array
Tables\Actions\LinkAction::make('viewlogfile')
->label('View')
->url(function (LogFile $record) {
return LogViewerViewLogPage::getUrl(['record' => $record]);
return LogViewerViewLogPage::getUrl(['fileName' => $record->name]);
})


Expand Down
35 changes: 19 additions & 16 deletions src/Pages/LogViewerViewDetailsPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,54 +14,57 @@
use Rabol\FilamentLogviewer\Models\LogFile;
use Filament\Tables\Concerns\InteractsWithTable;
use Rabol\FilamentLogviewer\Models\LogFileEntry;

use stdClass;

class LogViewerViewDetailsPage extends Page
{
private $logEntries;
private $log;
private $recordId;
private $fileName;
private $entry;

protected static ?string $navigationIcon = 'heroicon-o-document-text';

protected static string $view = 'filament-log-viewer::log-viewer-view-details';

protected static bool $shouldRegisterNavigation = false;

protected static ?string $title = 'test';
protected static ?string $title = 'Log details';
protected function getActions(): array
{
return [
ButtonAction::make('back')
->label('Back')
->url(LogViewerViewLogPage::getUrl()),
->url(LogViewerViewLogPage::getUrl(['fileName' => $this->fileName])),
];
}

public function mount(string $record): void
public function mount(string $recordId, string $fileName): void
{
debug($record);
/*
$this->log = LogReader::filename($record->name);
$this->logEntries = $this->log->get(); // we need to paginate...
self::$title = 'Log file: ' . $record->name;
*/
$this->recordId = $recordId;
$this->fileName = $fileName;

$this->entry = LogReader::find($recordId);
debug($this->entry);
debug($recordId);
debug($fileName);
}

protected function getViewData(): array
{
return [
'header' => null,
'header' => null, //'Log details: ' . $this->recordId . ' / ' . $this->fileName,
'footer' => null,
'logEntries' => $this->logEntries,
'log' => $this->log,
'recordid' => $this->recordId,
'filename' => $this->fileName,
'entry' => $this->entry,
];
}

public static function getRoutes(): Closure
{
return function () {
$slug = static::getSlug();
Route::get("{$slug}/{record?}", static::class)->name($slug);
Route::get("{$slug}/{recordId?}/{fileName?}", static::class)->name($slug);
};
}
}
13 changes: 8 additions & 5 deletions src/Pages/LogViewerViewLogPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ class LogViewerViewLogPage extends Page
{
private $logEntries;
private $log;
private $fileName;

protected static ?string $navigationIcon = 'heroicon-o-document-text';

protected static string $view = 'filament-log-viewer::log-viewer-view';

protected static bool $shouldRegisterNavigation = false;

protected static ?string $title = 'test';
protected static ?string $title = 'View log file';
protected function getActions(): array
{
return [
Expand All @@ -37,11 +38,12 @@ protected function getActions(): array
];
}

public function mount(LogFile $record): void
public function mount(string $fileName): void
{
$this->log = LogReader::filename($record->name);
$this->log = LogReader::filename($fileName);
$this->logEntries = $this->log->get(); // we need to paginate...
self::$title = 'Log file: ' . $record->name;
self::$title = 'Log file: ' . $fileName;
$this->fileName = $fileName;
}

protected function getViewData(): array
Expand All @@ -51,14 +53,15 @@ protected function getViewData(): array
'footer' => null,
'logEntries' => $this->logEntries,
'log' => $this->log,
'filename' => $this->fileName,
];
}

public static function getRoutes(): Closure
{
return function () {
$slug = static::getSlug();
Route::get("{$slug}/{record?}", static::class)->name($slug);
Route::get("{$slug}/{fileName?}", static::class)->name($slug);
};
}
}

0 comments on commit 8658ccc

Please sign in to comment.