mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Allow the server config to be reloaded.
This commit is contained in:
parent
128070877a
commit
4190933909
@ -179,6 +179,8 @@ class ServerNode(PGChildNodeView):
|
|||||||
'dependent': [{'get': 'dependents'}],
|
'dependent': [{'get': 'dependents'}],
|
||||||
'children': [{'get': 'children'}],
|
'children': [{'get': 'children'}],
|
||||||
'module.js': [{}, {}, {'get': 'module_js'}],
|
'module.js': [{}, {}, {'get': 'module_js'}],
|
||||||
|
'reload':
|
||||||
|
[{'get': 'reload_configuration'}],
|
||||||
'connect': [{
|
'connect': [{
|
||||||
'get': 'connect_status', 'post': 'connect', 'delete': 'disconnect'
|
'get': 'connect_status', 'post': 'connect', 'delete': 'disconnect'
|
||||||
}]
|
}]
|
||||||
@ -755,5 +757,29 @@ class ServerNode(PGChildNodeView):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def reload_configuration(self, gid, sid):
|
||||||
|
"""Reload the server configuration"""
|
||||||
|
|
||||||
|
# Reload the server configurations
|
||||||
|
from pgadmin.utils.driver import get_driver
|
||||||
|
manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(sid)
|
||||||
|
conn = manager.connection()
|
||||||
|
|
||||||
|
if conn.connected():
|
||||||
|
# Execute the command for reload configuration for the server
|
||||||
|
status, rid = conn.execute_scalar("SELECT pg_reload_conf();")
|
||||||
|
|
||||||
|
if not status:
|
||||||
|
return internal_server_error(
|
||||||
|
gettext("Could not reload the server configuration.")
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return make_json_response(data={'status': True,
|
||||||
|
'result': gettext('Server configuration reloaded.')})
|
||||||
|
|
||||||
|
else:
|
||||||
|
return make_json_response(data={'status': False,
|
||||||
|
'result': gettext('Not connected to the server or the connection to the server has been closed.')})
|
||||||
|
|
||||||
|
|
||||||
ServerNode.register_node_view(blueprint)
|
ServerNode.register_node_view(blueprint)
|
||||||
|
@ -39,6 +39,12 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
|
|||||||
applies: ['object', 'context'], callback: 'disconnect_server',
|
applies: ['object', 'context'], callback: 'disconnect_server',
|
||||||
category: 'drop', priority: 5, label: '{{ _('Disconnect Server...') }}',
|
category: 'drop', priority: 5, label: '{{ _('Disconnect Server...') }}',
|
||||||
icon: 'fa fa-chain-broken', enable : 'is_connected'
|
icon: 'fa fa-chain-broken', enable : 'is_connected'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'reload_configuration', node: 'server', module: this,
|
||||||
|
applies: ['tools', 'context'], callback: 'reload_configuration',
|
||||||
|
category: 'reload', priority: 6, label: '{{ _('Reload Configuration...') }}',
|
||||||
|
icon: 'fa fa-repeat', enable : 'is_connected'
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
pgBrowser.messages['PRIV_GRANTEE_NOT_SPECIFIED'] =
|
pgBrowser.messages['PRIV_GRANTEE_NOT_SPECIFIED'] =
|
||||||
@ -144,6 +150,49 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
|
|||||||
pgBrowser.serverInfo[data._id] = _.extend({}, data);
|
pgBrowser.serverInfo[data._id] = _.extend({}, data);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
},
|
||||||
|
/* Reload configuration */
|
||||||
|
reload_configuration: function(args){
|
||||||
|
var input = args || {};
|
||||||
|
obj = this,
|
||||||
|
t = pgBrowser.tree,
|
||||||
|
i = input.item || t.selected(),
|
||||||
|
d = i && i.length == 1 ? t.itemData(i) : undefined;
|
||||||
|
|
||||||
|
if (!d)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
alertify.confirm(
|
||||||
|
'{{ _('Reload server configuration') }}',
|
||||||
|
S('{{ _('Are you sure you want to reload the server configuration on %%s?') }}').sprintf(d.label).value(),
|
||||||
|
function(evt) {
|
||||||
|
$.ajax({
|
||||||
|
url: obj.generate_url(i, 'reload', d, true),
|
||||||
|
method:'GET',
|
||||||
|
success: function(res) {
|
||||||
|
if (res.data.status) {
|
||||||
|
alertify.success(res.data.result);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
alertify.error(res.data.result);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function(xhr, status, error) {
|
||||||
|
try {
|
||||||
|
var err = $.parseJSON(xhr.responseText);
|
||||||
|
if (err.success == 0) {
|
||||||
|
alertify.error(err.errormsg);
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
t.unload(i);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
function(evt) {
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
model: pgAdmin.Browser.Node.Model.extend({
|
model: pgAdmin.Browser.Node.Model.extend({
|
||||||
|
Loading…
Reference in New Issue
Block a user