mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Help buttons for various dialogues.
This commit is contained in:
@@ -485,6 +485,15 @@ def index():
|
||||
def browser_js():
|
||||
layout = get_setting('Browser/Layout', default='')
|
||||
snippets = []
|
||||
|
||||
prefs = Preferences.module('paths')
|
||||
|
||||
pg_help_path_pref = prefs.preference('pg_help_path')
|
||||
pg_help_path = pg_help_path_pref.get()
|
||||
|
||||
edbas_help_path_pref = prefs.preference('edbas_help_path')
|
||||
edbas_help_path = edbas_help_path_pref.get()
|
||||
|
||||
for submodule in current_blueprint.submodules:
|
||||
snippets.extend(submodule.jssnippets)
|
||||
return make_response(
|
||||
@@ -492,6 +501,8 @@ def browser_js():
|
||||
'browser/js/browser.js',
|
||||
layout=layout,
|
||||
jssnippets=snippets,
|
||||
pg_help_path=pg_help_path,
|
||||
edbas_help_path=edbas_help_path,
|
||||
_=gettext
|
||||
),
|
||||
200, {'Content-Type': 'application/x-javascript'})
|
||||
|
||||
@@ -681,10 +681,60 @@ function(require, $, _, S, Bootstrap, pgAdmin, alertify, CodeMirror) {
|
||||
// Do nothing as user cancel the operation
|
||||
}
|
||||
);
|
||||
},
|
||||
// General function to handle callbacks for object or dialog help.
|
||||
showHelp: function(type, url, node, item, label) {
|
||||
if (type == "object_help") {
|
||||
// See if we can find an existing panel, if not, create one
|
||||
pnlSqlHelp = this.docker.findPanels('pnl_sql_help')[0];
|
||||
|
||||
if (pnlSqlHelp == null) {
|
||||
pnlProperties = this.docker.findPanels('properties')[0];
|
||||
this.docker.addPanel('pnl_sql_help', wcDocker.DOCK.STACKED, pnlProperties);
|
||||
pnlSqlHelp = this.docker.findPanels('pnl_sql_help')[0];
|
||||
}
|
||||
|
||||
// Construct the URL
|
||||
server = node.getTreeNodeHierarchy(item).server;
|
||||
|
||||
baseUrl = '{{ pg_help_path }}'
|
||||
if (server.server_type == 'ppas') {
|
||||
baseUrl = '{{ edbas_help_path }}'
|
||||
}
|
||||
|
||||
major = Math.floor(server.version / 10000)
|
||||
minor = Math.floor(server.version / 100) - (major * 100)
|
||||
|
||||
baseUrl = baseUrl.replace('$VERSION$', major + '.' + minor)
|
||||
if (!S(baseUrl).endsWith('/')) {
|
||||
baseUrl = baseUrl + '/'
|
||||
}
|
||||
fullUrl = baseUrl+ url;
|
||||
// Update the panel
|
||||
iframe = $(pnlSqlHelp).data('embeddedFrame');
|
||||
pnlSqlHelp.title('Help: '+ label);
|
||||
|
||||
pnlSqlHelp.focus();
|
||||
iframe.openURL(fullUrl);
|
||||
} else if(type == "dialog_help") {
|
||||
// See if we can find an existing panel, if not, create one
|
||||
pnlDialogHelp = this.docker.findPanels('pnl_online_help')[0];
|
||||
|
||||
if (pnlDialogHelp == null) {
|
||||
pnlProperties = this.docker.findPanels('properties')[0];
|
||||
this.docker.addPanel('pnl_online_help', wcDocker.DOCK.STACKED, pnlProperties);
|
||||
pnlDialogHelp = this.docker.findPanels('pnl_online_help')[0];
|
||||
}
|
||||
|
||||
// Update the panel
|
||||
iframe = $(pnlDialogHelp).data('embeddedFrame');
|
||||
|
||||
pnlDialogHelp.focus();
|
||||
iframe.openURL(url);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
window.onbeforeunload = function(ev) {
|
||||
var e = ev || window.event;
|
||||
if(onbeforeunload_flag) {
|
||||
|
||||
Reference in New Issue
Block a user