mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Add newly created triggers to the treeview. Fixes #1747
This commit is contained in:
parent
6e68e7501a
commit
6e5126d571
@ -139,6 +139,10 @@ class IndexesView(PGChildNodeView):
|
||||
- This function will used to create all the child node within that
|
||||
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)
|
||||
- This function will show the properties of the selected Index node
|
||||
|
||||
@ -382,12 +386,15 @@ class IndexesView(PGChildNodeView):
|
||||
did: Database ID
|
||||
scid: Schema ID
|
||||
tid: Table ID
|
||||
idx: Index ID
|
||||
|
||||
Returns:
|
||||
JSON of available schema child nodes
|
||||
"""
|
||||
SQL = render_template("/".join([self.template_path,
|
||||
'nodes.sql']), idx=idx)
|
||||
'nodes.sql']),
|
||||
tid=tid,
|
||||
idx=idx)
|
||||
status, rset = self.conn.execute_2darray(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=rset)
|
||||
|
@ -9,4 +9,7 @@ FROM pg_index idx
|
||||
LEFT OUTER JOIN pg_constraint con ON (con.tableoid = dep.refclassid AND con.oid = dep.refobjid)
|
||||
WHERE indrelid = {{tid}}::OID
|
||||
AND conname is NULL
|
||||
{% if idx %}
|
||||
AND cls.oid = {{ idx }}::OID
|
||||
{% endif %}
|
||||
ORDER BY cls.relname
|
@ -2,4 +2,7 @@ SELECT t.oid, t.tgname as name, (CASE WHEN tgenabled = 'O' THEN true ElSE false
|
||||
FROM pg_trigger t
|
||||
WHERE NOT tgisinternal
|
||||
AND tgrelid = {{tid}}::OID
|
||||
{% if trid %}
|
||||
AND t.oid = {{trid}}::OID
|
||||
{% endif %}
|
||||
ORDER BY tgname;
|
||||
|
@ -159,6 +159,10 @@ class TriggerView(PGChildNodeView):
|
||||
- This function will used to create all the child node within that
|
||||
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)
|
||||
- This function will show the properties of the selected Trigger node
|
||||
|
||||
@ -358,6 +362,48 @@ class TriggerView(PGChildNodeView):
|
||||
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
|
||||
def nodes(self, gid, sid, did, scid, tid):
|
||||
"""
|
||||
@ -594,7 +640,7 @@ class TriggerView(PGChildNodeView):
|
||||
return jsonify(
|
||||
node=self.blueprint.generate_browser_node(
|
||||
trid,
|
||||
scid,
|
||||
tid,
|
||||
data['name'],
|
||||
icon="icon-trigger"
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user