public inbox for [email protected]help / color / mirror / Atom feed
[pgAdmin][Patch] #4059 Query Tool button in Query Tool to open a new Query Window 7+ messages / 2 participants [nested] [flat]
* [pgAdmin][Patch] #4059 Query Tool button in Query Tool to open a new Query Window @ 2020-08-27 14:40 Rahul Shirsat <[email protected]> 0 siblings, 1 reply; 7+ messages in thread From: Rahul Shirsat @ 2020-08-27 14:40 UTC (permalink / raw) To: pgadmin-hackers Hi Hackers, Please find the attached patch below which adds the functionality of the query tool button in the query tool sqleditor. *Acceptance criteria:* - For sqleditor on same window & on new tab: - When a query tool connection is initiated, as expected it will open the connection based on the selected database in the treeview. Now, when the user clicks the query tool connection button on the query tool window, irrespective of the selected database in treeview, it should open a connection based on the query tool connected database. - Similarly, for a new tab, clicking on the query tool connection button, it should open a connection based on the query tool connected database, instead of selected treeview node. [image: query tool button.png] Additionally, an error is handled in the form of message dialog prompting the user to initiate the connection, when sqleditor is opened in the new tab with the main application window kept closed. This can be reviewed by refreshing the window as well as clicking on the query tool connection button. A prompt dialog message box is seen as: [image: Screen Shot 2020-08-27 at 8.04.33 PM.png] -- *Rahul Shirsat* Software Engineer | EnterpriseDB Corporation. Attachments: [image/png] query tool button.png (78.2K, 3-query%20tool%20button.png) download | view image [image/png] Screen Shot 2020-08-27 at 8.04.33 PM.png (47.9K, 4-Screen%20Shot%202020-08-27%20at%208.04.33%20PM.png) download | view image [application/octet-stream] RM4059.patch (5.2K, 5-RM4059.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 9de7bf511..ae240cd5c 100644 --- a/web/pgadmin/tools/datagrid/templates/datagrid/index.html +++ b/web/pgadmin/tools/datagrid/templates/datagrid/index.html @@ -14,6 +14,14 @@ <div id="main-editor_panel"> <div class="sql-editor"> <div id="btn-toolbar" class="editor-toolbar" role="toolbar" aria-label=""> + <div class="btn-group mr-1" role="group" aria-label=""> + <button id="btn-show-query-tool" type="button" class="btn btn-sm btn-primary-icon btn-show-query-tool" + title="" + accesskey="" + tabindex="0"> + <i class="pg-font-icon icon-query-tool" aria-hidden="true" role="img"></i> + </button> + </div> <div class="btn-group mr-1" role="group" aria-label=""> <button id="btn-load-file" type="button" class="btn btn-sm btn-primary-icon btn-load-file" title="" diff --git a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js index dae9edea4..42fd1ad9f 100644 --- a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js +++ b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js @@ -90,6 +90,7 @@ define('tools.querytool', [ // Bind all the events events: { + 'click #btn-show-query-tool': 'on_show_query_tool', 'click .btn-load-file': 'on_file_load', 'click #btn-save-file': 'on_save_file', 'click #btn-file-menu-save': 'on_save_file', @@ -1959,6 +1960,20 @@ define('tools.querytool', [ ev.stopPropagation(); }, + // callback function for show query tool click. + on_show_query_tool: function(ev) { + var self = this; + + this._stopEventPropogation(ev); + this._closeDropDown(ev); + + self.handler.trigger( + 'pgadmin-sqleditor:button:show_query_tool', + self, + self.handler + ); + }, + // callback function for load file button click. on_file_load: function(ev) { var self = this; @@ -2017,6 +2032,48 @@ define('tools.querytool', [ this.initialize.apply(this, arguments); }; + /* This function is used to check whether user have closed + * the main window when query tool is opened on new tab + */ + var is_main_window_alive = function() { + + if((pgWindow.default && pgWindow.default.closed) || + pgWindow.default.pgAdmin && pgWindow.default.pgAdmin.Browser + && pgWindow.default.pgAdmin.Browser.preference_version() <= 0) { + + alertify.alert() + .setting({ + 'title': gettext('Connection lost'), + 'label':gettext('Close'), + 'message': gettext('Main Application window is closed. Login and initiate the session.'), + 'onok': function(){ + //Close the window after connection is lost + window.close(); + }, + }).show(); + } + }; + + var set_tree_node = function() { + + let browser = pgWindow.default.pgAdmin.Browser; + let tree = browser.tree; + + var t = tree, + i = t.selected(), + d = i && i.length == 1 ? t.itemData(i) : undefined; + + if(!d) + return; + + var selected_tree_node = { t, i, d }; + + if(!pgWindow.default.pgAdmin.selected_tree_map) + pgWindow.default.pgAdmin.selected_tree_map = new Map(); + + pgWindow.default.pgAdmin.selected_tree_map.set(d._id.toString(), selected_tree_node); + }; + _.extend( SqlEditorController.prototype, Backbone.Events, @@ -2026,6 +2083,11 @@ define('tools.querytool', [ this.container = container; this.state = {}; this.csrf_token = pgAdmin.csrf_token; + + //call to check whether user have closed the parent window and trying to refresh, if yes return error. + is_main_window_alive(); + set_tree_node(); + // Disable animation first modifyAnimation.modifyAlertifyAnimation(); @@ -2411,6 +2473,7 @@ define('tools.querytool', [ self.on('pgadmin-sqleditor:button:explain-timing', self._explain_timing, self); self.on('pgadmin-sqleditor:button:explain-summary', self._explain_summary, self); self.on('pgadmin-sqleditor:button:explain-settings', self._explain_settings, self); + self.on('pgadmin-sqleditor:button:show_query_tool', self._show_query_tool, self); // Indentation related self.on('pgadmin-sqleditor:indent_selected_code', self._indent_selected_code, self); self.on('pgadmin-sqleditor:unindent_selected_code', self._unindent_selected_code, self); @@ -4227,6 +4290,19 @@ define('tools.querytool', [ this._toggle_explain_option('settings'); }, + _show_query_tool: function() { + var self = this; + + setTimeout(() => { + var tree_node = pgWindow.default.pgAdmin.selected_tree_map.get(self.url_params.did); + if(self.preferences.new_browser_tab) { + is_main_window_alive(); + } + + pgWindow.default.pgAdmin.DataGrid.show_query_tool('', tree_node.i); + }, 200); + }, + /* * This function will indent selected code */ ^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: [pgAdmin][Patch] #4059 Query Tool button in Query Tool to open a new Query Window @ 2020-08-27 14:45 Rahul Shirsat <[email protected]> parent: Rahul Shirsat <[email protected]> 0 siblings, 1 reply; 7+ messages in thread From: Rahul Shirsat @ 2020-08-27 14:45 UTC (permalink / raw) To: pgadmin-hackers Please find the update patch attached here. On Thu, Aug 27, 2020 at 8:10 PM Rahul Shirsat < [email protected]> wrote: > Hi Hackers, > > Please find the attached patch below which adds the functionality of the > query tool button in the query tool sqleditor. > > *Acceptance criteria:* > - For sqleditor on same window & on new tab: > > - When a query tool connection is initiated, as expected it will open > the connection based on the selected database in the treeview. Now, when > the user clicks the query tool connection button on the query tool window, > irrespective of the selected database in treeview, it should open a > connection based on the query tool connected database. > - Similarly, for a new tab, clicking on the query tool connection > button, it should open a connection based on the query tool connected > database, instead of selected treeview node. > > [image: query tool button.png] > > Additionally, an error is handled in the form of message dialog prompting > the user to initiate the connection, when sqleditor is opened in the new > tab with the main application window kept closed. This can be reviewed by > refreshing the window as well as clicking on the query tool connection > button. > > A prompt dialog message box is seen as: > > [image: Screen Shot 2020-08-27 at 8.04.33 PM.png] > > -- > *Rahul Shirsat* > Software Engineer | EnterpriseDB Corporation. > -- *Rahul Shirsat* Software Engineer | EnterpriseDB Corporation. Attachments: [image/png] query tool button.png (78.2K, 3-query%20tool%20button.png) download | view image [image/png] Screen Shot 2020-08-27 at 8.04.33 PM.png (47.9K, 4-Screen%20Shot%202020-08-27%20at%208.04.33%20PM.png) download | view image [application/octet-stream] RM4059_v2.patch (5.3K, 5-RM4059_v2.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 9de7bf511..ae240cd5c 100644 --- a/web/pgadmin/tools/datagrid/templates/datagrid/index.html +++ b/web/pgadmin/tools/datagrid/templates/datagrid/index.html @@ -14,6 +14,14 @@ <div id="main-editor_panel"> <div class="sql-editor"> <div id="btn-toolbar" class="editor-toolbar" role="toolbar" aria-label=""> + <div class="btn-group mr-1" role="group" aria-label=""> + <button id="btn-show-query-tool" type="button" class="btn btn-sm btn-primary-icon btn-show-query-tool" + title="" + accesskey="" + tabindex="0"> + <i class="pg-font-icon icon-query-tool" aria-hidden="true" role="img"></i> + </button> + </div> <div class="btn-group mr-1" role="group" aria-label=""> <button id="btn-load-file" type="button" class="btn btn-sm btn-primary-icon btn-load-file" title="" diff --git a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js index dae9edea4..a0724ff9e 100644 --- a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js +++ b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js @@ -90,6 +90,7 @@ define('tools.querytool', [ // Bind all the events events: { + 'click #btn-show-query-tool': 'on_show_query_tool', 'click .btn-load-file': 'on_file_load', 'click #btn-save-file': 'on_save_file', 'click #btn-file-menu-save': 'on_save_file', @@ -1959,6 +1960,20 @@ define('tools.querytool', [ ev.stopPropagation(); }, + // callback function for show query tool click. + on_show_query_tool: function(ev) { + var self = this; + + this._stopEventPropogation(ev); + this._closeDropDown(ev); + + self.handler.trigger( + 'pgadmin-sqleditor:button:show_query_tool', + self, + self.handler + ); + }, + // callback function for load file button click. on_file_load: function(ev) { var self = this; @@ -2017,6 +2032,48 @@ define('tools.querytool', [ this.initialize.apply(this, arguments); }; + /* This function is used to check whether user have closed + * the main window when query tool is opened on new tab + */ + var is_main_window_alive = function() { + + if((pgWindow.default && pgWindow.default.closed) || + pgWindow.default.pgAdmin && pgWindow.default.pgAdmin.Browser + && pgWindow.default.pgAdmin.Browser.preference_version() <= 0) { + + alertify.alert() + .setting({ + 'title': gettext('Connection lost'), + 'label':gettext('Close'), + 'message': gettext('The pgAdmin browser window has been closed and the connection to the server is lost. Please close this window and open a new pgAdmin session.'), + 'onok': function(){ + //Close the window after connection is lost + window.close(); + }, + }).show(); + } + }; + + var set_tree_node = function() { + + let browser = pgWindow.default.pgAdmin.Browser; + let tree = browser.tree; + + var t = tree, + i = t.selected(), + d = i && i.length == 1 ? t.itemData(i) : undefined; + + if(!d) + return; + + var selected_tree_node = { t, i, d }; + + if(!pgWindow.default.pgAdmin.selected_tree_map) + pgWindow.default.pgAdmin.selected_tree_map = new Map(); + + pgWindow.default.pgAdmin.selected_tree_map.set(d._id.toString(), selected_tree_node); + }; + _.extend( SqlEditorController.prototype, Backbone.Events, @@ -2026,6 +2083,11 @@ define('tools.querytool', [ this.container = container; this.state = {}; this.csrf_token = pgAdmin.csrf_token; + + //call to check whether user have closed the parent window and trying to refresh, if yes return error. + is_main_window_alive(); + set_tree_node(); + // Disable animation first modifyAnimation.modifyAlertifyAnimation(); @@ -2411,6 +2473,7 @@ define('tools.querytool', [ self.on('pgadmin-sqleditor:button:explain-timing', self._explain_timing, self); self.on('pgadmin-sqleditor:button:explain-summary', self._explain_summary, self); self.on('pgadmin-sqleditor:button:explain-settings', self._explain_settings, self); + self.on('pgadmin-sqleditor:button:show_query_tool', self._show_query_tool, self); // Indentation related self.on('pgadmin-sqleditor:indent_selected_code', self._indent_selected_code, self); self.on('pgadmin-sqleditor:unindent_selected_code', self._unindent_selected_code, self); @@ -4227,6 +4290,19 @@ define('tools.querytool', [ this._toggle_explain_option('settings'); }, + _show_query_tool: function() { + var self = this; + + setTimeout(() => { + var tree_node = pgWindow.default.pgAdmin.selected_tree_map.get(self.url_params.did); + if(self.preferences.new_browser_tab) { + is_main_window_alive(); + } + + pgWindow.default.pgAdmin.DataGrid.show_query_tool('', tree_node.i); + }, 200); + }, + /* * This function will indent selected code */ ^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: [pgAdmin][Patch] #4059 Query Tool button in Query Tool to open a new Query Window @ 2020-08-28 12:54 Akshay Joshi <[email protected]> parent: Rahul Shirsat <[email protected]> 0 siblings, 1 reply; 7+ messages in thread From: Akshay Joshi @ 2020-08-28 12:54 UTC (permalink / raw) To: Rahul Shirsat <[email protected]>; +Cc: pgadmin-hackers Thanks, patch applied. On Thu, Aug 27, 2020 at 8:16 PM Rahul Shirsat < [email protected]> wrote: > > Please find the update patch attached here. > > On Thu, Aug 27, 2020 at 8:10 PM Rahul Shirsat < > [email protected]> wrote: > >> Hi Hackers, >> >> Please find the attached patch below which adds the functionality of the >> query tool button in the query tool sqleditor. >> >> *Acceptance criteria:* >> - For sqleditor on same window & on new tab: >> >> - When a query tool connection is initiated, as expected it will open >> the connection based on the selected database in the treeview. Now, when >> the user clicks the query tool connection button on the query tool window, >> irrespective of the selected database in treeview, it should open a >> connection based on the query tool connected database. >> - Similarly, for a new tab, clicking on the query tool connection >> button, it should open a connection based on the query tool connected >> database, instead of selected treeview node. >> >> [image: query tool button.png] >> >> Additionally, an error is handled in the form of message dialog prompting >> the user to initiate the connection, when sqleditor is opened in the new >> tab with the main application window kept closed. This can be reviewed by >> refreshing the window as well as clicking on the query tool connection >> button. >> >> A prompt dialog message box is seen as: >> >> [image: Screen Shot 2020-08-27 at 8.04.33 PM.png] >> >> -- >> *Rahul Shirsat* >> Software Engineer | EnterpriseDB Corporation. >> > > > -- > *Rahul Shirsat* > Software Engineer | EnterpriseDB Corporation. > -- *Thanks & Regards* *Akshay Joshi* *pgAdmin Hacker | Sr. Software Architect* *EDB Postgres <http://edbpostgres.com>* *Mobile: +91 976-788-8246* Attachments: [image/png] query tool button.png (78.2K, 3-query%20tool%20button.png) download | view image [image/png] Screen Shot 2020-08-27 at 8.04.33 PM.png (47.9K, 4-Screen%20Shot%202020-08-27%20at%208.04.33%20PM.png) download | view image ^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: [pgAdmin][Patch] #4059 Query Tool button in Query Tool to open a new Query Window @ 2020-09-09 12:53 Rahul Shirsat <[email protected]> parent: Akshay Joshi <[email protected]> 0 siblings, 1 reply; 7+ messages in thread From: Rahul Shirsat @ 2020-09-09 12:53 UTC (permalink / raw) To: Akshay Joshi <[email protected]>; +Cc: pgadmin-hackers Hi Akshay, Please find the attached patch which adds / corrects following features / issues : 1. Added tooltip & keyboard shortcut for query tool button 2. Corrected the *Uncaught TypeError: Cannot read property ‘i’ of undefined* This issue can be reproduced by : *Keeping the click on any node other than database, refresh the page, open the same server (it should navigate to the previously selected node), open query tool, now open query tool via sqleditor query tool button, issue should be reproduced* - *Resolved* 3. Aditya's changes for *popups are blocked* are now extended for the new tab query tool too. On Fri, Aug 28, 2020 at 6:24 PM Akshay Joshi <[email protected]> wrote: > Thanks, patch applied. > > On Thu, Aug 27, 2020 at 8:16 PM Rahul Shirsat < > [email protected]> wrote: > >> >> Please find the update patch attached here. >> >> On Thu, Aug 27, 2020 at 8:10 PM Rahul Shirsat < >> [email protected]> wrote: >> >>> Hi Hackers, >>> >>> Please find the attached patch below which adds the functionality of the >>> query tool button in the query tool sqleditor. >>> >>> *Acceptance criteria:* >>> - For sqleditor on same window & on new tab: >>> >>> - When a query tool connection is initiated, as expected it will >>> open the connection based on the selected database in the treeview. Now, >>> when the user clicks the query tool connection button on the query tool >>> window, irrespective of the selected database in treeview, it should open a >>> connection based on the query tool connected database. >>> - Similarly, for a new tab, clicking on the query tool connection >>> button, it should open a connection based on the query tool connected >>> database, instead of selected treeview node. >>> >>> [image: query tool button.png] >>> >>> Additionally, an error is handled in the form of message dialog >>> prompting the user to initiate the connection, when sqleditor is opened in >>> the new tab with the main application window kept closed. This can be >>> reviewed by refreshing the window as well as clicking on the query tool >>> connection button. >>> >>> A prompt dialog message box is seen as: >>> >>> [image: Screen Shot 2020-08-27 at 8.04.33 PM.png] >>> >>> -- >>> *Rahul Shirsat* >>> Software Engineer | EnterpriseDB Corporation. >>> >> >> >> -- >> *Rahul Shirsat* >> Software Engineer | EnterpriseDB Corporation. >> > > > -- > *Thanks & Regards* > *Akshay Joshi* > *pgAdmin Hacker | Sr. Software Architect* > *EDB Postgres <http://edbpostgres.com>* > > *Mobile: +91 976-788-8246* > -- *Rahul Shirsat* Software Engineer | EnterpriseDB Corporation. Attachments: [image/png] query tool button.png (78.2K, 3-query%20tool%20button.png) download | view image [image/png] Screen Shot 2020-08-27 at 8.04.33 PM.png (47.9K, 4-Screen%20Shot%202020-08-27%20at%208.04.33%20PM.png) download | view image [application/octet-stream] RM4059_v3.patch (6.8K, 5-RM4059_v3.patch) download | inline diff: diff --git a/web/pgadmin/static/js/keyboard_shortcuts.js b/web/pgadmin/static/js/keyboard_shortcuts.js index c021d1830..f02851720 100644 --- a/web/pgadmin/static/js/keyboard_shortcuts.js +++ b/web/pgadmin/static/js/keyboard_shortcuts.js @@ -199,6 +199,7 @@ function keyboardShortcutsQueryTool( let commitKeys = sqlEditorController.preferences.commit_transaction; let rollbackKeys = sqlEditorController.preferences.rollback_transaction; let saveDataKeys = sqlEditorController.preferences.save_data; + let queryToolKeys = sqlEditorController.preferences.show_query_tool; if (this.validateShortcutKeys(executeKeys, event)) { this._stopEventPropagation(event); @@ -230,6 +231,9 @@ function keyboardShortcutsQueryTool( } else if (this.validateShortcutKeys(saveDataKeys, event)) { this._stopEventPropagation(event); queryToolActions.saveDataChanges(sqlEditorController); + } else if (this.validateShortcutKeys(queryToolKeys, event)) { + this._stopEventPropagation(event); + queryToolActions.openQueryTool(sqlEditorController); } else if (( (this.isMac() && event.metaKey) || (!this.isMac() && event.ctrlKey) diff --git a/web/pgadmin/static/js/sqleditor/query_tool_actions.js b/web/pgadmin/static/js/sqleditor/query_tool_actions.js index a97582e6a..98297cf18 100644 --- a/web/pgadmin/static/js/sqleditor/query_tool_actions.js +++ b/web/pgadmin/static/js/sqleditor/query_tool_actions.js @@ -161,6 +161,14 @@ let queryToolActions = { sqlEditorController.close_on_save = false; sqlEditorController.save_data(); }, + + openQueryTool: function (sqlEditorController) { + sqlEditorController.gridView.handler.trigger( + 'pgadmin-sqleditor:button:show_query_tool', + sqlEditorController.gridView, + sqlEditorController.gridView.handler + ); + }, }; module.exports = queryToolActions; diff --git a/web/pgadmin/static/js/sqleditor/query_tool_preferences.js b/web/pgadmin/static/js/sqleditor/query_tool_preferences.js index 5a3d15582..ba4e7c882 100644 --- a/web/pgadmin/static/js/sqleditor/query_tool_preferences.js +++ b/web/pgadmin/static/js/sqleditor/query_tool_preferences.js @@ -136,6 +136,12 @@ function updateUIPreferences(sqlEditor) { .attr('aria-label', shortcut_title(gettext('Rollback'),preferences.rollback_transaction)); + $el.find('#btn-show-query-tool') + .attr('title', + shortcut_title(gettext('Query tool'),preferences.show_query_tool)) + .attr('aria-label', + shortcut_title(gettext('Query tool'),preferences.show_query_tool)); + /* Set explain options on query editor */ if (preferences.explain_verbose){ $el.find('.explain-verbose').removeClass('visibility-hidden'); 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..9e0723665 100644 --- a/web/pgadmin/tools/datagrid/static/js/show_query_tool.js +++ b/web/pgadmin/tools/datagrid/static/js/show_query_tool.js @@ -65,7 +65,15 @@ export function showQueryTool(datagrid, pgBrowser, alertify, url, aciTreeIdentif const gridUrl = generateUrl(transId, queryToolTitle, parentData); - datagrid.launch_grid(transId, gridUrl, true, queryToolTitle, sURL); + let retVal = datagrid.launch_grid(transId, gridUrl, true, queryToolTitle, sURL); + 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.' + ) + ); + } } export function generateScript(parentData, datagrid) { diff --git a/web/pgadmin/tools/datagrid/templates/datagrid/index.html b/web/pgadmin/tools/datagrid/templates/datagrid/index.html index ae240cd5c..e81a42a47 100644 --- a/web/pgadmin/tools/datagrid/templates/datagrid/index.html +++ b/web/pgadmin/tools/datagrid/templates/datagrid/index.html @@ -17,7 +17,6 @@ <div class="btn-group mr-1" role="group" aria-label=""> <button id="btn-show-query-tool" type="button" class="btn btn-sm btn-primary-icon btn-show-query-tool" title="" - accesskey="" tabindex="0"> <i class="pg-font-icon icon-query-tool" aria-hidden="true" role="img"></i> </button> diff --git a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js index 060207202..b0d5a118f 100644 --- a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js +++ b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js @@ -7,6 +7,8 @@ // ////////////////////////////////////////////////////////////// +import {getTreeNodeHierarchyFromIdentifier} from 'sources/tree/pgadmin_tree_node'; + define('tools.querytool', [ 'sources/gettext', 'sources/url_for', 'jquery', 'jquery.ui', 'jqueryui.position', 'underscore', 'pgadmin.alertifyjs', @@ -151,7 +153,8 @@ define('tools.querytool', [ reflectPreferences: function() { let self = this, - browser = pgWindow.default.pgAdmin.Browser; + browser = pgWindow.default.pgAdmin.Browser, + browser_preferences = browser.get_preferences_for_module('browser'); /* pgBrowser is different obj from pgWindow.default.pgAdmin.Browser * Make sure to get only the latest update. Older versions will be discarded @@ -162,6 +165,7 @@ define('tools.querytool', [ if(pgBrowser.preference_version() < browser.preference_version()){ pgBrowser.preference_version(browser.preference_version()); self.preferences = browser.get_preferences_for_module('sqleditor'); + self.preferences.show_query_tool = browser_preferences.sub_menu_query_tool; self.handler.preferences = self.preferences; queryToolPref.updateUIPreferences(self); } @@ -2078,12 +2082,20 @@ define('tools.querytool', [ if(!d) return; + const parentData = getTreeNodeHierarchyFromIdentifier.call(pgWindow.default.pgAdmin.Browser, i); + + if(!parentData) { + return; + } + + let conn_param = parentData.database || parentData.server; + var selected_tree_node = { t, i, d }; if(!pgWindow.default.pgAdmin.selected_tree_map) pgWindow.default.pgAdmin.selected_tree_map = new Map(); - pgWindow.default.pgAdmin.selected_tree_map.set(d._pid.toString(), selected_tree_node); + pgWindow.default.pgAdmin.selected_tree_map.set(conn_param._id.toString(), selected_tree_node); }; _.extend( @@ -4306,7 +4318,7 @@ define('tools.querytool', [ var self = this; setTimeout(() => { - var tree_node = pgWindow.default.pgAdmin.selected_tree_map.get(self.url_params.did); + var tree_node = pgWindow.default.pgAdmin.selected_tree_map.get(self.url_params.did || self.url_params.sid); if(self.preferences.new_browser_tab) { is_main_window_alive(); } ^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: [pgAdmin][Patch] #4059 Query Tool button in Query Tool to open a new Query Window @ 2020-09-09 14:43 Akshay Joshi <[email protected]> parent: Rahul Shirsat <[email protected]> 0 siblings, 1 reply; 7+ messages in thread From: Akshay Joshi @ 2020-09-09 14:43 UTC (permalink / raw) To: Rahul Shirsat <[email protected]>; +Cc: pgadmin-hackers Thanks, patch applied. On Wed, Sep 9, 2020 at 6:23 PM Rahul Shirsat <[email protected]> wrote: > Hi Akshay, > > Please find the attached patch which adds / corrects following features / > issues : > > 1. Added tooltip & keyboard shortcut for query tool button > 2. Corrected the *Uncaught TypeError: Cannot read property ‘i’ of > undefined* > This issue can be reproduced by : > *Keeping the click on any node other than database, refresh the > page, open the same server (it should navigate to the previously selected > node), open query tool, now open query tool via sqleditor query tool > button, issue should be reproduced* - *Resolved* > 3. Aditya's changes for *popups are blocked* are now extended for the new > tab query tool too. > > > On Fri, Aug 28, 2020 at 6:24 PM Akshay Joshi < > [email protected]> wrote: > >> Thanks, patch applied. >> >> On Thu, Aug 27, 2020 at 8:16 PM Rahul Shirsat < >> [email protected]> wrote: >> >>> >>> Please find the update patch attached here. >>> >>> On Thu, Aug 27, 2020 at 8:10 PM Rahul Shirsat < >>> [email protected]> wrote: >>> >>>> Hi Hackers, >>>> >>>> Please find the attached patch below which adds the functionality of >>>> the query tool button in the query tool sqleditor. >>>> >>>> *Acceptance criteria:* >>>> - For sqleditor on same window & on new tab: >>>> >>>> - When a query tool connection is initiated, as expected it will >>>> open the connection based on the selected database in the treeview. Now, >>>> when the user clicks the query tool connection button on the query tool >>>> window, irrespective of the selected database in treeview, it should open a >>>> connection based on the query tool connected database. >>>> - Similarly, for a new tab, clicking on the query tool connection >>>> button, it should open a connection based on the query tool connected >>>> database, instead of selected treeview node. >>>> >>>> [image: query tool button.png] >>>> >>>> Additionally, an error is handled in the form of message dialog >>>> prompting the user to initiate the connection, when sqleditor is opened in >>>> the new tab with the main application window kept closed. This can be >>>> reviewed by refreshing the window as well as clicking on the query tool >>>> connection button. >>>> >>>> A prompt dialog message box is seen as: >>>> >>>> [image: Screen Shot 2020-08-27 at 8.04.33 PM.png] >>>> >>>> -- >>>> *Rahul Shirsat* >>>> Software Engineer | EnterpriseDB Corporation. >>>> >>> >>> >>> -- >>> *Rahul Shirsat* >>> Software Engineer | EnterpriseDB Corporation. >>> >> >> >> -- >> *Thanks & Regards* >> *Akshay Joshi* >> *pgAdmin Hacker | Sr. Software Architect* >> *EDB Postgres <http://edbpostgres.com>* >> >> *Mobile: +91 976-788-8246* >> > > > -- > *Rahul Shirsat* > Software Engineer | EnterpriseDB Corporation. > -- *Thanks & Regards* *Akshay Joshi* *pgAdmin Hacker | Sr. Software Architect* *EDB Postgres <http://edbpostgres.com>* *Mobile: +91 976-788-8246* Attachments: [image/png] query tool button.png (78.2K, 3-query%20tool%20button.png) download | view image [image/png] Screen Shot 2020-08-27 at 8.04.33 PM.png (47.9K, 4-Screen%20Shot%202020-08-27%20at%208.04.33%20PM.png) download | view image ^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: [pgAdmin][Patch] #4059 Query Tool button in Query Tool to open a new Query Window @ 2020-09-09 16:15 Rahul Shirsat <[email protected]> parent: Akshay Joshi <[email protected]> 0 siblings, 1 reply; 7+ messages in thread From: Rahul Shirsat @ 2020-09-09 16:15 UTC (permalink / raw) To: Akshay Joshi <[email protected]>; +Cc: pgadmin-hackers Hi Akshay, Issue is fixed for alerts getting popped up on the main window instead of the current window. On Wed, Sep 9, 2020 at 8:13 PM Akshay Joshi <[email protected]> wrote: > Thanks, patch applied. > > On Wed, Sep 9, 2020 at 6:23 PM Rahul Shirsat < > [email protected]> wrote: > >> Hi Akshay, >> >> Please find the attached patch which adds / corrects following features / >> issues : >> >> 1. Added tooltip & keyboard shortcut for query tool button >> 2. Corrected the *Uncaught TypeError: Cannot read property ‘i’ of >> undefined* >> This issue can be reproduced by : >> *Keeping the click on any node other than database, refresh the >> page, open the same server (it should navigate to the previously selected >> node), open query tool, now open query tool via sqleditor query tool >> button, issue should be reproduced* - *Resolved* >> 3. Aditya's changes for *popups are blocked* are now extended for the >> new tab query tool too. >> >> >> On Fri, Aug 28, 2020 at 6:24 PM Akshay Joshi < >> [email protected]> wrote: >> >>> Thanks, patch applied. >>> >>> On Thu, Aug 27, 2020 at 8:16 PM Rahul Shirsat < >>> [email protected]> wrote: >>> >>>> >>>> Please find the update patch attached here. >>>> >>>> On Thu, Aug 27, 2020 at 8:10 PM Rahul Shirsat < >>>> [email protected]> wrote: >>>> >>>>> Hi Hackers, >>>>> >>>>> Please find the attached patch below which adds the functionality of >>>>> the query tool button in the query tool sqleditor. >>>>> >>>>> *Acceptance criteria:* >>>>> - For sqleditor on same window & on new tab: >>>>> >>>>> - When a query tool connection is initiated, as expected it will >>>>> open the connection based on the selected database in the treeview. Now, >>>>> when the user clicks the query tool connection button on the query tool >>>>> window, irrespective of the selected database in treeview, it should open a >>>>> connection based on the query tool connected database. >>>>> - Similarly, for a new tab, clicking on the query tool connection >>>>> button, it should open a connection based on the query tool connected >>>>> database, instead of selected treeview node. >>>>> >>>>> [image: query tool button.png] >>>>> >>>>> Additionally, an error is handled in the form of message dialog >>>>> prompting the user to initiate the connection, when sqleditor is opened in >>>>> the new tab with the main application window kept closed. This can be >>>>> reviewed by refreshing the window as well as clicking on the query tool >>>>> connection button. >>>>> >>>>> A prompt dialog message box is seen as: >>>>> >>>>> [image: Screen Shot 2020-08-27 at 8.04.33 PM.png] >>>>> >>>>> -- >>>>> *Rahul Shirsat* >>>>> Software Engineer | EnterpriseDB Corporation. >>>>> >>>> >>>> >>>> -- >>>> *Rahul Shirsat* >>>> Software Engineer | EnterpriseDB Corporation. >>>> >>> >>> >>> -- >>> *Thanks & Regards* >>> *Akshay Joshi* >>> *pgAdmin Hacker | Sr. Software Architect* >>> *EDB Postgres <http://edbpostgres.com>* >>> >>> *Mobile: +91 976-788-8246* >>> >> >> >> -- >> *Rahul Shirsat* >> Software Engineer | EnterpriseDB Corporation. >> > > > -- > *Thanks & Regards* > *Akshay Joshi* > *pgAdmin Hacker | Sr. Software Architect* > *EDB Postgres <http://edbpostgres.com>* > > *Mobile: +91 976-788-8246* > -- *Rahul Shirsat* Software Engineer | EnterpriseDB Corporation. Attachments: [image/png] query tool button.png (78.2K, 3-query%20tool%20button.png) download | view image [image/png] Screen Shot 2020-08-27 at 8.04.33 PM.png (47.9K, 4-Screen%20Shot%202020-08-27%20at%208.04.33%20PM.png) download | view image [application/x-patch] RM4059_v4.patch (1.6K, 5-RM4059_v4.patch) download | inline diff: diff --git a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js index b0d5a118f..95ce1203b 100644 --- a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js +++ b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js @@ -8,6 +8,7 @@ ////////////////////////////////////////////////////////////// import {getTreeNodeHierarchyFromIdentifier} from 'sources/tree/pgadmin_tree_node'; +import {showQueryTool} from 'tools/datagrid/static/js/show_query_tool'; define('tools.querytool', [ 'sources/gettext', 'sources/url_for', 'jquery', 'jquery.ui', @@ -4317,14 +4318,16 @@ define('tools.querytool', [ _show_query_tool: function() { var self = this; - setTimeout(() => { - var tree_node = pgWindow.default.pgAdmin.selected_tree_map.get(self.url_params.did || self.url_params.sid); - if(self.preferences.new_browser_tab) { - is_main_window_alive(); - } + var tree_node = pgWindow.default.pgAdmin.selected_tree_map.get(self.url_params.did || self.url_params.sid); + if(self.preferences.new_browser_tab) { + is_main_window_alive(); + } + this._open_query_tool(tree_node); + }, - pgWindow.default.pgAdmin.DataGrid.show_query_tool('', tree_node.i); - }, 200); + _open_query_tool: function(tree_node) { + const transId = pgadminUtils.getRandomInt(1, 9999999); + showQueryTool(pgWindow.default.pgAdmin.DataGrid, pgWindow.default.pgAdmin.Browser, alertify, '', tree_node.i, transId); }, /* ^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: [pgAdmin][Patch] #4059 Query Tool button in Query Tool to open a new Query Window @ 2020-09-10 06:40 Akshay Joshi <[email protected]> parent: Rahul Shirsat <[email protected]> 0 siblings, 0 replies; 7+ messages in thread From: Akshay Joshi @ 2020-09-10 06:40 UTC (permalink / raw) To: Rahul Shirsat <[email protected]>; +Cc: pgadmin-hackers Thanks, patch applied. On Wed, Sep 9, 2020 at 9:45 PM Rahul Shirsat <[email protected]> wrote: > Hi Akshay, > > Issue is fixed for alerts getting popped up on the main window instead of > the current window. > > On Wed, Sep 9, 2020 at 8:13 PM Akshay Joshi <[email protected]> > wrote: > >> Thanks, patch applied. >> >> On Wed, Sep 9, 2020 at 6:23 PM Rahul Shirsat < >> [email protected]> wrote: >> >>> Hi Akshay, >>> >>> Please find the attached patch which adds / corrects following features >>> / issues : >>> >>> 1. Added tooltip & keyboard shortcut for query tool button >>> 2. Corrected the *Uncaught TypeError: Cannot read property ‘i’ of >>> undefined* >>> This issue can be reproduced by : >>> *Keeping the click on any node other than database, refresh the >>> page, open the same server (it should navigate to the previously selected >>> node), open query tool, now open query tool via sqleditor query tool >>> button, issue should be reproduced* - *Resolved* >>> 3. Aditya's changes for *popups are blocked* are now extended for the >>> new tab query tool too. >>> >>> >>> On Fri, Aug 28, 2020 at 6:24 PM Akshay Joshi < >>> [email protected]> wrote: >>> >>>> Thanks, patch applied. >>>> >>>> On Thu, Aug 27, 2020 at 8:16 PM Rahul Shirsat < >>>> [email protected]> wrote: >>>> >>>>> >>>>> Please find the update patch attached here. >>>>> >>>>> On Thu, Aug 27, 2020 at 8:10 PM Rahul Shirsat < >>>>> [email protected]> wrote: >>>>> >>>>>> Hi Hackers, >>>>>> >>>>>> Please find the attached patch below which adds the functionality of >>>>>> the query tool button in the query tool sqleditor. >>>>>> >>>>>> *Acceptance criteria:* >>>>>> - For sqleditor on same window & on new tab: >>>>>> >>>>>> - When a query tool connection is initiated, as expected it will >>>>>> open the connection based on the selected database in the treeview. Now, >>>>>> when the user clicks the query tool connection button on the query tool >>>>>> window, irrespective of the selected database in treeview, it should open a >>>>>> connection based on the query tool connected database. >>>>>> - Similarly, for a new tab, clicking on the query tool connection >>>>>> button, it should open a connection based on the query tool connected >>>>>> database, instead of selected treeview node. >>>>>> >>>>>> [image: query tool button.png] >>>>>> >>>>>> Additionally, an error is handled in the form of message dialog >>>>>> prompting the user to initiate the connection, when sqleditor is opened in >>>>>> the new tab with the main application window kept closed. This can be >>>>>> reviewed by refreshing the window as well as clicking on the query tool >>>>>> connection button. >>>>>> >>>>>> A prompt dialog message box is seen as: >>>>>> >>>>>> [image: Screen Shot 2020-08-27 at 8.04.33 PM.png] >>>>>> >>>>>> -- >>>>>> *Rahul Shirsat* >>>>>> Software Engineer | EnterpriseDB Corporation. >>>>>> >>>>> >>>>> >>>>> -- >>>>> *Rahul Shirsat* >>>>> Software Engineer | EnterpriseDB Corporation. >>>>> >>>> >>>> >>>> -- >>>> *Thanks & Regards* >>>> *Akshay Joshi* >>>> *pgAdmin Hacker | Sr. Software Architect* >>>> *EDB Postgres <http://edbpostgres.com>* >>>> >>>> *Mobile: +91 976-788-8246* >>>> >>> >>> >>> -- >>> *Rahul Shirsat* >>> Software Engineer | EnterpriseDB Corporation. >>> >> >> >> -- >> *Thanks & Regards* >> *Akshay Joshi* >> *pgAdmin Hacker | Sr. Software Architect* >> *EDB Postgres <http://edbpostgres.com>* >> >> *Mobile: +91 976-788-8246* >> > > > -- > *Rahul Shirsat* > Software Engineer | EnterpriseDB Corporation. > -- *Thanks & Regards* *Akshay Joshi* *pgAdmin Hacker | Sr. Software Architect* *EDB Postgres <http://edbpostgres.com>* *Mobile: +91 976-788-8246* Attachments: [image/png] query tool button.png (78.2K, 3-query%20tool%20button.png) download | view image [image/png] Screen Shot 2020-08-27 at 8.04.33 PM.png (47.9K, 4-Screen%20Shot%202020-08-27%20at%208.04.33%20PM.png) download | view image ^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2020-09-10 06:40 UTC | newest] Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2020-08-27 14:40 [pgAdmin][Patch] #4059 Query Tool button in Query Tool to open a new Query Window Rahul Shirsat <[email protected]> 2020-08-27 14:45 ` Rahul Shirsat <[email protected]> 2020-08-28 12:54 ` Akshay Joshi <[email protected]> 2020-09-09 12:53 ` Rahul Shirsat <[email protected]> 2020-09-09 14:43 ` Akshay Joshi <[email protected]> 2020-09-09 16:15 ` Rahul Shirsat <[email protected]> 2020-09-10 06:40 ` 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