From c53b57a013b4d76df64685668c79cfba44989a7e Mon Sep 17 00:00:00 2001 From: Ashesh Vashi Date: Wed, 28 Oct 2015 22:34:23 +0530 Subject: [PATCH] Resolved couple of small bugs introduced during database server connection management implementation. --- .../browser/server_groups/servers/__init__.py | 2 +- .../servers/templates/css/servers.css | 6 +++++- .../static/css/wcDocker/Themes/pgadmin.css | 8 ++++---- .../static/js/alertifyjs/pgadmin.defaults.js | 4 ++-- web/pgadmin/utils/driver/psycopg2/__init__.py | 18 ++++++++---------- 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/web/pgadmin/browser/server_groups/servers/__init__.py b/web/pgadmin/browser/server_groups/servers/__init__.py index 7f4ba204b..ba4eca84a 100644 --- a/web/pgadmin/browser/server_groups/servers/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/__init__.py @@ -493,7 +493,7 @@ class ServerNode(NodeView): """Check and return the connection status.""" from pgadmin.utils.driver import get_driver manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(sid) - conn = manager.get_connection() + conn = manager.connection() return make_json_response(data={'connected': conn.connected()}) diff --git a/web/pgadmin/browser/server_groups/servers/templates/css/servers.css b/web/pgadmin/browser/server_groups/servers/templates/css/servers.css index 798564456..a5951e9d3 100644 --- a/web/pgadmin/browser/server_groups/servers/templates/css/servers.css +++ b/web/pgadmin/browser/server_groups/servers/templates/css/servers.css @@ -1,6 +1,10 @@ .icon-server { background-image: url('{{ url_for('NODE-server.static', filename='img/server.png') }}') !important; - border-radius: 10px + border-radius: 10px; + background-repeat: no-repeat; + align-content: center; + vertical-align: middle; + height: 1.3em; } .icon-server-not-connected { diff --git a/web/pgadmin/static/css/wcDocker/Themes/pgadmin.css b/web/pgadmin/static/css/wcDocker/Themes/pgadmin.css index 2532750e5..4c8790eea 100644 --- a/web/pgadmin/static/css/wcDocker/Themes/pgadmin.css +++ b/web/pgadmin/static/css/wcDocker/Themes/pgadmin.css @@ -203,22 +203,22 @@ background-color: #A44; } -.wcButtonHover, .wcButton:hover, button:hover { +.wcButtonHover, .wcButton:hover { border: 1px outset #B66; background-color: #B66; } -.wcButtonActive, .wcButton:active, button:active { +.wcButtonActive, .wcButton:active { border: 1px inset #B66; background-color: #B66; } -.wcButtonActive.wcButtonHover, .wcButton:hover.wcButtonActive, .wcButton:active.wcButtonHover, .wcButton:active:hover, button:active:hover { +.wcButtonActive.wcButtonHover, .wcButton:hover.wcButtonActive, .wcButton:active.wcButtonHover, .wcButton:active:hover { border: 1px inset #C88; background-color: #C88; } -.wcButtonDisabled, .wcButton.disabled, button:disabled { +.wcButtonDisabled, .wcButton.disabled { border: 1px outset #933 !important; background-color: #933 !important; color: #533 !important; diff --git a/web/pgadmin/static/js/alertifyjs/pgadmin.defaults.js b/web/pgadmin/static/js/alertifyjs/pgadmin.defaults.js index 3c47925fa..5734b0b2e 100644 --- a/web/pgadmin/static/js/alertifyjs/pgadmin.defaults.js +++ b/web/pgadmin/static/js/alertifyjs/pgadmin.defaults.js @@ -1,6 +1,6 @@ require( - ['alertify'], -function(alertify) { + ['alertify', 'underscore.string'], +function(alertify, S) { alertify.defaults.transition = "zoom"; alertify.defaults.theme.ok = "btn btn-primary"; alertify.defaults.theme.cancel = "btn btn-danger"; diff --git a/web/pgadmin/utils/driver/psycopg2/__init__.py b/web/pgadmin/utils/driver/psycopg2/__init__.py index 7bc62a535..33f8ec339 100644 --- a/web/pgadmin/utils/driver/psycopg2/__init__.py +++ b/web/pgadmin/utils/driver/psycopg2/__init__.py @@ -418,7 +418,8 @@ class ServerManager(object): def connection(self, database=None, conn_id=None, auto_reconnect=True): my_id = ('CONN:' + str(conn_id)) if conn_id is not None else \ - ('DB:' + str(database)) + ('DB:' + (str(database) if database is not None else \ + self.db)) self.pinged = datetime.now() @@ -507,7 +508,7 @@ class Driver(BaseDriver): managers = self.managers[session['_id']] managers['pinged'] = datetime.datetime.now() - if sid not in managers: + if str(sid) not in managers: from pgadmin.settings.settings_model import Server s = Server.query.filter_by(id=sid).first() @@ -560,16 +561,16 @@ class Driver(BaseDriver): connection, and it stops working on disconnection. """ - manager = connection_manager(sid) + manager = self.connection_manager(sid) - return manager.connection(database, conn_id, connect, **kwargs) + return manager.connection(database, conn_id, auto_reconnect) def release_connection(self, sid, database=None, conn_id=None): """ Release the connection for the given connection-id/database in this session. """ - return connection_manager(sid).release(database, conn_id) + return self.connection_manager(sid).release(database, conn_id) def gc(self): """ @@ -577,13 +578,10 @@ class Driver(BaseDriver): server for more than config.MAX_SESSION_IDLE_TIME. """ import datetime - from config import MAX_SESSION_IDLE_TIME - - assert(MAX_SESSION_IDLE_TIME is not None and - isinstance(MAX_SESSION_IDLE_TIME, int)) + import config # Mininum session idle is 20 minutes - max_idle_time = max(MAX_SESSION_IDLE_TIME, 20) + max_idle_time = max(config.MAX_SESSION_IDLE_TIME or 60, 20) session_idle_timeout = datetime.timedelta(minutes=max_idle_time) curr_time = datetime.datetime.now()