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 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,25 +2411,26 @@ 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',
contentType: "application/json", contentType: "application/json",
data: JSON.stringify(data), data: JSON.stringify(data),
success: function(res) { success: function(res) {
if(res.success == undefined || !res.success) { if(res.success == undefined || !res.success) {
alertify.alert('Explain options error',
'{{ _('Error occurred while setting verbose option in explain') }}'
);
}
},
error: function(e) {
alertify.alert('Explain options error', alertify.alert('Explain options error',
'{{ _('Error occurred while setting verbose option in explain') }}' '{{ _('Error occurred while setting verbose option in explain') }}'
); );
return;
} }
}, });
error: function(e) {
alertify.alert('Explain options error',
'{{ _('Error occurred while setting verbose option in explain') }}'
);
return;
}
});
}, },
// This function will toggle "costs" option in explain // This function will toggle "costs" option in explain
@ -2445,24 +2448,25 @@ 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',
contentType: "application/json", contentType: "application/json",
data: JSON.stringify(data), data: JSON.stringify(data),
success: function(res) { success: function(res) {
if(res.success == undefined || !res.success) { if(res.success == undefined || !res.success) {
alertify.alert('Explain options error',
'{{ _('Error occurred while setting costs option in explain') }}'
);
}
},
error: function(e) {
alertify.alert('Explain options error', alertify.alert('Explain options error',
'{{ _('Error occurred while setting costs option in explain') }}' '{{ _('Error occurred while setting costs option in explain') }}'
); );
} }
}, });
error: function(e) {
alertify.alert('Explain options error',
'{{ _('Error occurred while setting costs option in explain') }}'
);
}
});
}, },
// This function will toggle "buffers" option in explain // This function will toggle "buffers" option in explain
@ -2480,25 +2484,25 @@ 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',
contentType: "application/json", contentType: "application/json",
data: JSON.stringify(data), data: JSON.stringify(data),
success: function(res) { success: function(res) {
if(res.success == undefined || !res.success) { if(res.success == undefined || !res.success) {
alertify.alert('Explain options error',
'{{ _('Error occurred while setting buffers option in explain') }}'
);
}
},
error: function(e) {
alertify.alert('Explain options error', alertify.alert('Explain options error',
'{{ _('Error occurred while setting buffers option in explain') }}' '{{ _('Error occurred while setting buffers option in explain') }}'
); );
} }
}, });
error: function(e) {
alertify.alert('Explain options error',
'{{ _('Error occurred while setting buffers option in explain') }}'
);
}
});
}, },
// This function will toggle "timing" option in explain // This function will toggle "timing" option in explain
@ -2515,25 +2519,25 @@ 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',
contentType: "application/json", contentType: "application/json",
data: JSON.stringify(data), data: JSON.stringify(data),
success: function(res) { success: function(res) {
if(res.success == undefined || !res.success) { if(res.success == undefined || !res.success) {
alertify.alert('Explain options error',
'{{ _('Error occurred while setting timing option in explain') }}'
);
}
},
error: function(e) {
alertify.alert('Explain options error', alertify.alert('Explain options error',
'{{ _('Error occurred while setting timing option in explain') }}' '{{ _('Error occurred while setting timing option in explain') }}'
); );
} }
}, });
error: function(e) {
alertify.alert('Explain options error',
'{{ _('Error occurred while setting timing option in explain') }}'
);
}
});
} }
} }
); );