mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
1) Fixed an issue where the user is unable to create a subscription if the host/IP address for connection is 127.0.0.1. Fixes #6253
2) Ensure that proper error message should be shown on the properties and statistics tab in case of insufficient privileges for a subscription. Fixes #6259 3) Fixed an issue where the 'Create Slot' option is disabled in case of the same IP/host provided but the port is different. Fixes #6260
This commit is contained in:
committed by
Akshay Joshi
parent
cafd2af96d
commit
4267207c7f
@@ -245,6 +245,7 @@ class ServerModule(sg.ServerGroupPluginModule):
|
||||
in_recovery=in_recovery,
|
||||
wal_pause=wal_paused,
|
||||
host=server.host,
|
||||
port=server.port,
|
||||
is_password_saved=bool(server.save_password),
|
||||
is_tunnel_password_saved=True
|
||||
if server.tunnel_password is not None else False,
|
||||
|
||||
@@ -195,7 +195,7 @@ class SubscriptionView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
'nodes': [{'get': 'node'}, {'get': 'nodes'}],
|
||||
'sql': [{'get': 'sql'}],
|
||||
'msql': [{'get': 'msql'}, {'get': 'msql'}],
|
||||
'stats': [{'get': 'statistics'}],
|
||||
'stats': [{'get': 'statistics'}, {'get': 'statistics'}],
|
||||
'dependency': [{'get': 'dependencies'}],
|
||||
'dependent': [{'get': 'dependents'}],
|
||||
'get_publications': [{}, {'get': 'get_publications'}],
|
||||
@@ -261,11 +261,6 @@ class SubscriptionView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
self._PROPERTIES_SQL]), did=did)
|
||||
status, res = self.conn.execute_dict(sql)
|
||||
|
||||
# Check for permission denied message
|
||||
if 'permission denied' in res:
|
||||
return internal_server_error(
|
||||
errormsg="Access is revoked for normal users")
|
||||
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
@@ -386,7 +381,7 @@ class SubscriptionView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
return True, res['rows'][0]
|
||||
|
||||
@check_precondition
|
||||
def statistics(self, gid, sid, did, subid):
|
||||
def statistics(self, gid, sid, did, subid=None):
|
||||
"""
|
||||
This function gets the statistics and returns an ajax response
|
||||
for the view node.
|
||||
@@ -399,7 +394,7 @@ class SubscriptionView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
"""
|
||||
sql = render_template("/".join([self.template_path,
|
||||
'stats.sql']),
|
||||
subid=subid, conn=self.conn)
|
||||
subid=subid, did=did, conn=self.conn)
|
||||
status, res = self.conn.execute_dict(sql)
|
||||
return make_json_response(
|
||||
data=res,
|
||||
|
||||
@@ -396,8 +396,8 @@ define('pgadmin.node.subscription', [
|
||||
type: 'switch', mode: ['create'],
|
||||
group: gettext('With'),
|
||||
disabled: 'isSameDB',
|
||||
readonly: 'isConnect', deps :['connect', 'host'],
|
||||
helpMessage: gettext('Specifies whether the command should create the replication slot on the publisher.'),
|
||||
readonly: 'isConnect', deps :['connect', 'host', 'port'],
|
||||
helpMessage: gettext('Specifies whether the command should create the replication slot on the publisher.This field will be disabled and set to false if subscription connects to same database.Otherwise, the CREATE SUBSCRIPTION call will hang.'),
|
||||
|
||||
},
|
||||
{
|
||||
@@ -456,7 +456,14 @@ define('pgadmin.node.subscription', [
|
||||
return true;
|
||||
},
|
||||
isSameDB:function(m){
|
||||
if (m.attributes['host'] == m.node_info.server.host){
|
||||
let host = m.attributes['host'],
|
||||
port = m.attributes['port'];
|
||||
|
||||
if ((m.attributes['host'] == 'localhost' || m.attributes['host'] == '127.0.0.1') &&
|
||||
(m.node_info.server.host == 'localhost' || m.node_info.server.host == '127.0.0.1')){
|
||||
host = m.node_info.server.host;
|
||||
}
|
||||
if (host == m.node_info.server.host && port == m.node_info.server.port){
|
||||
setTimeout( function() {
|
||||
m.set('create_slot', false);
|
||||
}, 10);
|
||||
|
||||
@@ -4,5 +4,8 @@ SELECT
|
||||
latest_end_lsn AS {{ conn|qtIdent(_('Latest end lsn')) }},
|
||||
last_msg_receipt_time AS {{ conn|qtIdent(_('Last message receipt')) }},
|
||||
last_msg_send_time AS {{ conn|qtIdent(_('Last message send time'))}}
|
||||
FROM pg_stat_subscription WHERE subid = {{ subid }};
|
||||
FROM pg_stat_subscription
|
||||
{% if subid %}
|
||||
WHERE subid = {{ subid }};
|
||||
{% endif %}
|
||||
|
||||
|
||||
@@ -289,7 +289,8 @@ define([
|
||||
timer = setTimeout(function() {
|
||||
// notify user if request is taking longer than 1 second
|
||||
|
||||
$msgContainer.text(gettext('Retrieving data from the server...'));
|
||||
if (!$msgContainer.text()== 'Failed to retrieve data from the server.')
|
||||
$msgContainer.text(gettext('Retrieving data from the server...'));
|
||||
$msgContainer.removeClass('d-none');
|
||||
if (self.grid) {
|
||||
self.grid.remove();
|
||||
|
||||
Reference in New Issue
Block a user