public inbox for [email protected]
help / color / mirror / Atom feedFrom: Murtuza Zabuawala <[email protected]>
To: Akshay Joshi <[email protected]>
Cc: pgadmin-hackers <[email protected]>
Subject: Re: [pgAdmin4][RM#4858] Allow user to reconnect to DB server when connection is drop
Date: Wed, 15 Apr 2020 12:22:36 +0530
Message-ID: <CAKKotZQG5gWXcFomD5mHVSDUJaZJixiQSL7o_ymp2x_t0bcS5w@mail.gmail.com> (raw)
In-Reply-To: <CANxoLDfh3_YVeB=k0ENT1b-_stGgs56NuY=ZpOEiewuZhrmUmg@mail.gmail.com>
References: <CAKKotZSE2NN73s2nbnoxsNdZAw-nG7TBEvG3bPGx45TDUica9A@mail.gmail.com>
<CANxoLDfh3_YVeB=k0ENT1b-_stGgs56NuY=ZpOEiewuZhrmUmg@mail.gmail.com>
Hi Akshay,
PFA updated patch.
--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
On Mon, Apr 13, 2020 at 2:28 PM Akshay Joshi <[email protected]>
wrote:
> Hi Murtuza
>
> The issue has been fixed with your patch, but there is an existing issue
> discover with the fix.
> After disconnecting the server and click on Download CSV button
> confirmation dialog comes and user needs to click twice.
> Following error observed in the browser:
>
> sqleditor.js?ver=42000:1 Uncaught TypeError: Cannot read property 'apply'
> of undefined
> at Object.<anonymous> (sqleditor.js?ver=42000:1)
> at Object.callback (vendor.others.js?ver=42000:2)
> at Tt (vendor.others.js?ver=42000:2)
> at Object.Ct (vendor.others.js?ver=42000:2)
> at HTMLDivElement.<anonymous> (vendor.others.js?ver=42000:2)
>
> If possible can you please fix the above and resend the combined patch.
>
> On Fri, Apr 10, 2020 at 7:02 PM Murtuza Zabuawala <
> [email protected]> wrote:
>
>> Hi,
>>
>> Upon downloading the csv file, we used the prompt for re-connecting to
>> the database server when there is a database server connection issue.
>> Currently the user tries to download CSV and there is a connection issue
>> then it is showing a python exception error.
>>
>> Steps:
>> 1) Open query tool
>> 2) Execute -> SELECT 1,2,3
>> 3) Disconnect from server from browser tree
>> 4) Click on Download CSV button
>>
>> Current: Python exception error
>> Expected: It should display dialog to reconnect the server.
>>
>>
>> --
>> Regards,
>> Murtuza Zabuawala
>> EnterpriseDB: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>>
>
> --
> *Thanks & Regards*
> *Akshay Joshi*
>
> *Sr. Software Architect*
> *EnterpriseDB Software India Private Limited*
> *Mobile: +91 976-788-8246*
>
Attachments:
[application/octet-stream] RM_4858_v1.diff (8.4K, 3-RM_4858_v1.diff)
download | inline diff:
diff --git a/web/pgadmin/static/js/sqleditor/query_tool_http_error_handler.js b/web/pgadmin/static/js/sqleditor/query_tool_http_error_handler.js
index 97575c1ea..651ff6e91 100644
--- a/web/pgadmin/static/js/sqleditor/query_tool_http_error_handler.js
+++ b/web/pgadmin/static/js/sqleditor/query_tool_http_error_handler.js
@@ -63,6 +63,8 @@ export function handleQueryToolAjaxError(
if(exception.status === 503 && exception.responseJSON.info !== undefined &&
exception.responseJSON.info == 'CONNECTION_LOST') {
+ // We will display re-connect dialog, no need to display error message again
+ msg = null;
setTimeout(function() {
if (stateToSave) {
handler.saveState(stateToSave, stateParameters);
diff --git a/web/pgadmin/tools/sqleditor/__init__.py b/web/pgadmin/tools/sqleditor/__init__.py
index 386a655e4..6d53632a1 100644
--- a/web/pgadmin/tools/sqleditor/__init__.py
+++ b/web/pgadmin/tools/sqleditor/__init__.py
@@ -1370,8 +1370,12 @@ def start_query_download_tool(trans_id):
] = "attachment;filename={0}".format(filename)
return r
+ except (ConnectionLost, SSHTunnelConnectionLost):
+ raise
except Exception as e:
- err_msg = gettext("Error: {0}").format(e.strerror)
+ current_app.logger.error(e)
+ err_msg = "Error: {0}".format(
+ e.strerror if hasattr(e, 'strerror') else str(e))
return internal_server_error(errormsg=err_msg)
else:
return internal_server_error(
diff --git a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
index f5519fcdf..128e30bb0 100644
--- a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
+++ b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
@@ -1305,7 +1305,8 @@ define('tools.querytool', [
let msg = httpErrorHandler.handleQueryToolAjaxError(
pgAdmin, self, e, null, [], false
);
- self.update_msg_history(false, msg);
+ if (msg)
+ self.update_msg_history(false, msg);
});
},
@@ -2159,8 +2160,12 @@ define('tools.querytool', [
if (args.indexOf('connect') == -1) {
args.push('connect');
}
+ if (fn in self) {
+ self[fn].apply(self, args);
+ } else {
+ console.warn('The callback is not valid for this context');
+ }
- self[fn].apply(self, args);
}
}, function() {
self.saveState();
@@ -2195,9 +2200,10 @@ define('tools.querytool', [
let msg = httpErrorHandler.handleQueryToolAjaxError(
pgAdmin, self, xhr, null, [], false
);
- alertify.dlgGetServerPass(
- gettext('Connect to Server'), msg
- );
+ if (msg)
+ alertify.dlgGetServerPass(
+ gettext('Connect to Server'), msg
+ );
});
},
/* This function is used to create instance of SQLEditorView,
@@ -2300,10 +2306,10 @@ define('tools.querytool', [
msg = httpErrorHandler.handleQueryToolAjaxError(
pgAdmin, self, jqx, null, [], false
);
-
- pgBrowser.report_error(
- gettext('Error fetching SQL for script: %s.', msg)
- );
+ if (msg)
+ pgBrowser.report_error(
+ gettext('Error fetching SQL for script: %s.', msg)
+ );
});
}
}
@@ -2484,7 +2490,8 @@ define('tools.querytool', [
let msg = httpErrorHandler.handleQueryToolAjaxError(
pgAdmin, self, e, '_execute_view_data_query', [], true
);
- self.update_msg_history(false, msg);
+ if (msg)
+ self.update_msg_history(false, msg);
});
},
@@ -3237,7 +3244,8 @@ define('tools.querytool', [
// Enable query tool buttons and cancel button only if query tool
if(self.is_query_tool)
self.disable_tool_buttons(false);
- self.update_msg_history(false, msg);
+ if (msg)
+ self.update_msg_history(false, msg);
});
},
@@ -3395,7 +3403,8 @@ define('tools.querytool', [
let msg = httpErrorHandler.handleQueryToolAjaxError(
pgAdmin, self, e, '_select_file_handler', stateParams, false
);
- alertify.error(msg);
+ if (msg)
+ alertify.error(msg);
// hide cursor
$busy_icon_div.removeClass('show_progress');
});
@@ -3446,7 +3455,8 @@ define('tools.querytool', [
let msg = httpErrorHandler.handleQueryToolAjaxError(
pgAdmin, self, e, '_save_file_handler', stateParams, false
);
- alertify.error(msg);
+ if (msg)
+ alertify.error(msg);
});
},
@@ -3575,7 +3585,8 @@ define('tools.querytool', [
let msg = httpErrorHandler.handleQueryToolAjaxError(
pgAdmin, self, e, '_include_filter', [], true
);
- alertify.alert(gettext('Filter By Selection Error'), msg);
+ if (msg)
+ alertify.alert(gettext('Filter By Selection Error'), msg);
});
},
@@ -3634,7 +3645,8 @@ define('tools.querytool', [
let msg = httpErrorHandler.handleQueryToolAjaxError(
pgAdmin, self, e, '_exclude_filter', [], true
);
- alertify.alert(gettext('Filter Exclude Selection Error'), msg);
+ if (msg)
+ alertify.alert(gettext('Filter Exclude Selection Error'), msg);
});
},
@@ -3672,7 +3684,8 @@ define('tools.querytool', [
let msg = httpErrorHandler.handleQueryToolAjaxError(
pgAdmin, self, e, '_remove_filter', [], true
);
- alertify.alert(gettext('Remove Filter Error'), msg);
+ if (msg)
+ alertify.alert(gettext('Remove Filter Error'), msg);
});
},
@@ -3803,7 +3816,8 @@ define('tools.querytool', [
let msg = httpErrorHandler.handleQueryToolAjaxError(
pgAdmin, self, e, '_set_limit', [], true
);
- alertify.alert(gettext('Change limit Error'), msg);
+ if (msg)
+ alertify.alert(gettext('Change limit Error'), msg);
});
},
@@ -3948,7 +3962,8 @@ define('tools.querytool', [
let msg = httpErrorHandler.handleQueryToolAjaxError(
pgAdmin, self, e, '_cancel_query', [], false
);
- alertify.alert(gettext('Cancel Query Error'), msg);
+ if (msg)
+ alertify.alert(gettext('Cancel Query Error'), msg);
});
},
@@ -4012,7 +4027,6 @@ define('tools.querytool', [
self.trigger('pgadmin-sqleditor:loading-icon:hide');
}).fail(function(err) {
let msg = '';
-
// Enable the execute button
$('#btn-flash').prop('disabled', false);
$('#btn-download').prop('disabled', false);
@@ -4024,10 +4038,12 @@ define('tools.querytool', [
msg = gettext('CSV Download cancelled.');
} else {
msg = httpErrorHandler.handleQueryToolAjaxError(
- pgAdmin, self, err, gettext('Download CSV'), [], true
+ pgAdmin, self, err, 'trigger_csv_download', [], true
);
}
- alertify.alert(gettext('Download CSV error'), msg);
+ // Check if error message is present
+ if (msg)
+ alertify.alert(gettext('Download CSV error'), msg);
});
},
@@ -4068,7 +4084,8 @@ define('tools.querytool', [
let msg = httpErrorHandler.handleQueryToolAjaxError(
pgAdmin, self, e, '_auto_rollback', [], true
);
- alertify.alert(gettext('Auto Rollback Error'), msg);
+ if (msg)
+ alertify.alert(gettext('Auto Rollback Error'), msg);
});
},
@@ -4100,7 +4117,8 @@ define('tools.querytool', [
let msg = httpErrorHandler.handleQueryToolAjaxError(
pgAdmin, self, e, '_auto_commit', [], true
);
- alertify.alert(gettext('Auto Commit Error'), msg);
+ if (msg)
+ alertify.alert(gettext('Auto Commit Error'), msg);
});
},
view thread (4+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: [pgAdmin4][RM#4858] Allow user to reconnect to DB server when connection is drop
In-Reply-To: <CAKKotZQG5gWXcFomD5mHVSDUJaZJixiQSL7o_ymp2x_t0bcS5w@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox