Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
9351997f
Commit
9351997f
authored
Feb 15, 2018
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move roles statistic to separate page
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
e5d3d06a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
56 additions
and
49 deletions
+56
-49
app/views/admin/dashboard/index.html.haml
app/views/admin/dashboard/index.html.haml
+2
-1
config/routes/admin.rb
config/routes/admin.rb
+2
-0
ee/app/controllers/ee/admin/dashboard_controller.rb
ee/app/controllers/ee/admin/dashboard_controller.rb
+1
-7
ee/app/views/admin/dashboard/_roles_stats.html.haml
ee/app/views/admin/dashboard/_roles_stats.html.haml
+0
-14
ee/app/views/admin/dashboard/stats.html.haml
ee/app/views/admin/dashboard/stats.html.haml
+22
-0
spec/ee/spec/features/admin/admin_dashboard_spec.rb
spec/ee/spec/features/admin/admin_dashboard_spec.rb
+29
-27
No files found.
app/views/admin/dashboard/index.html.haml
View file @
9351997f
...
@@ -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
...
...
config/routes/admin.rb
View file @
9351997f
...
@@ -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
...
...
ee/app/controllers/ee/admin/dashboard_controller.rb
View file @
9351997f
...
@@ -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
...
...
ee/app/views/admin/dashboard/_roles_stats.html.haml
deleted
100644 → 0
View file @
e5d3d06a
-
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'
]
ee/app/views/admin/dashboard/stats.html.haml
0 → 100644
View file @
9351997f
%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'
]
spec/ee/spec/features/admin/admin_dashboard_spec.rb
View file @
9351997f
require
'spec_helper'
require
'spec_helper'
describe
"Admin Dashboard"
do
describe
'Admin Dashboard'
do
before
do
describe
'Users statistic'
do
3
.
times
do
before
do
project
=
create
(
:project
)
3
.
times
do
user
=
create
(
:user
)
project
=
create
(
:project
)
project
.
add_reporter
(
user
)
user
=
create
(
:user
)
end
project
.
add_reporter
(
user
)
end
2
.
times
do
2
.
times
do
project
=
create
(
:project
)
project
=
create
(
:project
)
user
=
create
(
:user
)
user
=
create
(
:user
)
project
.
add_developer
(
user
)
project
.
add_developer
(
user
)
end
end
# Add same user as Reporter and Developer to different projects
# Add same user as Reporter and Developer to different projects
# and expect it to be counted once for the stats
# and expect it to be counted once for the stats
user
=
create
(
:user
)
user
=
create
(
:user
)
project1
=
Project
.
first
project1
=
Project
.
first
project2
=
Project
.
last
project2
=
Project
.
last
project1
.
add_reporter
(
user
)
project1
.
add_reporter
(
user
)
project2
.
add_developer
(
user
)
project2
.
add_developer
(
user
)
sign_in
(
create
(
:admin
))
sign_in
(
create
(
:admin
))
end
end
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment