public inbox for [email protected]
help / color / mirror / Atom feed[pgAdmin4][Patch]: Slickgrid loading issue in Query tool
2+ messages / 2 participants
[nested] [flat]
* [pgAdmin4][Patch]: Slickgrid loading issue in Query tool
@ 2016-09-19 13:58 Surinder Kumar <[email protected]>
0 siblings, 1 reply; 2+ messages in thread
From: Surinder Kumar @ 2016-09-19 13:58 UTC (permalink / raw)
To: pgadmin-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 %}
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: [pgAdmin4][Patch]: Slickgrid loading issue in Query tool
@ 2016-09-19 16:09 Dave Page <[email protected]>
parent: Surinder Kumar <[email protected]>
0 siblings, 0 replies; 2+ messages in thread
From: Dave Page @ 2016-09-19 16:09 UTC (permalink / raw)
To: Surinder Kumar <[email protected]>; +Cc: pgadmin-hackers
Thanks, applied.
On Mon, Sep 19, 2016 at 2:58 PM, Surinder Kumar
<[email protected]> wrote:
> 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
>
--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2016-09-19 16:09 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-09-19 13:58 [pgAdmin4][Patch]: Slickgrid loading issue in Query tool Surinder Kumar <[email protected]>
2016-09-19 16:09 ` Dave Page <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox