Class: Effective::LogsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Effective::LogsController
- Includes:
- CrudController
- Defined in:
- app/controllers/effective/logs_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
This is a post from our Javascript.
- #html_part ⇒ Object
-
#index ⇒ Object
This is the User index event.
Instance Method Details
#create ⇒ Object
This is a post from our Javascript
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 |
# File 'app/controllers/effective/logs_controller.rb', line 15 def create EffectiveResources.(self, :create, resource_scope.new) @log = resource_scope.new.tap do |log| log. = log_params[:message] log.status = EffectiveLogging.statuses.find { |status| status == log_params[:status] } || 'info' log.user = EffectiveLogging.current_user || current_user count = -1 Array((JSON.parse(log_params[:details]) rescue [])).flatten(1).each do |obj| if obj.kind_of?(Hash) obj.each { |k, v| log.details[k] = v if v.present? } else log.details["param_#{(count += 1)}"] = obj if obj.present? end end # Match the referrer log.details[:ip] ||= request.ip log.details[:referrer] ||= request.referrer log.details[:user_agent] ||= request.user_agent log.save end render text: 'ok', status: :ok, json: {} end |
#html_part ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'app/controllers/effective/logs_controller.rb', line 49 def html_part @log = resource_scope.find(params[:id]) EffectiveResources.(self, :show, @log) value = @log.details[(params[:key] || '').to_sym].to_s open = value.index('<!DOCTYPE html') || value.index('<html') close = value.rindex('</html>') if open.present? if open.present? && close.present? render inline: value[open...(close+7)].html_safe else render inline: value.html_safe end end |
#index ⇒ Object
This is the User index event
44 45 46 47 |
# File 'app/controllers/effective/logs_controller.rb', line 44 def index EffectiveResources.(self, :index, resource_scope.new(user: current_user, user_id: current_user.id)) @datatable = EffectiveLogsDatatable.new(self, for: current_user.id) end |