kenui 0.1.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 +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +34 -0
- data/Rakefile +36 -0
- data/app/assets/config/kenui_manifest.js +2 -0
- data/app/assets/javascripts/application.js +17 -0
- data/app/assets/javascripts/kenui/email_notifications.js +2 -0
- data/app/assets/javascripts/kenui/kenui.js +14 -0
- data/app/assets/stylesheets/application.css +19 -0
- data/app/assets/stylesheets/bootstrap_and_overrides.css +13 -0
- data/app/assets/stylesheets/kenui/email_notifications.css +81 -0
- data/app/controllers/kenui/email_notifications_controller.rb +82 -0
- data/app/controllers/kenui/engine_controller.rb +29 -0
- data/app/helpers/kenui/application_helper.rb +4 -0
- data/app/services/kenui/email_notification_service.rb +61 -0
- data/app/views/kenui/email_notifications/_configure_events_modal.html.erb +77 -0
- data/app/views/kenui/email_notifications/index.html.erb +50 -0
- data/app/views/kenui/layouts/kenui_application.html.erb +31 -0
- data/config/routes.rb +13 -0
- data/lib/kenui.rb +20 -0
- data/lib/kenui/engine.rb +17 -0
- data/lib/kenui/version.rb +3 -0
- data/lib/tasks/kenui_tasks.rake +4 -0
- metadata +191 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d3e83b87c2b3e2512053dfb1baacbaf4f73b23c8
|
4
|
+
data.tar.gz: 152bf9e4f5c9ee72dd2dffc1c902895cb924d78c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b402e0bb3ef302d9fa3851d1214f356e62cc627bb11d381f7875c0fc22cab422b775f408ee6898c5cd05a5f579308b613ea9a7d7680d8a0c9022aa419b611264
|
7
|
+
data.tar.gz: 194f2fad0d077a6ea089d1a910a9fd10f85767bffcec34d37c657a14241d9118fa0a8101fb4b0c85acab1118753f9650ff763ff5c5dda7c86b2c89ab1b351ea8
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2017 The Billing Project, LLC
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# killbill-email-notifications-ui
|
2
|
+
Rails mountable engine to configure the email notifications plugin
|
3
|
+
|
4
|
+
* See [killbill-email-notifications-plugin](https://github.com/killbill/killbill-email-notifications-plugin) to get started with the email notification plugin.
|
5
|
+
* See [killbill-admin-ui-standalone](https://github.com/killbill/killbill-admin-ui-standalone) to get started with the Kill Bill Admin UI.
|
6
|
+
|
7
|
+
Getting Started
|
8
|
+
---------------
|
9
|
+
|
10
|
+
You can run this locally by using the test/dummy app provided.
|
11
|
+
|
12
|
+
To do so, specify your Kill Bill server url, api key and secret in ```test/dummy/config/initializers/killbill_client.rb```:
|
13
|
+
|
14
|
+
```
|
15
|
+
KillBillClient.url = 'http://127.0.0.1:8080/'
|
16
|
+
KillBillClient.api_key = 'bob'
|
17
|
+
KillBillClient.api_secret = 'lazar'
|
18
|
+
```
|
19
|
+
|
20
|
+
Then, simply run:
|
21
|
+
|
22
|
+
```
|
23
|
+
rails s
|
24
|
+
```
|
25
|
+
|
26
|
+
|
27
|
+
To run tests:
|
28
|
+
|
29
|
+
```
|
30
|
+
rails t
|
31
|
+
```
|
32
|
+
|
33
|
+
## License
|
34
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'Kenui'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
load 'rails/tasks/statistics.rake'
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
require 'bundler/gem_tasks'
|
26
|
+
|
27
|
+
require 'rake/testtask'
|
28
|
+
|
29
|
+
Rake::TestTask.new(:test) do |t|
|
30
|
+
t.libs << 'test'
|
31
|
+
t.pattern = 'test/**/*_test.rb'
|
32
|
+
t.verbose = false
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
task default: :test
|
@@ -0,0 +1,17 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require jquery
|
14
|
+
//= require twitter/bootstrap
|
15
|
+
//= require dataTables/jquery.dataTables
|
16
|
+
//= require dataTables/bootstrap/3/jquery.dataTables.bootstrap
|
17
|
+
//= require kenui/kenui
|
@@ -0,0 +1,14 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
14
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_self
|
14
|
+
*= require dataTables/jquery.dataTables
|
15
|
+
*= require dataTables/bootstrap/3/jquery.dataTables.bootstrap
|
16
|
+
*= require font-awesome
|
17
|
+
*= require kenui/email_notifications
|
18
|
+
*= require bootstrap_and_overrides
|
19
|
+
*/
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
*= require twitter-bootstrap-static/bootstrap
|
3
|
+
*/
|
4
|
+
|
5
|
+
/* Override Bootstrap 3 font locations */
|
6
|
+
@font-face {
|
7
|
+
font-family: 'Glyphicons Halflings';
|
8
|
+
src: url('../assets/glyphicons-halflings-regular.eot');
|
9
|
+
src: url('../assets/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'),
|
10
|
+
url('../assets/glyphicons-halflings-regular.woff') format('woff'),
|
11
|
+
url('../assets/glyphicons-halflings-regular.ttf') format('truetype'),
|
12
|
+
url('../assets/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');
|
13
|
+
}
|
@@ -0,0 +1,81 @@
|
|
1
|
+
/*
|
2
|
+
Place all the styles related to the matching controller here.
|
3
|
+
They will automatically be included in application.css.
|
4
|
+
*/
|
5
|
+
|
6
|
+
/* The switch - the box around the slider */
|
7
|
+
.switch {
|
8
|
+
position: relative;
|
9
|
+
display: inline-block;
|
10
|
+
width: 36px;
|
11
|
+
height: 20px;
|
12
|
+
}
|
13
|
+
|
14
|
+
/* Hide default HTML checkbox */
|
15
|
+
.switch input {display:none;}
|
16
|
+
|
17
|
+
/* The slider */
|
18
|
+
.slider {
|
19
|
+
position: absolute;
|
20
|
+
cursor: pointer;
|
21
|
+
top: 0;
|
22
|
+
left: 0;
|
23
|
+
right: 0;
|
24
|
+
bottom: 0;
|
25
|
+
background-color: #ccc;
|
26
|
+
-webkit-transition: .4s;
|
27
|
+
transition: .4s;
|
28
|
+
}
|
29
|
+
|
30
|
+
.slider:before {
|
31
|
+
position: absolute;
|
32
|
+
content: "";
|
33
|
+
height: 16px;
|
34
|
+
width: 16px;
|
35
|
+
left: 2px;
|
36
|
+
bottom: 2px;
|
37
|
+
background-color: white;
|
38
|
+
-webkit-transition: .4s;
|
39
|
+
transition: .4s;
|
40
|
+
}
|
41
|
+
|
42
|
+
input:checked + .slider {
|
43
|
+
background-color: #00919d;
|
44
|
+
}
|
45
|
+
|
46
|
+
input:focus + .slider {
|
47
|
+
box-shadow: 0 0 1px #2196F3;
|
48
|
+
}
|
49
|
+
|
50
|
+
input:checked + .slider:before {
|
51
|
+
-webkit-transform: translateX(16px);
|
52
|
+
-ms-transform: translateX(16px);
|
53
|
+
transform: translateX(16px);
|
54
|
+
}
|
55
|
+
|
56
|
+
/* Rounded sliders */
|
57
|
+
.slider.round {
|
58
|
+
border-radius: 26px;
|
59
|
+
}
|
60
|
+
|
61
|
+
.slider.round:before {
|
62
|
+
border-radius: 50%;
|
63
|
+
}
|
64
|
+
|
65
|
+
label.capitalize {
|
66
|
+
text-transform: capitalize;
|
67
|
+
}
|
68
|
+
|
69
|
+
#events {
|
70
|
+
margin-bottom: 15px;
|
71
|
+
}
|
72
|
+
|
73
|
+
#events .form-group{
|
74
|
+
margin-bottom: 0;
|
75
|
+
}
|
76
|
+
|
77
|
+
.event-class{
|
78
|
+
word-wrap: break-word;
|
79
|
+
max-width: 400px;
|
80
|
+
font-size: .8em;
|
81
|
+
}
|
@@ -0,0 +1,82 @@
|
|
1
|
+
module Kenui
|
2
|
+
class EmailNotificationsController < Kenui::EngineController
|
3
|
+
|
4
|
+
def index
|
5
|
+
@record_total = (KillBillClient::Model::Account.find_in_batches(nil,nil,false,false,options_for_klient) || []).size
|
6
|
+
end
|
7
|
+
|
8
|
+
# get account list, no sorting
|
9
|
+
def pagination
|
10
|
+
search_key = (params[:search] || {})[:value].presence
|
11
|
+
offset = (params[:start] || 0).to_i
|
12
|
+
limit = (params[:length] || 50).to_i
|
13
|
+
record_total = (params[:record_total] || 100).to_i
|
14
|
+
data = []
|
15
|
+
|
16
|
+
if search_key.present?
|
17
|
+
rows = KillBillClient::Model::Account.find_in_batches_by_search_key(search_key, offset, limit, false, false, options_for_klient)
|
18
|
+
else
|
19
|
+
rows = KillBillClient::Model::Account.find_in_batches(offset, limit, false, false, options_for_klient)
|
20
|
+
end
|
21
|
+
|
22
|
+
account_ids = rows.map { |account| account.account_id }
|
23
|
+
email_notifications_configuration = Kenui::EmailNotificationService.get_configurations(account_ids, options_for_klient)
|
24
|
+
|
25
|
+
rows.each do |row|
|
26
|
+
events = ''
|
27
|
+
unless email_notifications_configuration.first.is_a?(FalseClass)
|
28
|
+
configuration = email_notifications_configuration.select { |event| event[:kbAccountId] == row.account_id }
|
29
|
+
events = configuration.map { |event| event[:eventType] }.join(', ')
|
30
|
+
end
|
31
|
+
|
32
|
+
data << [
|
33
|
+
row.name,
|
34
|
+
view_context.link_to(row.account_id, "/accounts/#{row.account_id}"),
|
35
|
+
events,
|
36
|
+
view_context.link_to('<i class="fa fa-cog" aria-hidden="true"></i>'.html_safe,
|
37
|
+
'#configureEmailNotification',
|
38
|
+
data: { name: row.name, account_id: row.account_id,
|
39
|
+
events: events, toggle: 'modal', target: '#configureEmailNotification'})
|
40
|
+
]
|
41
|
+
end
|
42
|
+
|
43
|
+
respond_to do |format|
|
44
|
+
format.json { render json: { data: data, recordsTotal: record_total, recordsFiltered: record_total} }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def events_to_consider
|
49
|
+
data = Kenui::EmailNotificationService.get_events_to_consider(options_for_klient)
|
50
|
+
|
51
|
+
respond_to do |format|
|
52
|
+
format.json { render json: { data: data} }
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def configuration
|
57
|
+
account_id = params.require(:account_id)
|
58
|
+
data = Kenui::EmailNotificationService.get_configuration_per_account(account_id,options_for_klient)
|
59
|
+
|
60
|
+
respond_to do |format|
|
61
|
+
format.json { render json: { data: data} }
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def set_configuration
|
66
|
+
configuration = params.require(:configuration)
|
67
|
+
|
68
|
+
is_success, message = Kenui::EmailNotificationService.set_configuration_per_account(configuration[:account_id],
|
69
|
+
configuration[:event_types],
|
70
|
+
'kenui', nil, nil,
|
71
|
+
options_for_klient )
|
72
|
+
|
73
|
+
if is_success
|
74
|
+
flash[:notice] = message
|
75
|
+
else
|
76
|
+
flash[:error] = message
|
77
|
+
end
|
78
|
+
redirect_to email_notifications_path
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Kenui
|
2
|
+
class EngineController < ApplicationController
|
3
|
+
|
4
|
+
layout :get_layout
|
5
|
+
|
6
|
+
def get_layout
|
7
|
+
layout ||= Kenui.config[:layout]
|
8
|
+
end
|
9
|
+
|
10
|
+
def current_tenant_user
|
11
|
+
# If the rails application on which that engine is mounted defines such method (Devise), we extract the current user,
|
12
|
+
# if not we default to nil, and serve our static mock configuration
|
13
|
+
user = current_user if respond_to?(:current_user)
|
14
|
+
Kenui.current_tenant_user.call(session, user)
|
15
|
+
end
|
16
|
+
|
17
|
+
def options_for_klient
|
18
|
+
user = current_tenant_user
|
19
|
+
{
|
20
|
+
:username => user[:username],
|
21
|
+
:password => user[:password],
|
22
|
+
:session_id => user[:session_id],
|
23
|
+
:api_key => user[:api_key],
|
24
|
+
:api_secret => user[:api_secret]
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Kenui
|
2
|
+
# class where email notification services resides
|
3
|
+
class EmailNotificationService < KillBillClient::Model::Resource
|
4
|
+
|
5
|
+
KILLBILL_EMAIL_NOTIFICATION_PREFIX = '/plugins/killbill-email-notifications/v1'
|
6
|
+
|
7
|
+
class << self
|
8
|
+
|
9
|
+
def get_events_to_consider(options = {})
|
10
|
+
path = "#{KILLBILL_EMAIL_NOTIFICATION_PREFIX}/eventsToConsider"
|
11
|
+
response = KillBillClient::API.get path, {}, options
|
12
|
+
JSON.parse(response.body)
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_configurations(account_ids, options = {})
|
16
|
+
path = "#{KILLBILL_EMAIL_NOTIFICATION_PREFIX}/accounts"
|
17
|
+
response = KillBillClient::API.get path, {:kbAccountId => account_ids}, options
|
18
|
+
|
19
|
+
JSON.parse(response.body).map(&:symbolize_keys)
|
20
|
+
rescue => e
|
21
|
+
return false, e.message.to_s
|
22
|
+
end
|
23
|
+
|
24
|
+
def get_configuration_per_account(account_id, options = {})
|
25
|
+
path = "#{KILLBILL_EMAIL_NOTIFICATION_PREFIX}/accounts/#{account_id}"
|
26
|
+
response = KillBillClient::API.get path, {}, options
|
27
|
+
|
28
|
+
JSON.parse(response.body).map(&:symbolize_keys)
|
29
|
+
rescue => e
|
30
|
+
return false, e.message.to_s
|
31
|
+
end
|
32
|
+
|
33
|
+
def set_configuration_per_account(account_id, event_types, user = 'kenui', reason = nil, comment = nil, options = {})
|
34
|
+
path = "#{KILLBILL_EMAIL_NOTIFICATION_PREFIX}/accounts/#{account_id}"
|
35
|
+
more_options = {}
|
36
|
+
more_options[:user] = user
|
37
|
+
more_options[:reason] = reason unless reason.nil?
|
38
|
+
more_options[:comment] = comment unless comment.nil?
|
39
|
+
|
40
|
+
KillBillClient::API.post path, event_types, {}, options.merge(more_options)
|
41
|
+
|
42
|
+
return true, "Email notifications for account #{account_id} was successfully updated"
|
43
|
+
rescue => e
|
44
|
+
return false, e.message.to_s
|
45
|
+
end
|
46
|
+
|
47
|
+
def email_notification_plugin_available?(options = nil)
|
48
|
+
|
49
|
+
# inquire if the plugin is listening
|
50
|
+
path = KILLBILL_EMAIL_NOTIFICATION_PREFIX
|
51
|
+
KillBillClient::API.get path, nil, options
|
52
|
+
|
53
|
+
return true, nil
|
54
|
+
# Response error if email notification plugin is not listening
|
55
|
+
rescue KillBillClient::API::ResponseError => e
|
56
|
+
return false, e.message.to_s
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
<div class="modal fade" id="configureEmailNotification" tabindex="-1" role="dialog">
|
2
|
+
<div class="modal-dialog" role="document">
|
3
|
+
<div class="modal-content column-block">
|
4
|
+
<div>
|
5
|
+
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
6
|
+
<h1 class="modal-title">Configure email notifications</h1>
|
7
|
+
</div>
|
8
|
+
<div class="modal-body">
|
9
|
+
<%= form_for :configuration, :url => email_notifications_configuration_path , :method => :post, :html => {:class => 'form-horizontal'} do |f| %>
|
10
|
+
<div class='form-group'>
|
11
|
+
<%= f.label :name, 'Name', :class => 'col-sm-4 control-label' %>
|
12
|
+
<div class="col-sm-8">
|
13
|
+
<%= f.text_field :name, :class => 'form-control', :readonly => true %>
|
14
|
+
</div>
|
15
|
+
</div>
|
16
|
+
<div class='form-group'>
|
17
|
+
<%= f.label :account_id, 'Account id', :class => 'col-sm-4 control-label' %>
|
18
|
+
<div class="col-sm-8">
|
19
|
+
<%= f.text_field :account_id, :class => 'form-control', :readonly => true %>
|
20
|
+
</div>
|
21
|
+
</div>
|
22
|
+
<div id="events">
|
23
|
+
|
24
|
+
</div>
|
25
|
+
|
26
|
+
<div class="form-group">
|
27
|
+
<div class="col-sm-offset-4 col-sm-8">
|
28
|
+
<%= submit_tag 'Save', :class => 'btn btn-default' %>
|
29
|
+
</div>
|
30
|
+
</div>
|
31
|
+
<% end %>
|
32
|
+
</div>
|
33
|
+
</div><!-- /.modal-content -->
|
34
|
+
</div><!-- /.modal-dialog -->
|
35
|
+
</div><!-- /.modal -->
|
36
|
+
|
37
|
+
<%= javascript_tag do %>
|
38
|
+
$(document).ready(function() {
|
39
|
+
|
40
|
+
getEventsToConsider();
|
41
|
+
|
42
|
+
$('#configureEmailNotification').on('show.bs.modal', function (e) {
|
43
|
+
$("#configuration_account_id").val(e.relatedTarget.dataset['accountId']);
|
44
|
+
$("#configuration_name").val(e.relatedTarget.dataset['name']);
|
45
|
+
|
46
|
+
// reset toggles
|
47
|
+
var eventsToConsider = $("#configureEmailNotification").find('input[type="checkbox"]');
|
48
|
+
$.each( eventsToConsider, function( index, elem ) {
|
49
|
+
$(elem).prop('checked',false);
|
50
|
+
});
|
51
|
+
|
52
|
+
var events = (e.relatedTarget.dataset['events']).split(',');
|
53
|
+
$.each( events, function( index, val ) {
|
54
|
+
$("#"+val.trim()).prop('checked',true);
|
55
|
+
});
|
56
|
+
});
|
57
|
+
|
58
|
+
function getEventsToConsider(){
|
59
|
+
$.getJSON("<%= email_notification_events_to_consider_path %>", function( response ) {
|
60
|
+
var events = [];
|
61
|
+
$.each( response.data, function( index, val ) {
|
62
|
+
events.push( '<div class="form-group">' +
|
63
|
+
'<div class="col-sm-offset-4 col-sm-6">' +
|
64
|
+
' <div class="row"><div class="col-sm-4"><label class="switch">' +
|
65
|
+
' <input type="checkbox" value="' + val + '" name="configuration[event_types][]" id="' + val + '">' +
|
66
|
+
' <span class="slider round"></span>' +
|
67
|
+
' </label></div>' +
|
68
|
+
' <label class="col-sm-8 capitalize">' + val + '</label>' +
|
69
|
+
'</div></div>' +
|
70
|
+
'</div>');
|
71
|
+
});
|
72
|
+
|
73
|
+
$("#events").html(events.join( "" ));
|
74
|
+
});
|
75
|
+
}
|
76
|
+
});
|
77
|
+
<% end %>
|
@@ -0,0 +1,50 @@
|
|
1
|
+
<div class="search">
|
2
|
+
|
3
|
+
<div class="column-block">
|
4
|
+
|
5
|
+
<h1>Email notifications configuration - Showing accounts</h1>
|
6
|
+
|
7
|
+
<table id="accounts-table" class="table table-condensed mobile-data">
|
8
|
+
<thead>
|
9
|
+
<tr>
|
10
|
+
<th>Name</th>
|
11
|
+
<th>ID</th>
|
12
|
+
<th>Events</th>
|
13
|
+
<th></th>
|
14
|
+
</tr>
|
15
|
+
</thead>
|
16
|
+
<tbody>
|
17
|
+
<tr>
|
18
|
+
<td colspan="3" class="dataTables_empty">Loading data from server</td>
|
19
|
+
</tr>
|
20
|
+
</tbody>
|
21
|
+
</table>
|
22
|
+
|
23
|
+
</div>
|
24
|
+
|
25
|
+
<%= render :partial => 'configure_events_modal' %>
|
26
|
+
|
27
|
+
</div>
|
28
|
+
|
29
|
+
<%= javascript_tag do %>
|
30
|
+
$(document).ready(function() {
|
31
|
+
var table = $('#accounts-table').DataTable({
|
32
|
+
"pagingType": "simple",
|
33
|
+
"language": {
|
34
|
+
"info": "Showing _START_ to _END_ of _TOTAL_ entries"
|
35
|
+
},
|
36
|
+
"pageLength": 50,
|
37
|
+
"displayStart": 0,
|
38
|
+
"order": [[ 0, "asc" ]],
|
39
|
+
"ordering": false,
|
40
|
+
"processing": true,
|
41
|
+
"serverSide": true,
|
42
|
+
"search": {"search": null},
|
43
|
+
"ajax": "<%= email_notification_pagination_path(:record_total => @record_total, :format => :json) %>",
|
44
|
+
"columnDefs": [
|
45
|
+
{ className: "event-class", "targets": [ 2 ] }
|
46
|
+
]
|
47
|
+
});
|
48
|
+
|
49
|
+
});
|
50
|
+
<% end %>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Kenui</title>
|
5
|
+
<%= yield :scripts %>
|
6
|
+
<%= stylesheet_link_tag 'application', :media => 'all' %>
|
7
|
+
<%= javascript_include_tag 'application' %>
|
8
|
+
<%= csrf_meta_tags %>
|
9
|
+
</head>
|
10
|
+
<div class="container-fluid">
|
11
|
+
<%- # :alert used by devise -%>
|
12
|
+
<% [:error, :alert].each do |key| %>
|
13
|
+
<% if flash[key] %>
|
14
|
+
<div class="row">
|
15
|
+
<div class="col-md-10 col-md-offset-2">
|
16
|
+
<div class="alert alert-error"><%= flash[key] %></div>
|
17
|
+
</div>
|
18
|
+
</div>
|
19
|
+
<% end %>
|
20
|
+
<% end %>
|
21
|
+
<% if flash[:notice] %>
|
22
|
+
<div class="row">
|
23
|
+
<div class="col-md-10 col-md-offset-2">
|
24
|
+
<div class="alert alert-info"><%= flash[:notice] %></div>
|
25
|
+
</div>
|
26
|
+
</div>
|
27
|
+
<% end %>
|
28
|
+
<%= yield %>
|
29
|
+
</div>
|
30
|
+
</body>
|
31
|
+
</html>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Kenui::Engine.routes.draw do
|
2
|
+
|
3
|
+
root to: 'email_notifications#index'
|
4
|
+
|
5
|
+
resources :email_notifications, :only => [:index]
|
6
|
+
|
7
|
+
scope '/email_notifications' do
|
8
|
+
match '/pagination' => 'email_notifications#pagination', :via => :get, :as => 'email_notification_pagination'
|
9
|
+
match '/configuration' => 'email_notifications#configuration', :via => :get, :as => 'email_notifications_get_configuration'
|
10
|
+
match '/configuration' => 'email_notifications#set_configuration', :via => :post, :as => 'email_notifications_configuration'
|
11
|
+
match '/events_to_consider' => 'email_notifications#events_to_consider', :via => :get, :as => 'email_notification_events_to_consider'
|
12
|
+
end
|
13
|
+
end
|
data/lib/kenui.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require "kenui/engine"
|
2
|
+
|
3
|
+
module Kenui
|
4
|
+
mattr_accessor :current_tenant_user
|
5
|
+
mattr_accessor :layout
|
6
|
+
|
7
|
+
self.current_tenant_user = lambda { |session, user|
|
8
|
+
{:username => 'admin',
|
9
|
+
:password => 'password',
|
10
|
+
:session_id => nil,
|
11
|
+
:api_key => KillBillClient.api_key,
|
12
|
+
:api_secret => KillBillClient.api_secret}
|
13
|
+
}
|
14
|
+
|
15
|
+
def self.config(&block)
|
16
|
+
{
|
17
|
+
:layout => layout || 'kenui/layouts/kenui_application',
|
18
|
+
}
|
19
|
+
end
|
20
|
+
end
|
data/lib/kenui/engine.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# Dependencies
|
2
|
+
#
|
3
|
+
# Sigh. Rails autoloads the gems specified in the Gemfile and nothing else.
|
4
|
+
# We need to explicitly require all of our dependencies listed in avatax.gemspec
|
5
|
+
#
|
6
|
+
# See also https://github.com/carlhuda/bundler/issues/49
|
7
|
+
require 'jquery-rails'
|
8
|
+
require 'jquery-datatables-rails'
|
9
|
+
require 'font-awesome-rails'
|
10
|
+
require 'twitter-bootstrap-rails'
|
11
|
+
require 'killbill_client'
|
12
|
+
|
13
|
+
module Kenui
|
14
|
+
class Engine < ::Rails::Engine
|
15
|
+
isolate_namespace Kenui
|
16
|
+
end
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,191 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kenui
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kill Bill core team
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-11-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 5.1.4
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 5.1.4
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: jquery-rails
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '4.3'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '4.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: jquery-datatables-rails
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.3'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: twitter-bootstrap-rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: font-awesome-rails
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '4.7'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '4.7'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: killbill-client
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: sqlite3
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rake
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: listen
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
description: Rails UI plugin for the Email notification plugin.
|
140
|
+
email: killbilling-users@googlegroups.com
|
141
|
+
executables: []
|
142
|
+
extensions: []
|
143
|
+
extra_rdoc_files: []
|
144
|
+
files:
|
145
|
+
- MIT-LICENSE
|
146
|
+
- README.md
|
147
|
+
- Rakefile
|
148
|
+
- app/assets/config/kenui_manifest.js
|
149
|
+
- app/assets/javascripts/application.js
|
150
|
+
- app/assets/javascripts/kenui/email_notifications.js
|
151
|
+
- app/assets/javascripts/kenui/kenui.js
|
152
|
+
- app/assets/stylesheets/application.css
|
153
|
+
- app/assets/stylesheets/bootstrap_and_overrides.css
|
154
|
+
- app/assets/stylesheets/kenui/email_notifications.css
|
155
|
+
- app/controllers/kenui/email_notifications_controller.rb
|
156
|
+
- app/controllers/kenui/engine_controller.rb
|
157
|
+
- app/helpers/kenui/application_helper.rb
|
158
|
+
- app/services/kenui/email_notification_service.rb
|
159
|
+
- app/views/kenui/email_notifications/_configure_events_modal.html.erb
|
160
|
+
- app/views/kenui/email_notifications/index.html.erb
|
161
|
+
- app/views/kenui/layouts/kenui_application.html.erb
|
162
|
+
- config/routes.rb
|
163
|
+
- lib/kenui.rb
|
164
|
+
- lib/kenui/engine.rb
|
165
|
+
- lib/kenui/version.rb
|
166
|
+
- lib/tasks/kenui_tasks.rake
|
167
|
+
homepage: http://www.killbill.io
|
168
|
+
licenses:
|
169
|
+
- MIT
|
170
|
+
metadata: {}
|
171
|
+
post_install_message:
|
172
|
+
rdoc_options: []
|
173
|
+
require_paths:
|
174
|
+
- lib
|
175
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
176
|
+
requirements:
|
177
|
+
- - ">="
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: '0'
|
180
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
181
|
+
requirements:
|
182
|
+
- - ">="
|
183
|
+
- !ruby/object:Gem::Version
|
184
|
+
version: '0'
|
185
|
+
requirements: []
|
186
|
+
rubyforge_project:
|
187
|
+
rubygems_version: 2.6.13
|
188
|
+
signing_key:
|
189
|
+
specification_version: 4
|
190
|
+
summary: Kill Bill Email Notification UI mountable engine
|
191
|
+
test_files: []
|