fix for import thread
This commit is contained in:
parent
ada9e05f51
commit
9cee46cd13
|
@ -171,13 +171,16 @@ end
|
||||||
end
|
end
|
||||||
Rails.logger.info "rake universal_table_tasks:import[#{tmp_path},#{table_id},#{site_locales}]"
|
Rails.logger.info "rake universal_table_tasks:import[#{tmp_path},#{table_id},#{site_locales}]"
|
||||||
# Call the Rake task with file path
|
# Call the Rake task with file path
|
||||||
system("rake universal_table_tasks:import[#{tmp_path},#{table_id},#{site_locales}]")
|
Thread.new do
|
||||||
|
system("rake universal_table_tasks:import[#{tmp_path},#{table_id},#{site_locales}] >> #{Rails.root}/log/rake.log &")
|
||||||
|
end
|
||||||
|
|
||||||
render json: {
|
render json: {
|
||||||
success: true,
|
success: true,
|
||||||
totalCount: sheet.count - 3,
|
totalCount: sheet.count - 3,
|
||||||
id: table.id.to_s
|
id: table.id.to_s
|
||||||
}.to_json
|
}.to_json
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def new_entry
|
def new_entry
|
||||||
|
|
|
@ -37,6 +37,12 @@
|
||||||
<br />
|
<br />
|
||||||
<div style="text-align: center;">Importing <span class="current-number">0</span> / <span class="total-number">0</span></div>
|
<div style="text-align: center;">Importing <span class="current-number">0</span> / <span class="total-number">0</span></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="import-complete-zone" style="text-align: center; display:none;">
|
||||||
|
<span class="msg">Imported successfully!!!</span>
|
||||||
|
</div>
|
||||||
|
<div id="import-error-zone" style="text-align: center; display:none;">
|
||||||
|
<span class="msg"></span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button class="btn" id="import-modal-close-btn" style="display:none;" data-dismiss="modal" aria-hidden="true">Close</button>
|
<button class="btn" id="import-modal-close-btn" style="display:none;" data-dismiss="modal" aria-hidden="true">Close</button>
|
||||||
|
@ -48,7 +54,10 @@
|
||||||
checkForImportThread = null,
|
checkForImportThread = null,
|
||||||
importWaitZone = $("#import-wait-zone"),
|
importWaitZone = $("#import-wait-zone"),
|
||||||
importModalBtn = $("#import-modal-close-btn"),
|
importModalBtn = $("#import-modal-close-btn"),
|
||||||
|
importCompleteZone = $("#import-complete-zone"),
|
||||||
|
importErrorZone = $("#import-error-zone"),
|
||||||
currentNumber = importWaitZone.find(".current-number");
|
currentNumber = importWaitZone.find(".current-number");
|
||||||
|
totalNumber = importWaitZone.find(".total-number")
|
||||||
processManager = new ProcessManager();
|
processManager = new ProcessManager();
|
||||||
$("form.import_from_excel_form").on("submit",function(){
|
$("form.import_from_excel_form").on("submit",function(){
|
||||||
var form = this;
|
var form = this;
|
||||||
|
@ -57,11 +66,16 @@
|
||||||
importModal.modal("show");
|
importModal.modal("show");
|
||||||
importWaitZone.show();
|
importWaitZone.show();
|
||||||
importModalBtn.hide();
|
importModalBtn.hide();
|
||||||
|
importErrorZone.hide();
|
||||||
|
importCompleteZone.hide();
|
||||||
|
totalNumber.text("0");
|
||||||
|
currentNumber.text("0");
|
||||||
|
importWaitZone.find("img").show();
|
||||||
$(this).ajaxSubmit({
|
$(this).ajaxSubmit({
|
||||||
dataType : "json",
|
dataType : "json",
|
||||||
success : function(data){
|
success : function(data){
|
||||||
if(data.success){
|
if(data.success){
|
||||||
importWaitZone.find(".total-number").text(data.totalCount);
|
totalNumber.text(data.totalCount);
|
||||||
checkForThread = new Process(function(){
|
checkForThread = new Process(function(){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url : "/admin/universal_tables/checkforimportthread",
|
url : "/admin/universal_tables/checkforimportthread",
|
||||||
|
@ -72,17 +86,21 @@
|
||||||
currentNumber.text(threadData.currentCount)
|
currentNumber.text(threadData.currentCount)
|
||||||
if(threadData.currentCount >= threadData.totalCount){
|
if(threadData.currentCount >= threadData.totalCount){
|
||||||
checkForThread.kill();
|
checkForThread.kill();
|
||||||
importWaitZone.find(".msg").text("Imported successfully!!!");
|
importWaitZone.hide();
|
||||||
|
importCompleteZone.show();
|
||||||
importWaitZone.find("img").hide();
|
importWaitZone.find("img").hide();
|
||||||
importModalBtn.show();
|
importModalBtn.show();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
checkForThread.setTimeInterval(1000);
|
checkForThread.setTimeInterval(2000);
|
||||||
checkForThread.setRepeat(Process.CONSTANTS.REPEAT_INFINITE);
|
checkForThread.setRepeat(Process.CONSTANTS.REPEAT_INFINITE);
|
||||||
processManager.queue(checkForThread);
|
processManager.queue(checkForThread);
|
||||||
}else{
|
}else{
|
||||||
importWaitZone.find(".msg").text(data.msg)
|
importWaitZone.hide();
|
||||||
|
importErrorZone.show();
|
||||||
|
importModalBtn.show();
|
||||||
|
importErrorZone.find(".msg").text(data.msg);
|
||||||
}
|
}
|
||||||
form.reset();
|
form.reset();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue