mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fixed an issue where some properties are not being updated correctly for the shared server. Fixes #5867
This commit is contained in:
committed by
Akshay Joshi
parent
a707d818f5
commit
b097cec45e
Binary file not shown.
|
Before Width: | Height: | Size: 223 KiB After Width: | Height: | Size: 193 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 64 KiB After Width: | Height: | Size: 60 KiB |
@@ -49,7 +49,7 @@ Use the fields on the *Display* panel to specify general display preferences:
|
|||||||
the client will display the animated dialogues/notifications otherwise it
|
the client will display the animated dialogues/notifications otherwise it
|
||||||
will be unanimated.
|
will be unanimated.
|
||||||
|
|
||||||
* When the *Hide shared server?* switch is set to *True*, the client will hide
|
* When the *Hide shared servers?* switch is set to *True*, the client will hide
|
||||||
all the shared servers from the browser tree.
|
all the shared servers from the browser tree.
|
||||||
|
|
||||||
* Use the *Lock layout* field to lock the UI layout at different levels. This
|
* Use the *Lock layout* field to lock the UI layout at different levels. This
|
||||||
|
|||||||
@@ -33,4 +33,5 @@ Bug fixes
|
|||||||
| `Issue #5841 <https://redmine.postgresql.org/issues/5841>`_ - Fixed an issue where the server is not able to connect using the service.
|
| `Issue #5841 <https://redmine.postgresql.org/issues/5841>`_ - Fixed an issue where the server is not able to connect using the service.
|
||||||
| `Issue #5843 <https://redmine.postgresql.org/issues/5843>`_ - Fixed an issue where the 'PARALLEL UNSAFE' option is missing from reverse engineering SQL of function/procedure.
|
| `Issue #5843 <https://redmine.postgresql.org/issues/5843>`_ - Fixed an issue where the 'PARALLEL UNSAFE' option is missing from reverse engineering SQL of function/procedure.
|
||||||
| `Issue #5845 <https://redmine.postgresql.org/issues/5845>`_ - Fixed an issue where the query tool is not fetching more than 1000 rows for the table does not have any primary key.
|
| `Issue #5845 <https://redmine.postgresql.org/issues/5845>`_ - Fixed an issue where the query tool is not fetching more than 1000 rows for the table does not have any primary key.
|
||||||
| `Issue #5861 <https://redmine.postgresql.org/issues/5861>`_ - Ensure that the 'Remove Server' option should be visible in the context menu.
|
| `Issue #5861 <https://redmine.postgresql.org/issues/5861>`_ - Ensure that the 'Remove Server' option should be visible in the context menu.
|
||||||
|
| `Issue #5867 <https://redmine.postgresql.org/issues/5867>`_ - Fixed an issue where some properties are not being updated correctly for the shared server.
|
||||||
@@ -30,7 +30,7 @@ Use the fields in the *General* tab to identify the server:
|
|||||||
* If the *Connect now?* checkbox is checked, the client will attempt a
|
* If the *Connect now?* checkbox is checked, the client will attempt a
|
||||||
connection to the server upon completion of the dialog; this is the default
|
connection to the server upon completion of the dialog; this is the default
|
||||||
|
|
||||||
* If the *Shared with all?* switch is moved to *Yes* then that server can be
|
* If the *Shared?* switch is moved to *Yes* then that server can be
|
||||||
shared with all the other users. This option is available only to admin users. For more information on users see :ref:`User Management Dialog <user_management>`. The users can access the shared servers with some restritctions. The Users accessing the shared servers cannot do the following operations on the shared servers:
|
shared with all the other users. This option is available only to admin users. For more information on users see :ref:`User Management Dialog <user_management>`. The users can access the shared servers with some restritctions. The Users accessing the shared servers cannot do the following operations on the shared servers:
|
||||||
|
|
||||||
* Create a server
|
* Create a server
|
||||||
|
|||||||
@@ -27,10 +27,11 @@ def register_browser_preferences(self):
|
|||||||
if config.SERVER_MODE:
|
if config.SERVER_MODE:
|
||||||
self.hide_shared_server = self.preference.register(
|
self.hide_shared_server = self.preference.register(
|
||||||
'display', 'hide_shared_server',
|
'display', 'hide_shared_server',
|
||||||
gettext("Hide shared server?"), 'boolean', False,
|
gettext("Hide shared servers?"), 'boolean', False,
|
||||||
category_label=gettext('Display'),
|
category_label=gettext('Display'),
|
||||||
help_str=gettext(
|
help_str=gettext(
|
||||||
'If set to true, then all shared server will be hidden'
|
'If set to True, then all shared servers will be '
|
||||||
|
'hidden from browser tree'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -139,13 +139,16 @@ class ServerModule(sg.ServerGroupPluginModule):
|
|||||||
Return shared server properties
|
Return shared server properties
|
||||||
:param server:
|
:param server:
|
||||||
:param sharedserver:
|
:param sharedserver:
|
||||||
:return:
|
:return: shared server
|
||||||
"""
|
"""
|
||||||
|
|
||||||
server.bgcolor = sharedserver.bgcolor
|
server.bgcolor = sharedserver.bgcolor
|
||||||
server.fgcolor = sharedserver.fgcolor
|
server.fgcolor = sharedserver.fgcolor
|
||||||
server.name = sharedserver.name
|
server.name = sharedserver.name
|
||||||
server.role = sharedserver.role
|
server.role = sharedserver.role
|
||||||
|
server.use_ssh_tunnel = sharedserver.use_ssh_tunnel
|
||||||
|
server.tunnel_host = sharedserver.tunnel_host
|
||||||
|
server.tunnel_port = sharedserver.tunnel_port
|
||||||
|
server.tunnel_authentication = sharedserver.tunnel_authentication
|
||||||
server.tunnel_username = sharedserver.tunnel_username
|
server.tunnel_username = sharedserver.tunnel_username
|
||||||
server.tunnel_password = sharedserver.tunnel_password
|
server.tunnel_password = sharedserver.tunnel_password
|
||||||
server.save_password = sharedserver.save_password
|
server.save_password = sharedserver.save_password
|
||||||
@@ -157,45 +160,53 @@ class ServerModule(sg.ServerGroupPluginModule):
|
|||||||
|
|
||||||
return server
|
return server
|
||||||
|
|
||||||
@staticmethod
|
def get_servers(self, all_servers, hide_shared_server, gid):
|
||||||
def check_to_hide_shared_server(hide_shared_server, shared_server,
|
"""
|
||||||
auto_detected_server):
|
This function creates list of servers which needs to display
|
||||||
|
in browser tree
|
||||||
|
:param all_servers:
|
||||||
|
:param hide_shared_server:
|
||||||
|
:param gid:
|
||||||
|
:return: list of servers
|
||||||
|
"""
|
||||||
|
servers = []
|
||||||
|
for server in all_servers:
|
||||||
|
if server.discovery_id and \
|
||||||
|
not server.shared and \
|
||||||
|
config.SERVER_MODE and \
|
||||||
|
len(SharedServer.query.filter_by(
|
||||||
|
user_id=current_user.id,
|
||||||
|
name=server.name).all()) > 0 and not hide_shared_server:
|
||||||
|
continue
|
||||||
|
|
||||||
hide_server = False
|
if server.shared and server.user_id != current_user.id:
|
||||||
if hide_shared_server or \
|
|
||||||
shared_server.name == auto_detected_server:
|
|
||||||
hide_server = True
|
|
||||||
|
|
||||||
return hide_server
|
shared_server = self.get_shared_server(server, gid)
|
||||||
|
|
||||||
|
if hide_shared_server:
|
||||||
|
# Don't include shared server if hide shared server is
|
||||||
|
# set to true.
|
||||||
|
continue
|
||||||
|
|
||||||
|
server = self.get_shared_server_properties(server,
|
||||||
|
shared_server)
|
||||||
|
servers.append(server)
|
||||||
|
|
||||||
|
return servers
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def get_nodes(self, gid):
|
def get_nodes(self, gid):
|
||||||
"""Return a JSON document listing the server groups for the user"""
|
"""Return a JSON document listing the server groups for the user"""
|
||||||
|
|
||||||
hide_shared_server = get_preferences()
|
hide_shared_server = get_preferences()
|
||||||
|
|
||||||
servers = Server.query.filter(
|
servers = Server.query.filter(
|
||||||
or_(Server.user_id == current_user.id, Server.shared),
|
or_(Server.user_id == current_user.id, Server.shared),
|
||||||
Server.servergroup_id == gid)
|
Server.servergroup_id == gid)
|
||||||
|
|
||||||
driver = get_driver(PG_DEFAULT_DRIVER)
|
driver = get_driver(PG_DEFAULT_DRIVER)
|
||||||
|
servers = self.get_servers(servers, hide_shared_server, gid)
|
||||||
|
|
||||||
for server in servers:
|
for server in servers:
|
||||||
|
|
||||||
if server.shared and server.user_id != current_user.id:
|
|
||||||
|
|
||||||
shared_server, auto_detected_server = \
|
|
||||||
self.get_shared_server(server, gid)
|
|
||||||
|
|
||||||
if self.check_to_hide_shared_server(hide_shared_server,
|
|
||||||
shared_server,
|
|
||||||
auto_detected_server):
|
|
||||||
# Don't include shared server if hide shared server is
|
|
||||||
# set to true
|
|
||||||
continue
|
|
||||||
|
|
||||||
server = self.get_shared_server_properties(server,
|
|
||||||
shared_server)
|
|
||||||
connected = False
|
connected = False
|
||||||
manager = None
|
manager = None
|
||||||
errmsg = None
|
errmsg = None
|
||||||
@@ -323,6 +334,7 @@ class ServerModule(sg.ServerGroupPluginModule):
|
|||||||
|
|
||||||
shared_server = None
|
shared_server = None
|
||||||
try:
|
try:
|
||||||
|
db.session.rollback()
|
||||||
user = User.query.filter_by(id=data.user_id).first()
|
user = User.query.filter_by(id=data.user_id).first()
|
||||||
shared_server = SharedServer(
|
shared_server = SharedServer(
|
||||||
user_id=current_user.id,
|
user_id=current_user.id,
|
||||||
@@ -346,13 +358,13 @@ class ServerModule(sg.ServerGroupPluginModule):
|
|||||||
fgcolor=data.fgcolor if data.fgcolor else None,
|
fgcolor=data.fgcolor if data.fgcolor else None,
|
||||||
service=data.service if data.service else None,
|
service=data.service if data.service else None,
|
||||||
connect_timeout=0,
|
connect_timeout=0,
|
||||||
use_ssh_tunnel=0,
|
use_ssh_tunnel=data.use_ssh_tunnel,
|
||||||
tunnel_host=None,
|
tunnel_host=data.tunnel_host,
|
||||||
tunnel_port=22,
|
tunnel_port=22,
|
||||||
tunnel_username=None,
|
tunnel_username=None,
|
||||||
tunnel_authentication=0,
|
tunnel_authentication=0,
|
||||||
tunnel_identity_file=None,
|
tunnel_identity_file=None,
|
||||||
shared=data.shared if data.shared else None
|
shared=True
|
||||||
)
|
)
|
||||||
db.session.add(shared_server)
|
db.session.add(shared_server)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
@@ -372,12 +384,9 @@ class ServerModule(sg.ServerGroupPluginModule):
|
|||||||
:param gid:
|
:param gid:
|
||||||
:return: shared_server
|
:return: shared_server
|
||||||
"""
|
"""
|
||||||
auto_detected_server = None
|
|
||||||
shared_server = SharedServer.query.filter_by(
|
shared_server = SharedServer.query.filter_by(
|
||||||
name=server.name, user_id=current_user.id,
|
name=server.name, user_id=current_user.id,
|
||||||
servergroup_id=gid).first()
|
servergroup_id=gid).first()
|
||||||
if server.discovery_id:
|
|
||||||
auto_detected_server = server.name
|
|
||||||
|
|
||||||
if shared_server is None:
|
if shared_server is None:
|
||||||
ServerModule.create_shared_server(server, gid)
|
ServerModule.create_shared_server(server, gid)
|
||||||
@@ -386,7 +395,7 @@ class ServerModule(sg.ServerGroupPluginModule):
|
|||||||
name=server.name, user_id=current_user.id,
|
name=server.name, user_id=current_user.id,
|
||||||
servergroup_id=gid).first()
|
servergroup_id=gid).first()
|
||||||
|
|
||||||
return shared_server, auto_detected_server
|
return shared_server
|
||||||
|
|
||||||
|
|
||||||
class ServerMenuItem(MenuItem):
|
class ServerMenuItem(MenuItem):
|
||||||
@@ -494,8 +503,7 @@ class ServerNode(PGChildNodeView):
|
|||||||
|
|
||||||
for server in servers:
|
for server in servers:
|
||||||
if server.shared and server.user_id != current_user.id:
|
if server.shared and server.user_id != current_user.id:
|
||||||
shared_server, auto_detected_server = \
|
shared_server = ServerModule.get_shared_server(server, gid)
|
||||||
ServerModule.get_shared_server(server, gid)
|
|
||||||
server = \
|
server = \
|
||||||
ServerModule.get_shared_server_properties(server,
|
ServerModule.get_shared_server_properties(server,
|
||||||
shared_server)
|
shared_server)
|
||||||
@@ -552,8 +560,7 @@ class ServerNode(PGChildNodeView):
|
|||||||
server = Server.query.filter_by(id=sid).first()
|
server = Server.query.filter_by(id=sid).first()
|
||||||
|
|
||||||
if server.shared and server.user_id != current_user.id:
|
if server.shared and server.user_id != current_user.id:
|
||||||
shared_server, auto_detected_server = \
|
shared_server = ServerModule.get_shared_server(server, gid)
|
||||||
ServerModule.get_shared_server(server, gid)
|
|
||||||
server = ServerModule.get_shared_server_properties(server,
|
server = ServerModule.get_shared_server_properties(server,
|
||||||
shared_server)
|
shared_server)
|
||||||
|
|
||||||
@@ -677,8 +684,7 @@ class ServerNode(PGChildNodeView):
|
|||||||
|
|
||||||
if config.SERVER_MODE and server.shared and \
|
if config.SERVER_MODE and server.shared and \
|
||||||
server.user_id != current_user.id:
|
server.user_id != current_user.id:
|
||||||
sharedserver, auto_detected_server = \
|
sharedserver = ServerModule.get_shared_server(server, gid)
|
||||||
ServerModule.get_shared_server(server, gid)
|
|
||||||
|
|
||||||
# Not all parameters can be modified, while the server is connected
|
# Not all parameters can be modified, while the server is connected
|
||||||
config_param_map = {
|
config_param_map = {
|
||||||
@@ -781,6 +787,8 @@ class ServerNode(PGChildNodeView):
|
|||||||
True,
|
True,
|
||||||
self.node_type,
|
self.node_type,
|
||||||
connected=connected,
|
connected=connected,
|
||||||
|
shared=server.shared,
|
||||||
|
user_id=server.user_id,
|
||||||
user=manager.user_info if connected else None,
|
user=manager.user_info if connected else None,
|
||||||
server_type='pg' # default server type
|
server_type='pg' # default server type
|
||||||
)
|
)
|
||||||
@@ -849,8 +857,7 @@ class ServerNode(PGChildNodeView):
|
|||||||
|
|
||||||
for server in servers:
|
for server in servers:
|
||||||
if server.shared and server.user_id != current_user.id:
|
if server.shared and server.user_id != current_user.id:
|
||||||
shared_server, auto_detected_server = \
|
shared_server = ServerModule.get_shared_server(server, gid)
|
||||||
ServerModule.get_shared_server(server, gid)
|
|
||||||
server = \
|
server = \
|
||||||
ServerModule.get_shared_server_properties(server,
|
ServerModule.get_shared_server_properties(server,
|
||||||
shared_server)
|
shared_server)
|
||||||
@@ -907,10 +914,8 @@ class ServerNode(PGChildNodeView):
|
|||||||
conn = manager.connection()
|
conn = manager.connection()
|
||||||
connected = conn.connected()
|
connected = conn.connected()
|
||||||
|
|
||||||
# if server.shared and not current_user.has_role("Administrator"):
|
|
||||||
if server.shared and server.user_id != current_user.id:
|
if server.shared and server.user_id != current_user.id:
|
||||||
shared_server, auto_detected_server = \
|
shared_server = ServerModule.get_shared_server(server, gid)
|
||||||
ServerModule.get_shared_server(server, gid)
|
|
||||||
server = ServerModule.get_shared_server_properties(server,
|
server = ServerModule.get_shared_server_properties(server,
|
||||||
shared_server)
|
shared_server)
|
||||||
server_owner = server.server_owner
|
server_owner = server.server_owner
|
||||||
@@ -1136,6 +1141,7 @@ class ServerNode(PGChildNodeView):
|
|||||||
self.node_type,
|
self.node_type,
|
||||||
user=user,
|
user=user,
|
||||||
connected=connected,
|
connected=connected,
|
||||||
|
shared=server.shared,
|
||||||
server_type=manager.server_type
|
server_type=manager.server_type
|
||||||
if manager and manager.server_type
|
if manager and manager.server_type
|
||||||
else 'pg',
|
else 'pg',
|
||||||
@@ -1265,8 +1271,7 @@ class ServerNode(PGChildNodeView):
|
|||||||
server = Server.query.filter_by(id=sid).first()
|
server = Server.query.filter_by(id=sid).first()
|
||||||
shared_server = None
|
shared_server = None
|
||||||
if server.shared and server.user_id != current_user.id:
|
if server.shared and server.user_id != current_user.id:
|
||||||
shared_server, auto_detected_server = \
|
shared_server = ServerModule.get_shared_server(server, gid)
|
||||||
ServerModule.get_shared_server(server, gid)
|
|
||||||
server = ServerModule.get_shared_server_properties(server,
|
server = ServerModule.get_shared_server_properties(server,
|
||||||
shared_server)
|
shared_server)
|
||||||
if server is None:
|
if server is None:
|
||||||
|
|||||||
@@ -269,7 +269,10 @@ define('pgadmin.node.server', [
|
|||||||
gettext('Are you sure you want to disconnect the server %s?', d.label),
|
gettext('Are you sure you want to disconnect the server %s?', d.label),
|
||||||
function() { disconnect(); },
|
function() { disconnect(); },
|
||||||
function() { return true;}
|
function() { return true;}
|
||||||
);
|
).set('labels', {
|
||||||
|
ok: gettext('Ok'),
|
||||||
|
cancel: gettext('Cancel'),
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
disconnect();
|
disconnect();
|
||||||
}
|
}
|
||||||
@@ -752,6 +755,11 @@ define('pgadmin.node.server', [
|
|||||||
},
|
},
|
||||||
schema: [{
|
schema: [{
|
||||||
id: 'id', label: gettext('ID'), type: 'int', mode: ['properties'],
|
id: 'id', label: gettext('ID'), type: 'int', mode: ['properties'],
|
||||||
|
visible: function(model){
|
||||||
|
if (model.attributes.user_id != current_user.id && pgAdmin.server_mode == 'True')
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
},
|
||||||
},{
|
},{
|
||||||
id: 'name', label: gettext('Name'), type: 'text',
|
id: 'name', label: gettext('Name'), type: 'text',
|
||||||
mode: ['properties', 'edit', 'create'], disabled: 'isShared',
|
mode: ['properties', 'edit', 'create'], disabled: 'isShared',
|
||||||
@@ -759,7 +767,7 @@ define('pgadmin.node.server', [
|
|||||||
{
|
{
|
||||||
id: 'gid', label: gettext('Server group'), type: 'int',
|
id: 'gid', label: gettext('Server group'), type: 'int',
|
||||||
control: 'node-list-by-id', node: 'server_group',
|
control: 'node-list-by-id', node: 'server_group',
|
||||||
mode: ['create', 'edit'], select2: {allowClear: false}, visible: 'isVisible',
|
mode: ['create', 'edit'], select2: {allowClear: false}, disabled: 'isShared',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'server_owner', label: gettext('Shared Server Owner'), type: 'text', mode: ['properties'],
|
id: 'server_owner', label: gettext('Shared Server Owner'), type: 'text', mode: ['properties'],
|
||||||
@@ -795,7 +803,7 @@ define('pgadmin.node.server', [
|
|||||||
id: 'connect_now', controlLabel: gettext('Connect now?'), type: 'checkbox',
|
id: 'connect_now', controlLabel: gettext('Connect now?'), type: 'checkbox',
|
||||||
group: null, mode: ['create'],
|
group: null, mode: ['create'],
|
||||||
},{
|
},{
|
||||||
id: 'shared', label: gettext('Shared with all?'), type: 'switch',
|
id: 'shared', label: gettext('Shared?'), type: 'switch',
|
||||||
mode: ['properties', 'create', 'edit'], 'options': {'size': 'mini'},
|
mode: ['properties', 'create', 'edit'], 'options': {'size': 'mini'},
|
||||||
readonly: function(model){
|
readonly: function(model){
|
||||||
var serverOwner = model.attributes.user_id;
|
var serverOwner = model.attributes.user_id;
|
||||||
|
|||||||
@@ -346,7 +346,7 @@
|
|||||||
"mock_data": {
|
"mock_data": {
|
||||||
},
|
},
|
||||||
"expected_data": {
|
"expected_data": {
|
||||||
"status_code": 500
|
"status_code": 200
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user