mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Added support to launch PSQL for the connected database server. Fixes #2341
This commit is contained in:
committed by
Akshay Joshi
parent
37dece2cd8
commit
3ddf941cd7
@@ -34,6 +34,7 @@ from pgadmin.utils.constants import UNAUTH_REQ, MIMETYPE_APP_JS, \
|
||||
SERVER_CONNECTION_CLOSED
|
||||
from sqlalchemy import or_
|
||||
from pgadmin.utils.preferences import Preferences
|
||||
from .... import socketio as sio
|
||||
|
||||
|
||||
def has_any(data, keys):
|
||||
@@ -1499,6 +1500,13 @@ class ServerNode(PGChildNodeView):
|
||||
|
||||
# Release Connection
|
||||
manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(sid)
|
||||
# Check if any psql terminal is running for the current disconnecting
|
||||
# server. If any terminate the psql tool connection.
|
||||
if 'sid_soid_mapping' in current_app.config and str(sid) in \
|
||||
current_app.config['sid_soid_mapping']:
|
||||
if str(sid) in current_app.config['sid_soid_mapping']:
|
||||
for i in current_app.config['sid_soid_mapping'][str(sid)]:
|
||||
sio.emit('disconnect-psql', namespace='/pty', to=i)
|
||||
|
||||
status = manager.release()
|
||||
|
||||
|
||||
@@ -122,6 +122,9 @@ define('pgadmin.node.database', [
|
||||
is_connected: function(node) {
|
||||
return (node && node.connected == true && node.canDisconn == true);
|
||||
},
|
||||
is_psql_enabled: function(node) {
|
||||
return (node && node.connected == true) && pgAdmin['enable_psql'];
|
||||
},
|
||||
is_conn_allow: function(node) {
|
||||
return (node && node.allowConn == true);
|
||||
},
|
||||
|
||||
@@ -101,7 +101,8 @@ define('pgadmin.node.server', [
|
||||
icon: 'fa fa-unlink', enable : 'is_connected',data: {
|
||||
data_disabled: gettext('Database is already disconnected.'),
|
||||
},
|
||||
},{
|
||||
},
|
||||
{
|
||||
name: 'reload_configuration', node: 'server', module: this,
|
||||
applies: ['tools', 'context'], callback: 'reload_configuration',
|
||||
category: 'reload', priority: 6, label: gettext('Reload Configuration'),
|
||||
@@ -728,6 +729,14 @@ define('pgadmin.node.server', [
|
||||
|
||||
return false;
|
||||
},
|
||||
/* Open psql tool for server*/
|
||||
server_psql_tool: function(args) {
|
||||
var input = args || {},
|
||||
t = pgBrowser.tree,
|
||||
i = input.item || t.selected(),
|
||||
d = i && i.length == 1 ? t.itemData(i) : undefined;
|
||||
pgBrowser.psql.psql_tool(d, i, true);
|
||||
}
|
||||
},
|
||||
model: pgAdmin.Browser.Node.Model.extend({
|
||||
defaults: {
|
||||
|
||||
Reference in New Issue
Block a user