Allow the server config to be reloaded.

This commit is contained in:
Neel Patel 2016-05-06 15:08:22 +01:00 committed by Dave Page
parent 128070877a
commit 4190933909
2 changed files with 75 additions and 0 deletions

View File

@ -179,6 +179,8 @@ class ServerNode(PGChildNodeView):
'dependent': [{'get': 'dependents'}],
'children': [{'get': 'children'}],
'module.js': [{}, {}, {'get': 'module_js'}],
'reload':
[{'get': 'reload_configuration'}],
'connect': [{
'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)

View File

@ -39,6 +39,12 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
applies: ['object', 'context'], callback: 'disconnect_server',
category: 'drop', priority: 5, label: '{{ _('Disconnect Server...') }}',
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'] =
@ -144,6 +150,49 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
pgBrowser.serverInfo[data._id] = _.extend({}, data);
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({