[Grant Wizard] Added support for Materialized View in the Grant Wizard.

Also - done proper view clean up when the wizard is cancelled.
This commit is contained in:
Surinder Kumar 2016-05-25 17:40:36 +05:30 committed by Ashesh Vashi
parent b1aa956af8
commit 4741992ad7
10 changed files with 51 additions and 24 deletions

View File

@ -106,6 +106,12 @@
margin-right: 0 !important;
}
.wizard-header .wizard-cancel-event {
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAdklEQVQ4jd2SwQnAIAxF36GH0pOTFHEgF3IkR5LO0F4SCGJVEHroAy/f/E+igV+yAa6hO7nrcgAZuIBg9CBalppXEnDL0RA1q556ASdQqhBrLlLTxVch1uxHZiU2AuKs2Vdt23GGHSy/wfIvzOzBPhpjaRO/5wG/szevJ+ZXzAAAAABJRU5ErkJggg==) no-repeat center center;
padding: 10px;
margin-top: -1px;
}
/* Wizard Status bar CSS */
.pgadmin-wizard .wizard-description {
padding: 1.0em 0.1em;
@ -131,4 +137,4 @@
*/
.select2-container--open {
z-index: 10000;
}
}

View File

@ -42,6 +42,7 @@ function(_, Backbone, pgAdmin, pgBrowser) {
disable_prev: false,
disable_finish: false,
disable_cancel: false,
show_header_cancel_btn: false, /* show cancel button at wizard header */
height: 400,
width: 650,
show_left_panel: true
@ -55,16 +56,21 @@ function(_, Backbone, pgAdmin, pgBrowser) {
+ " <h3><span id='main-title'><%= this.options.title %></span> -"
+ " <span id='step-title'><%= page_title %></span></h3>"
+ " </div>"
+ " <% if (this.options.show_header_cancel_btn) { %>"
+ " <div class='col-sm-3'>"
+ " <button class='ajs-close wizard-cancel-event pull-right'></button>"
+ " </div>"
+ " <% } %>"
+ " </div>"
+ " </div>"
+ " <div class='wizard-content col-sm-12'>"
+ " <% if(this.options.show_left_panel) { %>"
+ " <% if (this.options.show_left_panel) { %>"
+ " <div class='col-sm-3 wizard-left-panel'>"
+ " <img src='<%= this.options.image %>'></div>"
+ " <% } %>"
+ " <div class='col-sm-<% if(this.options.show_left_panel){ %>9<% }"
+ " <div class='col-sm-<% if (this.options.show_left_panel) { %>9<% }"
+ " else { %>12<% } %> wizard-right-panel'>"
+ " <% if( typeof show_description != 'undefined'){ %>"
+ " <% if ( typeof show_description != 'undefined'){ %>"
+ " <div class='wizard-description'>"
+ " <%= show_description %>"
+ " </div>"
@ -79,7 +85,7 @@ function(_, Backbone, pgAdmin, pgBrowser) {
+ " <div class='footer col-sm-12'>"
+ " <div class='row'>"
+ " <div class='col-sm-4 wizard-progress-bar'>"
+ " <p><% if(show_progress_bar){ %><%= show_progress_bar %><% } %></p>"
+ " <p><% if (show_progress_bar) { %><%= show_progress_bar %><% } %></p>"
+ " </div>"
+ " <div class='col-sm-8'>"
+ " <div class='wizard-buttons'>"
@ -100,6 +106,7 @@ function(_, Backbone, pgAdmin, pgBrowser) {
"click button.wizard-next" : "nextPage",
"click button.wizard-back" : "prevPage",
"click button.wizard-cancel" : "onCancel",
"click button.wizard-cancel-event" : "onCancel",
"click button.wizard-finish" : "finishWizard",
},
initialize: function(options) {

View File

@ -281,7 +281,19 @@ def properties(gid, sid, did, node_id, node_type):
if ntype in ['schema', 'view']:
SQL = render_template("/".join(
[server_prop['template_path'], '/sql/view.sql']),
node_id=node_id, nspname=nspname)
node_id=node_id, node_type='v', nspname=nspname)
status, res = conn.execute_dict(SQL)
if not status:
return internal_server_error(errormsg=res)
res_data.extend(res['rows'])
# Fetch Materialzed Views against schema
if ntype in ['schema', 'mview']:
SQL = render_template("/".join(
[server_prop['template_path'], '/sql/view.sql']),
node_id=node_id, node_type='m', nspname=nspname)
status, res = conn.execute_dict(SQL)
if not status:

View File

@ -206,6 +206,7 @@ define([
resizable: true,
autoReset: false,
maximizable: false,
closable: false,
closableByDimmer: false
}
};
@ -219,7 +220,7 @@ define([
// Add pgadmin_grant_wizard_body class to dialog
$(this.elements.body).addClass('pgadmin_grant_wizard_body');
},
}
},
/**
@ -521,6 +522,11 @@ define([
case 'View':
object_type = 'table';
break;
case 'Materialized View':
object_type = 'table';
break;
default:
break;
}
/**
@ -1041,6 +1047,7 @@ define([
height: '',
curr_page: 0,
show_left_panel: false,
show_header_cancel_btn: true,
disable_finish: true
},

View File

@ -15,10 +15,6 @@
"type": "TABLE",
"acl": ["a", "w", "d", "D", "x", "t"]
},
"view": {
"type": "VIEW",
"acl": ["a", "w", "d", "D", "x", "t"]
},
"sequence": {
"type": "SEQUENCE",
"acl": ["w", "U"]

View File

@ -2,7 +2,7 @@
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
{% for obj in data.objects -%}
{% for priv in data.priv -%}
{% if obj.object_type == 'Table' or obj.object_type == 'View' %}
{% if obj.object_type == 'Table' or obj.object_type == 'View' or obj.object_type == 'Materialized View'%}
{{ PRIVILEGE.SET(conn, 'TABLE', priv['grantee'], obj.name, priv['without_grant'], priv['with_grant'], obj.nspname ) }}
{% endif %}
{% endfor -%}

View File

@ -1,8 +1,9 @@
{# ===== Fetch list of Database object types(View) ===== #}
{% if node_id %}
{% if node_id and node_type %}
{% set ntype = "View" if node_type == 'v' else "Materialized View" %}
SELECT
c.relname AS name,
'View' AS object_type,
'{{ ntype }}' AS object_type,
'icon-view' AS icon,
'{{ nspname }}' AS nspname
FROM
@ -20,7 +21,7 @@ WHERE
((r.ev_class = c.oid)
AND (bpchar(r.ev_type) = '1'::bpchar))
))
) OR (c.relkind = 'v'::char)
) AND (c.relkind = '{{ node_type }}'::char)
)
AND c.relnamespace = {{ node_id }}::oid
ORDER BY

View File

@ -15,10 +15,6 @@
"type": "TABLE",
"acl": ["a", "w", "d", "D", "x", "t"]
},
"view": {
"type": "VIEW",
"acl": ["a", "w", "d", "D", "x", "t"]
},
"sequence": {
"type": "SEQUENCE",
"acl": ["w", "U"]

View File

@ -2,7 +2,7 @@
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
{% for obj in data.objects -%}
{% for priv in data.priv -%}
{% if obj.object_type == 'Table' or obj.object_type == 'View' %}
{% if obj.object_type == 'Table' or obj.object_type == 'View' or obj.object_type == 'Materialized View'%}
{{ PRIVILEGE.SET(conn, 'TABLE', priv['grantee'], obj.name, priv['without_grant'], priv['with_grant'], obj.nspname ) }}
{% endif %}
{% endfor -%}

View File

@ -1,9 +1,11 @@
{# ===== Fetch list of Database object types(View) ===== #}
{% if node_id %}
{% if node_id and node_type %}
{% set ntype = "View" if node_type == 'v' else "Materialized View" %}
{% set view_icon = "icon-view" if node_type == 'v' else "icon-mview" %}
SELECT
c.relname AS name,
'View' AS object_type,
'icon-view' AS icon,
'{{ ntype }}' AS object_type,
'{{ view_icon }}' AS icon,
'{{ nspname }}' AS nspname
FROM
pg_class c
@ -20,7 +22,7 @@ WHERE
((r.ev_class = c.oid)
AND (bpchar(r.ev_type) = '1'::bpchar))
))
) OR (c.relkind = 'v'::char)
) AND (c.relkind = '{{ node_type }}'::char)
)
AND c.relnamespace = {{ node_id }}::oid
ORDER BY