diff --git a/web/pgadmin/dashboard/static/js/Dashboard.jsx b/web/pgadmin/dashboard/static/js/Dashboard.jsx index 0367015e8..babab91b3 100644 --- a/web/pgadmin/dashboard/static/js/Dashboard.jsx +++ b/web/pgadmin/dashboard/static/js/Dashboard.jsx @@ -819,35 +819,38 @@ export default function Dashboard({ - - - - - - - - - - - - + {!_.isUndefined(preferences) && preferences.show_activity && ( + <> + + + + + + + + + + + + + )} diff --git a/web/pgadmin/tools/sqleditor/static/js/SQLEditorModule.js b/web/pgadmin/tools/sqleditor/static/js/SQLEditorModule.js index 811ca1b00..bf46d34a3 100644 --- a/web/pgadmin/tools/sqleditor/static/js/SQLEditorModule.js +++ b/web/pgadmin/tools/sqleditor/static/js/SQLEditorModule.js @@ -288,16 +288,6 @@ export default class SQLEditor { panelTitleFunc.setQueryToolDockerTitle(queryToolPanel, is_query_tool, _.unescape(panel_title)); queryToolPanel.focus(); - // Listen on the panel closed event. - if (queryToolPanel.isVisible()) { - queryToolPanel.on(wcDocker.EVENT.CLOSED, function() { - $.ajax({ - url: closeUrl, - method: 'DELETE', - }); - }); - } - queryToolPanel.on(wcDocker.EVENT.VISIBILITY_CHANGED, function() { queryToolPanel.trigger(wcDocker.EVENT.RESIZED); }); diff --git a/web/pgadmin/tools/sqleditor/static/js/components/QueryToolComponent.jsx b/web/pgadmin/tools/sqleditor/static/js/components/QueryToolComponent.jsx index a5328ee60..d7f6021ad 100644 --- a/web/pgadmin/tools/sqleditor/static/js/components/QueryToolComponent.jsx +++ b/web/pgadmin/tools/sqleditor/static/js/components/QueryToolComponent.jsx @@ -341,6 +341,15 @@ export default function QueryToolComponent({params, pgWindow, pgAdmin, selectedN }, []); useEffect(()=>{ + const closeConn = ()=>{ + api.delete( + url_for('sqleditor.close', { + 'trans_id': qtState.params.trans_id, + }) + ); + }; + window.addEventListener('unload', closeConn); + const pushHistory = (h)=>{ api.post( url_for('sqleditor.add_query_history', { @@ -350,7 +359,10 @@ export default function QueryToolComponent({params, pgWindow, pgAdmin, selectedN ).catch((error)=>{console.error(error);}); }; eventBus.current.registerListener(QUERY_TOOL_EVENTS.PUSH_HISTORY, pushHistory); - return ()=>{eventBus.current.deregisterListener(QUERY_TOOL_EVENTS.PUSH_HISTORY, pushHistory);}; + return ()=>{ + eventBus.current.deregisterListener(QUERY_TOOL_EVENTS.PUSH_HISTORY, pushHistory); + window.removeEventListener('unload', closeConn); + }; }, [qtState.params.trans_id]); diff --git a/web/pgadmin/tools/sqleditor/templates/sqleditor/index.html b/web/pgadmin/tools/sqleditor/templates/sqleditor/index.html index bcb6a04ea..cd71864ff 100644 --- a/web/pgadmin/tools/sqleditor/templates/sqleditor/index.html +++ b/web/pgadmin/tools/sqleditor/templates/sqleditor/index.html @@ -42,21 +42,6 @@ window.pgAdmin.Tools.SQLEditor.loadComponent( document.getElementById('sqleditor-container'), {{ params|safe }}); - if(window.opener) { - $(window).on('unload', function(ev) { - $.ajax({ - method: 'DELETE', - url: '{{close_url}}' - }); - }); - } else { - $(window).on('beforeunload', function(ev) { - $.ajax({ - method: 'DELETE', - url: '{{close_url}}' - }); - }); - } }, function() { console.log(arguments); });