Ensure that the query tool tab should be closed after server disconnection when auto-commit/auto-rollback is set to false. Fixes #5519

This commit is contained in:
Pradip Parkale 2021-04-01 11:58:59 +05:30 committed by Akshay Joshi
parent 07f2df7e66
commit 566f03beca
6 changed files with 89 additions and 13 deletions

View File

@ -1,5 +1,5 @@
************
Version 5.1
Version 5.2
************
Release date: 2021-04-22
@ -18,6 +18,7 @@ Housekeeping
Bug fixes
*********
| `Issue #5519 <https://redmine.postgresql.org/issues/5519>`_ - Ensure that the query tool tab should be closed after server disconnection when auto-commit/auto-rollback is set to false.
| `Issue #6293 <https://redmine.postgresql.org/issues/6293>`_ - Fixed an issue where the procedure creation is failed when providing the Volatility option.
| `Issue #6344 <https://redmine.postgresql.org/issues/6344>`_ - Fixed cannot unpack non-iterable response object error when selecting any partition.
| `Issue #6356 <https://redmine.postgresql.org/issues/6356>`_ - Mark the Apache HTTPD config file as such in the web DEB and RPM packages.

View File

@ -287,7 +287,7 @@ define('pgadmin.node.server', [
function() { disconnect(); },
function() { return true;}
).set('labels', {
ok: gettext('Ok'),
ok: gettext('OK'),
cancel: gettext('Cancel'),
});
} else {

View File

@ -258,7 +258,7 @@ let NewConnectionDialog = {
}).fail(function() {
Alertify.alert().setting({
'title': gettext('Connection lost'),
'label':gettext('Ok'),
'label':gettext('OK'),
'message': gettext('Connection to the server has been lost.'),
'onok': function(){
//Close the window after connection is lost

View File

@ -244,7 +244,7 @@ function initFilterDialog(alertify, pgBrowser) {
alertify.alert()
.setting({
'title': gettext('Validation Error'),
'label':gettext('Ok'),
'label':gettext('OK'),
'message': gettext(res.data.result),
'onok': function(){
filter_editor.focus();

View File

@ -119,6 +119,7 @@ class SqlEditorModule(PgAdminModule):
'sqleditor.get_new_connection_data',
'sqleditor.get_new_connection_database',
'sqleditor.get_new_connection_user',
'sqleditor._check_server_connection_status',
'sqleditor.get_new_connection_role',
'sqleditor.connect_server',
'sqleditor.connect_server_with_user',
@ -1479,6 +1480,49 @@ def get_filter_data(trans_id):
return FilterDialog.get(status, error_msg, conn, trans_obj, session_ob)
@blueprint.route(
'/get_server_connection/<int:sgid>/<int:sid>',
methods=["GET"], endpoint='_check_server_connection_status'
)
@login_required
def _check_server_connection_status(sgid, sid=None):
"""
This function returns the server connection details
"""
try:
driver = get_driver(PG_DEFAULT_DRIVER)
from pgadmin.browser.server_groups.servers import \
server_icon_and_background
server = Server.query.filter_by(
id=sid).first()
manager = driver.connection_manager(server.id)
conn = manager.connection()
connected = conn.connected()
msg = "Success"
return make_json_response(
data={
'status': True,
'msg': msg,
'result': {
'server': connected
}
}
)
except Exception:
return make_json_response(
data={
'status': False,
'msg': ERROR_FETCHING_DATA,
'result': {
'server': False
}
}
)
@blueprint.route(
'/new_connection_dialog/<int:sgid>/<int:sid>',
methods=["GET"], endpoint='get_new_connection_data'

View File

@ -4809,7 +4809,7 @@ define('tools.querytool', [
else if (!ignore_unsaved_query && self.is_query_tool
&& self.is_query_changed
&& self.preferences.prompt_save_query_changes) {
msg = gettext('The text has changed. Do you want to save changes?');
msg = gettext('The query text has changed. Do you want to save changes?');
self.unsaved_changes_user_confirmation(msg, false);
} // If a transaction is currently ongoing
else if (self.preferences.prompt_commit_transaction
@ -4938,14 +4938,45 @@ define('tools.querytool', [
break;
case 1: // Don't Save
self.close_on_save = false;
if(this.is_unsaved_data)
self.ignore_on_close.unsaved_data = true;
else
self.ignore_on_close.unsaved_query = true;
// Go back to check for any other needed confirmations before closing
if (!self.check_needed_confirmations_before_closing_panel()){
closeEvent.cancel = true;
}
$.ajax({
url: url_for('sqleditor._check_server_connection_status', {
'sid': self.url_params.sid,
'sgid': self.url_params.sgid,
}),
headers: {
'Cache-Control' : 'no-cache',
},
}).done(function (res) {
let response = res.data.result.server;
if (response) {
closeEvent.cancel = true;
if (this.is_unsaved_data)
self.ignore_on_close.unsaved_data = true;
else
self.ignore_on_close.unsaved_query = true;
// Go back to check for any other needed confirmations before closing
if (!self.check_needed_confirmations_before_closing_panel()) {
closeEvent.cancel = true;
}
} else {
alertify.confirm(
gettext('Warning'),
gettext('The current transaction has been rolled back because the server was disconnected.'),
function() {
// Close the query tool if server is disconnected.
setTimeout(() => { self.close(); }, 200);
},
function() {
return true;
}
).set('labels', {
ok: gettext('OK')
});
}
}).fail(function() {
/* failure should be ignored */
});
break;
case 2: //Save
self.close_on_save = true;