Highlighting greenplum keywords in sql editor

This commit is contained in:
Teng Zhang 2017-09-11 19:39:50 +05:30 committed by Akshay Joshi
parent f79b7f26b1
commit 512afd6618
6 changed files with 22 additions and 13 deletions

View File

@ -54,7 +54,7 @@
"bootstrap-switch": "3.3.2",
"bowser": "1.6.1",
"browserify": "~14.1.0",
"codemirror": "^5.28.0",
"codemirror": "^5.29.0",
"css-loader": "0.14.0",
"cssnano": "^3.10.0",
"dropzone": "^5.1.1",

View File

@ -184,6 +184,12 @@ def panel(trans_id, is_query_tool, editor_title):
else:
sURL = None
# Fetch server type from request
if request.args and request.args['server_type'] != '':
server_type = request.args['server_type']
else:
server_type = None
# We need client OS information to render correct Keyboard shortcuts
user_agent = UserAgent(request.headers.get('User-Agent'))
@ -217,6 +223,7 @@ def panel(trans_id, is_query_tool, editor_title):
is_desktop_mode=app.PGADMIN_RUNTIME,
is_linux=is_linux_platform,
is_new_browser_tab=new_browser_tab,
server_type=server_type,
client_platform=user_agent.platform
)

View File

@ -164,7 +164,7 @@ define('pgadmin.datagrid', [
+ nsp_name + '.' + d.label;
// Initialize the data grid.
self.initialize_data_grid(baseUrl, grid_title, '');
self.initialize_data_grid(baseUrl, grid_title, '', parentData.server.server_type);
},
// This is a callback function to show filtered data when user click on menu item.
@ -283,7 +283,7 @@ define('pgadmin.datagrid', [
success: function(res) {
if (res.data.status) {
// Initialize the data grid.
self.initialize_data_grid(that.baseUrl, grid_title, sql);
self.initialize_data_grid(that.baseUrl, grid_title, sql, parentData.server.server_type);
}
else {
alertify.alert(
@ -336,7 +336,7 @@ define('pgadmin.datagrid', [
return grid_title;
},
initialize_data_grid: function(baseUrl, grid_title, sql_filter) {
initialize_data_grid: function(baseUrl, grid_title, sql_filter, server_type) {
var self = this;
self.grid_title = grid_title;
@ -361,7 +361,8 @@ define('pgadmin.datagrid', [
'editor_title': encodeURIComponent(self.grid_title)
};
var baseUrl = url_for('datagrid.panel', url_params);
var baseUrl = url_for('datagrid.panel', url_params) +
"?query_url=&server_type=" + encodeURIComponent(server_type);
var grid_title = gettext('Edit Data - ') + self.grid_title;
if (res.data.newBrowserTab) {
var newWin = window.open(baseUrl, '_blank');
@ -465,7 +466,7 @@ define('pgadmin.datagrid', [
}
var baseUrl = url_for('datagrid.panel', url_params) +
'?' + "query_url=" + encodeURI(sURL);
'?' + "query_url=" + encodeURI(sURL) + "&server_type=" + encodeURIComponent(parentData.server.server_type);
// Create title for CREATE/DELETE scripts
if (panel_title) {

View File

@ -369,6 +369,6 @@
// Start the query tool.
sqlEditorController.start({{ is_query_tool }}, "{{ editor_title }}",
script_sql, {{ is_new_browser_tab }});
script_sql, {{ is_new_browser_tab }}, "{{ server_type }}");
});
{% endblock %}

View File

@ -110,7 +110,7 @@ define('tools.querytool', [
self.filter_obj = CodeMirror.fromTextArea(filter.get(0), {
lineNumbers: true,
indentUnit: 4,
mode: "text/x-pgsql",
mode: self.handler.server_type === "gpdb" ? "text/x-gpsql" : "text/x-pgsql",
foldOptions: {
widget: "\u2026"
},
@ -155,7 +155,7 @@ define('tools.querytool', [
lineNumbers: true,
indentUnit: 4,
styleSelectedText: true,
mode: "text/x-pgsql",
mode: self.handler.server_type === "gpdb" ? "text/x-gpsql" : "text/x-pgsql",
foldOptions: {
widget: "\u2026"
},
@ -1514,7 +1514,7 @@ define('tools.querytool', [
* call the render method of the grid view to render the backgrid
* header and loading icon and start execution of the sql query.
*/
start: function (is_query_tool, editor_title, script_sql, is_new_browser_tab) {
start: function (is_query_tool, editor_title, script_sql, is_new_browser_tab, server_type) {
var self = this;
self.is_query_tool = is_query_tool;
@ -1528,6 +1528,7 @@ define('tools.querytool', [
self.has_more_rows = false;
self.fetching_rows = false;
self.close_on_save = false;
self.server_type = server_type;
// We do not allow to call the start multiple times.
if (self.gridView)

View File

@ -1497,9 +1497,9 @@ code-point-at@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77"
codemirror@^5.28.0:
version "5.28.0"
resolved "https://registry.yarnpkg.com/codemirror/-/codemirror-5.28.0.tgz#2978d9280d671351a4f5737d06bbd681a0fd6f83"
codemirror@^5.29.0:
version "5.29.0"
resolved "https://registry.yarnpkg.com/codemirror/-/codemirror-5.29.0.tgz#e68de1350e2f0ce804a3930576d0ae318736e967"
color-convert@^1.3.0:
version "1.9.0"