Using client-side 'url_for' implementation in the backup module.

REL-1_X
Ashesh Vashi 2017-06-13 08:47:15 +05:30
parent 1a7c9d5ca1
commit 4a46f7b1eb
2 changed files with 24 additions and 12 deletions

View File

@ -58,6 +58,13 @@ class BackupModule(PgAdminModule):
"""
return self.pref_show_system_objects
def get_exposed_url_endpoints(self):
"""
Returns:
list: URL endpoints for backup module
"""
return ['backup.create_server_job', 'backup.create_object_job']
# Create blueprint for BackupModule class
blueprint = BackupModule(
@ -229,7 +236,9 @@ def filename_with_file_manager_path(_file):
return fs_short_path(_file)
@blueprint.route('/create_job/<int:sid>', methods=['POST'])
@blueprint.route(
'/job/<int:sid>', methods=['POST'], endpoint='create_server_job'
)
@login_required
def create_backup_job(sid):
"""
@ -330,7 +339,9 @@ def create_backup_job(sid):
)
@blueprint.route('/create_job/backup_object/<int:sid>', methods=['POST'])
@blueprint.route(
'/job/<int:sid>/object', methods=['POST'], endpoint='create_object_job'
)
@login_required
def create_backup_objects_job(sid):
"""

View File

@ -1,8 +1,8 @@
// Backup dialog
define([
'sources/gettext', 'jquery', 'underscore', 'underscore.string', 'alertify',
'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'underscore.string', 'alertify',
'pgadmin.browser', 'backbone', 'backgrid', 'backform', 'pgadmin.browser.node'
], function(gettext, $, _, S, alertify, pgBrowser, Backbone, Backgrid, Backform, pgNode) {
], function(gettext, url_for, $, _, S, alertify, pgBrowser, Backbone, Backgrid, Backform, pgNode) {
// if module is already initialized, refer to that.
if (pgBrowser.Backup) {
@ -441,8 +441,9 @@ TODO LIST FOR BACKUP:
attrs:{name:'object_help', type:'button', url: 'backup.html', label: gettext('Backup')}
},{
text: '', key: 112, className: 'btn btn-default pull-left fa fa-lg fa-question',
attrs:{name:'dialog_help', type:'button', label: gettext('Backup'),
url: '{{ url_for('help.static', filename='backup_dialog.html') }}'
attrs:{
name:'dialog_help', type:'button', label: gettext('Backup'),
url: url_for('help.static', {'filename': 'backup_dialog.html'})
}
},{
text: gettext('Backup'), key: 13, className: 'btn btn-primary fa fa-lg fa-save pg-alertify-button',
@ -545,8 +546,7 @@ TODO LIST FOR BACKUP:
var treeInfo = node.getTreeNodeHierarchy.apply(node, [i]);
var self = this,
baseUrl = "{{ url_for('backup.index') }}" +
"create_job/" + treeInfo.server._id,
baseUrl = url_for('backup.create_server_job', {'sid': treeInfo.server._id}),
args = this.view.model.toJSON();
$.ajax({
@ -657,8 +657,10 @@ TODO LIST FOR BACKUP:
attrs:{name:'object_help', type:'button', url: 'backup.html', label: gettext('Backup')}
},{
text: '', key: 112, className: 'btn btn-default pull-left fa fa-lg fa-question',
attrs:{name:'dialog_help', type:'button', label: gettext('Backup'),
url: '{{ url_for('help.static', filename='backup_dialog.html') }}'}
attrs:{
name:'dialog_help', type:'button', label: gettext('Backup'),
url: url_for('help.static', {'filename': 'backup_dialog.html'})
}
},{
text: gettext('Backup'), key: 13, className: 'btn btn-primary fa fa-lg fa-save pg-alertify-button',
'data-btn-name': 'backup'
@ -775,8 +777,7 @@ TODO LIST FOR BACKUP:
}
var self = this,
baseUrl = "{{ url_for('backup.index') }}" +
"create_job/backup_object/" + treeInfo.server._id,
baseUrl = url_for('backup.create_object_job', {'sid': treeInfo.server._id}),
args = this.view.model.toJSON();
$.ajax({