fix?
This commit is contained in:
parent
c56cfab46d
commit
d6da2bb587
|
@ -345,52 +345,47 @@ class Admin::GalleriesController < OrbitAdminController
|
||||||
|
|
||||||
|
|
||||||
def upload_process
|
def upload_process
|
||||||
if @@upload_success == true
|
if $upload_success == true
|
||||||
count = @@image_unprocessed.length
|
count = AlbumUnprocess.all.count
|
||||||
Thread.new do
|
Thread.new do
|
||||||
begin
|
begin
|
||||||
@@start = true
|
@@start = true
|
||||||
@@image_unprocessed.each_with_index do |image,i|
|
album_unprocess = AlbumUnprocess.all
|
||||||
@@progress_filename = @@file[i].original_filename
|
album_unprocess.each_with_index do |image,i|
|
||||||
image.file = @@file[i]
|
@@progress_filename = image.file.original_filename
|
||||||
image.save!
|
album = AlbumImage.where(id: image.album_id)
|
||||||
|
album.file = image.file
|
||||||
|
album.save!
|
||||||
@@progress_percent = ((i+1)*100.0/count).floor.to_s + '%'
|
@@progress_percent = ((i+1)*100.0/count).floor.to_s + '%'
|
||||||
end
|
end
|
||||||
|
AlbumUnprocess.delete_all
|
||||||
rescue => e
|
rescue => e
|
||||||
puts e.inspect
|
puts e.inspect
|
||||||
end
|
end
|
||||||
@@file = []
|
$upload_success = false
|
||||||
@@image_unprocessed = []
|
|
||||||
@upload_success = false
|
|
||||||
@@finish = true
|
@@finish = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def start_upload_process
|
def start_upload_process
|
||||||
@@upload_success = true
|
$upload_success = true
|
||||||
sleep 0.01
|
|
||||||
render :json => {}.to_json
|
render :json => {}.to_json
|
||||||
end
|
end
|
||||||
def init_upload
|
def init_upload
|
||||||
@@image_unprocessed = []
|
|
||||||
@@start = false
|
@@start = false
|
||||||
@@finish = false
|
@@finish = false
|
||||||
@@file = []
|
|
||||||
@@progress_percent = '0%'
|
@@progress_percent = '0%'
|
||||||
@@progress_filename = 'processing!!'
|
@@progress_filename = 'processing!!'
|
||||||
render :json => {}.to_json
|
render :json => {}.to_json
|
||||||
end
|
end
|
||||||
def upload_image
|
def upload_image
|
||||||
sleep 0.01
|
album = Album.find(params[:album_id])
|
||||||
if !(@@image_unprocessed.nil?)
|
files = params['files']
|
||||||
album = Album.find(params[:album_id])
|
files.each do |file|
|
||||||
files = params['files']
|
image = album.album_images.new
|
||||||
files.each do |file|
|
image.tags = (album.tags rescue [])
|
||||||
image = album.album_images.new
|
AlbumUnprocess.create(album_id:image.id,file:file)
|
||||||
@@file << file
|
image.save!
|
||||||
image.tags = (album.tags rescue [])
|
|
||||||
@@image_unprocessed << image
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
render :json=>{"files"=>[{}]}.to_json
|
render :json=>{"files"=>[{}]}.to_json
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
class AlbumUnprocess
|
||||||
|
include Mongoid::Document
|
||||||
|
include Mongoid::Timestamps
|
||||||
|
|
||||||
|
field :album_id
|
||||||
|
field :file
|
||||||
|
end
|
Loading…
Reference in New Issue