Class: Admin::DashboardsController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- ApplicationController
- BaseController
- Admin::DashboardsController
- Defined in:
- app/controllers/admin/dashboards_controller.rb
Constant Summary
Constants inherited from BaseController
BaseController::INTERNAL_SERVER_ERROR_MESSAGE
Instance Method Summary collapse
Methods inherited from BaseController
#destroy_session, #identity_cache_memoization, #sign_in_page, #user_developer_session
Methods included from LogrageCustomLogger
Methods included from AdminHelper
#dynamic_pricings_formatter, #link_to_admin_reservations_path_by_id, #link_to_admin_restaurants_path_by_id, #link_to_log, #optional_locales, #optional_locales_with_labels, #staff_signed_in?
Methods included from UpdateLocaleConcern
Methods inherited from ApplicationController
#after_sign_in_path_for, #after_sign_out_path_for, #default_url_options, #identity_cache_memoization, #render_not_found, #routing_error, search_params_key=
Methods included from ControllerHelpers
#check_boolean_param, #get_banners, #inventory_params, #reservation_params
Instance Method Details
#change_locale ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/admin/dashboards_controller.rb', line 6 def change_locale target_locale = if MyLocaleManager.normalize_locale == :en :th else :en end new_link = request.referrer.to_s if new_link.include? 'locale=' new_link = new_link.sub(/locale=\w+/, "locale=#{target_locale}") else new_link += if new_link.include?('?') "&locale=#{target_locale}" else "?locale=#{target_locale}" end end redirect_to new_link end |
#custom_notification ⇒ Object
25 |
# File 'app/controllers/admin/dashboards_controller.rb', line 25 def custom_notification; end |
#send_custom_notification ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/controllers/admin/dashboards_controller.rb', line 27 def send_custom_notification notif = PushNotification.new(params[:receiver_type].presence || 'staff') to = params[:token] title = params[:title] body = params[:body] deep_link = params[:deep_link] id = params[:id].presence || Reservation.last.id type = params[:type].presence || 'reservations' send_notif = notif.publish(to: to, title: title, body: body, deep_link: deep_link, id: id, type: type) if send_notif.try(:code)&.to_i == 200 redirect_to admin_custom_notification_path, notice: 'Notification sent successfully' else redirect_to admin_custom_notification_path, alert: 'Failed to send notification' end end |