diff --git a/app/controllers/admin/repp_logs_controller.rb b/app/controllers/admin/repp_logs_controller.rb new file mode 100644 index 000000000..f9caefadc --- /dev/null +++ b/app/controllers/admin/repp_logs_controller.rb @@ -0,0 +1,11 @@ +class Admin::ReppLogsController < ApplicationController + load_and_authorize_resource class: ApiLog::ReppLog + + def index + @repp_logs = ApiLog::ReppLog.order(id: :desc).page(params[:page]) + end + + def show + @repp_log = ApiLog::ReppLog.find(params[:id]) + end +end diff --git a/app/models/ability.rb b/app/models/ability.rb index 375f5b489..1a758b73e 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -25,6 +25,7 @@ class Ability can :manage, Keyrelay can :manage, LegalDocument can :read, ApiLog::EppLog + can :read, ApiLog::ReppLog can :index, :delayed_job can :create, :zonefile can :access, :settings_menu diff --git a/app/views/admin/epp_logs/show.haml b/app/views/admin/epp_logs/show.haml index faabc4acc..70ae49f9b 100644 --- a/app/views/admin/epp_logs/show.haml +++ b/app/views/admin/epp_logs/show.haml @@ -55,4 +55,3 @@ = preserve do %pre = @epp_log.response - diff --git a/app/views/admin/repp_logs/index.haml b/app/views/admin/repp_logs/index.haml new file mode 100644 index 000000000..d4900f8c9 --- /dev/null +++ b/app/views/admin/repp_logs/index.haml @@ -0,0 +1,28 @@ +.row + .col-sm-12 + %h2.text-center-xs= t('repp_logs') +%hr +.row + .col-md-12 + .table-responsive + %table.table.table-hover.table-bordered.table-condensed + %thead + %tr + %th{class: 'col-xs-2'}= t('request_path') + %th{class: 'col-xs-2'}= t('request_method') + %th{class: 'col-xs-2'}= t('response_code') + %th{class: 'col-xs-2'}= t('api_user') + %th{class: 'col-xs-2'}= t('registrar') + %th{class: 'col-xs-2'}= t('created_at') + %tbody + - @repp_logs.each do |x| + %tr + %td= link_to(x.request_path, admin_repp_log_path(x)) + %td= x.request_method + %td= x.response_code + %td= x.api_user_name + %td= x.api_user_registrar + %td= l(x.created_at) +.row + .col-md-12 + = paginate @repp_logs diff --git a/app/views/admin/repp_logs/show.haml b/app/views/admin/repp_logs/show.haml new file mode 100644 index 000000000..fcaa049b9 --- /dev/null +++ b/app/views/admin/repp_logs/show.haml @@ -0,0 +1,54 @@ +.row + .col-sm-6 + %h2.text-center-xs + = t('repp_log') + .col-sm-6 + %h2.text-right.text-center-xs + = link_to(t('back'), :back, class: 'btn btn-primary') +%hr +.row + .col-md-12 + .panel.panel-default + .panel-heading + %h3.panel-title= t('details') + .panel-body + %dl.dl-horizontal + %dt= t('request_path') + %dd= @repp_log.request_path + + %dt= t('request_method') + %dd= @repp_log.request_method + + %dt= t('response_code') + %dd= @repp_log.response_code + + %dt= t('api_user') + %dd= @repp_log.api_user_name + + %dt= t('registrar') + %dd= @repp_log.api_user_registrar + + %dt= t('ip') + %dd= @repp_log.ip + + %dt= t('created_at') + %dd= @repp_log.created_at + +.row + .col-md-6 + .panel.panel-default + .panel-heading + %h3.panel-title= t('request_params') + .panel-body + = preserve do + %pre + = JSON.pretty_generate(JSON.parse(@repp_log.request_params)) + / = @repp_log.request_params + .col-md-6 + .panel.panel-default + .panel-heading + %h3.panel-title= t('response') + .panel-body + = preserve do + %pre + = JSON.pretty_generate(JSON.parse(@repp_log.response)) diff --git a/app/views/layouts/application.haml b/app/views/layouts/application.haml index 63c3086f1..a7e4a80e9 100644 --- a/app/views/layouts/application.haml +++ b/app/views/layouts/application.haml @@ -49,6 +49,7 @@ %li= link_to t('zonefile'), admin_zonefile_settings_path %li= link_to t(:domains_history), admin_domain_versions_path %li= link_to t(:epp_logs), admin_epp_logs_path + %li= link_to t(:repp_logs), admin_repp_logs_path %li= link_to t(:background_jobs), admin_delayed_jobs_path %li.divider diff --git a/config/locales/en.yml b/config/locales/en.yml index a189cd60a..5e17ae60c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -490,3 +490,9 @@ en: response: 'Response' details: 'Details' ip: 'IP' + request_path: 'Request path' + request_method: 'Request method' + response_code: 'Response code' + request_params: 'Request params' + repp_log: 'REPP log' + repp_logs: 'REPP logs' diff --git a/config/routes.rb b/config/routes.rb index 8404209ac..8846b35b1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -41,6 +41,7 @@ Rails.application.routes.draw do resource :dashboard resources :epp_logs + resources :repp_logs root 'domains#index' end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 5b6adb3c2..d0c764f0c 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -22,6 +22,7 @@ describe User do it { should be_able_to(:manage, Keyrelay.new) } it { should be_able_to(:manage, LegalDocument.new) } it { should be_able_to(:read, ApiLog::EppLog.new) } + it { should be_able_to(:read, ApiLog::ReppLog.new) } it { should be_able_to(:index, :delayed_job) } it { should be_able_to(:create, :zonefile) } it { should be_able_to(:access, :settings_menu) } @@ -40,6 +41,7 @@ describe User do it { should_not be_able_to(:manage, EppUser.new) } it { should_not be_able_to(:manage, LegalDocument.new) } it { should_not be_able_to(:read, ApiLog::EppLog.new) } + it { should_not be_able_to(:read, ApiLog::ReppLog.new) } it { should_not be_able_to(:index, :delayed_job) } it { should_not be_able_to(:create, :zonefile) } it { should_not be_able_to(:access, :settings_menu) }