mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-30 19:00:09 +00:00
started reworking the file load reporting scheme (still thinking)...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
7cd5321dd5
commit
25af190b24
70
ui/files.js
70
ui/files.js
@ -79,7 +79,20 @@ function statusNotify(prefix, loader, not_queued){
|
|||||||
}
|
}
|
||||||
return loader
|
return loader
|
||||||
.progress(function(){
|
.progress(function(){
|
||||||
var args = Array.apply(null, arguments)
|
var args = args2array(arguments)
|
||||||
|
|
||||||
|
var getter = args[args.length-1]
|
||||||
|
if(getter != null && getter.isResolved != null){
|
||||||
|
args.pop()
|
||||||
|
.done(function(){
|
||||||
|
report(args.join(': '))
|
||||||
|
})
|
||||||
|
.fail(function(){
|
||||||
|
// XXX
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if(prefix != null && prefix != ''){
|
if(prefix != null && prefix != ''){
|
||||||
args.splice(0, 0, prefix)
|
args.splice(0, 0, prefix)
|
||||||
}
|
}
|
||||||
@ -102,21 +115,23 @@ function statusNotify(prefix, loader, not_queued){
|
|||||||
//
|
//
|
||||||
// Will return "from" object.
|
// Will return "from" object.
|
||||||
function bubbleProgress(prefix, from, to, only_progress){
|
function bubbleProgress(prefix, from, to, only_progress){
|
||||||
|
only_progress = only_progress == null ? false : only_progress
|
||||||
|
|
||||||
from
|
from
|
||||||
.progress(function(){
|
.progress(function(){
|
||||||
var args = Array.apply(null, arguments)
|
var args = args2array(arguments)
|
||||||
prefix != null && args.splice(0, 0, prefix)
|
prefix != null && args.splice(0, 0, prefix)
|
||||||
to.notify.apply(to, args)
|
to.notify.apply(to, args)
|
||||||
})
|
})
|
||||||
|
|
||||||
if(only_progress == null){
|
if(!only_progress){
|
||||||
from
|
from
|
||||||
.done(function(){
|
.done(function(){
|
||||||
var args = Array.apply(null, arguments)
|
var args = args2array(arguments)
|
||||||
to.resolve.apply(to, args)
|
to.resolve.apply(to, args)
|
||||||
})
|
})
|
||||||
.fail(function(){
|
.fail(function(){
|
||||||
var args = Array.apply(null, arguments)
|
var args = args2array(arguments)
|
||||||
prefix != null && args.splice(0, 0, prefix)
|
prefix != null && args.splice(0, 0, prefix)
|
||||||
to.reject.apply(to, args)
|
to.reject.apply(to, args)
|
||||||
})
|
})
|
||||||
@ -150,16 +165,15 @@ function loadLatestFile(path, dfl, pattern, diff_pattern, default_data){
|
|||||||
//path = path == dfl ? '.' : path
|
//path = path == dfl ? '.' : path
|
||||||
path = pparts.join('/')
|
path = pparts.join('/')
|
||||||
|
|
||||||
var res = $.Deferred()
|
var tracker = $.Deferred()
|
||||||
|
|
||||||
if(dfl == ''){
|
if(dfl == ''){
|
||||||
return res.reject()
|
return tracker.reject()
|
||||||
}
|
}
|
||||||
|
|
||||||
// can't find diffs if can't list dirs...
|
// can't find diffs if can't list dirs...
|
||||||
if(window.listDir == null && (pattern != null || diff_pattern != null)){
|
if(window.listDir == null && (pattern != null || diff_pattern != null)){
|
||||||
res.notify('Unsupported', 'directory listing.')
|
return tracker.reject('listDir unsupported.')
|
||||||
return res.reject('listDir unsupported.')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// find the latest...
|
// find the latest...
|
||||||
@ -181,20 +195,27 @@ function loadLatestFile(path, dfl, pattern, diff_pattern, default_data){
|
|||||||
diff_pattern = RegExp(diff_pattern)
|
diff_pattern = RegExp(diff_pattern)
|
||||||
var diff_data = [diff_data]
|
var diff_data = [diff_data]
|
||||||
var diffs_names = $.map(listDir(path), function(e){
|
var diffs_names = $.map(listDir(path), function(e){
|
||||||
//return diff_pattern.test(e) ? e : null
|
|
||||||
return diff_pattern.test(e) && e.split('-')[0] >= base_date ? e : null
|
return diff_pattern.test(e) && e.split('-')[0] >= base_date ? e : null
|
||||||
}).sort()
|
}).sort()
|
||||||
diff = $.when.apply(null, $.map(diffs_names, function(e, i){
|
diff = $.when.apply(null, $.map(diffs_names, function(e, i){
|
||||||
return $.getJSON(path +'/'+ e)
|
var getter = $.getJSON(path +'/'+ e)
|
||||||
.done(function(data){
|
.done(function(data){
|
||||||
|
// NOTE: we are not using push here so as to
|
||||||
|
// keep the sort order...
|
||||||
diff_data[i+1] = data
|
diff_data[i+1] = data
|
||||||
res.notify('Loaded', e)
|
|
||||||
})
|
})
|
||||||
.fail(function(){
|
// XXX this is a hack...
|
||||||
// XXX should we kill the load here???
|
.always(function(){
|
||||||
res.notify('Loading', e, 'Error')
|
tracker.notify(e, getter)
|
||||||
})
|
})
|
||||||
|
/*
|
||||||
|
// XXX the problem here is if we miss this, then there
|
||||||
|
// is no chance to get it back...
|
||||||
|
tracker.notify(e, getter)
|
||||||
|
*/
|
||||||
|
return getter
|
||||||
}))
|
}))
|
||||||
|
// merge the diffs...
|
||||||
// NOTE: .then(...) handlers get different signature args
|
// NOTE: .then(...) handlers get different signature args
|
||||||
// depending on the number of arguments to .when(...)...
|
// depending on the number of arguments to .when(...)...
|
||||||
.then(function(){
|
.then(function(){
|
||||||
@ -204,31 +225,30 @@ function loadLatestFile(path, dfl, pattern, diff_pattern, default_data){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// load the main file and merge the diff with it...
|
// load the main file and merge the diff with it...
|
||||||
$.when(diff, $.getJSON(path +'/'+ file))
|
var getter = $.getJSON(path +'/'+ file)
|
||||||
|
.always(function(){
|
||||||
|
tracker.notify(file, getter)
|
||||||
|
})
|
||||||
|
$.when(diff, getter)
|
||||||
.done(function(_, json){
|
.done(function(_, json){
|
||||||
json = json[0]
|
json = json[0]
|
||||||
|
|
||||||
res.notify('Loaded', file)
|
|
||||||
|
|
||||||
// merge diffs...
|
// merge diffs...
|
||||||
if(Object.keys(diff_data).length != 0){
|
if(Object.keys(diff_data).length != 0){
|
||||||
$.extend(json, diff_data)
|
$.extend(json, diff_data)
|
||||||
res.notify('Merged')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
res.resolve(json)
|
tracker.resolve(json)
|
||||||
})
|
})
|
||||||
.fail(function(){
|
.fail(function(){
|
||||||
res.notify('Loading', file, 'Error')
|
|
||||||
|
|
||||||
if(default_data != null){
|
if(default_data != null){
|
||||||
return res.resolve(default_data)
|
tracker.resolve(default_data)
|
||||||
} else {
|
} else {
|
||||||
return res.reject(file)
|
tracker.reject()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
return res
|
return tracker
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
2
ui/ui.js
2
ui/ui.js
@ -472,7 +472,7 @@ function getProgressContainer(mode, parent){
|
|||||||
// Make or get progress bar by name...
|
// Make or get progress bar by name...
|
||||||
//
|
//
|
||||||
// Events:
|
// Events:
|
||||||
// - progressUpdate
|
// - progressUpdate (done, total)
|
||||||
// Triggered by user to update progress bar state.
|
// Triggered by user to update progress bar state.
|
||||||
//
|
//
|
||||||
// takes two arguments:
|
// takes two arguments:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user