mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Ensure sort/filter dialog should display proper message after losing database connection. Fixes #3561
This commit is contained in:
parent
0f17b4f738
commit
25679fd542
@ -25,4 +25,5 @@ Bug fixes
|
|||||||
| `Bug #3528 <https://redmine.postgresql.org/issues/3528>`_ - Handle connection errors properly in the query tool.
|
| `Bug #3528 <https://redmine.postgresql.org/issues/3528>`_ - Handle connection errors properly in the query tool.
|
||||||
| `Bug #3547 <https://redmine.postgresql.org/issues/3547>`_ - Make session implementation thread safe
|
| `Bug #3547 <https://redmine.postgresql.org/issues/3547>`_ - Make session implementation thread safe
|
||||||
| `Bug #3558 <https://redmine.postgresql.org/issues/3558>`_ - Fix sort/filter dialog editing issue.
|
| `Bug #3558 <https://redmine.postgresql.org/issues/3558>`_ - Fix sort/filter dialog editing issue.
|
||||||
|
| `Bug #3561 <https://redmine.postgresql.org/issues/3561>`_ - Ensure sort/filter dialog should display proper message after losing database connection.
|
||||||
| `Bug #3578 <https://redmine.postgresql.org/issues/3578>`_ - Ensure sql for Role should be visible in SQL panel for GPDB.
|
| `Bug #3578 <https://redmine.postgresql.org/issues/3578>`_ - Ensure sql for Role should be visible in SQL panel for GPDB.
|
||||||
|
@ -7,17 +7,32 @@ import Backform from 'pgadmin.backform';
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import queryToolActions from 'sources/sqleditor/query_tool_actions';
|
import queryToolActions from 'sources/sqleditor/query_tool_actions';
|
||||||
import filterDialogModel from 'sources/sqleditor/filter_dialog_model';
|
import filterDialogModel from 'sources/sqleditor/filter_dialog_model';
|
||||||
|
import {handleQueryToolAjaxError} from 'sources/sqleditor/query_tool_http_error_handler';
|
||||||
|
|
||||||
let FilterDialog = {
|
let FilterDialog = {
|
||||||
'dialog': function(handler) {
|
geturl: function(transId, reconnect) {
|
||||||
|
let url = url_for('sqleditor.get_filter_data', {
|
||||||
|
'trans_id': transId,
|
||||||
|
});
|
||||||
|
|
||||||
|
if(reconnect) {
|
||||||
|
url += '?connect=1';
|
||||||
|
}
|
||||||
|
|
||||||
|
return url;
|
||||||
|
},
|
||||||
|
|
||||||
|
'dialog': function(handler, reconnect) {
|
||||||
let title = gettext('Sort/Filter options');
|
let title = gettext('Sort/Filter options');
|
||||||
axios.get(
|
|
||||||
url_for('sqleditor.get_filter_data', {
|
$.ajax({
|
||||||
'trans_id': handler.transId,
|
url: this.geturl(handler.transId, reconnect),
|
||||||
}),
|
headers: {
|
||||||
{ headers: {'Cache-Control' : 'no-cache'} }
|
'Cache-Control' : 'no-cache',
|
||||||
).then(function (res) {
|
},
|
||||||
let response = res.data.data.result;
|
})
|
||||||
|
.done(function (res) {
|
||||||
|
let response = res.data.result;
|
||||||
|
|
||||||
// Check the alertify dialog already loaded then delete it to clear
|
// Check the alertify dialog already loaded then delete it to clear
|
||||||
// the cache
|
// the cache
|
||||||
@ -234,6 +249,9 @@ let FilterDialog = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Alertify.filterDialog(title).resizeTo('65%', '60%');
|
Alertify.filterDialog(title).resizeTo('65%', '60%');
|
||||||
|
})
|
||||||
|
.fail(function(e) {
|
||||||
|
handleQueryToolAjaxError(pgAdmin, handler, e, '_show_filter', [], true);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -1526,7 +1526,11 @@ def get_filter_data(trans_id):
|
|||||||
Args:
|
Args:
|
||||||
trans_id: unique transaction id
|
trans_id: unique transaction id
|
||||||
"""
|
"""
|
||||||
return FilterDialog.get(*check_transaction_status(trans_id))
|
|
||||||
|
status, error_msg, conn, trans_obj, session_ob = \
|
||||||
|
check_transaction_status(trans_id)
|
||||||
|
|
||||||
|
return FilterDialog.get(status, error_msg, conn, trans_obj, session_ob)
|
||||||
|
|
||||||
|
|
||||||
@blueprint.route(
|
@blueprint.route(
|
||||||
@ -1541,8 +1545,12 @@ def set_filter_data(trans_id):
|
|||||||
Args:
|
Args:
|
||||||
trans_id: unique transaction id
|
trans_id: unique transaction id
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
status, error_msg, conn, trans_obj, session_ob = \
|
||||||
|
check_transaction_status(trans_id)
|
||||||
|
|
||||||
return FilterDialog.save(
|
return FilterDialog.save(
|
||||||
*check_transaction_status(trans_id),
|
status, error_msg, conn, trans_obj, session_ob,
|
||||||
request=request,
|
request=request,
|
||||||
trans_id=trans_id
|
trans_id=trans_id
|
||||||
)
|
)
|
||||||
|
@ -550,45 +550,40 @@ class TableCommand(GridCommand):
|
|||||||
all_sorted_columns = []
|
all_sorted_columns = []
|
||||||
data_sorting = self.get_data_sorting()
|
data_sorting = self.get_data_sorting()
|
||||||
all_columns = []
|
all_columns = []
|
||||||
if conn.connected():
|
# Fetch the primary key column names
|
||||||
|
query = render_template(
|
||||||
|
"/".join([self.sql_path, 'primary_keys.sql']),
|
||||||
|
obj_id=self.obj_id
|
||||||
|
)
|
||||||
|
|
||||||
# Fetch the primary key column names
|
status, result = conn.execute_dict(query)
|
||||||
query = render_template(
|
|
||||||
"/".join([self.sql_path, 'primary_keys.sql']),
|
if not status:
|
||||||
obj_id=self.obj_id
|
raise Exception(result)
|
||||||
|
|
||||||
|
for row in result['rows']:
|
||||||
|
all_columns.append(row['attname'])
|
||||||
|
all_sorted_columns.append(
|
||||||
|
{
|
||||||
|
'name': row['attname'],
|
||||||
|
'order': self.get_pk_order()
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
status, result = conn.execute_dict(query)
|
# Fetch the rest of the column names
|
||||||
if not status:
|
query = render_template(
|
||||||
raise Exception(result)
|
"/".join([self.sql_path, 'get_columns.sql']),
|
||||||
|
obj_id=self.obj_id
|
||||||
|
)
|
||||||
|
status, result = conn.execute_dict(query)
|
||||||
|
if not status:
|
||||||
|
raise Exception(result)
|
||||||
|
|
||||||
for row in result['rows']:
|
for row in result['rows']:
|
||||||
|
# Only append if not already present in the list
|
||||||
|
if row['attname'] not in all_columns:
|
||||||
all_columns.append(row['attname'])
|
all_columns.append(row['attname'])
|
||||||
all_sorted_columns.append(
|
|
||||||
{
|
|
||||||
'name': row['attname'],
|
|
||||||
'order': self.get_pk_order()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
# Fetch the rest of the column names
|
|
||||||
query = render_template(
|
|
||||||
"/".join([self.sql_path, 'get_columns.sql']),
|
|
||||||
obj_id=self.obj_id
|
|
||||||
)
|
|
||||||
status, result = conn.execute_dict(query)
|
|
||||||
if not status:
|
|
||||||
raise Exception(result)
|
|
||||||
|
|
||||||
for row in result['rows']:
|
|
||||||
# Only append if not already present in the list
|
|
||||||
if row['attname'] not in all_columns:
|
|
||||||
all_columns.append(row['attname'])
|
|
||||||
else:
|
|
||||||
raise Exception(
|
|
||||||
gettext('Not connected to server or connection with the '
|
|
||||||
'server has been closed.')
|
|
||||||
)
|
|
||||||
# If user has custom data sorting then pass as it as it is
|
# If user has custom data sorting then pass as it as it is
|
||||||
if data_sorting and len(data_sorting) > 0:
|
if data_sorting and len(data_sorting) > 0:
|
||||||
all_sorted_columns = data_sorting
|
all_sorted_columns = data_sorting
|
||||||
|
@ -3022,8 +3022,17 @@ define('tools.querytool', [
|
|||||||
|
|
||||||
// This function will show the filter in the text area.
|
// This function will show the filter in the text area.
|
||||||
_show_filter: function() {
|
_show_filter: function() {
|
||||||
let self = this;
|
let self = this,
|
||||||
FilterHandler.dialog(self);
|
reconnect = false;
|
||||||
|
|
||||||
|
/* When server is disconnected and connected, connection is lost,
|
||||||
|
* To reconnect pass true
|
||||||
|
*/
|
||||||
|
if (arguments.length > 0 &&
|
||||||
|
arguments[arguments.length - 1] == 'connect') {
|
||||||
|
reconnect = true;
|
||||||
|
}
|
||||||
|
FilterHandler.dialog(self, reconnect);
|
||||||
},
|
},
|
||||||
|
|
||||||
// This function will include the filter by selection.
|
// This function will include the filter by selection.
|
||||||
|
@ -11,9 +11,11 @@
|
|||||||
import pickle
|
import pickle
|
||||||
import simplejson as json
|
import simplejson as json
|
||||||
from flask_babelex import gettext
|
from flask_babelex import gettext
|
||||||
|
from flask import current_app
|
||||||
from pgadmin.utils.ajax import make_json_response, internal_server_error
|
from pgadmin.utils.ajax import make_json_response, internal_server_error
|
||||||
from pgadmin.tools.sqleditor.utils.update_session_grid_transaction import \
|
from pgadmin.tools.sqleditor.utils.update_session_grid_transaction import \
|
||||||
update_session_grid_transaction
|
update_session_grid_transaction
|
||||||
|
from pgadmin.utils.exception import ConnectionLost, SSHTunnelConnectionLost
|
||||||
|
|
||||||
|
|
||||||
class FilterDialog(object):
|
class FilterDialog(object):
|
||||||
@ -32,7 +34,16 @@ class FilterDialog(object):
|
|||||||
if status and conn is not None and \
|
if status and conn is not None and \
|
||||||
trans_obj is not None and session_obj is not None:
|
trans_obj is not None and session_obj is not None:
|
||||||
msg = gettext('Success')
|
msg = gettext('Success')
|
||||||
columns, column_list = trans_obj.get_all_columns_with_order(conn)
|
|
||||||
|
try:
|
||||||
|
columns, column_list = \
|
||||||
|
trans_obj.get_all_columns_with_order(conn)
|
||||||
|
except (ConnectionLost, SSHTunnelConnectionLost):
|
||||||
|
raise
|
||||||
|
except Exception as e:
|
||||||
|
current_app.logger.error(e)
|
||||||
|
raise
|
||||||
|
|
||||||
sql = trans_obj.get_filter()
|
sql = trans_obj.get_filter()
|
||||||
else:
|
else:
|
||||||
status = False
|
status = False
|
||||||
|
Loading…
Reference in New Issue
Block a user