From b9786a554660bd726a6a7b05ee3e449b6aa6b32b Mon Sep 17 00:00:00 2001 From: Hugo Heneault Date: Wed, 4 Jun 2025 19:43:26 +0200 Subject: [PATCH 1/3] feat: improve responsive & UI --- src/views/index.blade.php | 405 ++++++++++++++++++++++++++++++-------- 1 file changed, 322 insertions(+), 83 deletions(-) diff --git a/src/views/index.blade.php b/src/views/index.blade.php index 254a4bc..a1bdab2 100644 --- a/src/views/index.blade.php +++ b/src/views/index.blade.php @@ -2,138 +2,377 @@ - + {{ config('app.name') }} - Mail Viewer - - + + - + -
-

{{ config('app.name') }} - Outgoing mails

-
+ +
+
+
+
+ +

{{ config('app.name') }} - Outgoing Mails

+
+ + +
+
+
-
-
+
-
+ +
+ +
+
+

+ + Inbox +

+ + {{ $mails->total() ?? 0 }} + +
+
+ + +
@forelse($mails as $mail) -
-
- {{ $mail->subject }} -
-
-
- {{ $mail->to }} +
+ +
+
+
+ {{ strtoupper(substr($mail->to, 0, 1)) }} +
+
+

{{ $mail->to }}

+
+
+
+ @if(!$mail->is_read) +
+ @endif +
-
+
+ +

+ {{ $mail->subject ?: 'No Subject' }} +

+ +
+
+ {{ $mail->sent_at->diffForHumans() }}
+ @if($mail->has_attachments ?? false) + + @endif
@empty - No mail found +
+ +

No mails found

+
@endforelse - + + + @if($mails->hasPages()) +
+
+
+ @if($mails->onFirstPage()) + + @else + + + + @endif + + + {{ $mails->currentPage() }} of {{ $mails->lastPage() }} + + + @if($mails->hasMorePages()) + + + + @else + + @endif +
+ +
+ Showing {{ $mails->firstItem() ?? 0 }}-{{ $mails->lastItem() ?? 0 }} of {{ $mails->total() ?? 0 }} +
+
+
+ @endif +
+ + + +
+ + + // Function to select and display mail + function selectMail(mailId, mailElement) { + currentMailId = mailId; - - + \ No newline at end of file From 4d88b1217160c7949945dc4cec59ec3bb8386503 Mon Sep 17 00:00:00 2001 From: Hugo Heneault Date: Wed, 4 Jun 2025 19:53:16 +0200 Subject: [PATCH 2/3] feat: Add emails truncate --- src/MailController.php | 25 ++++++++- src/routes.php | 1 + src/views/index.blade.php | 114 ++++++++++++++++++++++++++++++++++++-- 3 files changed, 134 insertions(+), 6 deletions(-) diff --git a/src/MailController.php b/src/MailController.php index a163796..8286c1a 100644 --- a/src/MailController.php +++ b/src/MailController.php @@ -4,6 +4,8 @@ namespace Tkeer\Mailbase; +use Exception; +use Illuminate\Http\JsonResponse; use Illuminate\Routing\Controller; class MailController extends Controller @@ -22,4 +24,25 @@ public function show(Mailbase $mailbase) return response()->json($mailbase); } -} + /** + * Clear all emails from the database + * + * @return JsonResponse + */ + public function clear(): JsonResponse + { + try { + Mailbase::truncate(); + + return response()->json([ + 'success' => true, + 'message' => 'All emails have been cleared successfully.' + ]); + } catch (Exception $e) { + return response()->json([ + 'success' => false, + 'message' => 'Failed to clear emails: ' . $e->getMessage() + ], 500); + } + } +} \ No newline at end of file diff --git a/src/routes.php b/src/routes.php index 309c6da..2eafe39 100644 --- a/src/routes.php +++ b/src/routes.php @@ -8,4 +8,5 @@ Route::group(['as' => 'mailbase::', 'prefix' => 'mailbase', 'middleware' => SubstituteBindings::class], function () { Route::get('/', MailController::class . '@index')->name('index'); Route::get('/{mailbase}', MailController::class . '@show')->name('show'); + Route::post('/clear', MailController::class . '@clear')->name('clear'); }); diff --git a/src/views/index.blade.php b/src/views/index.blade.php index a1bdab2..a2cb427 100644 --- a/src/views/index.blade.php +++ b/src/views/index.blade.php @@ -48,22 +48,37 @@ .scrollbar-thin::-webkit-scrollbar-thumb:hover { background: #94a3b8; } + + /* Mobile header visibility */ + @media (max-width: 767px) { + /* Hide reset button when viewing mail details on mobile */ + .mobile-mail-viewer #reset-btn { + display: none; + } + } -
+

{{ config('app.name') }} - Outgoing Mails

- - +
+ + + + +
@@ -219,6 +234,30 @@
+ + +