77 lines
2.4 KiB
Plaintext
77 lines
2.4 KiB
Plaintext
<%= render_filter @filter_fields, "index_table" %>
|
|
<span id="index_table">
|
|
<%= render 'index'%>
|
|
</span>
|
|
|
|
<%= render 'layouts/delete_modal', delete_options: @delete_options %>
|
|
|
|
<div id="downloadModal" data-backdrop="static" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="downloadModalLabel" aria-hidden="true">
|
|
<div class="modal-header">
|
|
<h3 id="downloadModalLabel">Download</h3>
|
|
</div>
|
|
<div class="modal-body">
|
|
<p id="wait-zone" style="text-align: center;">
|
|
Please wait while we prepare your download. This may take a while.
|
|
<br />
|
|
<img src="/assets/spin.gif" />
|
|
</p>
|
|
<p id="link-zone" style="display: none; text-align: center;">
|
|
Please click the link below to download.
|
|
<br />
|
|
<a href="" id="download-link" target="_blank">Download</a>
|
|
</p>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button class="btn" id="modal-close-btn" style="display:none;" data-dismiss="modal" aria-hidden="true">Close</button>
|
|
</div>
|
|
</div>
|
|
<script type="text/javascript" src="/assets/lib/process.manager.js"></script>
|
|
<script type="text/javascript">
|
|
|
|
var downloadModal = $("#downloadModal"),
|
|
checkForThread = null,
|
|
waitZone = $("#wait-zone"),
|
|
linkZone = $("#link-zone"),
|
|
downloadLink = $("a#download-link"),
|
|
modalBtn = $("#modal-close-btn"),
|
|
processManager = new ProcessManager();
|
|
|
|
$(document).on("click", ".export-xls", function(){
|
|
var link = $(this).attr("href"),
|
|
title = null,
|
|
id = $(this).data("survey-id");
|
|
|
|
linkZone.hide();
|
|
waitZone.show();
|
|
modalBtn.hide();
|
|
$.ajax({
|
|
url : link,
|
|
type : "get",
|
|
dataType : "json"
|
|
}).done(function(data){
|
|
title = data.title;
|
|
checkForThread = new Process(function(){
|
|
$.ajax({
|
|
url : "/admin/surveys/checkforthread",
|
|
type : "get",
|
|
data : {"survey_id" : id, "survey_title" : title},
|
|
dataType : "json"
|
|
}).done(function(data){
|
|
if(!data.status){
|
|
downloadLink.attr("href", "/uploads/survey_export/" + id + "/" + title + ".xlsx");
|
|
waitZone.hide();
|
|
linkZone.show();
|
|
modalBtn.show();
|
|
checkForThread.kill();
|
|
}
|
|
})
|
|
})
|
|
checkForThread.setTimeInterval(1000);
|
|
checkForThread.setRepeat(Process.CONSTANTS.REPEAT_INFINITE);
|
|
processManager.queue(checkForThread);
|
|
})
|
|
downloadModal.modal("show");
|
|
return false;
|
|
})
|
|
|
|
</script> |