emailbutler 0.3.0 → 0.4.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: 2cb350207d1f0d4174a10f2589ee604cc3ddb71438ed6c63b057ef9975a93ed4
4
- data.tar.gz: a0dae6c1a23c417827d03abf56ae9386696ca175f5de107eb81473925d3010b4
3
+ metadata.gz: 97c7cc6c31716442ed040ee06b451d2a3a6abdac9262c08e5fee1c9c6de4f385
4
+ data.tar.gz: '048cacc8bb87d36cd5bd7b5ccced2b726dcde665ec3398adc348a605a2dd6774'
5
5
  SHA512:
6
- metadata.gz: 5c69ecaab954896b0378320e4c535dcfb152356117181fc55c3f5fb479afa73ddceee39bfbd10707c6b488710b07e8b281fa96dcc723c114fa76ed78a849aba2
7
- data.tar.gz: 8362e1119289ec26d18b29d7575d629a334265ae9365a052bc84f0e731694ad6372e314f976b22d118a31389691cc06c3194650dcc8b22f994bdfd8e05ab1282
6
+ metadata.gz: ed85dfd33c8f3a0e3f2a091db4921f1a70d696abbfd0869408bca4a1fa66f6f90bfd3d542a88f204b29c0e2c2c9b0a328e9252d1ba5183b7de8edeafc889abb1
7
+ data.tar.gz: 688b1af36d7eaa8ce68f5467ed4a7c22cdd442e0d126e013ac1b9c890f1ff1e308079fe9ee32696403aa21921d1f04f7b78ed3ca68f643bd735981cef571d4c4
data/README.md CHANGED
@@ -68,8 +68,8 @@ end
68
68
 
69
69
  ### UI
70
70
 
71
- Emailbutler provides UI with rendering email tracking statistics - /emailbutler/ui/dashboard.
72
- And with opportunity to resend emails.
71
+ Emailbutler provides UI with rendering email tracking statistics - /emailbutler/ui.
72
+ And with opportunity to resend and/or destroy emails.
73
73
 
74
74
  ## License
75
75
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -1,9 +1,11 @@
1
1
  #emailbutler {
2
2
  #dashboard {
3
3
  padding-top: 1rem;
4
+ display: flex;
4
5
 
5
6
  .summary {
6
7
  list-style: none;
8
+ flex: 1;
7
9
  display: flex;
8
10
  flex-direction: row;
9
11
  padding: .75rem 1rem;
@@ -37,8 +39,28 @@
37
39
  }
38
40
  }
39
41
 
42
+ .search-form {
43
+ width: 20rem;
44
+ padding-right: 2rem;
45
+
46
+ .form-field {
47
+ display: flex;
48
+ flex-direction: column;
49
+ margin-bottom: .5rem;
50
+
51
+ label {
52
+ margin-bottom: .25rem;
53
+ }
54
+
55
+ input {
56
+ padding: .25rem;
57
+ }
58
+ }
59
+ }
60
+
40
61
  .messages {
41
- width: 100%;
62
+ flex: 1;
63
+ height: 100%;
42
64
 
43
65
  thead {
44
66
  tr {
@@ -66,26 +88,8 @@
66
88
  display: flex;
67
89
 
68
90
  button {
69
- box-shadow: none;
70
- border: none;
71
- cursor: pointer;
72
- padding: .25rem;
73
-
74
- &.resend {
75
- background: #bbf7d0;
91
+ &:nth-of-type(1) {
76
92
  margin-right: .5rem;
77
-
78
- &:hover {
79
- background: #86efac;
80
- }
81
- }
82
-
83
- &.destroy {
84
- background: #fecaca;
85
-
86
- &:hover {
87
- background: #fca5a5;
88
- }
89
93
  }
90
94
  }
91
95
  }
@@ -94,4 +98,24 @@
94
98
  }
95
99
  }
96
100
  }
101
+
102
+ .button {
103
+ box-shadow: none;
104
+ border: none;
105
+ cursor: pointer;
106
+ padding: .25rem;
107
+ background: #bbf7d0;
108
+
109
+ &:hover {
110
+ background: #86efac;
111
+ }
112
+
113
+ &.warning {
114
+ background: #fecaca;
115
+
116
+ &:hover {
117
+ background: #fca5a5;
118
+ }
119
+ }
120
+ }
97
121
  }
@@ -7,12 +7,12 @@ module Emailbutler
7
7
 
8
8
  def update
9
9
  Emailbutler.resend_message(@message)
10
- redirect_to ui_dashboard_index_path
10
+ redirect_to ui_index_path
11
11
  end
12
12
 
13
13
  def destroy
14
14
  Emailbutler.destroy_message(@message)
15
- redirect_to ui_dashboard_index_path
15
+ redirect_to ui_index_path
16
16
  end
17
17
 
18
18
  private
@@ -6,8 +6,25 @@ module Emailbutler
6
6
  password: Emailbutler.configuration.ui_password,
7
7
  if: -> { basic_auth_enabled? }
8
8
 
9
+ def index
10
+ @summary = Emailbutler.count_messages_by_status
11
+ end
12
+
13
+ def show
14
+ @messages = Emailbutler.find_messages_by(search_condition)
15
+ end
16
+
9
17
  private
10
18
 
19
+ def search_condition
20
+ {
21
+ status: params[:id],
22
+ mailer: params[:mailer_name].presence,
23
+ action: params[:action_name].presence,
24
+ send_to: [params[:receiver].presence].compact.presence
25
+ }.compact
26
+ end
27
+
11
28
  def basic_auth_enabled?
12
29
  configuration = Emailbutler.configuration
13
30
 
@@ -6,7 +6,7 @@
6
6
  </li>
7
7
  <% Emailbutler.adapter.message_class.statuses.each_key do |status| %>
8
8
  <li>
9
- <%= link_to ui_dashboard_path(status), class: 'status-summary' do %>
9
+ <%= link_to ui_path(status), class: 'status-summary' do %>
10
10
  <span><%= @summary[status].to_i %></span>
11
11
  <span><%= status.capitalize %></span>
12
12
  <% end %>
@@ -1,6 +1,6 @@
1
1
  <header>
2
2
  <div class="header-wrapper flex justify-between items-center">
3
- <%= link_to ui_dashboard_index_path do %>
3
+ <%= link_to ui_index_path do %>
4
4
  <h1>Emailbutler</h1>
5
5
  <% end %>
6
6
  <nav>
@@ -0,0 +1,52 @@
1
+ <div id="dashboard">
2
+ <section class="search-form">
3
+ <%= form_with url: ui_path(params[:id]), method: :get do |form| %>
4
+ <div class="form-field">
5
+ <%= form.label :mailer_name, 'Mailer', class: 'form-label' %>
6
+ <%= form.text_field :mailer_name, class: 'form-value', value: params[:mailer_name] %>
7
+ </div>
8
+ <div class="form-field">
9
+ <%= form.label :action_name, 'Action', class: 'form-label' %>
10
+ <%= form.text_field :action_name, class: 'form-value', value: params[:action_name] %>
11
+ </div>
12
+ <div class="form-field">
13
+ <%= form.label :receiver, 'Receiver', class: 'form-label' %>
14
+ <%= form.text_field :receiver, class: 'form-value', value: params[:receiver] %>
15
+ </div>
16
+ <%= form.submit 'Search', class: 'button' %>
17
+ <% end %>
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| %>
33
+ <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>
48
+ </tr>
49
+ <% end %>
50
+ </tbody>
51
+ </table>
52
+ </div>
data/config/routes.rb CHANGED
@@ -3,8 +3,8 @@
3
3
  Emailbutler::Engine.routes.draw do
4
4
  post '/webhooks', to: 'webhooks#create'
5
5
 
6
+ resources :ui, only: %i[index show]
6
7
  namespace :ui do
7
- resources :dashboard, only: %i[index show]
8
8
  resources :messages, only: %i[update destroy]
9
9
  end
10
10
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Emailbutler
4
- VERSION = '0.3.0'
4
+ VERSION = '0.4.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: emailbutler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.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-10-04 00:00:00.000000000 Z
11
+ date: 2022-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -70,16 +70,16 @@ dependencies:
70
70
  name: puma
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">"
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '5.0'
75
+ version: '6.0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">"
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '5.0'
82
+ version: '6.0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '1.3'
103
+ version: '1.39'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '1.3'
110
+ version: '1.39'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rubocop-performance
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -150,7 +150,8 @@ dependencies:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
152
  version: '2.0'
153
- description: Write a longer description or delete this line.
153
+ description: Emailbutler allows you to track delivery status of emails sent by your
154
+ app.
154
155
  email:
155
156
  - kortirso@gmail.com
156
157
  executables: []
@@ -167,17 +168,15 @@ files:
167
168
  - app/assets/stylesheets/emailbutler/shared/header.scss
168
169
  - app/assets/stylesheets/emailbutler/views/dashboard.scss
169
170
  - app/controllers/emailbutler/application_controller.rb
170
- - app/controllers/emailbutler/ui/dashboard_controller.rb
171
171
  - app/controllers/emailbutler/ui/messages_controller.rb
172
172
  - app/controllers/emailbutler/ui_controller.rb
173
173
  - app/controllers/emailbutler/webhooks_controller.rb
174
- - app/views/emailbutler/ui/dashboard/index.html.erb
175
- - app/views/emailbutler/ui/dashboard/show.html.erb
174
+ - app/views/emailbutler/ui/index.html.erb
176
175
  - app/views/emailbutler/ui/shared/_footer.html.erb
177
176
  - app/views/emailbutler/ui/shared/_header.html.erb
177
+ - app/views/emailbutler/ui/show.html.erb
178
178
  - app/views/layouts/emailbutler/application.html.erb
179
179
  - config/routes.rb
180
- - db/migrate/20220916162720_create_emailbutler_tables.rb
181
180
  - lib/emailbutler.rb
182
181
  - lib/emailbutler/adapters/active_record.rb
183
182
  - lib/emailbutler/configuration.rb
@@ -216,5 +215,5 @@ requirements: []
216
215
  rubygems_version: 3.3.7
217
216
  signing_key:
218
217
  specification_version: 4
219
- summary: Write a short summary, because RubyGems requires one.
218
+ summary: Email tracker for Ruby on Rails applications.
220
219
  test_files: []
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Emailbutler
4
- module Ui
5
- class DashboardController < Emailbutler::UiController
6
- def index
7
- @summary = Emailbutler.count_messages_by_status
8
- end
9
-
10
- def show
11
- @messages = Emailbutler.find_messages_by(status: params[:id])
12
- end
13
- end
14
- end
15
- end
@@ -1,35 +0,0 @@
1
- <div id="dashboard">
2
- <table class="messages" cellspacing="0">
3
- <thead>
4
- <tr>
5
- <th>ID</th>
6
- <th>UUID</th>
7
- <th>Mailer</th>
8
- <th>Action</th>
9
- <th>Send to</th>
10
- <th>Params</th>
11
- <th></th>
12
- </tr>
13
- </thead>
14
- <tbody>
15
- <% @messages.each do |message| %>
16
- <tr>
17
- <td><%= message.id %></td>
18
- <td><%= message.uuid %></td>
19
- <td><%= message.mailer %></td>
20
- <td><%= message.action %></td>
21
- <td>
22
- <% message.send_to.each do |receiver| %>
23
- <p><%= receiver %></p>
24
- <% end %>
25
- </td>
26
- <td><%= message.params %></td>
27
- <td class="actions">
28
- <%= button_to 'Resend', ui_message_path(message.uuid), method: :patch, class: 'resend' %>
29
- <%= button_to 'Destroy', ui_message_path(message.uuid), method: :delete, class: 'destroy' %>
30
- </td>
31
- </tr>
32
- <% end %>
33
- </tbody>
34
- </table>
35
- </div>
@@ -1,23 +0,0 @@
1
- class CreateEmailbutlerTables < ActiveRecord::Migration[7.0]
2
- def self.up
3
- enable_extension 'pgcrypto' unless extensions.include?('pgcrypto')
4
- enable_extension 'uuid-ossp' unless extensions.include?('uuid-ossp')
5
-
6
- create_table :emailbutler_messages do |t|
7
- t.uuid :uuid, null: false, default: ''
8
- t.string :mailer, null: false
9
- t.string :action, null: false
10
- t.jsonb :params, null: false, default: {}
11
- t.string :send_to, array: true
12
- t.integer :status, null: false, default: 0
13
- t.datetime :timestamp
14
- t.integer :lock_version
15
- t.timestamps
16
- end
17
- add_index :emailbutler_messages, :uuid, unique: true
18
- end
19
-
20
- def self.down
21
- drop_table :emailbutler_messages
22
- end
23
- end