maily_herald-webui 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Gemfile +1 -3
- data/Gemfile.lock +179 -162
- data/README.md +33 -7
- data/Rakefile +1 -1
- data/app/assets/javascripts/maily_herald/webui/dispatches.coffee +1 -0
- data/app/assets/javascripts/maily_herald/webui/webui.coffee +22 -14
- data/app/assets/stylesheets/maily_herald/webui/webui.sass +23 -2
- data/app/controllers/maily_herald/webui/ad_hoc_mailings_controller.rb +33 -0
- data/app/controllers/maily_herald/webui/application_controller.rb +9 -5
- data/app/controllers/maily_herald/webui/dashboard_controller.rb +2 -2
- data/app/controllers/maily_herald/webui/dispatches_controller.rb +2 -2
- data/app/controllers/maily_herald/webui/lists_controller.rb +2 -2
- data/app/controllers/maily_herald/webui/mailings_controller.rb +20 -8
- data/app/controllers/maily_herald/webui/one_time_mailings_controller.rb +14 -11
- data/app/controllers/maily_herald/webui/periodical_mailings_controller.rb +1 -1
- data/app/controllers/maily_herald/webui/resources_controller.rb +10 -6
- data/app/controllers/maily_herald/webui/sequence_mailings_controller.rb +1 -1
- data/app/controllers/maily_herald/webui/sequences_controller.rb +6 -6
- data/app/controllers/maily_herald/webui/sessions_controller.rb +8 -4
- data/app/controllers/maily_herald/webui/subscriptions_controller.rb +4 -1
- data/app/helpers/maily_herald/webui/application_helper.rb +22 -2
- data/app/helpers/maily_herald/webui/dashboard_helper.rb +14 -0
- data/app/helpers/maily_herald/webui/lists_helper.rb +13 -0
- data/app/helpers/maily_herald/webui/logs_helper.rb +6 -1
- data/app/helpers/maily_herald/webui/mailings_helper.rb +50 -5
- data/app/helpers/maily_herald/webui/sequences_helper.rb +13 -0
- data/app/helpers/maily_herald/webui/subscribers_helper.rb +1 -1
- data/app/mailers/ad_hoc_mailer.rb +8 -0
- data/app/mailers/custom_one_time_mailer.rb +7 -0
- data/app/models/maily_herald/webui/settings.rb +70 -0
- data/app/views/layouts/maily_herald/webui/application.html.haml +6 -7
- data/app/views/maily_herald/webui/dashboard/index.html.haml +31 -17
- data/app/views/maily_herald/webui/dashboard/index.js.erb +6 -2
- data/app/views/maily_herald/webui/dispatches/_logs.html.haml +4 -0
- data/app/views/maily_herald/webui/dispatches/_schedules.html.haml +4 -0
- data/app/views/maily_herald/webui/dispatches/_subscribers.html.haml +13 -0
- data/app/views/maily_herald/webui/lists/_header.html.haml +0 -3
- data/app/views/maily_herald/webui/lists/_items.html.haml +1 -1
- data/app/views/maily_herald/webui/lists/{context_variables.html.haml → context_attributes.html.haml} +5 -2
- data/app/views/maily_herald/webui/lists/subscribe.js.erb +2 -2
- data/app/views/maily_herald/webui/lists/unsubscribe.js.erb +1 -1
- data/app/views/maily_herald/webui/logs/_items.html.haml +2 -2
- data/app/views/maily_herald/webui/logs/preview.html.haml +26 -1
- data/app/views/maily_herald/webui/mailings/_deliver.js.erb +1 -1
- data/app/views/maily_herald/webui/mailings/_details.html.haml +9 -6
- data/app/views/maily_herald/webui/mailings/_details_form.html.haml +4 -2
- data/app/views/maily_herald/webui/mailings/_form_one_time.html.haml +1 -0
- data/app/views/maily_herald/webui/mailings/_header.html.haml +3 -3
- data/app/views/maily_herald/webui/mailings/_template.html.haml +4 -3
- data/app/views/maily_herald/webui/resources/new.html.haml +1 -1
- data/app/views/maily_herald/webui/sequences/_header.html.haml +11 -6
- data/app/views/maily_herald/webui/sequences/_list.html.haml +1 -1
- data/app/views/maily_herald/webui/subscribers/_item.html.haml +4 -0
- data/app/views/maily_herald/webui/subscribers/_list.html.haml +2 -0
- data/app/views/maily_herald/webui/subscriptions/show.html.haml +5 -1
- data/config/locales/en.yml +51 -9
- data/config/routes.rb +13 -3
- data/lib/maily_herald/webui/form_builder.rb +7 -2
- data/lib/maily_herald/webui/menu_manager.rb +1 -0
- data/lib/maily_herald/webui/version.rb +1 -1
- data/maily_herald-webui.gemspec +2 -2
- data/spec/dummy/app/models/user.rb +2 -1
- data/spec/dummy/bin/spring +4 -7
- data/spec/dummy/config/application.rb +5 -2
- data/spec/dummy/config/environments/development.rb +5 -3
- data/spec/dummy/config/environments/test.rb +3 -1
- data/spec/dummy/config/initializers/maily_herald.rb +33 -34
- data/spec/dummy/config/maily_herald.yml +4 -0
- data/spec/dummy/config/sidekiq.yml +5 -0
- data/spec/dummy/db/migrate/20130723074347_create_users.rb +1 -0
- data/spec/dummy/db/migrate/20150602133024_create_maily_herald_tables.maily_herald.rb +54 -0
- data/spec/dummy/db/schema.rb +31 -34
- metadata +24 -14
- data/app/views/maily_herald/webui/dispatches/_entities.html.haml +0 -7
- data/spec/dummy/db/migrate/20140804152249_create_maily_herald_tables.maily_herald.rb +0 -68
- data/spec/dummy/db/migrate/20140804152250_create_lists.maily_herald.rb +0 -33
@@ -9,7 +9,7 @@ module MailyHerald
|
|
9
9
|
spec = super
|
10
10
|
spec.params.push(:start_at, :period_in_days)
|
11
11
|
spec.update_containers["schedules"] = true
|
12
|
-
spec.containers_order = ["details", "template", "
|
12
|
+
spec.containers_order = ["details", "template", "subscribers", "schedules", "logs"]
|
13
13
|
spec
|
14
14
|
end
|
15
15
|
|
@@ -49,9 +49,12 @@ module MailyHerald
|
|
49
49
|
yield(@item) if block_given?
|
50
50
|
|
51
51
|
if @item.save
|
52
|
-
|
52
|
+
if @item.is_a?(MailyHerald::SequenceMailing)
|
53
|
+
redirect_to sequence_mailing_path(@item.sequence, @item)
|
54
|
+
else
|
55
|
+
redirect_to @item
|
56
|
+
end
|
53
57
|
else
|
54
|
-
puts @item.errors.to_yaml
|
55
58
|
add_breadcrumb view_context.tw("#{controller_name}.new.label", :action => :new)
|
56
59
|
render :action => :new
|
57
60
|
end
|
@@ -126,10 +129,11 @@ module MailyHerald
|
|
126
129
|
# Run code required by rendered containers
|
127
130
|
def collect_action_dependencies
|
128
131
|
if @rendered_containers
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
132
|
+
action_dependencies @rendered_containers
|
133
|
+
#begin
|
134
|
+
#action_dependencies @rendered_containers
|
135
|
+
#rescue NoMethodError
|
136
|
+
#end
|
133
137
|
end
|
134
138
|
end
|
135
139
|
|
@@ -27,7 +27,7 @@ module MailyHerald
|
|
27
27
|
spec = super
|
28
28
|
spec.params.push(:absolute_delay_in_days)
|
29
29
|
spec.update_containers["schedules"] = true
|
30
|
-
spec.containers_order = ["details", "template", "
|
30
|
+
spec.containers_order = ["details", "template", "subscribers", "schedules", "logs"]
|
31
31
|
spec
|
32
32
|
end
|
33
33
|
|
@@ -21,11 +21,11 @@ module MailyHerald
|
|
21
21
|
spec.params = [:title, :list, :start_at, :override_subscription]
|
22
22
|
spec.update_containers = {
|
23
23
|
"mailings" => true,
|
24
|
-
"
|
24
|
+
"subscribers" => true,
|
25
25
|
"schedules" => true,
|
26
26
|
"logs" => true
|
27
27
|
}
|
28
|
-
spec.containers_order = ["details", "mailings", "
|
28
|
+
spec.containers_order = ["details", "mailings", "subscribers", "schedules", "logs"]
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
@@ -41,10 +41,10 @@ module MailyHerald
|
|
41
41
|
@logs = smart_listing_create(:logs, @item.logs.processed, :partial => "maily_herald/webui/logs/items", default_sort: {processing_at: "desc"})
|
42
42
|
when "schedules"
|
43
43
|
@schedules = smart_listing_create(:schedules, @item.logs.scheduled, :partial => "maily_herald/webui/logs/items", default_sort: {processing_at: "asc"})
|
44
|
-
when "
|
45
|
-
@
|
46
|
-
@
|
47
|
-
@
|
44
|
+
when "subscribers"
|
45
|
+
@subscribers = @item.list.subscribers
|
46
|
+
@subscribers = @subscribers.merge(@item.list.context.scope_like(params[:subscribers_filter])) if params[:subscribers_filter]
|
47
|
+
@subscribers = smart_listing_create(:subscribers, @subscribers, :partial => "maily_herald/webui/subscribers/list")
|
48
48
|
when "mailings"
|
49
49
|
@mailings = smart_listing_create(:mailings, @item.mailings, :partial => "maily_herald/webui/mailings/list")
|
50
50
|
else
|
@@ -1,11 +1,15 @@
|
|
1
1
|
module MailyHerald
|
2
2
|
class Webui::SessionsController < Webui::ApplicationController
|
3
|
-
def
|
4
|
-
|
5
|
-
session[:work_mode] = params[:mode].to_sym
|
6
|
-
end
|
3
|
+
def switch_setting
|
4
|
+
settings.toggle params[:setting]
|
7
5
|
|
8
6
|
redirect_to :back
|
9
7
|
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def setting_cookie_name setting
|
12
|
+
"maily_settings_#{setting}"
|
13
|
+
end
|
10
14
|
end
|
11
15
|
end
|
@@ -13,7 +13,7 @@ module MailyHerald
|
|
13
13
|
add_breadcrumb view_context.tw("subscriptions.show.users_subscription", user: @item.entity.to_s)
|
14
14
|
|
15
15
|
@entity = @item
|
16
|
-
smart_listing_create(:
|
16
|
+
smart_listing_create(:processed_logs, @item.logs.processed, :partial => "maily_herald/webui/logs/items", default_sort: {processing_at: "desc"})
|
17
17
|
smart_listing_create(:scheduled_logs, @item.logs.scheduled, :partial => "maily_herald/webui/logs/items", default_sort: {processing_at: "asc"})
|
18
18
|
end
|
19
19
|
|
@@ -29,5 +29,8 @@ module MailyHerald
|
|
29
29
|
spec.klass = MailyHerald::Subscription
|
30
30
|
end
|
31
31
|
end
|
32
|
+
|
33
|
+
def action_dependencies *containers
|
34
|
+
end
|
32
35
|
end
|
33
36
|
end
|
@@ -41,7 +41,7 @@ module MailyHerald
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def link_to_context_attributes_overview list, options = {}
|
44
|
-
link_to
|
44
|
+
link_to context_attributes_list_path(id: list, context: list.context_name), data: {toggle: "modal", target: "#modal-generic"}, class: ["link link-help", options[:class]] do
|
45
45
|
html = concat(icon(:list))
|
46
46
|
html.concat(" ").concat(list.context_name) if options[:text]
|
47
47
|
end if list.try(:context_name)
|
@@ -67,13 +67,17 @@ module MailyHerald
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def content_for_expert
|
70
|
-
yield if expert_mode
|
70
|
+
yield if settings.expert_mode
|
71
71
|
end
|
72
72
|
|
73
73
|
def work_mode_t mode
|
74
74
|
t(mode, {scope: [:maily_herald, :webui, :work_modes]})
|
75
75
|
end
|
76
76
|
|
77
|
+
def setting_t setting
|
78
|
+
t(setting, {scope: [:maily_herald, :webui, :settings]})
|
79
|
+
end
|
80
|
+
|
77
81
|
def tw(key, options = {})
|
78
82
|
t(key, {scope: [:maily_herald, :webui]}.merge(options))
|
79
83
|
end
|
@@ -149,9 +153,25 @@ module MailyHerald
|
|
149
153
|
end
|
150
154
|
end
|
151
155
|
|
156
|
+
def setting_switcher setting
|
157
|
+
link_to(switch_setting_path(setting), method: :post) do
|
158
|
+
concat(icon(settings.get(setting) ? "toggle-on" : "toggle-off"))
|
159
|
+
concat(" ".html_safe)
|
160
|
+
concat(setting_t(setting))
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
152
164
|
def smart_listing_config_profile
|
153
165
|
:maily_herald
|
154
166
|
end
|
167
|
+
|
168
|
+
def display_timestamp t
|
169
|
+
if t && settings.friendly_timestamps?
|
170
|
+
content_tag(:abbr, tw((t > Time.now) ? "commons.time_in" : "commons.time_ago", time: distance_of_time_in_words(t, Time.now)), title: t)
|
171
|
+
else
|
172
|
+
t
|
173
|
+
end
|
174
|
+
end
|
155
175
|
end
|
156
176
|
end
|
157
177
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module MailyHerald
|
2
|
+
module Webui
|
3
|
+
module ListsHelper
|
4
|
+
def display_list_scope_status list, entity
|
5
|
+
if list.context.scope.exists?(entity)
|
6
|
+
content_tag(:span, icon(:check, tw("commons.positive")))
|
7
|
+
else
|
8
|
+
content_tag(:span, icon(:times, tw("commons.negative")), class: "text-warning")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -3,7 +3,7 @@ module MailyHerald
|
|
3
3
|
module LogsHelper
|
4
4
|
def log_actions log
|
5
5
|
actions = []
|
6
|
-
subscription = log.mailing.list.subscription_for(log.entity) if log.entity
|
6
|
+
subscription = log.mailing.list.subscription_for(log.entity) if log.mailing && log.entity
|
7
7
|
actions << {
|
8
8
|
name: :custom,
|
9
9
|
url: subscription_path(subscription),
|
@@ -26,12 +26,17 @@ module MailyHerald
|
|
26
26
|
when :delivered
|
27
27
|
content_tag(:span, icon(:check, tw("logs.status.delivered")), class: "text-success")
|
28
28
|
when :skipped
|
29
|
+
content_tag(:span, icon(:times, tw("logs.status.skipped")), class: "text-warning")
|
29
30
|
when :error
|
30
31
|
content_tag(:span, icon(:exclamation, tw("logs.status.error")), class: "text-danger")
|
31
32
|
when :scheduled
|
32
33
|
content_tag(:span, icon(:"clock-o", tw("logs.status.scheduled")), class: "text-muted")
|
33
34
|
end
|
34
35
|
end
|
36
|
+
|
37
|
+
def display_log_skip_reason skip_reason
|
38
|
+
tw("logs.skip_reason.#{skip_reason}") if skip_reason
|
39
|
+
end
|
35
40
|
end
|
36
41
|
end
|
37
42
|
end
|
@@ -15,14 +15,14 @@ module MailyHerald
|
|
15
15
|
actions = []
|
16
16
|
actions << {
|
17
17
|
name: :custom,
|
18
|
-
url:
|
18
|
+
url: deliver_ad_hoc_mailing_path(mailing, entity),
|
19
19
|
icon: "fa fa-paper-plane",
|
20
20
|
title: tw("mailings.list.deliver"),
|
21
21
|
if: mailing.processable?(entity),
|
22
22
|
remote: true,
|
23
23
|
method: :post,
|
24
|
-
confirm:
|
25
|
-
} if mailing.
|
24
|
+
data: {confirm: tw("mailings.list.deliver_confirm")}
|
25
|
+
} if mailing.ad_hoc?
|
26
26
|
actions << {
|
27
27
|
name: :custom,
|
28
28
|
url: {action: :preview, id: mailing, entity_id: entity},
|
@@ -44,11 +44,21 @@ module MailyHerald
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def link_to_mailing mailing
|
47
|
-
|
47
|
+
if mailing
|
48
|
+
link_to url_for_mailing(mailing) do
|
49
|
+
concat(friendly_name(mailing))
|
50
|
+
if mailing.locked?
|
51
|
+
concat(" ".html_safe)
|
52
|
+
concat(icon(:lock))
|
53
|
+
end
|
54
|
+
end
|
55
|
+
else
|
56
|
+
tw("mailings.missing")
|
57
|
+
end
|
48
58
|
end
|
49
59
|
|
50
60
|
def display_mailing_from mailing
|
51
|
-
tw("mailings.from.default", email: mailing.mailer.default[:from])
|
61
|
+
mailing.from || tw("mailings.from.default", email: mailing.mailer.default[:from])
|
52
62
|
end
|
53
63
|
|
54
64
|
def display_mailing_period mailing
|
@@ -59,6 +69,41 @@ module MailyHerald
|
|
59
69
|
def display_mailing_absolute_delay mailing
|
60
70
|
distance_of_time_in_words mailing.absolute_delay
|
61
71
|
end
|
72
|
+
|
73
|
+
def display_mailing_conditions mailing
|
74
|
+
if mailing.has_conditions_proc?
|
75
|
+
content_tag :span, class: "text-warning", data: {:toggle => "tooltip", :placement => "top"}, :title => tw("dispatches.hardcoded_info") do
|
76
|
+
concat(icon(:gears))
|
77
|
+
concat(" ".html_safe)
|
78
|
+
concat(tw(:label_hardcoded))
|
79
|
+
end
|
80
|
+
elsif mailing.conditions.is_a?(String)
|
81
|
+
content_tag(:code, mailing.conditions)
|
82
|
+
else
|
83
|
+
tw("mailings.conditions.missing")
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def display_mailing_conditions_status mailing, entity
|
88
|
+
if mailing.conditions_met?(entity)
|
89
|
+
content_tag(:span, icon(:check, tw("mailings.conditions.met")))
|
90
|
+
else
|
91
|
+
content_tag(:span, icon(:times, tw("mailings.conditions.unmet")), class: "text-warning")
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def display_mailing_start_at mailing
|
96
|
+
if mailing.has_start_at_proc?
|
97
|
+
content_tag :span, class: "text-warning", data: {:toggle => "tooltip", :placement => "top"}, :title => tw("dispatches.hardcoded_info") do
|
98
|
+
concat(icon(:gears))
|
99
|
+
concat(" ".html_safe)
|
100
|
+
concat(tw(:label_hardcoded))
|
101
|
+
end
|
102
|
+
elsif mailing.start_at.is_a?(String)
|
103
|
+
content_tag(:code, mailing.start_at)
|
104
|
+
else
|
105
|
+
end
|
106
|
+
end
|
62
107
|
end
|
63
108
|
end
|
64
109
|
end
|
@@ -1,6 +1,19 @@
|
|
1
1
|
module MailyHerald
|
2
2
|
module Webui
|
3
3
|
module SequencesHelper
|
4
|
+
def link_to_sequence sequence
|
5
|
+
if sequence
|
6
|
+
link_to url_for(sequence) do
|
7
|
+
concat(friendly_name(sequence))
|
8
|
+
if sequence.locked?
|
9
|
+
concat(" ".html_safe)
|
10
|
+
concat(icon(:lock))
|
11
|
+
end
|
12
|
+
end
|
13
|
+
else
|
14
|
+
tw("mailings.missing")
|
15
|
+
end
|
16
|
+
end
|
4
17
|
end
|
5
18
|
end
|
6
19
|
end
|
@@ -3,7 +3,7 @@ module MailyHerald
|
|
3
3
|
module SubscribersHelper
|
4
4
|
def subscriber_actions list, entity
|
5
5
|
actions = []
|
6
|
-
subscription = list.subscription_for(entity)
|
6
|
+
subscription = MailyHerald::Subscription.get_from(entity) || list.subscription_for(entity)
|
7
7
|
actions << {
|
8
8
|
name: :custom,
|
9
9
|
url: subscription_path(subscription),
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module MailyHerald
|
2
|
+
module Webui
|
3
|
+
class Settings
|
4
|
+
MAP = {
|
5
|
+
expert_mode: {type: :boolean, default: false},
|
6
|
+
show_skipped: {type: :boolean, default: false},
|
7
|
+
friendly_timestamps: {type: :boolean, default: true},
|
8
|
+
}.freeze
|
9
|
+
|
10
|
+
def initialize cookies
|
11
|
+
@cookies = cookies
|
12
|
+
end
|
13
|
+
|
14
|
+
def get setting
|
15
|
+
return unless exists?(setting)
|
16
|
+
|
17
|
+
v = @cookies[setting_key(setting)]
|
18
|
+
case setting_type(setting)
|
19
|
+
when :boolean
|
20
|
+
return setting_default(setting) unless v
|
21
|
+
return v == "1" ? true : false
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def set setting, value
|
26
|
+
return unless exists?(setting)
|
27
|
+
|
28
|
+
value = case setting_type(setting)
|
29
|
+
when :boolean
|
30
|
+
value ? "1" : "0"
|
31
|
+
end
|
32
|
+
@cookies.permanent[setting_key(setting)] = value
|
33
|
+
end
|
34
|
+
|
35
|
+
def toggle setting
|
36
|
+
return unless exists?(setting)
|
37
|
+
|
38
|
+
if setting_type(setting) == :boolean
|
39
|
+
v = get(setting)
|
40
|
+
set(setting, !v)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def exists? s
|
45
|
+
MAP.keys.include?(s.to_sym)
|
46
|
+
end
|
47
|
+
|
48
|
+
def method_missing(m, *args, &block)
|
49
|
+
m = m[0..(m.length-2)] if m[-1] == "?"
|
50
|
+
if exists?(m)
|
51
|
+
get(m)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def setting_key s
|
58
|
+
"maily_settings_#{s}"
|
59
|
+
end
|
60
|
+
|
61
|
+
def setting_type s
|
62
|
+
MAP[s.to_sym][:type]
|
63
|
+
end
|
64
|
+
|
65
|
+
def setting_default s
|
66
|
+
MAP[s.to_sym][:default]
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -13,14 +13,13 @@
|
|
13
13
|
%h1= link_to image_tag("maily_herald/webui/logo.svg", :class => "img-responsive logo"), root_path
|
14
14
|
.col-sm-6= render_breadcrumbs
|
15
15
|
.col-sm-3
|
16
|
-
.dropdown.pull-right
|
17
|
-
%a{:href => '#', :data => { toggle: 'dropdown'}
|
18
|
-
|
16
|
+
.dropdown.pull-right.dropdown-settings
|
17
|
+
%a{:href => '#', :data => { toggle: 'dropdown'}}
|
18
|
+
= icon(:cog, nil, title: t(".settings"))
|
19
19
|
%ul.dropdown-menu{'role' => 'menu'}
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
%li= link_to work_mode_t(:expert), switch_mode_path(:expert), :method => :post
|
20
|
+
%li= setting_switcher :expert_mode
|
21
|
+
%li= setting_switcher :show_skipped
|
22
|
+
%li= setting_switcher :friendly_timestamps
|
24
23
|
|
25
24
|
.section-wrapper
|
26
25
|
= render_main_menu
|