mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-27 00:07:16 +00:00
Pastes dataTable now display only the latest clicked paste even if there were discarded queries
This commit is contained in:
parent
2dd69fbb25
commit
7763bfb4c7
3 changed files with 73 additions and 48 deletions
|
@ -811,7 +811,8 @@ def showsavedpaste():
|
||||||
|
|
||||||
@app.route("/showpreviewpaste/")
|
@app.route("/showpreviewpaste/")
|
||||||
def showpreviewpaste():
|
def showpreviewpaste():
|
||||||
return showpaste(max_preview_modal)
|
num = request.args.get('num', '')
|
||||||
|
return "|num|"+num+"|num|"+showpaste(max_preview_modal)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/getmoredata/")
|
@app.route("/getmoredata/")
|
||||||
|
|
|
@ -59,7 +59,10 @@ function deploy_source() {
|
||||||
<script>
|
<script>
|
||||||
var moduleName = "{{ moduleName }}";
|
var moduleName = "{{ moduleName }}";
|
||||||
var search_table;
|
var search_table;
|
||||||
|
var last_clicked_paste;
|
||||||
|
var can_change_modal_content = true;
|
||||||
$("#myTable_"+moduleName).attr('data-numElem', "{{ all_path|length }}");
|
$("#myTable_"+moduleName).attr('data-numElem', "{{ all_path|length }}");
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
$('[data-toggle="tooltip"]').tooltip();
|
$('[data-toggle="tooltip"]').tooltip();
|
||||||
|
|
||||||
|
@ -80,6 +83,7 @@ $(document).ready(function(){
|
||||||
|
|
||||||
// When the modal goes out, refresh it to normal content
|
// When the modal goes out, refresh it to normal content
|
||||||
$("#mymodal").on('hidden.bs.modal', function () {
|
$("#mymodal").on('hidden.bs.modal', function () {
|
||||||
|
can_change_modal_content = true;
|
||||||
$("#mymodalbody").html("<p>Loading paste information...</p>");
|
$("#mymodalbody").html("<p>Loading paste information...</p>");
|
||||||
var loading_gif = "<img id='loading-gif-modal' class='img-center' src=\"{{url_for('static', filename='image/loading.gif') }}\" height='26' width='26' style='margin: 4px;'>";
|
var loading_gif = "<img id='loading-gif-modal' class='img-center' src=\"{{url_for('static', filename='image/loading.gif') }}\" height='26' width='26' style='margin: 4px;'>";
|
||||||
$("#mymodalbody").append(loading_gif); // Show the loading GIF
|
$("#mymodalbody").append(loading_gif); // Show the loading GIF
|
||||||
|
@ -128,8 +132,14 @@ $(document).ready(function(){
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
var modal=$(this);
|
var modal=$(this);
|
||||||
var url = " {{ url_for('showpreviewpaste') }}?paste=" + $(this).attr('data-path') + "&num=" + $(this).attr('data-num');
|
var url = " {{ url_for('showpreviewpaste') }}?paste=" + $(this).attr('data-path') + "&num=" + $(this).attr('data-num');
|
||||||
|
last_clicked_paste = $(this).attr('data-num');
|
||||||
$.get(url, function (data) {
|
$.get(url, function (data) {
|
||||||
|
|
||||||
|
// verify that the reveived data is really the current clicked paste. Otherwise, ignore it.
|
||||||
|
var received_num = parseInt(data.split("|num|")[1]);
|
||||||
|
if (received_num == last_clicked_paste && can_change_modal_content) {
|
||||||
|
can_change_modal_content = false;
|
||||||
|
|
||||||
// clear data by removing html, body, head tags. prevent dark modal background stack bug.
|
// clear data by removing html, body, head tags. prevent dark modal background stack bug.
|
||||||
var cleared_data = data.split("<body>")[1].split("</body>")[0];
|
var cleared_data = data.split("<body>")[1].split("</body>")[0];
|
||||||
$("#mymodalbody").html(cleared_data);
|
$("#mymodalbody").html(cleared_data);
|
||||||
|
@ -155,6 +165,9 @@ $(document).ready(function(){
|
||||||
update_preview();
|
update_preview();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else if (can_change_modal_content) {
|
||||||
|
$("#mymodalbody").html("Ignoring previous not finished query of paste #" + received_num);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} );
|
} );
|
||||||
|
|
|
@ -128,7 +128,8 @@
|
||||||
<!-- enable tooltip and dataTable -->
|
<!-- enable tooltip and dataTable -->
|
||||||
<script>
|
<script>
|
||||||
var search_table;
|
var search_table;
|
||||||
|
var last_clicked_paste;
|
||||||
|
var can_change_modal_content = true;
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
$('[data-toggle="tooltip"]').tooltip();
|
$('[data-toggle="tooltip"]').tooltip();
|
||||||
|
@ -184,6 +185,7 @@
|
||||||
|
|
||||||
// When the modal goes out, refresh it to normal content
|
// When the modal goes out, refresh it to normal content
|
||||||
$("#mymodal").on('hidden.bs.modal', function () {
|
$("#mymodal").on('hidden.bs.modal', function () {
|
||||||
|
can_change_modal_content = true;
|
||||||
$("#mymodalbody").html("<p>Loading paste information...</p>");
|
$("#mymodalbody").html("<p>Loading paste information...</p>");
|
||||||
var loading_gif = "<img id='loading-gif-modal' class='img-center' src=\"{{url_for('static', filename='image/loading.gif') }}\" height='26' width='26' style='margin: 4px;'>";
|
var loading_gif = "<img id='loading-gif-modal' class='img-center' src=\"{{url_for('static', filename='image/loading.gif') }}\" height='26' width='26' style='margin: 4px;'>";
|
||||||
$("#mymodalbody").append(loading_gif); // Show the loading GIF
|
$("#mymodalbody").append(loading_gif); // Show the loading GIF
|
||||||
|
@ -228,8 +230,14 @@
|
||||||
$("[data-toggle='modal']").off('click.openmodal').on("click.openmodal", function (event) {
|
$("[data-toggle='modal']").off('click.openmodal').on("click.openmodal", function (event) {
|
||||||
var modal=$(this);
|
var modal=$(this);
|
||||||
var url = " {{ url_for('showpreviewpaste') }}?paste=" + $(this).attr('data-path') + "&num=" + $(this).attr('data-num');
|
var url = " {{ url_for('showpreviewpaste') }}?paste=" + $(this).attr('data-path') + "&num=" + $(this).attr('data-num');
|
||||||
|
last_clicked_paste = $(this).attr('data-num');
|
||||||
$.get(url, function (data) {
|
$.get(url, function (data) {
|
||||||
|
|
||||||
|
// verify that the reveived data is really the current clicked paste. Otherwise, ignore it.
|
||||||
|
var received_num = parseInt(data.split("|num|")[1]);
|
||||||
|
if (received_num == last_clicked_paste && can_change_modal_content) {
|
||||||
|
can_change_modal_content = false;
|
||||||
|
|
||||||
// clear data by removing html, body, head tags. prevent dark modal background stack bug.
|
// clear data by removing html, body, head tags. prevent dark modal background stack bug.
|
||||||
var cleared_data = data.split("<body>")[1].split("</body>")[0];
|
var cleared_data = data.split("<body>")[1].split("</body>")[0];
|
||||||
$("#mymodalbody").html(cleared_data);
|
$("#mymodalbody").html(cleared_data);
|
||||||
|
@ -255,6 +263,9 @@
|
||||||
update_preview();
|
update_preview();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else if (can_change_modal_content) {
|
||||||
|
$("#mymodalbody").html("Ignoring previous not finished query of paste #" + received_num);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} );
|
} );
|
||||||
|
|
Loading…
Reference in a new issue