emailbutler 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 97c7cc6c31716442ed040ee06b451d2a3a6abdac9262c08e5fee1c9c6de4f385
4
- data.tar.gz: '048cacc8bb87d36cd5bd7b5ccced2b726dcde665ec3398adc348a605a2dd6774'
3
+ metadata.gz: 66b96f7ab9361587e0c960875903a0c85cece5ed19ed6891a2acac9027600735
4
+ data.tar.gz: 93d341ed01c2a44c50b84bcdcbce9bb174a6aae6f88e896ac4f8e2a298a9cb2b
5
5
  SHA512:
6
- metadata.gz: ed85dfd33c8f3a0e3f2a091db4921f1a70d696abbfd0869408bca4a1fa66f6f90bfd3d542a88f204b29c0e2c2c9b0a328e9252d1ba5183b7de8edeafc889abb1
7
- data.tar.gz: 688b1af36d7eaa8ce68f5467ed4a7c22cdd442e0d126e013ac1b9c890f1ff1e308079fe9ee32696403aa21921d1f04f7b78ed3ca68f643bd735981cef571d4c4
6
+ metadata.gz: 2c3b0c916fc98bde2ab88bc1b0a226288ab1bb5123faac70b121b6d025e22e6892bfc56d55bbffb96f0c9370b15be8b4f096f3d3c773b1afd4baa614aa687fc6
7
+ data.tar.gz: b844827b40c941522993c4993a4c0aa2ab75d789a703189ed1f47c92733166a34d1c16f9b93d7e599d3a699d88e82655024146d4f879c7f28ce880457d1f9986
data/README.md CHANGED
@@ -42,6 +42,13 @@ Add this line to config/routes.rb
42
42
  mount Emailbutler::Engine => '/emailbutler'
43
43
  ```
44
44
 
45
+ ### UI styles
46
+
47
+ For adding styles for UI you need to add this line to assets/config/manifest.js
48
+ ```js
49
+ //= link emailbutler.css
50
+ ```
51
+
45
52
  ### Mailers
46
53
 
47
54
  Update you application mailer
@@ -68,8 +75,12 @@ end
68
75
 
69
76
  ### UI
70
77
 
71
- Emailbutler provides UI with rendering email tracking statistics - /emailbutler/ui.
72
- And with opportunity to resend and/or destroy emails.
78
+ Emailbutler provides UI with rendering email tracking statistics - /emailbutler/ui, with opportunity to search, resend and/or destroy emails.
79
+
80
+ <img width="1463" alt="ui_index" src="https://user-images.githubusercontent.com/6195394/202743189-19d1845d-7991-494f-93c1-0dd92b0b5dac.png">
81
+
82
+ <img width="1461" alt="ui_show" src="https://user-images.githubusercontent.com/6195394/202743225-b0ba0ca2-d373-428c-973d-5ec4566a3784.png">
83
+
73
84
 
74
85
  ## License
75
86
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -62,34 +62,52 @@
62
62
  flex: 1;
63
63
  height: 100%;
64
64
 
65
- thead {
66
- tr {
67
- th {
68
- text-align: left;
69
- padding: .125rem .25rem;
65
+ .pagination {
66
+ margin-bottom: 1rem;
67
+
68
+ .page {
69
+ padding: .25rem .5rem;
70
+ background: #bbf7d0;
71
+ color: #000;
72
+
73
+ a {
74
+ color: #000;
70
75
  }
71
76
  }
72
77
  }
73
78
 
74
- tbody {
75
- tr {
76
- &:nth-of-type(odd) {
77
- background: #e5e7eb;
78
- }
79
+ table {
80
+ width: 100%;
79
81
 
80
- &:hover {
81
- background: #d1d5db;
82
+ thead {
83
+ tr {
84
+ th {
85
+ text-align: left;
86
+ padding: .125rem .25rem;
87
+ }
82
88
  }
89
+ }
90
+
91
+ tbody {
92
+ tr {
93
+ &:nth-of-type(odd) {
94
+ background: #e5e7eb;
95
+ }
96
+
97
+ &:hover {
98
+ background: #d1d5db;
99
+ }
83
100
 
84
- td {
85
- padding: .125rem .25rem;
101
+ td {
102
+ padding: .125rem .25rem;
86
103
 
87
- &.actions {
88
- display: flex;
104
+ &.actions {
105
+ display: flex;
89
106
 
90
- button {
91
- &:nth-of-type(1) {
92
- margin-right: .5rem;
107
+ button {
108
+ &:nth-of-type(1) {
109
+ margin-right: .5rem;
110
+ }
93
111
  }
94
112
  }
95
113
  }
@@ -1,7 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'pagy'
4
+
3
5
  module Emailbutler
4
6
  class UiController < Emailbutler::ApplicationController
7
+ include Pagy::Backend
8
+
5
9
  http_basic_authenticate_with name: Emailbutler.configuration.ui_username,
6
10
  password: Emailbutler.configuration.ui_password,
7
11
  if: -> { basic_auth_enabled? }
@@ -11,14 +15,14 @@ module Emailbutler
11
15
  end
12
16
 
13
17
  def show
14
- @messages = Emailbutler.find_messages_by(search_condition)
18
+ @pagy, @messages = pagy(Emailbutler.find_messages_by(search_condition))
15
19
  end
16
20
 
17
21
  private
18
22
 
19
23
  def search_condition
20
24
  {
21
- status: params[:id],
25
+ status: params[:id] == 'all' ? nil : params[:id],
22
26
  mailer: params[:mailer_name].presence,
23
27
  action: params[:action_name].presence,
24
28
  send_to: [params[:receiver].presence].compact.presence
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Emailbutler
4
+ module ApplicationHelper
5
+ include Pagy::Frontend
6
+ end
7
+ end
@@ -1,8 +1,10 @@
1
1
  <div id="dashboard">
2
2
  <ul class="summary">
3
- <li class="status-summary">
4
- <span><%= @summary.values.sum %></span>
5
- <span>Total</span>
3
+ <li>
4
+ <%= link_to ui_path(:all), class: 'status-summary' do %>
5
+ <span><%= @summary.values.sum %></span>
6
+ <span>Total</span>
7
+ <% end %>
6
8
  </li>
7
9
  <% Emailbutler.adapter.message_class.statuses.each_key do |status| %>
8
10
  <li>
@@ -16,37 +16,46 @@
16
16
  <%= form.submit 'Search', class: 'button' %>
17
17
  <% end %>
18
18
  </section>
19
- <table class="messages" cellspacing="0">
20
- <thead>
21
- <tr>
22
- <th>ID</th>
23
- <th>Mailer</th>
24
- <th>Action</th>
25
- <th>Send to</th>
26
- <th>Action params</th>
27
- <th>Mailer params</th>
28
- <th></th>
29
- </tr>
30
- </thead>
31
- <tbody>
32
- <% @messages.each do |message| %>
19
+ <section class="messages">
20
+ <%== pagy_nav(@pagy) %>
21
+ <table cellspacing="0">
22
+ <thead>
33
23
  <tr>
34
- <td><%= message.id %></td>
35
- <td><%= message.mailer %></td>
36
- <td><%= message.action %></td>
37
- <td>
38
- <% message.send_to.each do |receiver| %>
39
- <p><%= receiver %></p>
40
- <% end %>
41
- </td>
42
- <td><%= message.params['action_params'] %></td>
43
- <td><%= message.params['mailer_params'] %></td>
44
- <td class="actions">
45
- <%= button_to 'Resend', ui_message_path(message.uuid), method: :patch, class: 'button' %>
46
- <%= button_to 'Destroy', ui_message_path(message.uuid), method: :delete, class: 'button warning' %>
47
- </td>
24
+ <th>ID</th>
25
+ <th>Mailer</th>
26
+ <th>Action</th>
27
+ <th>Send to</th>
28
+ <% if params[:id] == 'all' %>
29
+ <th>Status</th>
30
+ <% end %>
31
+ <th>Action params</th>
32
+ <th>Mailer params</th>
33
+ <th></th>
48
34
  </tr>
49
- <% end %>
50
- </tbody>
51
- </table>
35
+ </thead>
36
+ <tbody>
37
+ <% @messages.each do |message| %>
38
+ <tr>
39
+ <td><%= message.id %></td>
40
+ <td><%= message.mailer %></td>
41
+ <td><%= message.action %></td>
42
+ <td>
43
+ <% message.send_to.each do |receiver| %>
44
+ <p><%= receiver %></p>
45
+ <% end %>
46
+ </td>
47
+ <% if params[:id] == 'all' %>
48
+ <td><%= message.status %></td>
49
+ <% end %>
50
+ <td><%= message.params['action_params'] %></td>
51
+ <td><%= message.params['mailer_params'] %></td>
52
+ <td class="actions">
53
+ <%= button_to 'Resend', ui_message_path(message.uuid), method: :patch, class: 'button' %>
54
+ <%= button_to 'Destroy', ui_message_path(message.uuid), method: :delete, class: 'button warning' %>
55
+ </td>
56
+ </tr>
57
+ <% end %>
58
+ </tbody>
59
+ </table>
60
+ </section>
52
61
  </div>
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Emailbutler
4
- VERSION = '0.4.0'
4
+ VERSION = '0.5.0'
5
5
  end
@@ -12,8 +12,8 @@ module Emailbutler
12
12
  'dropped' => 'failed'
13
13
  }.freeze
14
14
 
15
- def self.call(args={})
16
- new.call(**args)
15
+ def self.call(...)
16
+ new.call(...)
17
17
  end
18
18
 
19
19
  def call(payload:)
@@ -7,8 +7,8 @@ module Emailbutler
7
7
  class Receiver
8
8
  SENDGRID_USER_AGENT = 'SendGrid Event API'
9
9
 
10
- def self.call(args={})
11
- new.call(**args)
10
+ def self.call(...)
11
+ new.call(...)
12
12
  end
13
13
 
14
14
  def call(user_agent:, payload:)
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: emailbutler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bogdanov Anton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-17 00:00:00.000000000 Z
11
+ date: 2022-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pagy
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '5.10'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '5.10'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rails
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -171,6 +185,7 @@ files:
171
185
  - app/controllers/emailbutler/ui/messages_controller.rb
172
186
  - app/controllers/emailbutler/ui_controller.rb
173
187
  - app/controllers/emailbutler/webhooks_controller.rb
188
+ - app/helpers/emailbutler/application_helper.rb
174
189
  - app/views/emailbutler/ui/index.html.erb
175
190
  - app/views/emailbutler/ui/shared/_footer.html.erb
176
191
  - app/views/emailbutler/ui/shared/_header.html.erb