diff --git a/app/controllers/admin/surveys_controller.rb b/app/controllers/admin/surveys_controller.rb index aee9932..5c5454e 100644 --- a/app/controllers/admin/surveys_controller.rb +++ b/app/controllers/admin/surveys_controller.rb @@ -145,14 +145,25 @@ class Admin::SurveysController < OrbitAdminController # redirect_to panel_survey_back_end_surveys_url(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options]) end - def export + def checkforthread + render :json => {"status" => @download_thread.alive?}.to_json + end - @chart_data, @survey_questions, @survey_answers = @survey.generate_chart_data - respond_to do |format| - format.xlsx { - response.headers['Content-Disposition'] = 'attachment; filename="export.xlsx"' - } + def export + @download_thread = Thread.new do + # %x[rake survey_tasks:prepare_download[#{@survey.id}]] + (1..10).each do |i| + sleep(1) + end end + @download_thread.join + render :json => {"success" => true}.to_json + # @chart_data, @survey_questions, @survey_answers = @survey.generate_chart_data + # respond_to do |format| + # format.xlsx { + # response.headers['Content-Disposition'] = 'attachment; filename="export.xlsx"' + # } + # end end diff --git a/app/views/admin/surveys/_index.html.erb b/app/views/admin/surveys/_index.html.erb index 8731df0..626fb83 100644 --- a/app/views/admin/surveys/_index.html.erb +++ b/app/views/admin/surveys/_index.html.erb @@ -30,7 +30,7 @@