Added database and server information on the Maintenance process watcher dialog. Fixes #4629

This commit is contained in:
Aditya Toshniwal 2021-08-24 17:10:16 +05:30 committed by Akshay Joshi
parent 8bf1c96065
commit 7efef73ff7
2 changed files with 43 additions and 31 deletions

View File

@ -10,6 +10,7 @@ New features
************
| `Issue #4264 <https://redmine.postgresql.org/issues/4264>`_ - Make code folding case insensitive in the code mirror.
| `Issue #4629 <https://redmine.postgresql.org/issues/4629>`_ - Added database and server information on the Maintenance process watcher dialog.
| `Issue #6691 <https://redmine.postgresql.org/issues/6691>`_ - Set PSQLRC and PSQL_HISTORY env vars to apt. user storage path in the server mode.
Housekeeping

View File

@ -81,18 +81,49 @@ class Message(IProcessDesc):
self.data = _data
self.query = _query
def get_server_name(self):
s = get_server(self.sid)
from pgadmin.utils.driver import get_driver
driver = get_driver(PG_DEFAULT_DRIVER)
manager = driver.connection_manager(self.sid)
host = manager.local_bind_host if manager.use_ssh_tunnel else s.host
port = manager.local_bind_port if manager.use_ssh_tunnel else s.port
s.name = html.safe_str(s.name)
host = html.safe_str(host)
port = html.safe_str(port)
return "{0} ({1}:{2})".format(s.name, host, port)
def get_op(self):
op = self._check_for_vacuum()
if self.data['op'] == "ANALYZE":
op = _('ANALYZE')
if self.data['verbose']:
op += '(' + _('VERBOSE') + ')'
if self.data['op'] == "REINDEX":
if 'schema' in self.data and self.data['schema']:
if 'primary_key' in self.data or \
'unique_constraint' in self.data or \
'index' in self.data:
return _('REINDEX INDEX')
else:
return _('REINDEX TABLE')
op = _('REINDEX')
if self.data['op'] == "CLUSTER":
op = _('CLUSTER')
return op
@property
def message(self):
res = _("Maintenance ({0})")
if self.data['op'] == "VACUUM":
return res.format(_('Vacuum'))
if self.data['op'] == "ANALYZE":
return res.format(_('Analyze'))
if self.data['op'] == "REINDEX":
return res.format(_('Reindex'))
if self.data['op'] == "CLUSTER":
return res.format(_('Cluster'))
res = _("{0} on database '{1}' of server {2}")
return res.format(
self.get_op(), self.data['database'], self.get_server_name())
@property
def type_desc(self):
@ -119,28 +150,8 @@ class Message(IProcessDesc):
return res
def details(self, cmd, args):
res = self._check_for_vacuum()
if self.data['op'] == "ANALYZE":
res = _('ANALYZE')
if self.data['verbose']:
res += '(' + _('VERBOSE') + ')'
if self.data['op'] == "REINDEX":
if 'schema' in self.data and self.data['schema']:
if 'primary_key' in self.data or\
'unique_constraint' in self.data or\
'index' in self.data:
return _('REINDEX INDEX')
else:
return _('REINDEX TABLE')
res = _('REINDEX')
if self.data['op'] == "CLUSTER":
res = _('CLUSTER')
res = '<div>' + html.safe_str(res)
res = '<div>' + self.message
res += '</div><div class="py-1">'
res += _("Running Query:")
res += '<div class="pg-bg-cmd enable-selection p-1">'