@@ -99,6 +99,13 @@ export default {
9999 this .loadMessages ();
100100 },
101101
102+ resetSearch : function (e ) {
103+ e .preventDefault ();
104+ this .search = ' ' ;
105+ this .scrollInPlace = true ;
106+ this .loadMessages ();
107+ },
108+
102109 reloadMessages : function () {
103110 this .search = " " ;
104111 this .start = 0 ;
@@ -198,6 +205,16 @@ export default {
198205 });
199206 },
200207
208+ markAllRead : function () {
209+ let self = this ;
210+ let uri = ' api/' + self .mailbox + ' /read'
211+ self .get (uri, false , function (response ) {
212+ window .location .hash = " " ;
213+ self .scrollInPlace = true ;
214+ self .loadMessages ();
215+ });
216+ },
217+
201218 // websocket connect
202219 connect : function () {
203220 let wsproto = location .protocol == ' https:' ? ' wss' : ' ws' ;
@@ -210,12 +227,14 @@ export default {
210227 }
211228 // new messages
212229 if (response .Type == " new" && response .Data ) {
213- if (self .start < 1 ) {
214- if (! self .searching ) {
230+ if (! self .searching ) {
231+ if (self .start < 1 ) {
215232 self .items .unshift (response .Data );
216233 if (self .items .length > self .limit ) {
217234 self .items .pop ();
218235 }
236+ } else {
237+ self .start ++ ;
219238 }
220239 }
221240 self .total ++ ;
@@ -299,7 +318,7 @@ export default {
299318 </script >
300319
301320<template >
302- <div class =" navbar navbar-expand-lg navbar-light row flex-shrink-0 bg-light" >
321+ <div class =" navbar navbar-expand-lg navbar-light row flex-shrink-0 bg-light shadow-sm " >
303322 <div class =" col-lg-2 col-md-3 col-auto" >
304323 <a class =" navbar-brand" href =" #" v-on:click =" reloadMessages" >
305324 <img src =" mailpit.svg" alt =" Mailpit" >
@@ -325,7 +344,10 @@ export default {
325344 <div class =" col col-md-9 col-lg-5" v-if =" !message && total" >
326345 <form v-on:submit =" doSearch" >
327346 <div class =" input-group" >
328- <input type =" text" class =" form-control" v-model.trim =" search" placeholder =" Search mailbox" >
347+ <div class =" d-flex bg-white border rounded-start flex-fill position-relative" >
348+ <input type =" text" class =" form-control border-0" v-model.trim =" search" placeholder =" Search mailbox" >
349+ <span class =" btn btn-link position-absolute end-0 text-muted" v-if =" search" v-on:click =" resetSearch" ><i class =" bi bi-x-circle" ></i ></span >
350+ </div >
329351 <button class =" btn btn-outline-secondary" type =" submit" ><i class =" bi bi-search" ></i ></button >
330352 </div >
331353 </form >
@@ -358,15 +380,15 @@ export default {
358380 <div class =" row flex-fill" style =" min-height :0 " >
359381 <div class =" d-none d-md-block col-lg-2 col-md-3 mh-100 position-relative" style =" overflow-y : auto ;" >
360382 <ul class =" list-unstyled mt-3 mb-5" >
361- <li v-if =" isConnected" title =" Messages will auto-load" >
383+ <li v-if =" isConnected" title =" Messages will auto-load" class = " mb-2 " >
362384 <i class =" bi bi-power text-success" ></i >
363385 Connected
364386 </li >
365- <li v-else title =" Messages will auto-load " >
387+ <li v-else title =" You need to manually refresh your mailbox " class = " mb-3 " >
366388 <i class =" bi bi-power text-danger" ></i >
367389 Disconnected
368390 </li >
369- <li class =" mt-3 " >
391+ <li class =" mb-5 " >
370392 <a class =" position-relative ps-0" href =" #" v-on:click =" reloadMessages" >
371393 <i class =" bi bi-envelope me-1" v-if =" isConnected" ></i >
372394 <i class =" bi bi-arrow-clockwise me-1" v-else ></i >
@@ -376,20 +398,26 @@ export default {
376398 </span >
377399 </a >
378400 </li >
379- <li class =" mt-3" >
380- <a v-if =" total" href =" #" data-bs-toggle =" modal" data-bs-target =" #DeleteAllModal" >
401+ <li class =" my-3" v-if =" unread" >
402+ <a href =" #" data-bs-toggle =" modal" data-bs-target =" #MarkAllReadModal" >
403+ <i class =" bi bi-check2-square" ></i >
404+ Mark all read
405+ </a >
406+ </li >
407+ <li class =" my-3" v-if =" total" >
408+ <a href =" #" data-bs-toggle =" modal" data-bs-target =" #DeleteAllModal" >
381409 <i class =" bi bi-trash-fill me-1 text-danger" ></i >
382410 Delete all
383411 </a >
384412 </li >
385- <li class =" mt -3" v-if =" notificationsSupported && !notificationsEnabled" >
413+ <li class =" my -3" v-if =" notificationsSupported && !notificationsEnabled" >
386414 <a href =" #" data-bs-toggle =" modal" data-bs-target =" #EnableNotificationsModal" title =" Enable browser notifications" >
387415 <i class =" bi bi-bell" ></i >
388416 Enable alerts
389417 </a >
390418 </li >
391419 <li class =" mt-5 position-fixed bottom-0" >
392- <a href =" https://github.com/axllent/mailpit" target =" _blank" class =" text-muted w-100 d-block bg-white py-2 " >
420+ <a href =" https://github.com/axllent/mailpit" target =" _blank" class =" text-muted w-100 d-block bg-white my-3 " >
393421 <i class =" bi bi-github" ></i >
394422 GitHub
395423 </a >
@@ -433,7 +461,14 @@ export default {
433461 </div >
434462 </a >
435463 </div >
436- <div v-else class =" text-muted py-3" >No messages</div >
464+ <div v-else class =" text-muted my-3" >
465+ <span v-if =" searching" >
466+ No results matching your search
467+ </span >
468+ <span v-else >
469+ There are no emails in your mailbox
470+ </span >
471+ </div >
437472 </div >
438473
439474 <Message v-if =" message " :message =" message " :mailbox =" mailbox " ></Message >
@@ -466,6 +501,25 @@ export default {
466501 </div >
467502 </div >
468503
504+ <!-- Modal -->
505+ <div class =" modal fade" id =" MarkAllReadModal" tabindex =" -1" aria-labelledby =" MarkAllReadModalLabel" aria-hidden =" true" >
506+ <div class =" modal-dialog" >
507+ <div class =" modal-content" >
508+ <div class =" modal-header" >
509+ <h5 class =" modal-title" id =" MarkAllReadModalLabel" >Mark all messages as read?</h5 >
510+ <button type =" button" class =" btn-close" data-bs-dismiss =" modal" aria-label =" Close" ></button >
511+ </div >
512+ <div class =" modal-body" >
513+ This will mark {{ formatNumber(unread) }} message<span v-if =" unread > 1" >s</span > as read.
514+ </div >
515+ <div class =" modal-footer" >
516+ <button type =" button" class =" btn btn-secondary" data-bs-dismiss =" modal" >Cancel</button >
517+ <button type =" button" class =" btn btn-primary" data-bs-dismiss =" modal" v-on:click =" markAllRead" >Confirm</button >
518+ </div >
519+ </div >
520+ </div >
521+ </div >
522+
469523 <!-- Modal -->
470524 <div class =" modal fade" id =" EnableNotificationsModal" tabindex =" -1" aria-labelledby =" EnableNotificationsModalLabel" aria-hidden =" true" >
471525 <div class =" modal-dialog modal-lg" >
0 commit comments