Use client-side url_for in the sql editor and data grid modules.
parent
6b6d3369b3
commit
cfb4b11573
|
@ -49,6 +49,21 @@ class DataGridModule(PgAdminModule):
|
|||
def get_panels(self):
|
||||
return []
|
||||
|
||||
def get_exposed_url_endpoints(self):
|
||||
"""
|
||||
Returns:
|
||||
list: URL endpoints for backup module
|
||||
"""
|
||||
return [
|
||||
'datagrid.initialize_datagrid',
|
||||
'datagrid.initialize_query_tool',
|
||||
'datagrid.initialize_query_tool_with_did',
|
||||
'datagrid.filter_validate',
|
||||
'datagrid.filter',
|
||||
'datagrid.panel',
|
||||
'datagrid.close'
|
||||
]
|
||||
|
||||
|
||||
blueprint = DataGridModule(MODULE_NAME, __name__, static_url_path='/static')
|
||||
|
||||
|
@ -67,7 +82,7 @@ def datagrid_css():
|
|||
)
|
||||
|
||||
|
||||
@blueprint.route("/filter")
|
||||
@blueprint.route("/filter", endpoint='filter')
|
||||
@login_required
|
||||
def show_filter():
|
||||
return render_template(MODULE_NAME + '/filter.html')
|
||||
|
@ -75,7 +90,7 @@ def show_filter():
|
|||
|
||||
@blueprint.route(
|
||||
'/initialize/datagrid/<int:cmd_type>/<obj_type>/<int:sid>/<int:did>/<int:obj_id>',
|
||||
methods=["PUT", "POST"]
|
||||
methods=["PUT", "POST"], endpoint="initialize_datagrid"
|
||||
)
|
||||
@login_required
|
||||
def initialize_datagrid(cmd_type, obj_type, sid, did, obj_id):
|
||||
|
@ -143,7 +158,11 @@ def initialize_datagrid(cmd_type, obj_type, sid, did, obj_id):
|
|||
'newBrowserTab': new_browser_tab})
|
||||
|
||||
|
||||
@blueprint.route('/panel/<int:trans_id>/<is_query_tool>/<path:editor_title>', methods=["GET"])
|
||||
@blueprint.route(
|
||||
'/panel/<int:trans_id>/<is_query_tool>/<path:editor_title>',
|
||||
methods=["GET"],
|
||||
endpoint='panel'
|
||||
)
|
||||
def panel(trans_id, is_query_tool, editor_title):
|
||||
"""
|
||||
This method calls index.html to render the data grid.
|
||||
|
@ -192,11 +211,11 @@ def panel(trans_id, is_query_tool, editor_title):
|
|||
|
||||
@blueprint.route(
|
||||
'/initialize/query_tool/<int:sid>/<int:did>',
|
||||
methods=["POST"]
|
||||
methods=["POST"], endpoint='initialize_query_tool_with_did'
|
||||
)
|
||||
@blueprint.route(
|
||||
'/initialize/query_tool/<int:sid>',
|
||||
methods=["POST"]
|
||||
methods=["POST"], endpoint='initialize_query_tool'
|
||||
)
|
||||
@login_required
|
||||
def initialize_query_tool(sid, did=None):
|
||||
|
@ -254,7 +273,7 @@ def initialize_query_tool(sid, did=None):
|
|||
'newBrowserTab': new_browser_tab})
|
||||
|
||||
|
||||
@blueprint.route('/close/<int:trans_id>', methods=["GET"])
|
||||
@blueprint.route('/close/<int:trans_id>', methods=["GET"], endpoint='close')
|
||||
def close(trans_id):
|
||||
"""
|
||||
This method is used to close the asynchronous connection
|
||||
|
@ -294,7 +313,8 @@ def close(trans_id):
|
|||
|
||||
|
||||
@blueprint.route('/filter/validate/<int:sid>/<int:did>/<int:obj_id>',
|
||||
methods=["PUT", "POST"])
|
||||
methods=["PUT", "POST"], endpoint='filter_validate'
|
||||
)
|
||||
@login_required
|
||||
def validate_filter(sid, did, obj_id):
|
||||
"""
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
define([
|
||||
'sources/gettext', 'jquery','alertify', 'pgadmin','codemirror',
|
||||
'sources/sqleditor_utils',
|
||||
'codemirror/mode/sql/sql', 'pgadmin.browser', 'wcdocker'
|
||||
], function(gettext, $, alertify, pgAdmin, CodeMirror, sqlEditorUtils) {
|
||||
'sources/gettext', 'sources/url_for', 'jquery','alertify', 'pgadmin','codemirror',
|
||||
'sources/sqleditor_utils', 'pgadmin.browser', 'wcdocker'
|
||||
], function(gettext, url_for, $, alertify, pgAdmin, codemirror, sqlEditorUtils) {
|
||||
// Some scripts do export their object in the window only.
|
||||
// Generally the one, which do no have AMD support.
|
||||
var wcDocker = window.wcDocker,
|
||||
|
@ -158,10 +157,15 @@ define([
|
|||
else if (parentData.catalog != undefined) {
|
||||
nsp_name = parentData.catalog.label;
|
||||
}
|
||||
var url_params = {
|
||||
'cmd_type': data.mnuid,
|
||||
'obj_type': d._type,
|
||||
'sid': parentData.server._id,
|
||||
'did': parentData.database._id,
|
||||
'obj_id': d._id
|
||||
};
|
||||
|
||||
var baseUrl = "{{ url_for('datagrid.index') }}" + "initialize/datagrid/" + data.mnuid + "/" + d._type + "/" +
|
||||
parentData.server._id + "/" + parentData.database._id + "/" + d._id;
|
||||
|
||||
var baseUrl = url_for('datagrid.initialize_datagrid', url_params);
|
||||
var grid_title = parentData.server.label + ' - ' + parentData.database.label + ' - '
|
||||
+ nsp_name + '.' + d.label;
|
||||
|
||||
|
@ -208,14 +212,23 @@ define([
|
|||
nsp_name = parentData.catalog.label;
|
||||
}
|
||||
|
||||
// Create base url to initialize the edit grid
|
||||
var baseUrl = "{{ url_for('datagrid.index') }}" + "initialize/datagrid/" + data.mnuid + "/" + d._type + "/" +
|
||||
parentData.server._id + "/" + parentData.database._id + "/" + d._id;
|
||||
var url_params = {
|
||||
'cmd_type': data.mnuid,
|
||||
'obj_type': d._type,
|
||||
'sid': parentData.server._id,
|
||||
'did': parentData.database._id,
|
||||
'obj_id': d._id
|
||||
|
||||
};
|
||||
|
||||
var baseUrl = url_for('datagrid.initialize_datagrid', url_params);
|
||||
|
||||
// Create url to validate the SQL filter
|
||||
var validateUrl = "{{ url_for('datagrid.index') }}" + "filter/validate/" +
|
||||
parentData.server._id + "/" + parentData.database._id + "/" + d._id;
|
||||
|
||||
var validateUrl = url_for('datagrid.filter_validate', {
|
||||
'sid': url_params['sid'],
|
||||
'did': url_params['did'],
|
||||
'obj_id': url_params['obj_id'],
|
||||
});
|
||||
var grid_title = parentData.server.label + '-' + parentData.database.label + '-'
|
||||
+ nsp_name + '.' + d.label;
|
||||
|
||||
|
@ -299,7 +312,7 @@ define([
|
|||
}
|
||||
|
||||
var content = '';
|
||||
$.get("{{ url_for('datagrid.index') }}" + "filter",
|
||||
$.get(url_for('datagrid.filter'),
|
||||
function(data) {
|
||||
alertify.filterDialog('Data Filter', data, baseUrl, validateUrl).resizeTo(600, 400);
|
||||
}
|
||||
|
@ -348,9 +361,13 @@ define([
|
|||
/* On successfully initialization find the dashboard panel,
|
||||
* create new panel and add it to the dashboard panel.
|
||||
*/
|
||||
var url_params = {
|
||||
'trans_id': res.data.gridTransId,
|
||||
'is_query_tool': 'false',
|
||||
'editor_title': encodeURIComponent(self.grid_title)
|
||||
};
|
||||
|
||||
baseUrl = "{{ url_for('datagrid.index') }}" + "panel/" + res.data.gridTransId + "/false/"
|
||||
+ encodeURIComponent(self.grid_title);
|
||||
var baseUrl = url_for('datagrid.panel', url_params);
|
||||
var grid_title = gettext('Edit Data - ') + self.grid_title;
|
||||
if (res.data.newBrowserTab) {
|
||||
var newWin = window.open(baseUrl, '_blank');
|
||||
|
@ -361,7 +378,16 @@ define([
|
|||
});
|
||||
} else {
|
||||
var dashboardPanel = pgBrowser.docker.findPanels('dashboard');
|
||||
dataGridPanel = pgBrowser.docker.addPanel('frm_datagrid', wcDocker.DOCK.STACKED, dashboardPanel[0]);
|
||||
var $frameArea = $('<div style="position:absolute;top:0 !important;width:100%;height:100%;display:table">');
|
||||
|
||||
var dataGridPanel = pgBrowser.docker.addPanel('frm_datagrid', wcDocker.DOCK.STACKED, dashboardPanel[0]);
|
||||
dataGridPanel.layout().addItem($frameArea);
|
||||
// Initialize empty frame
|
||||
var frame = new wcIFrame($frameArea, dataGridPanel);
|
||||
$(dataGridPanel).data('frameInitialized', false);
|
||||
$(dataGridPanel).data('embeddedFrame', frame);
|
||||
|
||||
// Set panel title and icon
|
||||
dataGridPanel.title('<span title="'+grid_title+'">'+grid_title+'</span>');
|
||||
dataGridPanel.icon('fa fa-bolt');
|
||||
dataGridPanel.focus();
|
||||
|
@ -369,17 +395,18 @@ define([
|
|||
// Listen on the panel closed event.
|
||||
dataGridPanel.on(wcDocker.EVENT.CLOSED, function() {
|
||||
$.ajax({
|
||||
url: "{{ url_for('datagrid.index') }}" + "close/" + res.data.gridTransId,
|
||||
url: url_for('datagrid.close', {'trans_id': res.data.gridTransId}),
|
||||
method: 'GET'
|
||||
});
|
||||
});
|
||||
|
||||
var openDataGridURL = function(j) {
|
||||
j.data('embeddedFrame').$container.append(self.spinner_el);
|
||||
// add spinner element
|
||||
$(j).data('embeddedFrame').$container.append(self.spinner_el);
|
||||
setTimeout(function() {
|
||||
var frameInitialized = j.data('frameInitialized');
|
||||
if (frameInitialized) {
|
||||
var frame = j.data('embeddedFrame');
|
||||
var frameInitialized = $(j).data('frameInitialized');
|
||||
if (!frameInitialized) {
|
||||
var frame = $(j).data('embeddedFrame');
|
||||
if (frame) {
|
||||
frame.openURL(baseUrl);
|
||||
frame.$container.find('.wcLoadingContainer').hide(1);
|
||||
|
@ -390,7 +417,7 @@ define([
|
|||
}, 100);
|
||||
};
|
||||
|
||||
openDataGridURL($(dataGridPanel));
|
||||
openDataGridURL(dataGridPanel);
|
||||
}
|
||||
},
|
||||
error: function(e) {
|
||||
|
@ -424,13 +451,17 @@ define([
|
|||
return;
|
||||
}
|
||||
|
||||
var baseUrl = "{{ url_for('datagrid.index') }}" + "initialize/query_tool/" + parentData.server._id;
|
||||
|
||||
var url_params = {
|
||||
'sid': parentData.server._id
|
||||
};
|
||||
var url_endpoint = 'datagrid.initialize_query_tool'
|
||||
// If database not present then use Maintenance database
|
||||
// We will handle this at server side
|
||||
if (parentData.database) {
|
||||
baseUrl += "/" + parentData.database._id;
|
||||
url_params['did'] = parentData.database._id;
|
||||
url_endpoint = 'datagrid.initialize_query_tool_with_did';
|
||||
}
|
||||
var baseUrl = url_for(url_endpoint, url_params);
|
||||
|
||||
$.ajax({
|
||||
url: baseUrl,
|
||||
|
@ -440,8 +471,15 @@ define([
|
|||
success: function(res) {
|
||||
var grid_title = self.get_panel_title();
|
||||
// Open the panel if frame is initialized
|
||||
baseUrl = "{{ url_for('datagrid.index') }}" + "panel/" + res.data.gridTransId + "/true/"
|
||||
+ encodeURIComponent(grid_title) + '?' + "query_url=" + encodeURI(sURL);
|
||||
var url_params = {
|
||||
'trans_id': res.data.gridTransId,
|
||||
'is_query_tool': 'true',
|
||||
'editor_title': encodeURIComponent(grid_title)
|
||||
}
|
||||
|
||||
var baseUrl = url_for('datagrid.panel', url_params) +
|
||||
'?' + "query_url=" + encodeURI(sURL);
|
||||
|
||||
// Create title for CREATE/DELETE scripts
|
||||
if (panel_title) {
|
||||
panel_title =
|
||||
|
@ -463,7 +501,16 @@ define([
|
|||
* create new panel and add it to the dashboard panel.
|
||||
*/
|
||||
var dashboardPanel = pgBrowser.docker.findPanels('dashboard');
|
||||
queryToolPanel = pgBrowser.docker.addPanel('frm_datagrid', wcDocker.DOCK.STACKED, dashboardPanel[0]);
|
||||
var $frameArea = $('<div style="position:absolute;top:0 !important;width:100%;height:100%;display:table">');
|
||||
|
||||
var queryToolPanel = pgBrowser.docker.addPanel('frm_datagrid', wcDocker.DOCK.STACKED, dashboardPanel[0]);
|
||||
queryToolPanel.layout().addItem($frameArea);
|
||||
// Initialize empty frame
|
||||
var frame = new wcIFrame($frameArea, queryToolPanel);
|
||||
$(queryToolPanel).data('frameInitialized', false);
|
||||
$(queryToolPanel).data('embeddedFrame', frame);
|
||||
|
||||
// Set panel title and icon
|
||||
queryToolPanel.title('<span title="'+panel_title+'">'+panel_title+'</span>');
|
||||
queryToolPanel.icon('fa fa-bolt');
|
||||
queryToolPanel.focus();
|
||||
|
@ -471,17 +518,18 @@ define([
|
|||
// Listen on the panel closed event.
|
||||
queryToolPanel.on(wcDocker.EVENT.CLOSED, function() {
|
||||
$.ajax({
|
||||
url: "{{ url_for('datagrid.index') }}" + "close/" + res.data.gridTransId,
|
||||
url: url_for('datagrid.close', {'trans_id': res.data.gridTransId}),
|
||||
method: 'GET'
|
||||
});
|
||||
});
|
||||
|
||||
var openQueryToolURL = function(j) {
|
||||
j.data('embeddedFrame').$container.append(pgAdmin.DataGrid.spinner_el);
|
||||
// add spinner element
|
||||
$(j).data('embeddedFrame').$container.append(pgAdmin.DataGrid.spinner_el);
|
||||
setTimeout(function() {
|
||||
var frameInitialized = j.data('frameInitialized');
|
||||
if (frameInitialized) {
|
||||
var frame = j.data('embeddedFrame');
|
||||
var frameInitialized = $(j).data('frameInitialized');
|
||||
if (!frameInitialized) {
|
||||
var frame = $(j).data('embeddedFrame');
|
||||
if (frame) {
|
||||
frame.openURL(baseUrl);
|
||||
frame.$container.find('.wcLoadingContainer').delay(1000).hide(1);
|
||||
|
@ -492,7 +540,7 @@ define([
|
|||
}, 100);
|
||||
};
|
||||
|
||||
openQueryToolURL($(queryToolPanel));
|
||||
openQueryToolURL(queryToolPanel);
|
||||
}
|
||||
},
|
||||
error: function(e) {
|
||||
|
|
|
@ -73,6 +73,35 @@ class SqlEditorModule(PgAdminModule):
|
|||
def get_panels(self):
|
||||
return []
|
||||
|
||||
def get_exposed_url_endpoints(self):
|
||||
"""
|
||||
Returns:
|
||||
list: URL endpoints for sqleditor module
|
||||
"""
|
||||
return [
|
||||
'sqleditor.view_data_start',
|
||||
'sqleditor.query_tool_start',
|
||||
'sqleditor.query_tool_preferences',
|
||||
'sqleditor.get_columns',
|
||||
'sqleditor.poll',
|
||||
'sqleditor.fetch_types',
|
||||
'sqleditor.save',
|
||||
'sqleditor.get_filter',
|
||||
'sqleditor.apply_filter',
|
||||
'sqleditor.inclusive_filter',
|
||||
'sqleditor.exclusive_filter',
|
||||
'sqleditor.remove_filter',
|
||||
'sqleditor.set_limit',
|
||||
'sqleditor.cancel_transaction',
|
||||
'sqleditor.get_object_name',
|
||||
'sqleditor.auto_commit',
|
||||
'sqleditor.auto_rollback',
|
||||
'sqleditor.autocomplete',
|
||||
'sqleditor.load_file',
|
||||
'sqleditor.save_file',
|
||||
'sqleditor.query_tool_download'
|
||||
]
|
||||
|
||||
def register_preferences(self):
|
||||
self.info_notifier_timeout = self.preference.register(
|
||||
'display', 'info_notifier_timeout',
|
||||
|
@ -216,7 +245,10 @@ def check_transaction_status(trans_id):
|
|||
None, trans_obj, session_obj
|
||||
|
||||
|
||||
@blueprint.route('/view_data/start/<int:trans_id>', methods=["GET"])
|
||||
@blueprint.route(
|
||||
'/view_data/start/<int:trans_id>',
|
||||
methods=["GET"], endpoint='view_data_start'
|
||||
)
|
||||
@login_required
|
||||
def start_view_data(trans_id):
|
||||
"""
|
||||
|
@ -273,7 +305,10 @@ def start_view_data(trans_id):
|
|||
)
|
||||
|
||||
|
||||
@blueprint.route('/query_tool/start/<int:trans_id>', methods=["PUT", "POST"])
|
||||
@blueprint.route(
|
||||
'/query_tool/start/<int:trans_id>',
|
||||
methods=["PUT", "POST"], endpoint='query_tool_start'
|
||||
)
|
||||
@login_required
|
||||
def start_query_tool(trans_id):
|
||||
"""
|
||||
|
@ -375,7 +410,10 @@ def start_query_tool(trans_id):
|
|||
)
|
||||
|
||||
|
||||
@blueprint.route('/query_tool/preferences/<int:trans_id>', methods=["GET", "PUT"])
|
||||
@blueprint.route(
|
||||
'/query_tool/preferences/<int:trans_id>',
|
||||
methods=["GET", "PUT"], endpoint='query_tool_preferences'
|
||||
)
|
||||
@login_required
|
||||
def preferences(trans_id):
|
||||
"""
|
||||
|
@ -429,7 +467,9 @@ def preferences(trans_id):
|
|||
return success_return()
|
||||
|
||||
|
||||
@blueprint.route('/columns/<int:trans_id>', methods=["GET"])
|
||||
@blueprint.route(
|
||||
'/columns/<int:trans_id>', methods=["GET"], endpoint='get_columns'
|
||||
)
|
||||
@login_required
|
||||
def get_columns(trans_id):
|
||||
"""
|
||||
|
@ -488,7 +528,7 @@ def get_columns(trans_id):
|
|||
'primary_keys': primary_keys})
|
||||
|
||||
|
||||
@blueprint.route('/poll/<int:trans_id>', methods=["GET"])
|
||||
@blueprint.route('/poll/<int:trans_id>', methods=["GET"], endpoint='poll')
|
||||
@login_required
|
||||
def poll(trans_id):
|
||||
"""
|
||||
|
@ -564,7 +604,9 @@ def poll(trans_id):
|
|||
)
|
||||
|
||||
|
||||
@blueprint.route('/fetch/types/<int:trans_id>', methods=["GET"])
|
||||
@blueprint.route(
|
||||
'/fetch/types/<int:trans_id>', methods=["GET"], endpoint='fetch_types'
|
||||
)
|
||||
@login_required
|
||||
def fetch_pg_types(trans_id):
|
||||
"""
|
||||
|
@ -606,7 +648,9 @@ def fetch_pg_types(trans_id):
|
|||
return make_json_response(data={'status': status, 'result': res})
|
||||
|
||||
|
||||
@blueprint.route('/save/<int:trans_id>', methods=["PUT", "POST"])
|
||||
@blueprint.route(
|
||||
'/save/<int:trans_id>', methods=["PUT", "POST"], endpoint='save'
|
||||
)
|
||||
@login_required
|
||||
def save(trans_id):
|
||||
"""
|
||||
|
@ -652,7 +696,10 @@ def save(trans_id):
|
|||
)
|
||||
|
||||
|
||||
@blueprint.route('/filter/get/<int:trans_id>', methods=["GET"])
|
||||
@blueprint.route(
|
||||
'/filter/get/<int:trans_id>',
|
||||
methods=["GET"], endpoint='get_filter'
|
||||
)
|
||||
@login_required
|
||||
def get_filter(trans_id):
|
||||
"""
|
||||
|
@ -675,7 +722,10 @@ def get_filter(trans_id):
|
|||
return make_json_response(data={'status': status, 'result': res})
|
||||
|
||||
|
||||
@blueprint.route('/filter/apply/<int:trans_id>', methods=["PUT", "POST"])
|
||||
@blueprint.route(
|
||||
'/filter/apply/<int:trans_id>',
|
||||
methods=["PUT", "POST"], endpoint='apply_filter'
|
||||
)
|
||||
@login_required
|
||||
def apply_filter(trans_id):
|
||||
"""
|
||||
|
@ -707,7 +757,10 @@ def apply_filter(trans_id):
|
|||
return make_json_response(data={'status': status, 'result': res})
|
||||
|
||||
|
||||
@blueprint.route('/filter/inclusive/<int:trans_id>', methods=["PUT", "POST"])
|
||||
@blueprint.route(
|
||||
'/filter/inclusive/<int:trans_id>',
|
||||
methods=["PUT", "POST"], endpoint='inclusive_filter'
|
||||
)
|
||||
@login_required
|
||||
def append_filter_inclusive(trans_id):
|
||||
"""
|
||||
|
@ -750,7 +803,10 @@ def append_filter_inclusive(trans_id):
|
|||
return make_json_response(data={'status': status, 'result': res})
|
||||
|
||||
|
||||
@blueprint.route('/filter/exclusive/<int:trans_id>', methods=["PUT", "POST"])
|
||||
@blueprint.route(
|
||||
'/filter/exclusive/<int:trans_id>',
|
||||
methods=["PUT", "POST"], endpoint='exclusive_filter'
|
||||
)
|
||||
@login_required
|
||||
def append_filter_exclusive(trans_id):
|
||||
"""
|
||||
|
@ -794,7 +850,10 @@ def append_filter_exclusive(trans_id):
|
|||
return make_json_response(data={'status': status, 'result': res})
|
||||
|
||||
|
||||
@blueprint.route('/filter/remove/<int:trans_id>', methods=["PUT", "POST"])
|
||||
@blueprint.route(
|
||||
'/filter/remove/<int:trans_id>',
|
||||
methods=["PUT", "POST"], endpoint='remove_filter'
|
||||
)
|
||||
@login_required
|
||||
def remove_filter(trans_id):
|
||||
"""
|
||||
|
@ -825,7 +884,9 @@ def remove_filter(trans_id):
|
|||
return make_json_response(data={'status': status, 'result': res})
|
||||
|
||||
|
||||
@blueprint.route('/limit/<int:trans_id>', methods=["PUT", "POST"])
|
||||
@blueprint.route(
|
||||
'/limit/<int:trans_id>', methods=["PUT", "POST"], endpoint='set_limit'
|
||||
)
|
||||
@login_required
|
||||
def set_limit(trans_id):
|
||||
"""
|
||||
|
@ -860,7 +921,10 @@ def set_limit(trans_id):
|
|||
return make_json_response(data={'status': status, 'result': res})
|
||||
|
||||
|
||||
@blueprint.route('/cancel/<int:trans_id>', methods=["PUT", "POST"])
|
||||
@blueprint.route(
|
||||
'/cancel/<int:trans_id>',
|
||||
methods=["PUT", "POST"], endpoint='cancel_transaction'
|
||||
)
|
||||
@login_required
|
||||
def cancel_transaction(trans_id):
|
||||
"""
|
||||
|
@ -925,7 +989,10 @@ def cancel_transaction(trans_id):
|
|||
)
|
||||
|
||||
|
||||
@blueprint.route('/object/get/<int:trans_id>', methods=["GET"])
|
||||
@blueprint.route(
|
||||
'/object/get/<int:trans_id>',
|
||||
methods=["GET"], endpoint='get_object_name'
|
||||
)
|
||||
@login_required
|
||||
def get_object_name(trans_id):
|
||||
"""
|
||||
|
@ -948,7 +1015,10 @@ def get_object_name(trans_id):
|
|||
return make_json_response(data={'status': status, 'result': res})
|
||||
|
||||
|
||||
@blueprint.route('/auto_commit/<int:trans_id>', methods=["PUT", "POST"])
|
||||
@blueprint.route(
|
||||
'/auto_commit/<int:trans_id>',
|
||||
methods=["PUT", "POST"], endpoint='auto_commit'
|
||||
)
|
||||
@login_required
|
||||
def set_auto_commit(trans_id):
|
||||
"""
|
||||
|
@ -986,7 +1056,10 @@ def set_auto_commit(trans_id):
|
|||
return make_json_response(data={'status': status, 'result': res})
|
||||
|
||||
|
||||
@blueprint.route('/auto_rollback/<int:trans_id>', methods=["PUT", "POST"])
|
||||
@blueprint.route(
|
||||
'/auto_rollback/<int:trans_id>',
|
||||
methods=["PUT", "POST"], endpoint='auto_rollback'
|
||||
)
|
||||
@login_required
|
||||
def set_auto_rollback(trans_id):
|
||||
"""
|
||||
|
@ -1024,7 +1097,10 @@ def set_auto_rollback(trans_id):
|
|||
return make_json_response(data={'status': status, 'result': res})
|
||||
|
||||
|
||||
@blueprint.route('/autocomplete/<int:trans_id>', methods=["PUT", "POST"])
|
||||
@blueprint.route(
|
||||
'/autocomplete/<int:trans_id>',
|
||||
methods=["PUT", "POST"], endpoint='autocomplete'
|
||||
)
|
||||
@login_required
|
||||
def auto_complete(trans_id):
|
||||
"""
|
||||
|
@ -1232,7 +1308,7 @@ def is_begin_required(query):
|
|||
return True
|
||||
|
||||
|
||||
@blueprint.route('/load_file/', methods=["PUT", "POST"])
|
||||
@blueprint.route('/load_file/', methods=["PUT", "POST"], endpoint='load_file')
|
||||
@login_required
|
||||
def load_file():
|
||||
"""
|
||||
|
@ -1282,7 +1358,7 @@ def load_file():
|
|||
)
|
||||
|
||||
|
||||
@blueprint.route('/save_file/', methods=["PUT", "POST"])
|
||||
@blueprint.route('/save_file/', methods=["PUT", "POST"], endpoint='save_file')
|
||||
@login_required
|
||||
def save_file():
|
||||
"""
|
||||
|
@ -1342,7 +1418,11 @@ def save_file():
|
|||
)
|
||||
|
||||
|
||||
@blueprint.route('/query_tool/download/<int:trans_id>', methods=["GET"])
|
||||
@blueprint.route(
|
||||
'/query_tool/download/<int:trans_id>',
|
||||
methods=["GET"],
|
||||
endpoint='query_tool_download'
|
||||
)
|
||||
@login_required
|
||||
def start_query_download_tool(trans_id):
|
||||
sync_conn = None
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
define([
|
||||
'jquery', 'underscore', 'underscore.string', 'alertify', 'pgadmin',
|
||||
'backbone', 'backgrid', 'codemirror', 'pgadmin.misc.explain',
|
||||
'sources/gettext','sources/url_for', 'jquery', 'underscore', 'underscore.string', 'alertify',
|
||||
'pgadmin', 'backbone', 'backgrid', 'codemirror', 'pgadmin.misc.explain',
|
||||
'sources/selection/grid_selector',
|
||||
'sources/selection/active_cell_capture',
|
||||
'sources/selection/clipboard',
|
||||
|
@ -9,8 +9,8 @@ define([
|
|||
'sources/slickgrid/event_handlers/handle_query_output_keyboard_event',
|
||||
'sources/selection/xcell_selection_model',
|
||||
'sources/selection/set_staged_rows',
|
||||
'sources/gettext',
|
||||
'sources/sqleditor_utils',
|
||||
|
||||
'sources/generated/history',
|
||||
'sources/generated/reactComponents',
|
||||
|
||||
|
@ -25,13 +25,14 @@ define([
|
|||
'codemirror/addon/search/search',
|
||||
'codemirror/addon/search/searchcursor',
|
||||
'codemirror/addon/search/jump-to-line',
|
||||
|
||||
'backgrid.sizeable.columns',
|
||||
'slick.pgadmin.formatters',
|
||||
'slick.pgadmin.editors',
|
||||
], function(
|
||||
$, _, S, alertify, pgAdmin, Backbone, Backgrid, CodeMirror,
|
||||
gettext, url_for, $, _, S, alertify, pgAdmin, Backbone, Backgrid, CodeMirror,
|
||||
pgExplain, GridSelector, ActiveCellCapture, clipboard, copyData, RangeSelectionHelper, handleQueryOutputKeyboardEvent,
|
||||
XCellSelectionModel, setStagedRows, gettext, SqlEditorUtils, HistoryBundle, reactComponents
|
||||
XCellSelectionModel, setStagedRows, SqlEditorUtils, HistoryBundle, reactComponents
|
||||
) {
|
||||
/* Return back, this has been called more than once */
|
||||
if (pgAdmin.SqlEditor)
|
||||
|
@ -108,7 +109,6 @@ define([
|
|||
filter = self.$el.find('#sql_filter');
|
||||
|
||||
$('.editor-title').text(_.unescape(self.editor_title));
|
||||
|
||||
self.filter_obj = CodeMirror.fromTextArea(filter.get(0), {
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
|
@ -132,7 +132,7 @@ define([
|
|||
'#editor-panel', {
|
||||
allowContextMenu: false,
|
||||
allowCollapse: false,
|
||||
themePath: '{{ url_for("static", filename="css") }}',
|
||||
themePath: url_for('static', {'filename': 'css'}),
|
||||
theme: 'webcabin.overrides.css'
|
||||
});
|
||||
|
||||
|
@ -288,8 +288,7 @@ define([
|
|||
ctx = {
|
||||
editor: editor,
|
||||
// URL for auto-complete
|
||||
url: "{{ url_for('sqleditor.index') }}" + "autocomplete/" +
|
||||
self.transId,
|
||||
url: url_for('sqleditor.autocomplete', {'trans_id': self.transId}),
|
||||
data: data,
|
||||
// Get the line number in the cursor position
|
||||
current_line: cur.line,
|
||||
|
@ -534,7 +533,8 @@ define([
|
|||
collection = [];
|
||||
}
|
||||
|
||||
var grid_columns = [];
|
||||
var grid_columns = [],
|
||||
table_name;
|
||||
var column_size = self.handler['col_size'],
|
||||
query = self.handler.query,
|
||||
// Extract table name from query
|
||||
|
@ -874,7 +874,7 @@ define([
|
|||
if (self.history_grid) {
|
||||
self.history_grid.remove();
|
||||
}
|
||||
|
||||
|
||||
self.history_collection = new HistoryBundle.historyCollection([]);
|
||||
|
||||
let queryHistoryElement = reactComponents.React.createElement(
|
||||
|
@ -1517,7 +1517,7 @@ define([
|
|||
);
|
||||
|
||||
$.ajax({
|
||||
url: "{{ url_for('sqleditor.index') }}" + "view_data/start/" + self.transId,
|
||||
url: url_for('sqleditor.view_data_start', {'trans_id': self.transId}),
|
||||
method: 'GET',
|
||||
success: function(res) {
|
||||
if (res.data.status) {
|
||||
|
@ -1588,7 +1588,7 @@ define([
|
|||
// or use the columns data stored locally from previous call?
|
||||
if (self.FETCH_COLUMNS_FROM_SERVER) {
|
||||
$.ajax({
|
||||
url: "{{ url_for('sqleditor.index') }}" + "columns/" + self.transId,
|
||||
url: url_for('sqleditor.get_columns', {'trans_id': self.transId}),
|
||||
method: 'GET',
|
||||
success: function(res) {
|
||||
poll_result.colinfo = res.data.columns;
|
||||
|
@ -1660,7 +1660,7 @@ define([
|
|||
setTimeout(
|
||||
function() {
|
||||
$.ajax({
|
||||
url: "{{ url_for('sqleditor.index') }}" + "poll/" + self.transId,
|
||||
url: url_for('sqleditor.poll', {'trans_id': self.transId}),
|
||||
method: 'GET',
|
||||
success: function(res) {
|
||||
if (res.data.status === 'Success') {
|
||||
|
@ -1863,7 +1863,7 @@ define([
|
|||
|
||||
// Make ajax call to fetch the pg types to map numeric data type
|
||||
$.ajax({
|
||||
url: "{{ url_for('sqleditor.index') }}" + "fetch/types/" + self.transId,
|
||||
url: url_for('sqleditor.fetch_types', {'trans_id': self.transId}),
|
||||
method: 'GET',
|
||||
success: function(res) {
|
||||
if (res.data.status) {
|
||||
|
@ -1888,7 +1888,9 @@ define([
|
|||
// To show column label and data type in multiline,
|
||||
// The elements should be put inside the div.
|
||||
// Create column label and type.
|
||||
var col_type = column_label = '';
|
||||
var col_type = '',
|
||||
column_label = '',
|
||||
col_cell;
|
||||
var type = pg_types[c.type_code] ?
|
||||
pg_types[c.type_code][0] :
|
||||
// This is the case where user might
|
||||
|
@ -2020,7 +2022,8 @@ define([
|
|||
var self = this;
|
||||
|
||||
// Calculate the difference in milliseconds
|
||||
var difference_ms = miliseconds = end_time.getTime() - start_time.getTime();
|
||||
var difference_ms, miliseconds;
|
||||
difference_ms = miliseconds = end_time.getTime() - start_time.getTime();
|
||||
//take out milliseconds
|
||||
difference_ms = difference_ms/1000;
|
||||
var seconds = Math.floor(difference_ms % 60);
|
||||
|
@ -2191,7 +2194,7 @@ define([
|
|||
|
||||
// Make ajax call to save the data
|
||||
$.ajax({
|
||||
url: "{{ url_for('sqleditor.index') }}" + "save/" + self.transId,
|
||||
url: url_for('sqleditor.save', {'trans_id': self.transId}),
|
||||
method: 'POST',
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify(req_data),
|
||||
|
@ -2419,7 +2422,7 @@ define([
|
|||
|
||||
// Make ajax call to load the data from file
|
||||
$.ajax({
|
||||
url: "{{ url_for('sqleditor.index') }}" + "load_file/",
|
||||
url: url_for('sqleditor.load_file'),
|
||||
method: 'POST',
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify(data),
|
||||
|
@ -2464,7 +2467,7 @@ define([
|
|||
|
||||
// Make ajax call to save the data to file
|
||||
$.ajax({
|
||||
url: "{{ url_for('sqleditor.index') }}" + "save_file/",
|
||||
url: url_for('sqleditor.save_file'),
|
||||
method: 'POST',
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify(data),
|
||||
|
@ -2584,7 +2587,7 @@ define([
|
|||
gettext("Loading the existing filter options...")
|
||||
);
|
||||
$.ajax({
|
||||
url: "{{ url_for('sqleditor.index') }}" + "filter/get/" + self.transId,
|
||||
url: url_for('sqleditor.get_filter', {'trans_id': self.transId}),
|
||||
method: 'GET',
|
||||
success: function(res) {
|
||||
self.trigger('pgadmin-sqleditor:loading-icon:hide');
|
||||
|
@ -2656,7 +2659,7 @@ define([
|
|||
|
||||
// Make ajax call to include the filter by selection
|
||||
$.ajax({
|
||||
url: "{{ url_for('sqleditor.index') }}" + "filter/inclusive/" + self.transId,
|
||||
url: url_for('sqleditor.inclusive_filter', {'trans_id': self.transId}),
|
||||
method: 'POST',
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify(data),
|
||||
|
@ -2726,7 +2729,7 @@ define([
|
|||
|
||||
// Make ajax call to exclude the filter by selection.
|
||||
$.ajax({
|
||||
url: "{{ url_for('sqleditor.index') }}" + "filter/exclusive/" + self.transId,
|
||||
url: url_for('sqleditor.exclusive_filter', {'trans_id': self.transId}),
|
||||
method: 'POST',
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify(data),
|
||||
|
@ -2779,7 +2782,7 @@ define([
|
|||
|
||||
// Make ajax call to exclude the filter by selection.
|
||||
$.ajax({
|
||||
url: "{{ url_for('sqleditor.index') }}" + "filter/remove/" + self.transId,
|
||||
url: url_for('sqleditor.remove_filter', {'trans_id': self.transId}),
|
||||
method: 'POST',
|
||||
success: function(res) {
|
||||
self.trigger('pgadmin-sqleditor:loading-icon:hide');
|
||||
|
@ -2830,7 +2833,7 @@ define([
|
|||
|
||||
// Make ajax call to include the filter by selection
|
||||
$.ajax({
|
||||
url: "{{ url_for('sqleditor.index') }}" + "filter/apply/" + self.transId,
|
||||
url: url_for('sqleditor.apply_filter', {'trans_id': self.transId}),
|
||||
method: 'POST',
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify(sql),
|
||||
|
@ -2953,7 +2956,7 @@ define([
|
|||
);
|
||||
// Make ajax call to change the limit
|
||||
$.ajax({
|
||||
url: "{{ url_for('sqleditor.index') }}" + "limit/" + self.transId,
|
||||
url: url_for('sqleditor.set_limit', {'trans_id': self.transId}),
|
||||
method: 'POST',
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify(limit),
|
||||
|
@ -3041,7 +3044,7 @@ define([
|
|||
$("#btn-cancel-query").prop('disabled', false);
|
||||
|
||||
$.ajax({
|
||||
url: "{{ url_for('sqleditor.index') }}" + "query_tool/start/" + self.transId,
|
||||
url: url_for('sqleditor.query_tool_start', {'trans_id': self.transId}),
|
||||
method: 'POST',
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify(sql),
|
||||
|
@ -3167,7 +3170,7 @@ define([
|
|||
|
||||
$("#btn-cancel-query").prop('disabled', true);
|
||||
$.ajax({
|
||||
url: "{{ url_for('sqleditor.index') }}" + "cancel/" + self.transId,
|
||||
url: url_for('sqleditor.cancel_transaction', {'trans_id': self.transId}),
|
||||
method: 'POST',
|
||||
contentType: "application/json",
|
||||
success: function(res) {
|
||||
|
@ -3218,7 +3221,7 @@ define([
|
|||
*/
|
||||
if (!self.is_query_tool) {
|
||||
$.ajax({
|
||||
url: "{{ url_for('sqleditor.index') }}" + "object/get/" + self.transId,
|
||||
url: url_for('sqleditor.get_object_name', {'trans_id': self.transId}),
|
||||
method: 'GET',
|
||||
success: function(res) {
|
||||
if (res.data.status) {
|
||||
|
@ -3252,7 +3255,7 @@ define([
|
|||
_trigger_csv_download: function(query, filename) {
|
||||
var self = this,
|
||||
link = $(this.container).find("#download-csv"),
|
||||
url = "{{ url_for('sqleditor.index') }}" + "query_tool/download/" + self.transId;
|
||||
url = url_for('sqleditor.query_tool_download', {'trans_id': self.transId});
|
||||
|
||||
url +="?" + $.param({query:query, filename:filename});
|
||||
link.attr("src", url);
|
||||
|
@ -3271,7 +3274,7 @@ define([
|
|||
|
||||
// Make ajax call to change the limit
|
||||
$.ajax({
|
||||
url: "{{ url_for('sqleditor.index') }}" + "auto_rollback/" + self.transId,
|
||||
url: url_for('sqleditor.auto_rollback', {'trans_id': self.transId}),
|
||||
method: 'POST',
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify(auto_rollback),
|
||||
|
@ -3310,7 +3313,7 @@ define([
|
|||
|
||||
// Make ajax call to change the limit
|
||||
$.ajax({
|
||||
url: "{{ url_for('sqleditor.index') }}" + "auto_commit/" + self.transId,
|
||||
url: url_for('sqleditor.auto_commit', {'trans_id': self.transId}),
|
||||
method: 'POST',
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify(auto_commit),
|
||||
|
@ -3379,7 +3382,7 @@ define([
|
|||
};
|
||||
|
||||
$.ajax({
|
||||
url: "{{ url_for('sqleditor.index') }}" + "query_tool/preferences/" + self.transId ,
|
||||
url: url_for('sqleditor.query_tool_preferences', {'trans_id': self.transId}),
|
||||
method: 'PUT',
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify(data),
|
||||
|
@ -3417,7 +3420,7 @@ define([
|
|||
};
|
||||
|
||||
$.ajax({
|
||||
url: "{{ url_for('sqleditor.index') }}" + "query_tool/preferences/" + self.transId ,
|
||||
url: url_for('sqleditor.query_tool_preferences', {'trans_id': self.transId}),
|
||||
method: 'PUT',
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify(data),
|
||||
|
@ -3454,7 +3457,7 @@ define([
|
|||
};
|
||||
|
||||
$.ajax({
|
||||
url: "{{ url_for('sqleditor.index') }}" + "query_tool/preferences/" + self.transId ,
|
||||
url: url_for('sqleditor.query_tool_preferences', {'trans_id': self.transId}),
|
||||
method: 'PUT',
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify(data),
|
||||
|
@ -3490,7 +3493,7 @@ define([
|
|||
};
|
||||
|
||||
$.ajax({
|
||||
url: "{{ url_for('sqleditor.index') }}" + "query_tool/preferences/" + self.transId ,
|
||||
url: url_for('sqleditor.query_tool_preferences', {'trans_id': self.transId}),
|
||||
method: 'PUT',
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify(data),
|
||||
|
@ -3564,7 +3567,7 @@ define([
|
|||
};
|
||||
|
||||
$.ajax({
|
||||
url: "{{ url_for('sqleditor.index') }}" + "query_tool/preferences/" + self.transId ,
|
||||
url: url_for('sqleditor.query_tool_preferences', {'trans_id': self.transId}),
|
||||
method: 'GET',
|
||||
success: function(res) {
|
||||
if (res.data) {
|
||||
|
|
Loading…
Reference in New Issue