mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-09 23:15:58 -06:00
Fixed blank screen issue while opening query tools in new tab from native menu. #5503
This commit is contained in:
parent
8f5a58a163
commit
cc0d467927
@ -248,9 +248,16 @@ function launchPgAdminWindow() {
|
||||
docsURLSubStrings.forEach(function (key) {
|
||||
if (url.indexOf(key) >= 0) {
|
||||
isDocURL = true;
|
||||
|
||||
if(key.indexOf('help') >= 0) {
|
||||
url = url.slice(url.indexOf('/help'))
|
||||
url = startPageUrl.slice(0, startPageUrl.indexOf('?') -1 ) + url;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
if (openDocsInBrowser && isDocURL) {
|
||||
// Do not open the window
|
||||
policy.ignore();
|
||||
|
@ -9,11 +9,13 @@
|
||||
|
||||
import _ from 'lodash';
|
||||
import $ from 'jquery';
|
||||
import url_for from './url_for';
|
||||
import gettext from 'sources/gettext';
|
||||
import 'wcdocker';
|
||||
import Notify from './helpers/Notifier';
|
||||
import { hasTrojanSource } from 'anti-trojan-source';
|
||||
import convert from 'convert-units';
|
||||
import getApiInstance from './api_instance';
|
||||
|
||||
let wcDocker = window.wcDocker;
|
||||
|
||||
@ -665,3 +667,38 @@ export function fullHexColor(shortHex) {
|
||||
}
|
||||
return shortHex;
|
||||
}
|
||||
|
||||
export function openNewWindow(toolForm, title) {
|
||||
let {name: browser} = getBrowser();
|
||||
if(browser == 'Nwjs') {
|
||||
let api = getApiInstance();
|
||||
api({
|
||||
url: url_for('tools.initialize', null),
|
||||
method: 'GET',
|
||||
})
|
||||
.then(function () {
|
||||
openWindow(toolForm, title);
|
||||
})
|
||||
.catch(function (error) {
|
||||
Notify.error(gettext(`Error in Tool initialize ${error.response.data}`));
|
||||
});
|
||||
}
|
||||
else {
|
||||
openWindow(toolForm, title);
|
||||
}
|
||||
}
|
||||
|
||||
function openWindow(toolForm, title) {
|
||||
let newWin = window.open('', '_blank');
|
||||
if (newWin) {
|
||||
newWin.document.write(toolForm);
|
||||
newWin.document.title = title;
|
||||
let pgBrowser = window.pgAdmin.Browser;
|
||||
// Send the signal to runtime, so that proper zoom level will be set.
|
||||
setTimeout(function() {
|
||||
pgBrowser.send_signal_to_runtime('Runtime new window opened');
|
||||
}, 500);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@ from flask import url_for
|
||||
from flask_babel import Domain, gettext
|
||||
|
||||
from pgadmin.utils import PgAdminModule
|
||||
from pgadmin.utils.ajax import bad_request
|
||||
from pgadmin.utils.ajax import bad_request, make_json_response
|
||||
from pgadmin.utils.constants import MIMETYPE_APP_JS
|
||||
|
||||
MODULE_NAME = 'tools'
|
||||
@ -67,6 +67,15 @@ class ToolsModule(PgAdminModule):
|
||||
from .user_management import blueprint as module
|
||||
app.register_blueprint(module)
|
||||
|
||||
def get_exposed_url_endpoints(self):
|
||||
"""
|
||||
Returns:
|
||||
list: URL endpoints for tools module
|
||||
"""
|
||||
return [
|
||||
'tools.initialize',
|
||||
]
|
||||
|
||||
|
||||
# Initialise the module
|
||||
blueprint = ToolsModule(MODULE_NAME, __name__)
|
||||
@ -94,3 +103,14 @@ def translations():
|
||||
status=200,
|
||||
mimetype=MIMETYPE_APP_JS
|
||||
)
|
||||
|
||||
|
||||
@blueprint.route(
|
||||
'/initialize/',
|
||||
methods=["GET"],
|
||||
endpoint='initialize'
|
||||
)
|
||||
def initialize():
|
||||
return make_json_response(
|
||||
data={}
|
||||
)
|
||||
|
@ -17,6 +17,7 @@ import ReactDOM from 'react-dom';
|
||||
import ERDTool from './erd_tool/components/ERDTool';
|
||||
import ModalProvider from '../../../../static/js/helpers/ModalProvider';
|
||||
import Theme from '../../../../static/js/Theme';
|
||||
import { openNewWindow } from '../../../../static/js/utils';
|
||||
import $ from 'jquery';
|
||||
|
||||
const wcDocker = window.wcDocker;
|
||||
@ -131,13 +132,7 @@ export default class ERDModule {
|
||||
|
||||
let open_new_tab = this.pgBrowser.get_preferences_for_module('browser').new_browser_tab_open;
|
||||
if (open_new_tab && open_new_tab.includes('erd_tool')) {
|
||||
let newWin = window.open('', '_blank');
|
||||
newWin.document.write(erdToolForm);
|
||||
newWin.document.title = panelTitle;
|
||||
// Send the signal to runtime, so that proper zoom level will be set.
|
||||
setTimeout(function() {
|
||||
this.pgBrowser.send_signal_to_runtime('Runtime new window opened');
|
||||
}, 500);
|
||||
openNewWindow(erdToolForm, panelTitle);
|
||||
} else {
|
||||
/* On successfully initialization find the dashboard panel,
|
||||
* create new panel and add it to the dashboard panel.
|
||||
@ -181,7 +176,6 @@ export default class ERDModule {
|
||||
openErdToolURL(erdToolPanel);
|
||||
}
|
||||
}
|
||||
|
||||
getPanelUrl(transId, parentData, gen) {
|
||||
let openUrl = url_for('erd.panel', {
|
||||
trans_id: transId,
|
||||
|
@ -18,7 +18,7 @@ import {retrieveAncestorOfTypeServer} from 'sources/tree/tree_utils';
|
||||
import pgWindow from 'sources/window';
|
||||
import Notify from '../../../../static/js/helpers/Notifier';
|
||||
import { copyToClipboard } from '../../../../static/js/clipboard';
|
||||
|
||||
import { openNewWindow } from '../../../../static/js/utils';
|
||||
import {generateTitle, refresh_db_node} from 'tools/sqleditor/static/js/sqleditor_title';
|
||||
|
||||
|
||||
@ -167,9 +167,7 @@ export function initialize(gettext, url_for, $, _, pgAdmin, csrfToken, Browser)
|
||||
`;
|
||||
let open_new_tab = pgBrowser.get_preferences_for_module('browser').new_browser_tab_open;
|
||||
if (open_new_tab && open_new_tab.includes('psql_tool')) {
|
||||
let newWin = window.open('', '_blank');
|
||||
newWin.document.write(psqlToolForm);
|
||||
newWin.document.title = panelTitle;
|
||||
openNewWindow(psqlToolForm, panelTitle);
|
||||
} else {
|
||||
/* On successfully initialization find the properties panel,
|
||||
* create new panel and add it to the dashboard panel.
|
||||
|
@ -26,6 +26,7 @@ import QueryToolComponent from './components/QueryToolComponent';
|
||||
import ModalProvider from '../../../../static/js/helpers/ModalProvider';
|
||||
import Theme from '../../../../static/js/Theme';
|
||||
import { showRenamePanel } from '../../../../static/js/Dialogs';
|
||||
import { openNewWindow } from '../../../../static/js/utils';
|
||||
|
||||
const wcDocker = window.wcDocker;
|
||||
|
||||
@ -340,17 +341,7 @@ export default class SQLEditor {
|
||||
let browser_preferences = pgBrowser.get_preferences_for_module('browser');
|
||||
let open_new_tab = browser_preferences.new_browser_tab_open;
|
||||
if (open_new_tab && open_new_tab.includes('qt')) {
|
||||
let newWin = window.open('', '_blank');
|
||||
if(newWin) {
|
||||
newWin.document.write(queryToolForm);
|
||||
newWin.document.title = panel_title;
|
||||
// Send the signal to runtime, so that proper zoom level will be set.
|
||||
setTimeout(function() {
|
||||
pgBrowser.send_signal_to_runtime('Runtime new window opened');
|
||||
}, 500);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
openNewWindow(queryToolForm, panel_title);
|
||||
} else {
|
||||
/* On successfully initialization find the dashboard panel,
|
||||
* create new panel and add it to the dashboard panel.
|
||||
@ -359,7 +350,6 @@ export default class SQLEditor {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
setupPreferencesWorker() {
|
||||
if (window.location == window.parent?.location) {
|
||||
/* Sync the local preferences with the main window if in new tab */
|
||||
|
Loading…
Reference in New Issue
Block a user