Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
}
},
"scripts": {
"analyse": "vendor/bin/phpstan analyse",
"analyse": "vendor/bin/phpstan analyse --memory-limit=-1",
"test": "vendor/bin/pest",
"test-coverage": "vendor/bin/pest --coverage",
"format": "vendor/bin/pint -v"
Expand Down
2 changes: 1 addition & 1 deletion resources/dist/css/theme.css

Large diffs are not rendered by default.

291 changes: 184 additions & 107 deletions resources/views/modals/details.blade.php
Original file line number Diff line number Diff line change
@@ -1,123 +1,200 @@
<div
class="text-sm"
x-init="
if (localStorage.getItem('theme') === 'light') {
$refs.variables.classList.add('theme-light');
} else {
$refs.variables.classList.add('theme-dark');
}
x-data="{
activeTab: null,
highlighted: false,

hljs.highlightAll()">
<div>
<p class="font-bold mb-1">Sender</p>
@if ($log->sender->name)
<p>{{ $log->sender->name }} &lt;{{ $log->sender->email }}&gt;</p>
@else
<p>{{ $log->sender->email }}</p>
@endif
</div>
init() {
this.setTab('data');

<div class="mt-4">
<p class="font-bold mb-1">Recipient</p>
<p>{{ $log->recipient }}</p>
</div>
if (localStorage.getItem('theme') === 'light') {
document.getElementById('log-variables').classList.add('theme-light');
} else {
document.getElementById('log-variables').classList.add('theme-dark');
}
},
setTab(tabName) {
this.activeTab = tabName;

<div class="mt-4">
<p class="font-bold mb-1">Subject</p>
<p>{{ $log->subject }}</p>
</div>
if (tabName === 'data' && !this.highlighted) {
this.highlighted = true;
hljs.highlightAll();
}
},
}"
x-init="init()">
<x-filament::tabs class="mb-6" style="width: fit-content">
<x-filament::tabs.item
icon="heroicon-o-at-symbol"
alpine-active="activeTab === 'data'"
x-on:click="setTab('data')">
Data
</x-filament::tabs.item>

<div class="mt-4">
<p class="font-bold mb-1">Cc</p>
@forelse (($log->cc ?: []) as $cc)
@if ($cc->name)
<p>{{ $cc->name }} &lt;{{ $cc->email }}&gt;</p>
@else
<p>{{ $cc->email }}</p>
@endif
@empty
<p class="italic opacity-80 text-xs">No data available</p>
@endforelse
</div>
<x-filament::tabs.item
icon="heroicon-o-paper-clip"
alpine-active="activeTab === 'attachments'"
x-on:click="setTab('attachments')">
Attachments ({{ count($log->attachments) }})
</x-filament::tabs.item>

<div class="mt-4">
<p class="font-bold mb-1">Bcc</p>
@forelse (($log->bcc ?: []) as $bcc)
@if ($bcc->name)
<p>{{ $bcc->name }} &lt;{{ $bcc->email }}&gt;</p>
<x-filament::tabs.item
icon="heroicon-o-rss"
alpine-active="activeTab === 'events'"
x-on:click="setTab('events')">
Events ({{ count($log->events) }})
</x-filament::tabs.item>
</x-filament::tabs>

<!-- Data -->
<x-filament::section x-show="activeTab === 'data'">
<div>
<p class="font-bold mb-1">Sender</p>
@if ($log->sender->name)
<p>{{ $log->sender->name }} &lt;{{ $log->sender->email }}&gt;</p>
@else
<p>{{ $bcc->email }}</p>
<p>{{ $log->sender->email }}</p>
@endif
@empty
<p class="italic opacity-80 text-xs">No data available</p>
@endforelse
</div>
</div>

<div class="mt-4">
<p class="font-bold mb-1">Template</p>
{!! $template !!}
</div>
<div class="mt-4">
<p class="font-bold mb-1">Recipient</p>
<p>{{ $log->recipient }}</p>
</div>

<div class="mt-4">
<p class="font-bold mb-1">Attachments</p>
<table class="w-full table-auto border-collapse text-left rtl:text-right divide-y dark:divide-gray-700 text-sm rounded-lg overflow-hidden">
<thead>
<tr class="bg-gray-50 dark:bg-gray-500/10">
<th>
<span class="p-0 flex items-center w-full px-4 py-2 whitespace-nowrap space-x-1 rtl:space-x-reverse font-medium text-gray-600 dark:text-gray-300 cursor-default">
Name
</span>
</th>
<th>
<span class="p-0 flex items-center w-full px-4 py-2 whitespace-nowrap space-x-1 rtl:space-x-reverse font-medium text-gray-600 dark:text-gray-300 cursor-default">
Size
</span>
</th>
<th>
<span class="p-0 flex items-center w-full px-4 py-2 whitespace-nowrap space-x-1 rtl:space-x-reverse font-medium text-gray-600 dark:text-gray-300 cursor-default">
Disk
</span>
</th>
<th class="w-5"></th>
</tr>
</thead>
<tbody class="divide-y whitespace-nowrap dark:divide-gray-700">
@forelse ($log->attachments as $attachment)
<tr class="dark:bg-gray-700/50 odd:bg-white even:bg-gray-50 even:dark:bg-gray-700/80">
<td class="px-4 py-2 dark:text-white">
{{ $attachment->name }}
</td>
<td class="px-4 py-2 dark:text-white">
{{ $attachment->readableSize() }}
</td>
<td class="px-4 py-2 dark:text-white">
{{ $attachment->disk ?: '-' }}
</td>
<td class="px-4 py-2">
@if ($attachment->canBeDownloaded())
<a
href="{{ URL::route('download.attachment', $attachment) }}"
class="font-medium text-primary-500 hover:text-primary-400"
target="_blank"
download>
Download
</a>
@endif
</td>
</tr>
@empty
<tr class="dark:bg-gray-700/50 odd:bg-white even:bg-gray-50 even:dark:bg-gray-700/80">
<td class="px-4 py-2 italic text-xs opacity-80" colspan="4">No attachment available</td>
<div class="mt-4">
<p class="font-bold mb-1">Subject</p>
<p>{{ $log->subject }}</p>
</div>

<div class="mt-4">
<p class="font-bold mb-1">Cc</p>
@forelse (($log->cc ?: []) as $cc)
@if ($cc->name)
<p>{{ $cc->name }} &lt;{{ $cc->email }}&gt;</p>
@else
<p>{{ $cc->email }}</p>
@endif
@empty
<p class="italic opacity-80 text-xs">No data available</p>
@endforelse
</div>

<div class="mt-4">
<p class="font-bold mb-1">Bcc</p>
@forelse (($log->bcc ?: []) as $bcc)
@if ($bcc->name)
<p>{{ $bcc->name }} &lt;{{ $bcc->email }}&gt;</p>
@else
<p>{{ $bcc->email }}</p>
@endif
@empty
<p class="italic opacity-80 text-xs">No data available</p>
@endforelse
</div>

<div class="mt-4">
<p class="font-bold mb-1">Template</p>
{!! $template !!}
</div>

<div class="mt-4">
<p class="font-bold mb-1">Variables</p>
<pre wire:ignore id="log-variables" class="hljs w-full rounded p-3 shadow-sm focus:border-primary-600 focus:ring-1 focus:ring-inset focus:ring-primary-600 disabled:opacity-70 border border-gray-300/50 dark:border-gray-600/50"><code class="language-json">{!! $variables !!}</code></pre>
</div>
</x-filament::section>

<!-- Attachments -->
<x-filament::section x-show="activeTab === 'attachments'">
@if (count($log->attachments) === 0)
<p class="italic text-xs opacity-80">No attachment available</p>
@else
<table class="w-full table-auto border-collapse text-left rtl:text-right divide-y dark:divide-gray-700 text-sm rounded-lg overflow-hidden">
<thead>
<tr>
<th>
<span class="p-0 flex items-center w-full px-4 py-2 whitespace-nowrap space-x-1 rtl:space-x-reverse font-bold cursor-default">
Name
</span>
</th>
<th>
<span class="p-0 flex items-center w-full px-4 py-2 whitespace-nowrap space-x-1 rtl:space-x-reverse font-bold cursor-default">
Size
</span>
</th>
<th>
<span class="p-0 flex items-center w-full px-4 py-2 whitespace-nowrap space-x-1 rtl:space-x-reverse font-bold cursor-default">
Disk
</span>
</th>
<th class="w-5"></th>
</tr>
@endforelse
</tbody>
</table>
</div>
</thead>
<tbody class="divide-y whitespace-nowrap dark:divide-gray-700">
@foreach ($log->attachments as $attachment)
<tr>
<td class="px-4 py-2 dark:text-white">
{{ $attachment->name }}
</td>
<td class="px-4 py-2 dark:text-white">
{{ $attachment->readableSize() }}
</td>
<td class="px-4 py-2 dark:text-white">
{{ $attachment->disk ?: '-' }}
</td>
<td class="px-4 py-2">
@if ($attachment->canBeDownloaded())
<a
href="{{ URL::route('download.attachment', $attachment) }}"
class="font-medium text-primary-500 hover:text-primary-400"
target="_blank"
download>
Download
</a>
@endif
</td>
</tr>
@endforeach
</tbody>
</table>
@endif
</x-filament::section>

<div class="mt-4">
<p class="font-bold mb-1">Variables</p>
<pre wire:ignore x-ref="variables" class="hljs w-full rounded p-3 shadow-sm focus:border-primary-600 focus:ring-1 focus:ring-inset focus:ring-primary-600 disabled:opacity-70 border border-gray-300/50 dark:border-gray-600/50"><code class="language-json">{!! $variables !!}</code></pre>
</div>
<!-- Events -->
<x-filament::section x-show="activeTab === 'events'">
@if (count($log->events) === 0)
<p class="italic text-xs opacity-80">No events available</p>
@else
<table class="w-full table-auto border-collapse text-left rtl:text-right divide-y dark:divide-gray-700 text-sm rounded-lg overflow-hidden">
<thead>
<tr>
<th>
<span class="p-0 flex items-center w-full px-4 py-2 whitespace-nowrap space-x-1 rtl:space-x-reverse font-bold cursor-default">
Name
</span>
</th>
<th>
<span class="p-0 flex items-center w-full px-4 py-2 whitespace-nowrap space-x-1 rtl:space-x-reverse font-bold cursor-default">
Date
</span>
</th>
</tr>
</thead>
<tbody class="divide-y whitespace-nowrap dark:divide-gray-700">
@foreach ($log->events as $event)
<tr>
<td class="px-4 py-2 dark:text-white" style="width: 60%">
{{ $event->name }}
</td>
<td class="px-4 py-2 dark:text-white">
{{ $event->created_at->toDateTimeString() }}
</td>
</tr>
@endforeach
</tbody>
</table>
@endif
</x-filament::section>
</div>

@assets
Expand Down
3 changes: 2 additions & 1 deletion src/Jobs/SendMailJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ protected function send(): void
$sent = Mail::send(new GenericMail($override ?: $this->genericMailDto));

if ($sent instanceof SentMessage) {
$this->log->message_id = $sent->getMessageId();
// MailGun for example sends <[email protected]> as value, but then in the Webhooks there are no < >
$this->log->message_id = str_replace(['<', '>'], '', $sent->getMessageId());
$this->log->save();
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Log.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function attachments(): HasMany
*/
public function events(): HasMany
{
return $this->hasMany(LogEvent::class);
return $this->hasMany(LogEvent::class)->latest();
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/Models/LogEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class LogEvent extends Model
protected $fillable = [
'log_id',
'name',
'created_at',
];

/**
Expand Down
26 changes: 26 additions & 0 deletions src/Resources/LogResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Filament\Support\Enums\Alignment;
use Filament\Tables;
use Filament\Tables\Actions\Action as TablesAction;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\View;
use Illuminate\Support\HtmlString;
Expand Down Expand Up @@ -69,8 +70,33 @@ public static function table(Tables\Table $table): Tables\Table
->icon(fn (Log $record) => $record->attachments->isNotEmpty() ? 'heroicon-o-paper-clip' : '')
->iconColor('primary'),

Tables\Columns\TextColumn::make('events_count')
->counts('events')
->label('Events')
->formatStateUsing(function (Log $record): HtmlString {
if ($record->events->isEmpty()) {
return new HtmlString('<span class="text-xs italic opacity-70">No events</span>');
}

// We don't use latestOfMany because it's not compatible with Postgresql UUIDs
$lastEvent = ucfirst($record->events->first()->name);
$hasMoreEvents = $record->events->count() > 1
? '<span style="font-size: 0.65rem" class="opacity-85 text-center">+ ' . ($record->events->count() - 1) . ' more</span>'
: '';

return new HtmlString(Blade::render(<<<HTML
<div class="flex gap-1">
<x-filament::badge icon="heroicon-o-rss">
$lastEvent
</x-filament::badge>
$hasMoreEvents
</div>
HTML));
}),

Tables\Columns\TextColumn::make('tries')
->badge()
->icon('heroicon-o-arrow-path')
->tooltip(function (Log $record) {
if ($record->status !== LogStatus::Failed || is_null($record->last_try_at)) {
return null;
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/LogResource/Pages/ListLogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ListLogs extends ListRecords
protected function getTableQuery(): EloquentBuilder
{
return Log::query()
->with(['template', 'attachments'])
->with(['template', 'attachments', 'events'])
->latest();
}

Expand Down
Loading