mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Gracefully informed the user that the database is already connected when they click on 'Connect Database...'. Fixes #3694
This commit is contained in:
parent
0fc2afb829
commit
d61b8eb1b3
@ -17,5 +17,6 @@ Housekeeping
|
|||||||
Bug fixes
|
Bug fixes
|
||||||
*********
|
*********
|
||||||
|
|
||||||
|
| `Issue #3694 <https://redmine.postgresql.org/issues/3694>`_ - Gracefully informed the user that the database is already connected when they click on "Connect Database...".
|
||||||
| `Issue #4279 <https://redmine.postgresql.org/issues/4279>`_ - Ensure that file browse "home" button should point to $HOME rather than /.
|
| `Issue #4279 <https://redmine.postgresql.org/issues/4279>`_ - Ensure that file browse "home" button should point to $HOME rather than /.
|
||||||
| `Issue #5422 <https://redmine.postgresql.org/issues/5422>`_ - Ensure that the dependencies tab shows correct information for Synonyms.
|
| `Issue #5422 <https://redmine.postgresql.org/issues/5422>`_ - Ensure that the dependencies tab shows correct information for Synonyms.
|
@ -456,30 +456,33 @@ class DatabaseView(PGChildNodeView):
|
|||||||
from pgadmin.utils.driver import get_driver
|
from pgadmin.utils.driver import get_driver
|
||||||
manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(sid)
|
manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(sid)
|
||||||
conn = manager.connection(did=did, auto_reconnect=True)
|
conn = manager.connection(did=did, auto_reconnect=True)
|
||||||
status, errmsg = conn.connect()
|
already_connected = conn.connected()
|
||||||
|
if not already_connected:
|
||||||
if not status:
|
status, errmsg = conn.connect()
|
||||||
current_app.logger.error(
|
if not status:
|
||||||
"Could not connected to database(#{0}).\nError: {1}".format(
|
current_app.logger.error(
|
||||||
did, errmsg
|
"Could not connected to database(#{0}).\nError: {1}"
|
||||||
|
.format(
|
||||||
|
did, errmsg
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
return internal_server_error(errmsg)
|
||||||
|
else:
|
||||||
return internal_server_error(errmsg)
|
current_app.logger.info(
|
||||||
else:
|
'Connection Established for Database Id: \
|
||||||
current_app.logger.info('Connection Established for Database Id: \
|
%s' % (did)
|
||||||
%s' % (did))
|
)
|
||||||
|
return make_json_response(
|
||||||
return make_json_response(
|
success=1,
|
||||||
success=1,
|
info=_("Database connected."),
|
||||||
info=_("Database connected."),
|
data={
|
||||||
data={
|
'icon': 'pg-icon-database',
|
||||||
'icon': 'pg-icon-database',
|
'already_connected': already_connected,
|
||||||
'connected': True,
|
'connected': True,
|
||||||
'info_prefix': '{0}/{1}'.
|
'info_prefix': '{0}/{1}'.
|
||||||
format(Server.query.filter_by(id=sid)[0].name, conn.db)
|
format(Server.query.filter_by(id=sid)[0].name, conn.db)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
def disconnect(self, gid, sid, did):
|
def disconnect(self, gid, sid, did):
|
||||||
"""Disconnect the database."""
|
"""Disconnect the database."""
|
||||||
|
@ -520,7 +520,6 @@ define('pgadmin.node.database', [
|
|||||||
tree.deselect(item);
|
tree.deselect(item);
|
||||||
tree.setInode(item);
|
tree.setInode(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res && res.data) {
|
if (res && res.data) {
|
||||||
if(typeof res.data.connected == 'boolean') {
|
if(typeof res.data.connected == 'boolean') {
|
||||||
data.connected = res.data.connected;
|
data.connected = res.data.connected;
|
||||||
@ -530,11 +529,17 @@ define('pgadmin.node.database', [
|
|||||||
data.icon = res.data.icon;
|
data.icon = res.data.icon;
|
||||||
tree.addIcon(item, {icon: data.icon});
|
tree.addIcon(item, {icon: data.icon});
|
||||||
}
|
}
|
||||||
|
if(res.data.already_connected) {
|
||||||
|
res.info = gettext('Database already connected.');
|
||||||
|
}
|
||||||
if(res.data.info_prefix) {
|
if(res.data.info_prefix) {
|
||||||
res.info = `${_.escape(res.data.info_prefix)} - ${res.info}`;
|
res.info = `${_.escape(res.data.info_prefix)} - ${res.info}`;
|
||||||
}
|
}
|
||||||
|
if(res.data.already_connected) {
|
||||||
Alertify.success(res.info);
|
Alertify.info(res.info);
|
||||||
|
} else {
|
||||||
|
Alertify.success(res.info);
|
||||||
|
}
|
||||||
obj.trigger('connected', obj, item, data);
|
obj.trigger('connected', obj, item, data);
|
||||||
pgBrowser.Events.trigger(
|
pgBrowser.Events.trigger(
|
||||||
'pgadmin:database:connected', item, data
|
'pgadmin:database:connected', item, data
|
||||||
|
Loading…
Reference in New Issue
Block a user