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) {
|
||||
|
||||
@@ -1028,7 +1028,7 @@ ul.nav.nav-tabs {
|
||||
}
|
||||
|
||||
.alertify .ajs-footer .ajs-buttons .ajs-button {
|
||||
min-width: 80px;
|
||||
min-width: 40px;
|
||||
min-height: 30px;
|
||||
}
|
||||
|
||||
@@ -1343,4 +1343,4 @@ height: calc(100% - 35px);
|
||||
|
||||
.pg-panel-statistics-container > table > thead > tr > th:last-child {
|
||||
border-right: 0px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -385,6 +385,14 @@ TODO LIST FOR BACKUP:
|
||||
setup:function() {
|
||||
return {
|
||||
buttons: [{
|
||||
text: '', key: 27, className: 'btn btn-default pull-left fa fa-lg fa-info',
|
||||
attrs:{name:'object_help', type:'button', url: 'backup.html', label: '{{ _('Backup') }}'}
|
||||
},{
|
||||
text: '', key: 27, className: 'btn btn-default pull-left fa fa-lg fa-question',
|
||||
attrs:{name:'dialog_help', type:'button', label: '{{ _('Backup') }}',
|
||||
url: '{{ url_for('help.static', filename='backup_dialog.html') }}'
|
||||
}
|
||||
},{
|
||||
text: '{{ _('Backup') }}', key: 27, className: 'btn btn-primary fa fa-lg fa-save pg-alertify-button'
|
||||
},{
|
||||
text: '{{ _('Cancel') }}', key: 27, className: 'btn btn-danger fa fa-lg fa-times pg-alertify-button'
|
||||
@@ -414,7 +422,7 @@ TODO LIST FOR BACKUP:
|
||||
prepare: function() {
|
||||
var self = this;
|
||||
// Disable Backup button until user provides Filename
|
||||
this.__internal.buttons[0].element.disabled = true;
|
||||
this.__internal.buttons[2].element.disabled = true;
|
||||
|
||||
var $container = $("<div class='backup_dialog'></div>");
|
||||
// Find current/selected node
|
||||
@@ -451,22 +459,30 @@ TODO LIST FOR BACKUP:
|
||||
this.view.model.on('change', function() {
|
||||
if (!_.isUndefined(this.get('file')) && this.get('file') !== '') {
|
||||
this.errorModel.clear();
|
||||
self.__internal.buttons[0].element.disabled = false;
|
||||
self.__internal.buttons[2].element.disabled = false;
|
||||
} else {
|
||||
self.__internal.buttons[0].element.disabled = true;
|
||||
self.__internal.buttons[2].element.disabled = true;
|
||||
this.errorModel.set('file', '{{ _('Please provide filename') }}')
|
||||
}
|
||||
});
|
||||
},
|
||||
// Callback functions when click on the buttons of the Alertify dialogs
|
||||
callback: function(e) {
|
||||
if (e.button.text === '{{ _('Backup') }}') {
|
||||
// Fetch current server id
|
||||
// Fetch current server id
|
||||
var t = pgBrowser.tree,
|
||||
i = t.selected(),
|
||||
d = i && i.length == 1 ? t.itemData(i) : undefined,
|
||||
node = d && pgBrowser.Nodes[d._type];
|
||||
|
||||
if (e.button.element.name == "dialog_help" || e.button.element.name == "object_help") {
|
||||
e.cancel = true;
|
||||
pgBrowser.showHelp(e.button.element.name, e.button.element.getAttribute('url'),
|
||||
node, i, e.button.element.getAttribute('label'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.button.text === '{{ _('Backup') }}') {
|
||||
|
||||
if (!d)
|
||||
return;
|
||||
|
||||
@@ -533,6 +549,13 @@ TODO LIST FOR BACKUP:
|
||||
setup:function() {
|
||||
return {
|
||||
buttons: [{
|
||||
text: '', key: 27, className: 'btn btn-default pull-left fa fa-lg fa-info',
|
||||
attrs:{name:'object_help', type:'button', url: 'backup.html', label: '{{ _('Backup') }}'}
|
||||
},{
|
||||
text: '', key: 27, className: 'btn btn-default pull-left fa fa-lg fa-question',
|
||||
attrs:{name:'dialog_help', type:'button', label: '{{ _('Backup') }}',
|
||||
url: '{{ url_for('help.static', filename='backup_dialog.html') }}'}
|
||||
},{
|
||||
text: '{{ _('Backup') }}', key: 27, className: 'btn btn-primary fa fa-lg fa-save pg-alertify-button'
|
||||
},{
|
||||
text: '{{ _('Cancel') }}', key: 27, className: 'btn btn-danger fa fa-lg fa-times pg-alertify-button'
|
||||
@@ -561,7 +584,7 @@ TODO LIST FOR BACKUP:
|
||||
prepare: function() {
|
||||
var self = this;
|
||||
// Disable Backup button until user provides Filename
|
||||
this.__internal.buttons[0].element.disabled = true;
|
||||
this.__internal.buttons[2].element.disabled = true;
|
||||
var $container = $("<div class='backup_dialog'></div>");
|
||||
var t = pgBrowser.tree,
|
||||
i = t.selected(),
|
||||
@@ -596,9 +619,9 @@ TODO LIST FOR BACKUP:
|
||||
this.view.model.on('change', function() {
|
||||
if (!_.isUndefined(this.get('file')) && this.get('file') !== '') {
|
||||
this.errorModel.clear();
|
||||
self.__internal.buttons[0].element.disabled = false;
|
||||
self.__internal.buttons[2].element.disabled = false;
|
||||
} else {
|
||||
self.__internal.buttons[0].element.disabled = true;
|
||||
self.__internal.buttons[2].element.disabled = true;
|
||||
this.errorModel.set('file', '{{ _('Please provide filename') }}')
|
||||
}
|
||||
});
|
||||
@@ -606,13 +629,20 @@ TODO LIST FOR BACKUP:
|
||||
},
|
||||
// Callback functions when click on the buttons of the Alertify dialogs
|
||||
callback: function(e) {
|
||||
if (e.button.text === "Backup") {
|
||||
// Fetch current server id
|
||||
// Fetch current server id
|
||||
var t = pgBrowser.tree,
|
||||
i = t.selected(),
|
||||
d = i && i.length == 1 ? t.itemData(i) : undefined,
|
||||
node = d && pgBrowser.Nodes[d._type];
|
||||
|
||||
if (e.button.element.name == "dialog_help" || e.button.element.name == "object_help") {
|
||||
e.cancel = true;
|
||||
pgBrowser.showHelp(e.button.element.name, e.button.element.getAttribute('url'),
|
||||
node, i, e.button.element.getAttribute('label'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.button.text === "Backup") {
|
||||
if (!d)
|
||||
return;
|
||||
|
||||
|
||||
@@ -191,20 +191,39 @@ define(
|
||||
},
|
||||
setup:function() {
|
||||
return {
|
||||
buttons:[{ text: "{{ _('OK') }}", key: 27, className: "btn btn-primary fa fa-lg fa-save pg-alertify-button" },
|
||||
{ text: "{{ _('Cancel') }}", key: 27, className: "btn btn-danger fa fa-lg fa-times pg-alertify-button" }],
|
||||
buttons:[{
|
||||
text: '', key: 27, className: 'btn btn-default pull-left fa fa-lg fa-info',
|
||||
attrs:{name:'object_help', type:'button', url: 'maintenance.html', label: '{{ _('Maintenance') }}'}
|
||||
},{
|
||||
text: '', key: 27, className: 'btn btn-default pull-left fa fa-lg fa-question',
|
||||
attrs:{name:'dialog_help', type:'button', label: '{{ _('Maintenance') }}',
|
||||
url: '{{ url_for('help.static', filename='maintenance_dialog.html') }}'}
|
||||
},{
|
||||
text: "{{ _('OK') }}", key: 27, className: "btn btn-primary fa fa-lg fa-save pg-alertify-button"
|
||||
},{
|
||||
text: "{{ _('Cancel') }}", key: 27, className: "btn btn-danger fa fa-lg fa-times pg-alertify-button"
|
||||
}],
|
||||
options: { modal: 0}
|
||||
};
|
||||
},
|
||||
// Callback functions when click on the buttons of the Alertify dialogs
|
||||
callback: function(e) {
|
||||
var i = pgBrowser.tree.selected(),
|
||||
d = i && i.length == 1 ? pgBrowser.tree.itemData(i) : undefined,
|
||||
node = d && pgBrowser.Nodes[d._type];
|
||||
|
||||
if (e.button.element.name == "dialog_help" || e.button.element.name == "object_help") {
|
||||
e.cancel = true;
|
||||
pgBrowser.showHelp(e.button.element.name, e.button.element.getAttribute('url'),
|
||||
node, i, e.button.element.getAttribute('label'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.button.text === "{{ _('OK') }}") {
|
||||
|
||||
var schema = '';
|
||||
var table = '';
|
||||
var i = pgBrowser.tree.selected(),
|
||||
d = i && i.length == 1 ? pgBrowser.tree.itemData(i) : undefined,
|
||||
node = d && pgBrowser.Nodes[d._type];
|
||||
|
||||
|
||||
if (!d)
|
||||
return;
|
||||
|
||||
@@ -308,6 +308,13 @@ define([
|
||||
setup:function() {
|
||||
return {
|
||||
buttons: [{
|
||||
text: '', key: 27, className: 'btn btn-default pull-left fa fa-lg fa-info',
|
||||
attrs:{name:'object_help', type:'button', url: 'backup.html', label: '{{ _('Restore') }}'}
|
||||
},{
|
||||
text: '', key: 27, className: 'btn btn-default pull-left fa fa-lg fa-question',
|
||||
attrs:{name:'dialog_help', type:'button', label: '{{ _('Restore') }}',
|
||||
url: '{{ url_for('help.static', filename='restore_dialog.html') }}'}
|
||||
},{
|
||||
text: '{{ _('Restore') }}', key: 27,
|
||||
className: 'btn btn-primary', restore: true
|
||||
},{
|
||||
@@ -344,7 +351,7 @@ define([
|
||||
|
||||
var self = this;
|
||||
// Disable Backup button until user provides Filename
|
||||
this.__internal.buttons[0].element.disabled = true;
|
||||
this.__internal.buttons[2].element.disabled = true;
|
||||
var $container = $("<div class='restore_dialog'></div>");
|
||||
var t = pgBrowser.tree,
|
||||
i = t.selected(),
|
||||
@@ -367,7 +374,7 @@ define([
|
||||
el: $container, model: newModel, schema: fields
|
||||
});
|
||||
|
||||
$(this.elements.body.childNodes[0]).addClass(
|
||||
$(this.elements.body.childNodes[2]).addClass(
|
||||
'alertify_tools_dialog_properties obj_properties'
|
||||
);
|
||||
|
||||
@@ -379,9 +386,9 @@ define([
|
||||
this.view.model.on('change', function() {
|
||||
if (!_.isUndefined(this.get('file')) && this.get('file') !== '') {
|
||||
this.errorModel.clear();
|
||||
self.__internal.buttons[0].element.disabled = false;
|
||||
self.__internal.buttons[2].element.disabled = false;
|
||||
} else {
|
||||
self.__internal.buttons[0].element.disabled = true;
|
||||
self.__internal.buttons[2].element.disabled = true;
|
||||
this.errorModel.set('file', '{{ _('Please provide filename') }}')
|
||||
}
|
||||
});
|
||||
@@ -389,17 +396,24 @@ define([
|
||||
},
|
||||
// Callback functions when click on the buttons of the Alertify dialogs
|
||||
callback: function(e) {
|
||||
if (e.button.restore) {
|
||||
// Fetch current server id
|
||||
var t = pgBrowser.tree,
|
||||
i = this.settings['pg_item'] || t.selected(),
|
||||
d = this.settings['pg_item_data'] || (
|
||||
i && i.length == 1 ? t.itemData(i) : undefined
|
||||
),
|
||||
node = this.settings['pg_node'] || (
|
||||
d && pgBrowser.Nodes[d._type]
|
||||
);
|
||||
// Fetch current server id
|
||||
var t = pgBrowser.tree,
|
||||
i = this.settings['pg_item'] || t.selected(),
|
||||
d = this.settings['pg_item_data'] || (
|
||||
i && i.length == 1 ? t.itemData(i) : undefined
|
||||
),
|
||||
node = this.settings['pg_node'] || (
|
||||
d && pgBrowser.Nodes[d._type]
|
||||
);
|
||||
|
||||
if (e.button.element.name == "dialog_help" || e.button.element.name == "object_help") {
|
||||
e.cancel = true;
|
||||
pgBrowser.showHelp(e.button.element.name, e.button.element.getAttribute('url'),
|
||||
node, i, e.button.element.getAttribute('label'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.button.restore) {
|
||||
if (!d)
|
||||
return;
|
||||
|
||||
|
||||
@@ -377,6 +377,10 @@ define([
|
||||
setup:function() {
|
||||
return {
|
||||
buttons: [{
|
||||
text: '', key: 27, className: 'btn btn-default pull-left fa fa-lg fa-question',
|
||||
attrs:{name:'dialog_help', type:'button', label: '{{ _('Users') }}',
|
||||
url: '{{ url_for('help.static', filename='user_management_dialog.html') }}'}
|
||||
},{
|
||||
text: '{{ _('Close') }}', key: 27, className: 'btn btn-danger fa fa-lg fa-times pg-alertify-button user_management_pg-alertify-button',
|
||||
attrs:{name:'close', type:'button'}
|
||||
}],
|
||||
@@ -621,6 +625,12 @@ define([
|
||||
});
|
||||
},
|
||||
callback: function(e) {
|
||||
if (e.button.element.name == "dialog_help") {
|
||||
e.cancel = true;
|
||||
pgBrowser.showHelp(e.button.element.name, e.button.element.getAttribute('url'),
|
||||
null, null, e.button.element.getAttribute('label'));
|
||||
return;
|
||||
}
|
||||
if (e.button.element.name == "close") {
|
||||
var self = this;
|
||||
if (!_.all(this.userCollection.pluck('id')) || !_.isEmpty(this.userCollection.invalidUsers)) {
|
||||
|
||||
Reference in New Issue
Block a user