public inbox for [email protected]
help / color / mirror / Atom feedFrom: Surinder Kumar <[email protected]>
To: pgadmin-hackers <[email protected]>
Subject: [pgAdmin4][Patch]: Slickgrid loading issue in Query tool
Date: Mon, 19 Sep 2016 19:28:49 +0530
Message-ID: <CAM5-9D8fkGNhktgspPc2wS78EEnxtzgCaQsaXADcn0oV=dLhoA@mail.gmail.com> (raw)
List-Unsubscribe: <mailto:[email protected]?body=unsub%20pgadmin-hackers>
Hi
*Issue:*
Slick-grid libraries loads when an instance of query tool is opened. But
sometimes it throws exception "jQuery is not defined" and it doesn't opens
up.
*Solution:*
As per my understanding, In *datagrid/index.html* file, we set the order of
loading libraries such as
*require(['jquery', 'pgadmin', 'pgadmin.sqleditor']) *
but it still loads *pgadmin.sqleditor.js* file before *jQuery* for unknown
reason.
To fix this, we load *pgadmin.sqleditor.js* file using *require([],
function(){}) *module loader which ensures that the code within
*function(){}* will be executed when pgadmin.sqleditor.js is loaded.
Please find attache patch.
This issue is fixed by *Ashesh Vashi*.
Thanks,
Surinder Kumar
--
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers
Attachments:
[application/octet-stream] slickgrid_js_load_issue.patch (4.2K, 3-slickgrid_js_load_issue.patch)
download | inline diff:
diff --git a/web/pgadmin/tools/datagrid/templates/datagrid/index.html b/web/pgadmin/tools/datagrid/templates/datagrid/index.html
index 37e4632..205ec53 100644
--- a/web/pgadmin/tools/datagrid/templates/datagrid/index.html
+++ b/web/pgadmin/tools/datagrid/templates/datagrid/index.html
@@ -181,7 +181,7 @@
</ul>
</div>
<div class="btn-group" role="group" aria-label="">
- <button id="btn-download" type="button" class="btn btn-default" title="{{ _('Download as CSV (F8)') }}">
+ <button id="btn-download" type="button" class="btn btn-default" title="{{ _('Download as CSV (F8)') }}" disabled>
<i class="fa fa-download" aria-hidden="true"></i>
</button>
</div>
@@ -209,64 +209,60 @@
</div>
{% endblock %}
-{% block init_script %}
-try {
-require(
-['jquery', 'pgadmin', 'pgadmin.sqleditor'],
-function($, pgAdmin) {
+{% block init_script %}require(
+ ['jquery', 'pgadmin', 'require', 'underscore.string'],
+function($, pgAdmin, R, S) {
+ R(['pgadmin.sqleditor'], function() {
+ var editorPanel = $('.sql-editor'),
+ loadingDiv = $('#fetching_data'),
+ msgDiv = loadingDiv.find('.sql-editor-busy-text');
-var editorPanel = $('.sql-editor'),
-loadingDiv = $('#fetching_data'),
-msgDiv = loadingDiv.find('.sql-editor-busy-text');
+ // Get the controller object from pgAdmin.SqlEditor
+ var sqlEditorController = pgAdmin.SqlEditor.create(editorPanel);
-// Get the controller object from pgAdmin.SqlEditor
-var sqlEditorController = pgAdmin.SqlEditor.create(editorPanel);
+ // Listen on events to show/hide loading-icon and change messages.
+ sqlEditorController.on('pgadmin-sqleditor:loading-icon:message', function(msg) {
+ msgDiv.text(msg);
+ }).on('pgadmin-sqleditor:loading-icon:show', function(msg) {
+ loadingDiv.removeClass('hide');
+ msgDiv.text(msg);
+ }).on('pgadmin-sqleditor:loading-icon:hide', function() {
+ if (!loadingDiv.hasClass('hide')) {
+ loadingDiv.addClass('hide');
+ }
+ });
-// Listen on events to show/hide loading-icon and change messages.
-sqlEditorController.on('pgadmin-sqleditor:loading-icon:message', function(msg) {
-msgDiv.text(msg);
-}).on('pgadmin-sqleditor:loading-icon:show', function(msg) {
-loadingDiv.removeClass('hide');
-msgDiv.text(msg);
-}).on('pgadmin-sqleditor:loading-icon:hide', function() {
-if (!loadingDiv.hasClass('hide')) {
-loadingDiv.addClass('hide');
-}
-});
-
-// Fetch the SQL for Scripts (eg: CREATE/UPDATE/DELETE/SELECT)
-var script_sql = '';
+ // Fetch the SQL for Scripts (eg: CREATE/UPDATE/DELETE/SELECT)
+ var script_sql = '';
{% if script_type_url%}
-// Call AJAX only if script type url is present
-$.ajax({
-url: '{{ script_type_url }}',
-type:'GET',
-async: false,
-success: function(res) {
-script_sql = res;
-},
-error: function(jqx) {
-var msg = jqx.responseText;
-/* Error from the server */
-if (jqx.status == 410 || jqx.status == 500) {
-try {
-var data = $.parseJSON(jqx.responseText);
-msg = data.errormsg;
-} catch (e) {}
-}
-pgBrowser.report_error(
-S('{{ _('Error fetching SQL for script: "%s"') }}')
-.sprintf(msg)
-.value(), msg);
-}
-});
+ // Call AJAX only if script type url is present
+ $.ajax({
+ url: '{{ script_type_url }}',
+ type:'GET',
+ async: false,
+ success: function(res) {
+ script_sql = res;
+ },
+ error: function(jqx) {
+ var msg = jqx.responseText;
+ /* Error from the server */
+ if (jqx.status == 410 || jqx.status == 500) {
+ try {
+ var data = $.parseJSON(jqx.responseText);
+ msg = data.errormsg;
+ } catch (e) {}
+ }
+ pgBrowser.report_error(
+ S('{{ _('Error fetching SQL for script: "%s"') }}')
+ .sprintf(msg)
+ .value(), msg
+ );
+ }
+ });
{% endif %}
-// Start the query tool.
-sqlEditorController.start({{ is_query_tool }}, "{{ editor_title }}", script_sql);
+ // Start the query tool.
+ sqlEditorController.start({{ is_query_tool }}, "{{ editor_title }}", script_sql);
+ });
});
-} catch (err) {
-/* Show proper error dialog */
-console.log(err);
-}
{% endblock %}
view thread (2+ 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]
Subject: Re: [pgAdmin4][Patch]: Slickgrid loading issue in Query tool
In-Reply-To: <CAM5-9D8fkGNhktgspPc2wS78EEnxtzgCaQsaXADcn0oV=dLhoA@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