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