Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/controllers/reports_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class ReportsController < ApplicationController
before_action :confirm_admin_user

def index; end
end
3 changes: 3 additions & 0 deletions app/helpers/reports_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
module ReportsHelper
def report_url
"https://datastudio.google.com/embed/reporting/#{ENV.fetch('DATASTUDIO_REPORT_URL', '')}"
end
end
1 change: 1 addition & 0 deletions app/views/layouts/_navigation_links.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<%= link_to t('navigation.admin_tools.config_management'), configs_path, class: 'dropdown-item' %>
<% end %>
<%= link_to t('navigation.admin_tools.accounting'), accountants_path, class: 'dropdown-item' %>
<%= link_to t('navigation.admin_tools.reports'), reports_path, class: 'dropdown-item' %>
<%= link_to t('navigation.admin_tools.export'), patients_path(format: :csv), class: 'dropdown-item' %>
</div>
</div>
Expand Down
5 changes: 5 additions & 0 deletions app/views/reports/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<h1><%= t 'navigation.admin_tools.reports' %></h1>

<div class="col">
<iframe width="100%" height="600" src="<%= report_url %>" frameborder="0" style="border:0" allowfullscreen></iframe>
</div>
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ en:
config_management: Config Management
export: Export anonymized CSV
label: Admin
reports: Reporting Dashboard
user_management: User Management
cm_resources:
label: CM Resources
Expand Down
1 change: 1 addition & 0 deletions config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ es:
config_management: Manejo de Configuración
export: Exportación anónima de CSV
label: Administración
reports: Panel de Informes
user_management: Manejo de Usuarios
cm_resources:
label: Recursos del Administrador de Casos
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
resources :clinics, only: [:index, :create, :update, :new, :destroy, :edit]
resources :configs, only: [:index, :create, :update]
resources :events, only: [:index]
resources :reports, only: [:index]
end

# Auth routes
Expand Down
18 changes: 18 additions & 0 deletions test/controllers/reports_controller_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require "test_helper"

# Tests for reports controller
class ReportsControllerTest < ActionDispatch::IntegrationTest
describe 'index' do
it 'should render if admin' do
sign_in create :user, role: :admin
get reports_path
assert_response :success
end

it 'should deny if not' do
sign_in create :user, role: :cm
get reports_path
assert_redirected_to root_url
end
end
end