diff --git a/inbucket.go b/inbucket.go index 9934084..506ace4 100644 --- a/inbucket.go +++ b/inbucket.go @@ -97,7 +97,7 @@ func main() { } // Create message hub - msgHub := msghub.New(rootCtx, 100) + msgHub := msghub.New(rootCtx, 30) // Grab our datastore ds := smtpd.DefaultFileDataStore() diff --git a/themes/bootstrap/public/inbucket.css b/themes/bootstrap/public/inbucket.css index 0da5a2f..63d80bb 100644 --- a/themes/bootstrap/public/inbucket.css +++ b/themes/bootstrap/public/inbucket.css @@ -81,3 +81,8 @@ table.metrics { width: 200px; } +/* Monitor */ +#monitor-message-list td { + cursor: pointer; + font-size: 12px; +} diff --git a/themes/bootstrap/public/monitor.js b/themes/bootstrap/public/monitor.js new file mode 100644 index 0000000..6a975ca --- /dev/null +++ b/themes/bootstrap/public/monitor.js @@ -0,0 +1,39 @@ +var baseURL = window.location.protocol + '//' + window.location.host; + +function startMonitor() { + $.addTemplateFormatter({ + "date": function(value, template) { + return moment(value).calendar(); + }, + "subject": function(value, template) { + if (value == null || value.length == 0) { + return "(No Subject)"; + } + return value; + } + }); + + var uri = '/api/v1/monitor/all/messages' + var l = window.location; + var url = ((l.protocol === "https:") ? "wss://" : "ws://") + l.host + uri + var ws = new WebSocket(url); + + ws.addEventListener('message', function (e) { + var msg = JSON.parse(e.data); + msg['href'] = '/mailbox?name=' + msg.mailbox + '&id=' + msg.id; + $('#monitor-message-list').loadTemplate( + $('#message-template'), + msg, + { append: true }); + }); +} + +function messageClick(node) { + var href = node.attributes['href'].value; + var url = baseURL + href; + window.location.assign(url); +} + +function clearClick() { + $('#monitor-message-list').empty(); +} diff --git a/themes/bootstrap/templates/_base.html b/themes/bootstrap/templates/_base.html index 1fecc90..e7be06b 100644 --- a/themes/bootstrap/templates/_base.html +++ b/themes/bootstrap/templates/_base.html @@ -48,7 +48,8 @@ {{end}} -