feat: audit logs UI (#6803)

* feat: init auditlogs ui

* chore: add api

* fix: action

* chore: add action,username,time

* feat: add pagination support

* chore: format time

* chore: refactor

* chore: refactor auditlogs api response

* chore: update icon

* chore: rubocop fixes

* Fixes the way meta is handled in store

* Fixes meta not appearing issue

---------

Co-authored-by: Sojan Jose <sojan@pepalo.com>
Co-authored-by: Nithin David Thomas <1277421+nithindavid@users.noreply.github.com>
This commit is contained in:
Vishnu Narayanan
2023-04-17 19:11:05 +05:30
committed by GitHub
parent 80dcd17f6e
commit 9e2f991484
15 changed files with 314 additions and 7 deletions

View File

@@ -2,22 +2,25 @@
class Api::V1::Accounts::AuditLogsController < Api::V1::Accounts::BaseController
before_action :check_admin_authorization?
before_action :fetch_audit
before_action :prepend_view_paths
RESULTS_PER_PAGE = 15
# Prepend the view path to the enterprise/app/views won't be available by default
def prepend_view_paths
prepend_view_path 'enterprise/app/views/'
end
def show
@audit_logs = @audit_logs.page(params[:page]).per(RESULTS_PER_PAGE)
render json: {
audit_logs: @audit_logs,
current_page: @audit_logs.current_page,
per_page: RESULTS_PER_PAGE,
total_entries: @audit_logs.total_count
}
@current_page = @audit_logs.current_page
@total_entries = @audit_logs.total_count
@per_page = RESULTS_PER_PAGE
end
private
def fetch_audit
@audit_logs = Current.account.associated_audits
@audit_logs = Current.account.associated_audits.order(created_at: :desc)
end
end

View File

@@ -0,0 +1,23 @@
json.per_page @per_page
json.total_entries @total_entries
json.current_page @current_page
json.audit_logs do
json.array! @audit_logs do |audit_log|
json.id audit_log.id
json.auditable_id audit_log.auditable_id
json.auditable_type audit_log.auditable_type
json.associated_id audit_log.associated_id
json.associated_type audit_log.associated_type
json.user_id audit_log.user_id
json.user_type audit_log.user_type
json.username audit_log.username
json.action audit_log.action
json.audited_changes audit_log.audited_changes
json.version audit_log.version
json.comment audit_log.comment
json.request_uuid audit_log.request_uuid
json.created_at audit_log.created_at.to_i
json.remote_address audit_log.remote_address
end
end