public inbox for [email protected]  
help / color / mirror / Atom feed
[pgAdmin][RM5815] Generate script is not working in new window
2+ messages / 2 participants
[nested] [flat]

* [pgAdmin][RM5815] Generate script is not working in new window
@ 2020-09-09 09:48 Aditya Toshniwal <[email protected]>
  2020-09-09 14:43 ` Re: [pgAdmin][RM5815] Generate script is not working in new window Akshay Joshi <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: Aditya Toshniwal @ 2020-09-09 09:48 UTC (permalink / raw)
  To: pgadmin-hackers

Hi Hackers,

If schema diff is opened in a new tab and "Generate script" is clicked
(with query tool setting "open in new tab" set to true) then it shows a
forever spinner because of pop up blocks.

Attached patch will show an alert message in that case so that the user can
allow pop up and generate the script again.

Please review.

-- 
Thanks,
Aditya Toshniwal
pgAdmin hacker | Sr. Software Engineer | *edbpostgres.com*
<http://edbpostgres.com;
"Don't Complain about Heat, Plant a TREE"


Attachments:

  [application/octet-stream] RM5815.patch (3.3K, 3-RM5815.patch)
  download | inline diff:
diff --git a/web/pgadmin/tools/datagrid/static/js/datagrid.js b/web/pgadmin/tools/datagrid/static/js/datagrid.js
index 640b325c4..bb4d333ca 100644
--- a/web/pgadmin/tools/datagrid/static/js/datagrid.js
+++ b/web/pgadmin/tools/datagrid/static/js/datagrid.js
@@ -234,8 +234,12 @@ define('pgadmin.datagrid', [
 
         if (self.preferences.new_browser_tab) {
           var newWin = window.open('', '_blank');
-          newWin.document.write(queryToolForm);
-          newWin.document.title = panel_title;
+          if(newWin) {
+            newWin.document.write(queryToolForm);
+            newWin.document.title = panel_title;
+          } else {
+            return false;
+          }
         } else {
           /* On successfully initialization find the dashboard panel,
            * create new panel and add it to the dashboard panel.
@@ -283,6 +287,7 @@ define('pgadmin.datagrid', [
 
           openQueryToolURL(queryToolPanel);
         }
+        return true;
       },
     },
     Backbone.Events);
diff --git a/web/pgadmin/tools/datagrid/static/js/show_query_tool.js b/web/pgadmin/tools/datagrid/static/js/show_query_tool.js
index 782bf78e3..0f3636e65 100644
--- a/web/pgadmin/tools/datagrid/static/js/show_query_tool.js
+++ b/web/pgadmin/tools/datagrid/static/js/show_query_tool.js
@@ -68,7 +68,7 @@ export function showQueryTool(datagrid, pgBrowser, alertify, url, aciTreeIdentif
   datagrid.launch_grid(transId, gridUrl, true, queryToolTitle, sURL);
 }
 
-export function generateScript(parentData, datagrid) {
+export function generateScript(parentData, datagrid, alertify) {
   const queryToolTitle = `${parentData.database}/${parentData.user}@${parentData.server}`;
   const transId = getRandomInt(1, 9999999);
 
@@ -82,6 +82,13 @@ export function generateScript(parentData, datagrid) {
     +`&server_type=${parentData.stype}`
     +`&did=${parentData.did}`;
 
-  datagrid.launch_grid(transId, url_endpoint, true, queryToolTitle, '');
-
+  let retVal = datagrid.launch_grid(transId, url_endpoint, true, queryToolTitle, '');
+  if(!retVal) {
+    alertify.alert(
+      gettext('Query tool launch error'),
+      gettext(
+        'Please allow the pop ups if they are blocked for pgAdmin. If the pgAdmin window is closed then close this window and open a new pgAdmin session.'
+      )
+    );
+  }
 }
diff --git a/web/pgadmin/tools/schema_diff/static/js/schema_diff_ui.js b/web/pgadmin/tools/schema_diff/static/js/schema_diff_ui.js
index 228271518..2e037e47d 100644
--- a/web/pgadmin/tools/schema_diff/static/js/schema_diff_ui.js
+++ b/web/pgadmin/tools/schema_diff/static/js/schema_diff_ui.js
@@ -239,7 +239,7 @@ export default class SchemaDiffUI {
             }
 
             pgWindow.pgAdmin.ddl_diff = generated_script;
-            generateScript(server_data, pgWindow.pgAdmin.DataGrid);
+            generateScript(server_data, pgWindow.pgAdmin.DataGrid, Alertify);
           }
 
           $('#diff_fetching_data').find('.schema-diff-busy-text').text('');
@@ -485,7 +485,7 @@ export default class SchemaDiffUI {
       contentType: 'application/json',
     })
       .done(function (res) {
-        let msg = res.data.compare_msg;
+        let msg = _.escape(res.data.compare_msg);
         if (res.data.diff_percentage != 100) {
           msg = msg + gettext(' (this may take a few minutes)...');
         }


^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: [pgAdmin][RM5815] Generate script is not working in new window
  2020-09-09 09:48 [pgAdmin][RM5815] Generate script is not working in new window Aditya Toshniwal <[email protected]>
@ 2020-09-09 14:43 ` Akshay Joshi <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Akshay Joshi @ 2020-09-09 14:43 UTC (permalink / raw)
  To: Aditya Toshniwal <[email protected]>; +Cc: pgadmin-hackers

Thanks, patch applied.

On Wed, Sep 9, 2020 at 3:19 PM Aditya Toshniwal <
[email protected]> wrote:

> Hi Hackers,
>
> If schema diff is opened in a new tab and "Generate script" is clicked
> (with query tool setting "open in new tab" set to true) then it shows a
> forever spinner because of pop up blocks.
>
> Attached patch will show an alert message in that case so that the user
> can allow pop up and generate the script again.
>
> Please review.
>
> --
> Thanks,
> Aditya Toshniwal
> pgAdmin hacker | Sr. Software Engineer | *edbpostgres.com*
> <http://edbpostgres.com;
> "Don't Complain about Heat, Plant a TREE"
>


-- 
*Thanks & Regards*
*Akshay Joshi*
*pgAdmin Hacker | Sr. Software Architect*
*EDB Postgres <http://edbpostgres.com>*

*Mobile: +91 976-788-8246*


^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2020-09-09 14:43 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-09-09 09:48 [pgAdmin][RM5815] Generate script is not working in new window Aditya Toshniwal <[email protected]>
2020-09-09 14:43 ` Akshay Joshi <[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