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

pull/3/head
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 class="divider"></li>
<li> <li>
<a id="btn-auto-commit" href="#"> <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> <span> {{ _('Auto-Commit') }} </span>
</a> </a>
</li> </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 @login_required
def get_preferences(): def preferences(trans_id):
""" """
This method is used to get/put explain options from/to preferences This method is used to get/put explain options from/to preferences
Args:
trans_id: unique transaction id
""" """
if request.method == 'GET': 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( return make_json_response(
data={ data={
'explain_verbose': blueprint.explain_verbose.get(), 'explain_verbose': blueprint.explain_verbose.get(),

View File

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