Class: Kenui::EmailNotificationsController
- Inherits:
-
EngineController
- Object
- ApplicationController
- EngineController
- Kenui::EmailNotificationsController
- Defined in:
- app/controllers/kenui/email_notifications_controller.rb
Instance Method Summary collapse
- #configuration ⇒ Object
- #events_to_consider ⇒ Object
- #index ⇒ Object
-
#pagination ⇒ Object
get account list, no sorting.
- #set_configuration ⇒ Object
Methods inherited from EngineController
#current_tenant_user, #get_layout, #options_for_klient
Instance Method Details
#configuration ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'app/controllers/kenui/email_notifications_controller.rb', line 56 def configuration account_id = params.require(:account_id) data = Kenui::EmailNotificationService.get_configuration_per_account(account_id,) respond_to do |format| format.json { render json: { data: data} } end end |
#events_to_consider ⇒ Object
48 49 50 51 52 53 54 |
# File 'app/controllers/kenui/email_notifications_controller.rb', line 48 def events_to_consider data = Kenui::EmailNotificationService.get_events_to_consider() respond_to do |format| format.json { render json: { data: data} } end end |
#index ⇒ Object
4 5 6 |
# File 'app/controllers/kenui/email_notifications_controller.rb', line 4 def index @record_total = (KillBillClient::Model::Account.find_in_batches(nil,nil,false,false,) || []).size end |
#pagination ⇒ Object
get account list, no sorting
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/controllers/kenui/email_notifications_controller.rb', line 9 def pagination search_key = (params[:search] || {})[:value].presence offset = (params[:start] || 0).to_i limit = (params[:length] || 50).to_i record_total = (params[:record_total] || 100).to_i data = [] if search_key.present? rows = KillBillClient::Model::Account.find_in_batches_by_search_key(search_key, offset, limit, false, false, ) else rows = KillBillClient::Model::Account.find_in_batches(offset, limit, false, false, ) end account_ids = rows.map { |account| account.account_id } email_notifications_configuration = Kenui::EmailNotificationService.get_configurations(account_ids, ) rows.each do |row| events = '' unless email_notifications_configuration.first.is_a?(FalseClass) configuration = email_notifications_configuration.select { |event| event[:kbAccountId] == row.account_id } events = configuration.map { |event| event[:eventType] }.join(', ') end data << [ row.name, view_context.link_to(row.account_id, "/accounts/#{row.account_id}"), events, view_context.link_to('<i class="fa fa-cog" aria-hidden="true"></i>'.html_safe, '#configureEmailNotification', data: { name: row.name, account_id: row.account_id, events: events, toggle: 'modal', target: '#configureEmailNotification'}) ] end respond_to do |format| format.json { render json: { data: data, recordsTotal: record_total, recordsFiltered: record_total} } end end |
#set_configuration ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'app/controllers/kenui/email_notifications_controller.rb', line 65 def set_configuration configuration = params.require(:configuration) is_success, = Kenui::EmailNotificationService.set_configuration_per_account(configuration[:account_id], configuration[:event_types], 'kenui', nil, nil, ) if is_success flash[:notice] = else flash[:error] = end redirect_to email_notifications_path end |