Merge branch 'master' into 'master'
Master reverse upload feature to make it work See merge request !5
This commit is contained in:
commit
78d8b419e1
|
@ -1,3 +1,94 @@
|
||||||
|
function form_submit(e) {
|
||||||
|
//var form_submit1 = $('form#fileupload');
|
||||||
|
//var url_submit = form_submit1.attr('action');
|
||||||
|
var temp_length = $('#file-list').find('li.template-upload').length
|
||||||
|
$.ajax({
|
||||||
|
type : "post",
|
||||||
|
url : "/admin/galleries/init_upload",
|
||||||
|
dataType : "json",
|
||||||
|
data:{all_length: temp_length},
|
||||||
|
async: false,
|
||||||
|
success: function()
|
||||||
|
{
|
||||||
|
},
|
||||||
|
error : function(data){
|
||||||
|
alert('init upload process failed, please try again later.')
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var length_upload
|
||||||
|
var count_upload
|
||||||
|
var send_start
|
||||||
|
$( 'form#fileupload' ).ajaxSuccess(function() {
|
||||||
|
if (typeof length_upload == "undefined"){
|
||||||
|
count_upload = 1
|
||||||
|
length_upload = $('#file-list').find('li.template-upload').length
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
count_upload ++
|
||||||
|
}
|
||||||
|
console.log('l')
|
||||||
|
console.log(length_upload)
|
||||||
|
console.log(count_upload)
|
||||||
|
if (count_upload === length_upload){
|
||||||
|
send_start = undefined
|
||||||
|
$.ajax({
|
||||||
|
url : "/admin/galleries/start_upload_process",
|
||||||
|
dataType : "json",
|
||||||
|
type : "post",
|
||||||
|
error: function(){
|
||||||
|
alert('init upload process failed, please try again later.')
|
||||||
|
},
|
||||||
|
success: function(){
|
||||||
|
window.location.href = '/admin/galleries/upload_process'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function form_only_one_submit(e) {
|
||||||
|
//var form_submit1 = $('form#fileupload');
|
||||||
|
//var url_submit = form_submit1.attr('action');
|
||||||
|
var temp_length = 1
|
||||||
|
$.ajax({
|
||||||
|
type : "post",
|
||||||
|
url : "/admin/galleries/init_upload",
|
||||||
|
dataType : "json",
|
||||||
|
data:{all_length: temp_length},
|
||||||
|
async: false,
|
||||||
|
success: function()
|
||||||
|
{
|
||||||
|
},
|
||||||
|
error : function(data){
|
||||||
|
alert('init upload process failed, please try again later.')
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var length_upload
|
||||||
|
var count_upload
|
||||||
|
var send_start
|
||||||
|
$( 'form#fileupload' ).ajaxSuccess(function() {
|
||||||
|
if (typeof length_upload == "undefined"){
|
||||||
|
count_upload = 1
|
||||||
|
length_upload = 1
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
count_upload ++
|
||||||
|
}
|
||||||
|
if (count_upload === length_upload){
|
||||||
|
send_start = undefined
|
||||||
|
$.ajax({
|
||||||
|
url : "/admin/galleries/start_upload_process",
|
||||||
|
dataType : "json",
|
||||||
|
type : "post",
|
||||||
|
error: function(){
|
||||||
|
alert('init upload process failed, please try again later.')
|
||||||
|
},
|
||||||
|
success: function(){
|
||||||
|
window.location.href = '/admin/galleries/upload_process'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
!function ($) {
|
!function ($) {
|
||||||
$.fn.checkListLength = function (param){
|
$.fn.checkListLength = function (param){
|
||||||
_defaultSettings = {
|
_defaultSettings = {
|
||||||
|
@ -81,45 +172,7 @@ function translate(ele,pretext,text){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$(function() {
|
$(function() {
|
||||||
var length_upload
|
|
||||||
var count_upload
|
|
||||||
var send_start
|
|
||||||
$( 'form#fileupload' ).ajaxSuccess(function() {
|
|
||||||
if (typeof length_upload == "undefined"){
|
|
||||||
count_upload = 1
|
|
||||||
length_upload = $('#file-list').find('li.template-upload').length
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
count_upload ++
|
|
||||||
}
|
|
||||||
if (count_upload === length_upload){
|
|
||||||
send_start = undefined
|
|
||||||
$.ajax({
|
|
||||||
url : "/admin/galleries/start_upload_process",
|
|
||||||
dataType : "json",
|
|
||||||
type : "post",
|
|
||||||
error: function(){
|
|
||||||
alert('init upload process failed, please try again later.')
|
|
||||||
},
|
|
||||||
success: function(){
|
|
||||||
window.location.href = '/admin/galleries/upload_process'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
});
|
|
||||||
$( 'form#fileupload' ).ajaxSend(function() {
|
|
||||||
if (typeof send_start == "undefined"){
|
|
||||||
send_start = 1
|
|
||||||
$.ajax({
|
|
||||||
url : "/admin/galleries/init_upload",
|
|
||||||
dataType : "json",
|
|
||||||
type : "post",
|
|
||||||
error : function(data){
|
|
||||||
alert('init upload process failed, please try again later.')
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
});
|
|
||||||
var $container = $('.gallery'),
|
var $container = $('.gallery'),
|
||||||
$containerData = $container.data();
|
$containerData = $container.data();
|
||||||
$container.data("order-edit","0");
|
$container.data("order-edit","0");
|
||||||
|
|
|
@ -139,11 +139,15 @@ class Admin::GalleriesController < OrbitAdminController
|
||||||
render :text => ''
|
render :text => ''
|
||||||
end
|
end
|
||||||
def recreate_progress
|
def recreate_progress
|
||||||
|
if self.class.class_variable_defined? :@@start
|
||||||
if @@start
|
if @@start
|
||||||
render :json => {'percent' => (@@progress_percent rescue '0%'), 'filename' => (@@progress_filename rescue ''), 'finish' => (@@finish rescue false) }.to_json
|
render :json => {'percent' => (@@progress_percent rescue '0%'), 'filename' => (@@progress_filename rescue ''), 'finish' => (@@finish rescue false) }.to_json
|
||||||
else
|
else
|
||||||
render :json => {'percent' => '0%', 'filename' => '', 'finish' => false }.to_json
|
render :json => {'percent' => '0%', 'filename' => '', 'finish' => false }.to_json
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
render :json => {'percent' => '0%', 'filename' => '', 'finish' => false }.to_json
|
||||||
|
end
|
||||||
end
|
end
|
||||||
def index
|
def index
|
||||||
Album.each do |album|
|
Album.each do |album|
|
||||||
|
@ -381,16 +385,13 @@ class Admin::GalleriesController < OrbitAdminController
|
||||||
render :json => {}.to_json
|
render :json => {}.to_json
|
||||||
end
|
end
|
||||||
def upload_image
|
def upload_image
|
||||||
sleep 0.01
|
|
||||||
if !(@@image_unprocessed.nil?)
|
|
||||||
album = Album.find(params[:album_id])
|
album = Album.find(params[:album_id])
|
||||||
files = params['files']
|
files = params['files']
|
||||||
files.each do |file|
|
files.each do |file|
|
||||||
image = album.album_images.new
|
image = album.album_images.new
|
||||||
@@file << file
|
image.file = file
|
||||||
image.tags = (album.tags rescue [])
|
image.tags = (album.tags rescue [])
|
||||||
@@image_unprocessed << image
|
image.save!
|
||||||
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