Commit 9351997f authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Move roles statistic to separate page

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent e5d3d06a
...@@ -23,8 +23,9 @@ ...@@ -23,8 +23,9 @@
%h3.text-center %h3.text-center
Users: Users:
= number_with_delimiter(User.count) = number_with_delimiter(User.count)
.text-center
= link_to 'Users statistics', admin_dashboard_stats_path
%hr %hr
= render "admin/dashboard/roles_stats"
= link_to 'New user', new_admin_user_path, class: "btn btn-new" = link_to 'New user', new_admin_user_path, class: "btn btn-new"
.col-sm-4 .col-sm-4
.info-well.dark-well .info-well.dark-well
......
...@@ -138,6 +138,8 @@ namespace :admin do ...@@ -138,6 +138,8 @@ namespace :admin do
get :status get :status
end end
end end
get '/dashboard/stats', to: 'dashboard#stats'
## EE-specific ## EE-specific
resources :labels resources :labels
......
...@@ -4,13 +4,7 @@ module EE ...@@ -4,13 +4,7 @@ module EE
module DashboardController module DashboardController
extend ActiveSupport::Concern extend ActiveSupport::Concern
prepended do def stats
before_action :set_roles_count, only: [:index]
end
private
def set_roles_count
@admin_count = ::User.admins.count @admin_count = ::User.admins.count
@roles_count = ::ProjectAuthorization.roles_stats @roles_count = ::ProjectAuthorization.roles_stats
end end
......
- if @admin_count
%p
Admin users
%span.light.pull-right
= @admin_count
- if @roles_count
- @roles_count.each do |row|
%p
Users with highest role
%strong
= row['kind']
%span.light.pull-right
= row['amount']
%h3 Users statistics
%table.table
%tr
%td Users total
%td
= User.count
- if @admin_count
%tr
%td Admin users
%td
= @admin_count
- if @roles_count
- @roles_count.each do |row|
%tr
%td
Users with highest role
%strong
= row['kind']
%td
= row['amount']
require 'spec_helper' require 'spec_helper'
describe "Admin Dashboard" do describe 'Admin Dashboard' do
describe 'Users statistic' do
before do before do
3.times do 3.times do
project = create(:project) project = create(:project)
...@@ -27,11 +28,12 @@ describe "Admin Dashboard" do ...@@ -27,11 +28,12 @@ describe "Admin Dashboard" do
describe 'Roles stats' do describe 'Roles stats' do
it 'show correct amount of users per role' do it 'show correct amount of users per role' do
visit admin_root_path visit admin_dashboard_stats_path
expect(page).to have_content('Admin users 1') expect(page).to have_content('Admin users 1')
expect(page).to have_content('Users with highest role developer 3') expect(page).to have_content('Users with highest role developer 3')
expect(page).to have_content('Users with highest role reporter 3') expect(page).to have_content('Users with highest role reporter 3')
end end
end end
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment