Skip to content

Commit a4d6726

Browse files
committed
List user quota
1 parent 10559bb commit a4d6726

12 files changed

+86
-65
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
#test_18_3-ee_CDB: { uses: "rammpeter/panorama/.github/workflows/run_tests.yml@master", needs: [setup], with: { db_version: "18.3.0.0-ee", container: "CDB", max_parallel: 4 }, secrets: "inherit"}
3737
#test_18_3-ee_PDB: { uses: "rammpeter/panorama/.github/workflows/run_tests.yml@master", needs: [setup], with: { db_version: "18.3.0.0-ee", container: "PDB", max_parallel: 4 }, secrets: "inherit"}
3838
test_18_4-xe_CDB: { uses: "rammpeter/panorama/.github/workflows/run_tests.yml@master", needs: [setup], with: { db_version: "18.4.0.0-xe", container: "CDB", max_parallel: 4 }, secrets: "inherit"}
39-
test_18_4-xe_PDB: { uses: "rammpeter/panorama/.github/workflows/run_tests.yml@master", needs: [setup], with: { db_version: "18.4.0.0-xe", container: "PDB", max_parallel: 4 }, secrets: "inherit"}
39+
# test_18_4-xe_PDB: { uses: "rammpeter/panorama/.github/workflows/run_tests.yml@master", needs: [setup], with: { db_version: "18.4.0.0-xe", container: "PDB", max_parallel: 4 }, secrets: "inherit"}
4040
#test_19_10-ee_CDB: { uses: "rammpeter/panorama/.github/workflows/run_tests.yml@master", needs: [setup], with: { db_version: "19.10.0.0-ee", container: "CDB", max_parallel: 4 }, secrets: "inherit"}
4141
test_19_10-ee_PDB: { uses: "rammpeter/panorama/.github/workflows/run_tests.yml@master", needs: [setup], with: { db_version: "19.10.0.0-ee", container: "PDB", max_parallel: 4 }, secrets: "inherit"}
4242
test_19_10-se2_CDB: { uses: "rammpeter/panorama/.github/workflows/run_tests.yml@master", needs: [setup], with: { db_version: "19.10.0.0-se2", container: "CDB", max_parallel: 4 }, secrets: "inherit"}

app/controllers/dba_schema_controller.rb

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,22 @@ def list_db_users
5858
Objects AS (SELECT /*+ NO_MERGE MATERIALIZE */ Owner, COUNT(*) Object_Cnt
5959
FROM DBA_Objects
6060
GROUP BY Owner
61-
)
61+
),
62+
Quotas AS (SELECT /*+ NO_MERGE MATERIALIZE */ Username, COUNT(*) Quota_Cnt FROM DBA_TS_Quotas GROUP BY UserName)
6263
SELECT u.*,
6364
NVL(p.Granted_Roles, 0) Granted_Roles,
6465
NVL(s.Privilege_Cnt,0) Privilege_Cnt,
6566
NVL(t.Obj_Grants,0) Obj_Grants,
6667
NVL(gt.Granted_Obj_Grants,0) Granted_Obj_Grants,
67-
NVL(o.Object_Cnt, 0) Object_Cnt
68+
NVL(o.Object_Cnt, 0) Object_Cnt,
69+
NVL(q.Quota_Cnt, 0) Quota_Cnt
6870
FROM Users u
69-
LEFT OUTER JOIN Role_Privs p ON p.Grantee = u.UserName
70-
LEFT OUTER JOIN Tab_Privs t ON t.Grantee = u.UserName
71-
LEFT OUTER JOIN Granted_Tab_Privs gt ON gt.Grantor = u.UserName
72-
LEFT OUTER JOIN Sys_Privs s ON s.Grantee = u.UserName
73-
LEFT OUTER JOIN Objects o ON o.Owner = u.UserName
71+
LEFT OUTER JOIN Role_Privs p ON p.Grantee = u.UserName
72+
LEFT OUTER JOIN Tab_Privs t ON t.Grantee = u.UserName
73+
LEFT OUTER JOIN Granted_Tab_Privs gt ON gt.Grantor = u.UserName
74+
LEFT OUTER JOIN Sys_Privs s ON s.Grantee = u.UserName
75+
LEFT OUTER JOIN Objects o ON o.Owner = u.UserName
76+
LEFT OUTER JOIN Quotas q ON q.UserName = u.UserName
7477
ORDER BY u.UserName
7578
"].concat(where_values)
7679
render_partial
@@ -336,6 +339,14 @@ def list_user_profiles
336339
render_partial
337340
end
338341

342+
def list_ts_quotas
343+
@username = prepare_param :username
344+
345+
@quotas = sql_select_iterator ["SELECT * FROM DBA_TS_Quotas WHERE UserName = ?", @username]
346+
347+
render_partial
348+
end
349+
339350
def list_gradual_password_rollover
340351
@user_info = sql_select_all("\
341352
SELECT u.Account_Status, u.Password_Change_Date, u.Profile, u.UserName, u.Last_Login,

app/helpers/ajax_helper.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,17 @@ def link_sql_id(update_area, instance, sql_id, childno: nil, parsing_schema_name
279279
)
280280
end
281281

282+
def link_username(update_area, username)
283+
ajax_link(username,
284+
{ controller: :dba_schema,
285+
action: :list_db_users,
286+
username: username,
287+
update_area: update_area,
288+
},
289+
title: "Show details for user '#{username}'"
290+
)
291+
292+
end
282293
def link_current_or_historic_sql_id(update_area, instance, sql_id, time_selection_start, time_selection_end, parsing_schema_name=nil, con_id=nil)
283294
unique_id = get_unique_area_id
284295
prefix = "Show details in SGA or AWR history for SQL-ID = '#{sql_id}'#{", Instance = #{instance}" if instance}"

app/views/dba/_list_db_vault_auths.html.erb

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,11 @@
99
}, title: "Show realm #{rec.realm_name} from DBA_DV_REALM")
1010
end
1111

12-
link_column_grantee = proc do |rec|
13-
# TODO: distinguish between user and role
14-
ajax_link(rec.grantee, {
15-
controller: :dba_schema,
16-
action: :list_db_users,
17-
username: rec.grantee,
18-
update_area: @update_area
19-
}, title: "Show user info for '#{rec.grantee}'")
20-
end
12+
# TODO: distinguish between user and role
2113

2214
column_options = []
2315
column_options << {caption: 'Realm name', data: link_column_realm_name, title: 'Name of DB vault realm'}
24-
column_options << {caption: 'Grantee', data: link_column_grantee, title: 'Grantee name'}
16+
column_options << {caption: 'Grantee', data: proc{|rec| link_username(@update_area, rec.grantee) }, title: 'Grantee name'}
2517
column_options << {caption: 'Rule set', data: proc{|rec| rec.auth_rule_set_name}, title: "Rule set to check before authorizing.\nIf the rule set evaluates to TRUE, then the authorization is allowed."}
2618
column_options << {caption: 'Auth. options', data: proc{|rec| rec.auth_options}, title: "Type of realm authorization: either Participant or Owner."}
2719
column_options << {caption: 'Common auth.', data: proc{|rec| rec.common_auth}, title: "Type of realm authorization: either Participant or Owner."}

app/views/dba_schema/_list_db_users.html.erb

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@
6161
)
6262
end
6363

64+
link_quotas = proc do |rec|
65+
ajax_link(fn(rec.quota_cnt),
66+
{action: :list_ts_quotas,
67+
username: rec.username,
68+
update_area: @update_area,
69+
},
70+
title: "Show tablespace quotas of user '#{rec.username}'"
71+
)
72+
end
73+
6474
render_action_buttons = proc do |rec|
6575
retval =
6676
"<div style=\"float:left\">#{
@@ -91,7 +101,7 @@
91101
column_options << {caption: 'Auth. type', data: proc{|rec| rec.authentication_type}, title: 'Indicates the authentication mechanism for the user'}
92102
column_options << {caption: 'Cm.', data: proc{|rec| rec.common}, title: 'Indicates whether a given user is common'} if get_db_version >= '12.1'
93103
column_options << {caption: 'Orcl. maint.',data: proc{|rec| rec.oracle_maintained}, title: "Denotes whether the user was created, and is maintained, by Oracle-supplied scripts (such as catalog.sql or catproc.sql).\nA user for which this column has the value Y must not be changed in any way except by running an Oracle-supplied script."} if get_db_version >= '12.1'
94-
column_options << {caption: 'Pr. o.', data: proc{|rec| rec.proxy_only_connect}, title: 'Indicates whether a user can connect directly (N) or whether the account can only be proxied (Y) by users who have proxy privileges for this account (that is, by users who have been granted the "connect through" privilege for this account).'} if get_db_version >= '12.1'
104+
column_options << {caption: 'Pr. o.', data: proc{|rec| rec.proxy_only_connect}, title: "Proxy only connect\nIndicates whether a user can connect directly (N) or whether the account can only be proxied (Y) by users who have proxy privileges for this account (that is, by users who have been granted the \"connect through\" privilege for this account)."} if get_db_version >= '12.1'
95105
column_options << {caption: 'Last login', data: proc{|rec| localeDateTime(rec.last_login)},title: 'The time of the last user login.'} if get_db_version >= '12.1'
96106
column_options << {caption: 'Inh.', data: proc{|rec| rec.inherited}, title: "Indicates whether the user definition was inherited from another container (YES) or not (NO)"} if get_db_version >= '12.2'
97107
column_options << {caption: 'Default collation', data: proc{|rec| rec.default_collation}, title: "Default collation for the user’s schema"} if get_db_version >= '12.2'
@@ -102,7 +112,8 @@
102112
column_options << {caption: 'Object privs', data: link_obj_grants, title: 'Number of object privileges granted to this user', align: :right}
103113
column_options << {caption: 'System privs', data: link_privileges, title: 'Number of system privileges granted this user', align: :right}
104114
column_options << {caption: 'Granted object privs', data: link_granted_obj_privs, title: 'Number of object privileges granted to others by this user', align: :right}
105-
column_options << {caption: 'DB objects', data: link_objects, title: 'Number of DB objects owned by this user', align: :right}
115+
column_options << {caption: 'DB obj.', data: link_objects, title: 'Number of DB objects owned by this user', align: :right}
116+
column_options << {caption: 'TS quot.', data: link_quotas, title: 'Number of tablespace quotas for this user', align: :right}
106117
column_options << {caption: 'Action', data: render_action_buttons, title: 'Call action for this user'}
107118
%>
108119

app/views/dba_schema/_list_dependency_grants.html.erb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,7 @@
44
link_grantee = proc do |rec|
55
case rec.grantee_type
66
when 'USER' then
7-
ajax_link(rec.grantee, {
8-
action: :list_db_users,
9-
username: rec.grantee,
10-
update_area: @update_area
11-
}, title: "Show user details"
12-
)
7+
link_username(@update_area, rec.grantee)
138
when 'ROLE' then
149
ajax_link(rec.grantee, {
1510
action: :list_roles,

app/views/dba_schema/_list_granted_sys_privileges.html.erb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,7 @@
44
link_grantee = proc do |rec|
55
case rec.grantee_type
66
when 'USER' then
7-
ajax_link(rec.grantee,
8-
{action: :list_db_users,
9-
username: rec.grantee,
10-
update_area: @update_area,
11-
},
12-
title: "Show details for user '#{rec.grantee}'"
13-
)
7+
link_username(@update_area, rec.grantee)
148
when 'ROLE' then
159
ajax_link(rec.grantee,
1610
{action: :list_roles,

app/views/dba_schema/_list_grants.html.erb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@
55
link_grantee = proc do |rec|
66
case rec.grantee_type
77
when 'USER' then
8-
ajax_link(rec.grantee, {
9-
action: :list_db_users,
10-
username: rec.grantee,
11-
update_area: @update_area
12-
}, title: "Show user details"
13-
)
8+
link_username(@update_area, rec.grantee)
149
when 'ROLE' then
1510
ajax_link(rec.grantee, {
1611
action: :list_roles,

app/views/dba_schema/_list_obj_grants.html.erb

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,7 @@
44
link_grantee = proc do |rec|
55
case rec.grantee_type
66
when 'USER' then
7-
ajax_link(rec.grantee,
8-
{action: :list_db_users,
9-
username: rec.grantee,
10-
update_area: @update_area,
11-
},
12-
title: "Show details for user '#{rec.grantee}'"
13-
)
7+
link_username(@update_area, rec.grantee)
148
when 'ROLE' then
159
ajax_link(rec.grantee,
1610
{action: :list_roles,
@@ -23,24 +17,13 @@
2317
end
2418
end
2519

26-
link_grantor = proc do |rec|
27-
ajax_link(rec.grantor,
28-
{action: :list_db_users,
29-
username: rec.grantor,
30-
update_area: @update_area,
31-
},
32-
title: "Show details for user '#{rec.grantor}'"
33-
)
34-
end
35-
36-
3720
column_options = []
3821
column_options << {caption: 'Grantee', data: link_grantee, title: 'Name of the user or role receiving the grant'}
3922
column_options << {caption: 'Grantee type', data: proc{|rec| rec.grantee_type}, title: 'Type of grantee'}
4023
column_options << {caption: 'Owner', data: proc{|rec| rec.owner}, title: 'Owner of the object'}
4124
column_options << {caption: 'Object name', data: proc{|rec| link_object_description(@update_area, rec.owner, rec.table_name, rec.table_name)}, title: 'Name of the object. The object can be any object, including tables, packages, indexes, sequences, and so on.'}
4225
column_options << {caption: 'Object type', data: proc{|rec| rec.type}, title: 'Type of the object'} if get_db_version >= '12.1'
43-
column_options << {caption: 'Grantor', data: link_grantor, title: 'Name of the user who performed the grant'}
26+
column_options << {caption: 'Grantor', data: proc{|rec| link_username(@update_area, rec.grantor)}, title: 'Name of the user who performed the grant'}
4427
column_options << {caption: 'Privilege', data: proc{|rec| rec.privilege}, title: "Granted object privilege"}
4528
column_options << {caption: 'Grantable', data: proc{|rec| rec.grantable}, title: "Indicates whether the privilege was granted with the GRANT OPTION (YES) or not (NO)"}
4629
column_options << {caption: 'Hierarchy', data: proc{|rec| rec.hierarchy}, title: "Indicates whether the privilege was granted with the HIERARCHY OPTION (YES) or not (NO)"}

app/views/dba_schema/_list_role_grants.html.erb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,7 @@
44
link_grantee = proc do |rec|
55
case rec.grantee_type
66
when 'USER' then
7-
ajax_link(rec.grantee,
8-
{action: :list_db_users,
9-
username: rec.grantee,
10-
update_area: @update_area,
11-
},
12-
title: "Show details for user '#{rec.grantee}'"
13-
)
7+
link_username(@update_area, rec.grantee)
148
when 'ROLE' then
159
ajax_link(rec.grantee,
1610
{action: :list_roles,

0 commit comments

Comments
 (0)