Add newly created triggers to the treeview. Fixes #1747

This commit is contained in:
Murtuza Zabuawala 2016-11-18 13:58:35 +00:00 committed by Dave Page
parent 6e68e7501a
commit 6e5126d571
4 changed files with 61 additions and 2 deletions

View File

@ -139,6 +139,10 @@ class IndexesView(PGChildNodeView):
- This function will used to create all the child node within that - This function will used to create all the child node within that
collection, Here it will create all the Index node. collection, Here it will create all the Index node.
* node()
- This function will used to create the child node within that
collection, Here it will create specific the Index node.
* properties(gid, sid, did, scid, tid, idx) * properties(gid, sid, did, scid, tid, idx)
- This function will show the properties of the selected Index node - This function will show the properties of the selected Index node
@ -382,12 +386,15 @@ class IndexesView(PGChildNodeView):
did: Database ID did: Database ID
scid: Schema ID scid: Schema ID
tid: Table ID tid: Table ID
idx: Index ID
Returns: Returns:
JSON of available schema child nodes JSON of available schema child nodes
""" """
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'nodes.sql']), idx=idx) 'nodes.sql']),
tid=tid,
idx=idx)
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
if not status: if not status:
return internal_server_error(errormsg=rset) return internal_server_error(errormsg=rset)

View File

@ -9,4 +9,7 @@ FROM pg_index idx
LEFT OUTER JOIN pg_constraint con ON (con.tableoid = dep.refclassid AND con.oid = dep.refobjid) LEFT OUTER JOIN pg_constraint con ON (con.tableoid = dep.refclassid AND con.oid = dep.refobjid)
WHERE indrelid = {{tid}}::OID WHERE indrelid = {{tid}}::OID
AND conname is NULL AND conname is NULL
{% if idx %}
AND cls.oid = {{ idx }}::OID
{% endif %}
ORDER BY cls.relname ORDER BY cls.relname

View File

@ -2,4 +2,7 @@ SELECT t.oid, t.tgname as name, (CASE WHEN tgenabled = 'O' THEN true ElSE false
FROM pg_trigger t FROM pg_trigger t
WHERE NOT tgisinternal WHERE NOT tgisinternal
AND tgrelid = {{tid}}::OID AND tgrelid = {{tid}}::OID
{% if trid %}
AND t.oid = {{trid}}::OID
{% endif %}
ORDER BY tgname; ORDER BY tgname;

View File

@ -159,6 +159,10 @@ class TriggerView(PGChildNodeView):
- This function will used to create all the child node within that - This function will used to create all the child node within that
collection, Here it will create all the Trigger node. collection, Here it will create all the Trigger node.
* node()
- This function will used to create child node within that
collection, Here it will create specific the Trigger node.
* properties(gid, sid, did, scid, tid, trid) * properties(gid, sid, did, scid, tid, trid)
- This function will show the properties of the selected Trigger node - This function will show the properties of the selected Trigger node
@ -358,6 +362,48 @@ class TriggerView(PGChildNodeView):
status=200 status=200
) )
@check_precondition
def node(self, gid, sid, did, scid, tid, trid):
"""
This function will used to create the child node within that collection.
Here it will create specific the trigger node.
Args:
gid: Server Group ID
sid: Server ID
did: Database ID
scid: Schema ID
tid: Table ID
trid: Trigger ID
Returns:
JSON of available trigger child nodes
"""
res = []
SQL = render_template("/".join([self.template_path,
'nodes.sql']),
tid=tid,
trid=trid)
status, rset = self.conn.execute_2darray(SQL)
if not status:
return internal_server_error(errormsg=rset)
if len(rset['rows']) == 0:
return gone(gettext("""Could not find the trigger in the table."""))
res = self.blueprint.generate_browser_node(
rset['rows'][0]['oid'],
tid,
rset['rows'][0]['name'],
icon="icon-trigger" if rset['rows'][0]['is_enable_trigger']
else "icon-trigger-bad"
)
return make_json_response(
data=res,
status=200
)
@check_precondition @check_precondition
def nodes(self, gid, sid, did, scid, tid): def nodes(self, gid, sid, did, scid, tid):
""" """
@ -594,7 +640,7 @@ class TriggerView(PGChildNodeView):
return jsonify( return jsonify(
node=self.blueprint.generate_browser_node( node=self.blueprint.generate_browser_node(
trid, trid,
scid, tid,
data['name'], data['name'],
icon="icon-trigger" icon="icon-trigger"
) )