Fixed issue change 'Auto Commit' option from preferences not reflacted properly on UI and also not set the class variable

This commit is contained in:
Akshay Joshi 2016-05-17 12:31:39 +05:30
parent 1606f1d8e8
commit 216b6b16b5
3 changed files with 79 additions and 62 deletions

View File

@ -111,7 +111,7 @@ body {
<li class="divider"></li>
<li>
<a id="btn-auto-commit" href="#">
<i class="auto-commit fa fa-check" aria-hidden="true"></i>
<i class="auto-commit fa fa-check visibility-hidden" aria-hidden="true"></i>
<span> {{ _('Auto-Commit') }} </span>
</a>
</li>

View File

@ -321,13 +321,26 @@ def start_query_tool(trans_id):
)
@blueprint.route('/query_tool/preferences', methods=["GET", "PUT"])
@blueprint.route('/query_tool/preferences/<int:trans_id>', methods=["GET", "PUT"])
@login_required
def get_preferences():
def preferences(trans_id):
"""
This method is used to get/put explain options from/to preferences
Args:
trans_id: unique transaction id
"""
if request.method == 'GET':
# Check the transaction and connection status
status, error_msg, conn, trans_obj, session_obj = check_transaction_status(trans_id)
if status and conn is not None \
and trans_obj is not None and session_obj is not None:
# Call the set_auto_commit method of transaction object
trans_obj.set_auto_commit(blueprint.auto_commit.get())
trans_obj.set_auto_rollback(blueprint.auto_rollback.get())
return make_json_response(
data={
'explain_verbose': blueprint.explain_verbose.get(),

View File

@ -305,8 +305,10 @@ define(
* values from preferences
*/
get_preferences: function() {
var self = this;
$.ajax({
url: "{{ url_for('sqleditor.index') }}" + "query_tool/preferences" ,
url: "{{ url_for('sqleditor.index') }}" + "query_tool/preferences/" + self.transId ,
method: 'GET',
async: false,
success: function(res) {
@ -863,7 +865,7 @@ define(
el: self.container,
handler: self
});
self.transId = self.container.data('transId');
self.transId = self.gridView.transId = self.container.data('transId');
self.gridView.editor_title = editor_title;
self.gridView.current_file = undefined;
@ -2409,6 +2411,7 @@ define(
var data = {
'explain_verbose': self.explain_verbose
};
$.ajax({
url: "{{ url_for('sqleditor.index') }}" + "query_tool/preferences" ,
method: 'PUT',
@ -2445,6 +2448,7 @@ define(
var data = {
'explain_costs': self.explain_costs
};
$.ajax({
url: "{{ url_for('sqleditor.index') }}" + "query_tool/preferences" ,
method: 'PUT',
@ -2480,6 +2484,7 @@ define(
var data = {
'explain_buffers': self.explain_buffers
};
$.ajax({
url: "{{ url_for('sqleditor.index') }}" + "query_tool/preferences" ,
method: 'PUT',
@ -2498,7 +2503,6 @@ define(
);
}
});
},
// This function will toggle "timing" option in explain
@ -2515,6 +2519,7 @@ define(
var data = {
'explain_timing': self.explain_timing
};
$.ajax({
url: "{{ url_for('sqleditor.index') }}" + "query_tool/preferences" ,
method: 'PUT',
@ -2533,7 +2538,6 @@ define(
);
}
});
}
}
);