1) Ensure that the zoom level should be set for the newly opened window.

2) Ensure that if the zoom level is changed on the main window then it should
   be applicable for all the opened windows.

refs #6271
This commit is contained in:
Akshay Joshi 2021-03-22 17:50:26 +05:30
parent 723d97971d
commit 2872b5c5d3
9 changed files with 59 additions and 18 deletions

View File

@ -293,10 +293,20 @@ const setZoomEvents = () => {
});
};
// This function is used to iterate all open windows and set the zoom level.
const setZoomLevelForAllWindows = () => {
nw.Window.getAll(function(winArray) {
for (var i = 0; i < winArray.length; i++) {
winArray[i].zoomLevel = pgAdminWindowObject.zoomLevel;
}
})
};
// This function used to zoom in the pgAdmin window.
const zoomIn = () => {
if (pgAdminWindowObject != null) {
pgAdminWindowObject.zoomLevel += 0.5;
setZoomLevelForAllWindows();
ConfigureStore.set('zoomLevel', pgAdminWindowObject.zoomLevel);
ConfigureStore.saveConfig();
}
@ -306,6 +316,7 @@ const zoomIn = () => {
const zoomOut = () => {
if (pgAdminWindowObject != null) {
pgAdminWindowObject.zoomLevel -= 0.5;
setZoomLevelForAllWindows();
ConfigureStore.set('zoomLevel', pgAdminWindowObject.zoomLevel);
ConfigureStore.saveConfig();
}
@ -315,6 +326,7 @@ const zoomOut = () => {
const actualSize = () => {
if (pgAdminWindowObject != null) {
pgAdminWindowObject.zoomLevel = 0;
setZoomLevelForAllWindows();
ConfigureStore.set('zoomLevel', pgAdminWindowObject.zoomLevel);
ConfigureStore.saveConfig();
}
@ -458,5 +470,6 @@ module.exports = {
setZoomEvents: setZoomEvents,
registerZoomEvents: registerZoomEvents,
unregisterZoomEvents: unregisterZoomEvents,
setZoomLevelForAllWindows: setZoomLevelForAllWindows,
ConfigureStore: ConfigureStore,
};

View File

@ -118,14 +118,16 @@ function startDesktopMode() {
'focus': true,
'show': true,
});
} else if (chunk.indexOf('Runtime Zoom In') > -1) {
} else if (chunk.indexOf('Runtime Zoom In') >= 0) {
misc.zoomIn();
} else if (chunk.indexOf('Runtime Zoom Out') > -1) {
} else if (chunk.indexOf('Runtime Zoom Out') >= 0) {
misc.zoomOut();
} else if (chunk.indexOf('Runtime Actual Size') > -1) {
} else if (chunk.indexOf('Runtime Actual Size') >= 0) {
misc.actualSize();
} else if (chunk.indexOf('Runtime Toggle Full Screen') > -1) {
} else if (chunk.indexOf('Runtime Toggle Full Screen') >= 0) {
misc.toggleFullScreen();
} else if (chunk.indexOf('Runtime new window opened') >= 0) {
misc.setZoomLevelForAllWindows();
} else {
misc.writeServerLog(chunk);
}

View File

@ -1060,22 +1060,24 @@ def lock_layout():
@blueprint.route("/signal_runtime", endpoint="signal_runtime",
methods=["POST"])
def signal_runtime():
data = None
# If not runtime then no need to send signal
if current_app.PGADMIN_RUNTIME:
data = None
if hasattr(request.data, 'decode'):
data = request.data.decode('utf-8')
if hasattr(request.data, 'decode'):
data = request.data.decode('utf-8')
if data != '':
data = json.loads(data)
if data != '':
data = json.loads(data)
# Add Info Handler to current app just to send signal to runtime
tmp_handler = logging.StreamHandler()
tmp_handler.setLevel(logging.INFO)
current_app.logger.addHandler(tmp_handler)
# Send signal to runtime
current_app.logger.info(data['command'])
# Remove the temporary handler
current_app.logger.removeHandler(tmp_handler)
# Add Info Handler to current app just to send signal to runtime
tmp_handler = logging.StreamHandler()
tmp_handler.setLevel(logging.INFO)
current_app.logger.addHandler(tmp_handler)
# Send signal to runtime
current_app.logger.info(data['command'])
# Remove the temporary handler
current_app.logger.removeHandler(tmp_handler)
return make_json_response()

View File

@ -242,6 +242,10 @@ define('pgadmin.datagrid', [
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;
}

View File

@ -115,7 +115,7 @@ export function launchDataGrid(datagrid, transId, gridUrl, queryToolTitle, sURL,
alertify.alert(
gettext('Query tool launch error'),
gettext(
'Please allow the pop-ups for this site to perform the desired action. If the main window of pgAdmin is closed then close this window and open a new pgAdmin session.'
'Please allow pop-ups for this site to perform the desired action. If the main window of pgAdmin is closed then close this window and open a new pgAdmin session.'
)
);
}

View File

@ -415,6 +415,10 @@ define([
var open_new_tab = browser_preferences.new_browser_tab_open;
if (open_new_tab && open_new_tab.includes('debugger')) {
window.open(url, '_blank');
// 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 {
pgBrowser.Events.once(
'pgadmin-browser:frame:urlloaded:frm_debugger',
@ -559,6 +563,10 @@ define([
var open_new_tab = browser_preferences.new_browser_tab_open;
if (open_new_tab && open_new_tab.includes('debugger')) {
window.open(url, '_blank');
// 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 {
pgBrowser.Events.once(
'pgadmin-browser:frame:urlloaded:frm_debugger',

View File

@ -765,6 +765,10 @@ define([
var open_new_tab = browserPreferences.new_browser_tab_open;
if (open_new_tab && open_new_tab.includes('debugger')) {
window.open(url, '_blank');
// 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 {
pgBrowser.Events.once(
'pgadmin-browser:frame:urlloaded:frm_debugger',

View File

@ -142,6 +142,10 @@ export function initialize(gettext, url_for, $, _, pgAdmin, csrfToken, pgBrowser
var 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() {
pgBrowser.send_signal_to_runtime('Runtime new window opened');
}, 500);
} else {
/* On successfully initialization find the dashboard panel,
* create new panel and add it to the dashboard panel.

View File

@ -110,6 +110,10 @@ define('pgadmin.schemadiff', [
var open_new_tab = browser_preferences.new_browser_tab_open;
if (open_new_tab && open_new_tab.includes('schema_diff')) {
window.open(baseUrl, '_blank');
// 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 {
var propertiesPanel = pgBrowser.docker.findPanels('properties'),