survey/app/views/admin/surveys/index.html.erb

77 lines
2.4 KiB
Plaintext
Raw Permalink Normal View History

2014-10-06 05:55:25 +00:00
<%= render_filter @filter_fields, "index_table" %>
<span id="index_table">
<%= render 'index'%>
</span>
2017-04-11 06:10:01 +00:00
<%= render 'layouts/delete_modal', delete_options: @delete_options %>
2017-04-11 10:43:22 +00:00
<div id="downloadModal" data-backdrop="static" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="downloadModalLabel" aria-hidden="true">
2017-04-11 06:10:01 +00:00
<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>
2017-04-11 10:43:22 +00:00
<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>
2017-04-11 06:10:01 +00:00
</div>
<div class="modal-footer">
2017-04-11 10:43:22 +00:00
<button class="btn" id="modal-close-btn" style="display:none;" data-dismiss="modal" aria-hidden="true">Close</button>
2017-04-11 06:10:01 +00:00
</div>
</div>
2017-04-11 10:43:22 +00:00
<script type="text/javascript" src="/assets/lib/process.manager.js"></script>
2017-04-11 06:10:01 +00:00
<script type="text/javascript">
2017-04-11 10:43:22 +00:00
var downloadModal = $("#downloadModal"),
checkForThread = null,
waitZone = $("#wait-zone"),
linkZone = $("#link-zone"),
downloadLink = $("a#download-link"),
modalBtn = $("#modal-close-btn"),
processManager = new ProcessManager();
2017-04-11 06:10:01 +00:00
$(document).on("click", ".export-xls", function(){
2017-04-11 10:43:22 +00:00
var link = $(this).attr("href"),
title = null,
id = $(this).data("survey-id");
linkZone.hide();
waitZone.show();
modalBtn.hide();
2017-04-11 06:10:01 +00:00
$.ajax({
url : link,
type : "get",
dataType : "json"
}).done(function(data){
2017-04-11 10:43:22 +00:00
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);
2017-04-11 06:10:01 +00:00
})
downloadModal.modal("show");
return false;
})
</script>