fixed import
This commit is contained in:
parent
a43523d91f
commit
007da54954
|
|
@ -124,7 +124,11 @@ end
|
||||||
|
|
||||||
def checkforimportthread
|
def checkforimportthread
|
||||||
utable = UTable.find(params[:utable_id])
|
utable = UTable.find(params[:utable_id])
|
||||||
render :json => {"currentCount" => utable.current_xlsx_value, "totalCount" => utable.table_entries.count}.to_json
|
render :json => {
|
||||||
|
"currentCount" => utable.current_xlsx_value,
|
||||||
|
"totalCount" => utable.table_entries.count,
|
||||||
|
"id" => utable.id.to_s
|
||||||
|
}.to_json
|
||||||
end
|
end
|
||||||
|
|
||||||
def export_data
|
def export_data
|
||||||
|
|
@ -177,8 +181,7 @@ end
|
||||||
|
|
||||||
render json: {
|
render json: {
|
||||||
success: true,
|
success: true,
|
||||||
totalCount: sheet.count - 3,
|
totalCount: sheet.count - 3
|
||||||
id: table.id.to_s
|
|
||||||
}.to_json
|
}.to_json
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -56,8 +56,9 @@
|
||||||
importModalBtn = $("#import-modal-close-btn"),
|
importModalBtn = $("#import-modal-close-btn"),
|
||||||
importCompleteZone = $("#import-complete-zone"),
|
importCompleteZone = $("#import-complete-zone"),
|
||||||
importErrorZone = $("#import-error-zone"),
|
importErrorZone = $("#import-error-zone"),
|
||||||
currentNumber = importWaitZone.find(".current-number");
|
currentNumber = importWaitZone.find(".current-number"),
|
||||||
totalNumber = importWaitZone.find(".total-number")
|
totalNumber = importWaitZone.find(".total-number"),
|
||||||
|
firstData = null,
|
||||||
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;
|
||||||
|
|
@ -74,28 +75,30 @@
|
||||||
$(this).ajaxSubmit({
|
$(this).ajaxSubmit({
|
||||||
dataType : "json",
|
dataType : "json",
|
||||||
success : function(data){
|
success : function(data){
|
||||||
|
firstData = data;
|
||||||
if(data.success){
|
if(data.success){
|
||||||
totalNumber.text(data.totalCount);
|
totalNumber.text(data.totalCount);
|
||||||
checkForThread = new Process(function(){
|
checkForImportThread = new Process(function(){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url : "/admin/universal_tables/checkforimportthread",
|
url : "/admin/universal_tables/checkforimportthread",
|
||||||
type : "get",
|
type : "get",
|
||||||
data : {"utable_id" : tableID},
|
data : {"utable_id" : tableID},
|
||||||
dataType : "json"
|
dataType : "json"
|
||||||
}).done(function(threadData){
|
}).done(function(threadData){
|
||||||
currentNumber.text(threadData.currentCount)
|
currentNumber.text(threadData.currentCount);
|
||||||
if(threadData.currentCount >= threadData.totalCount){
|
if(threadData.currentCount >= firstData.totalCount){
|
||||||
checkForThread.kill();
|
checkForImportThread.kill();
|
||||||
importWaitZone.hide();
|
importWaitZone.hide();
|
||||||
importCompleteZone.show();
|
importCompleteZone.show();
|
||||||
importWaitZone.find("img").hide();
|
importWaitZone.find("img").hide();
|
||||||
importModalBtn.show();
|
importModalBtn.show();
|
||||||
|
$("tr#table_" + threadData.id + " td:eq(2)").text(threadData.totalCount);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
checkForThread.setTimeInterval(2000);
|
checkForImportThread.setTimeInterval(3000);
|
||||||
checkForThread.setRepeat(Process.CONSTANTS.REPEAT_INFINITE);
|
checkForImportThread.setRepeat(Process.CONSTANTS.REPEAT_INFINITE);
|
||||||
processManager.queue(checkForThread);
|
processManager.queue(checkForImportThread);
|
||||||
}else{
|
}else{
|
||||||
importWaitZone.hide();
|
importWaitZone.hide();
|
||||||
importErrorZone.show();
|
importErrorZone.show();
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,8 @@ Rails.application.routes.draw do
|
||||||
get "/universal_tables/get_mindmaps", to: 'universal_tables#get_mindmaps'
|
get "/universal_tables/get_mindmaps", to: 'universal_tables#get_mindmaps'
|
||||||
patch "/universal_tables/update_entry", to: 'universal_tables#update_entry'
|
patch "/universal_tables/update_entry", to: 'universal_tables#update_entry'
|
||||||
post "/universal_tables/import_data_from_excel", to: 'universal_tables#import_data_from_excel'
|
post "/universal_tables/import_data_from_excel", to: 'universal_tables#import_data_from_excel'
|
||||||
get "universal_tables/checkforthread", to: "universal_tables#checkforthread"
|
get "/universal_tables/checkforthread", to: "universal_tables#checkforthread"
|
||||||
get "universal_tables/checkforimportthread", to: "universal_tables#checkforimportthread"
|
get "/universal_tables/checkforimportthread", to: "universal_tables#checkforimportthread"
|
||||||
get "/universal_table/:id/mind_maps", to: "mind_maps#index"
|
get "/universal_table/:id/mind_maps", to: "mind_maps#index"
|
||||||
resources :universal_tables do
|
resources :universal_tables do
|
||||||
get "new_entry"
|
get "new_entry"
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,12 @@ namespace :universal_table_tasks do
|
||||||
end.to_h
|
end.to_h
|
||||||
|
|
||||||
sheet.each_with_index do |row, i|
|
sheet.each_with_index do |row, i|
|
||||||
next if i < 3 || row.cells.compact.map { |c| c.value.to_s.strip }.all?(&:blank?)
|
if i >= 3 && row.cells.all? { |c| c.nil? || c.value.to_s.strip.blank? }
|
||||||
|
table.inc(current_xlsx_value: 1)
|
||||||
|
next
|
||||||
|
end
|
||||||
|
|
||||||
|
next if i < 3
|
||||||
uid_val = row[0]&.value.to_s.strip rescue nil
|
uid_val = row[0]&.value.to_s.strip rescue nil
|
||||||
|
|
||||||
te = uid_val.present? ? TableEntry.where(uid: uid_val, u_table_id: table.id).first_or_initialize : TableEntry.new
|
te = uid_val.present? ? TableEntry.where(uid: uid_val, u_table_id: table.id).first_or_initialize : TableEntry.new
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue