mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-30 19:00:09 +00:00 
			
		
		
		
	fixed several bugs in tasks + started working on sort...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									588e3ccaf8
								
							
						
					
					
						commit
						e1390b2747
					
				| @ -513,8 +513,14 @@ actions.Actions({ | |||||||
| 	// XXX align to ribbon...
 | 	// XXX align to ribbon...
 | ||||||
| 
 | 
 | ||||||
| 	// XXX this also requires images...
 | 	// XXX this also requires images...
 | ||||||
|  | 	// XXX cache order???
 | ||||||
| 	sortImages: ['Sort/', | 	sortImages: ['Sort/', | ||||||
| 		function(method){  | 		function(method){  | ||||||
|  | 			if(this.images){ | ||||||
|  | 				// select method...
 | ||||||
|  | 				this.data.order = this.images.sortImages().reverse() | ||||||
|  | 			} | ||||||
|  | 			this.data.updateImagePositions() | ||||||
| 		}], | 		}], | ||||||
| 
 | 
 | ||||||
| 	// basic image editing...
 | 	// basic image editing...
 | ||||||
|  | |||||||
| @ -56,6 +56,8 @@ var FileSystemLoaderActions = actions.Actions({ | |||||||
| 
 | 
 | ||||||
| 		'image-file-pattern': '*+(jpg|jpeg|png|JPG|JPEG|PNG)', | 		'image-file-pattern': '*+(jpg|jpeg|png|JPG|JPEG|PNG)', | ||||||
| 
 | 
 | ||||||
|  | 		'image-file-read-stat': true, | ||||||
|  | 
 | ||||||
| 		// XXX if true and multiple indexes found, load only the first 
 | 		// XXX if true and multiple indexes found, load only the first 
 | ||||||
| 		// 		without merging...
 | 		// 		without merging...
 | ||||||
| 		'load-first-index-only': false, | 		'load-first-index-only': false, | ||||||
| @ -220,13 +222,38 @@ var FileSystemLoaderActions = actions.Actions({ | |||||||
| 				method: 'loadImages', | 				method: 'loadImages', | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
| 			glob(path + '/'+ this.config['image-file-pattern']) | 			glob(path + '/'+ this.config['image-file-pattern'],  | ||||||
|  | 					{stat: !!this.config['image-file-read-stat']}) | ||||||
| 				.on('error', function(err){ | 				.on('error', function(err){ | ||||||
| 					console.log('!!!!', err) | 					console.log('!!!!', err) | ||||||
| 				}) | 				}) | ||||||
|  | 				/* | ||||||
|  | 				.on('match', function(img){ | ||||||
|  | 					// XXX stat stuff...
 | ||||||
|  | 					fse.statSync(img) | ||||||
|  | 				}) | ||||||
|  | 				*/ | ||||||
| 				.on('end', function(lst){  | 				.on('end', function(lst){  | ||||||
| 					that.loadURLs(lst | 					that.loadURLs(lst, path) | ||||||
| 						.map(function(p){ return util.normalizePath(p) }), path) | 					// XXX do we need to normalize paths after we get them from glob??
 | ||||||
|  | 					//that.loadURLs(lst.map(pathlib.posix.normalize), path)
 | ||||||
|  | 					//that.loadURLs(lst
 | ||||||
|  | 					//	.map(function(p){ return util.normalizePath(p) }), path)
 | ||||||
|  | 
 | ||||||
|  | 					if(!!that.config['image-file-read-stat']){ | ||||||
|  | 						var stats = this.statCache | ||||||
|  | 						var p = pathlib.posix | ||||||
|  | 
 | ||||||
|  | 						that.images.forEach(function(gid, img){ | ||||||
|  | 							var stat = stats[p.join(img.base_path, img.path)] | ||||||
|  | 
 | ||||||
|  | 							img.atime = stat.atime | ||||||
|  | 							img.mtime = stat.mtime | ||||||
|  | 							img.ctime = stat.ctime | ||||||
|  | 
 | ||||||
|  | 							// XXX do we need anything else???
 | ||||||
|  | 						}) | ||||||
|  | 					} | ||||||
| 
 | 
 | ||||||
| 					// NOTE: we set it again because .loadURLs() does a clear
 | 					// NOTE: we set it again because .loadURLs() does a clear
 | ||||||
| 					// 		before it starts loading...
 | 					// 		before it starts loading...
 | ||||||
|  | |||||||
| @ -279,6 +279,9 @@ var MetadataUIActions = actions.Actions({ | |||||||
| 			// base
 | 			// base
 | ||||||
| 			'GID',  | 			'GID',  | ||||||
| 			'File Name', 'Parent Directory', 'Full Path', | 			'File Name', 'Parent Directory', 'Full Path', | ||||||
|  | 			'Date file created', 'Date file modified', 'Date file accessed', | ||||||
|  | 
 | ||||||
|  | 			'Index (ribbon)', 'Index (crop)', 'Index (global)', | ||||||
| 
 | 
 | ||||||
| 			// metadata...
 | 			// metadata...
 | ||||||
| 			'Make', 'Camera Model Name', 'Lens ID', 'Lens', 'Lens Profile Name', 'Focal Length', | 			'Make', 'Camera Model Name', 'Lens ID', 'Lens', 'Lens Profile Name', 'Focal Length', | ||||||
| @ -321,9 +324,9 @@ var MetadataUIActions = actions.Actions({ | |||||||
| 
 | 
 | ||||||
| 			// helpers...
 | 			// helpers...
 | ||||||
| 			var _cmp = function(a, b){ | 			var _cmp = function(a, b){ | ||||||
| 				a = field_order.indexOf(a[0].replace(/: $/, '')) | 				a = field_order.indexOf(a[0].replace(/^- |: $/g, '')) | ||||||
| 				a = a == -1 ? x : a | 				a = a == -1 ? x : a | ||||||
| 				b = field_order.indexOf(b[0].replace(/: $/, '')) | 				b = field_order.indexOf(b[0].replace(/^- |: $/g, '')) | ||||||
| 				b = b == -1 ? x : b | 				b = b == -1 ? x : b | ||||||
| 				return a - b | 				return a - b | ||||||
| 			} | 			} | ||||||
| @ -374,6 +377,10 @@ var MetadataUIActions = actions.Actions({ | |||||||
| 							_dirname((img.base_path || '.') +'/'+ img.path)], | 							_dirname((img.base_path || '.') +'/'+ img.path)], | ||||||
| 						['Full Path: ',  | 						['Full Path: ',  | ||||||
| 							_normalize((img.base_path || '.') +'/'+ img.path)], | 							_normalize((img.base_path || '.') +'/'+ img.path)], | ||||||
|  | 
 | ||||||
|  | 						['Date file created: ', img.ctime && new Date(img.ctime).toShortDate()], | ||||||
|  | 						['- Date file modified: ', img.mtime && new Date(img.mtime).toShortDate()], | ||||||
|  | 						['- Date file accessed: ', img.atime && new Date(img.atime).toShortDate()], | ||||||
| 					]) | 					]) | ||||||
| 
 | 
 | ||||||
| 					// comment and tags...
 | 					// comment and tags...
 | ||||||
|  | |||||||
| @ -625,6 +625,7 @@ module.ViewerActions = actions.Actions({ | |||||||
| 
 | 
 | ||||||
| 	reverseImages: [ reloadAfter() ], | 	reverseImages: [ reloadAfter() ], | ||||||
| 	reverseRibbons: [ reloadAfter() ], | 	reverseRibbons: [ reloadAfter() ], | ||||||
|  | 	sortImages: [ reloadAfter() ], | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 	// basic image editing...
 | 	// basic image editing...
 | ||||||
|  | |||||||
| @ -51,10 +51,20 @@ module.QueueActions = actions.Actions({ | |||||||
| 	set length(val){}, | 	set length(val){}, | ||||||
| 
 | 
 | ||||||
| 	// can be:
 | 	// can be:
 | ||||||
| 	// 	- running
 | 	// 	- stopped 	- (initial)
 | ||||||
| 	// 	- ready
 | 	// 	- ready		- right after .start()
 | ||||||
| 	// 	- done
 | 	// 	- running	- while tasks are running
 | ||||||
| 	// 	- ...
 | 	//
 | ||||||
|  | 	// 									   +-------<done>--------+
 | ||||||
|  | 	// 									   v					 |
 | ||||||
|  | 	// 		o---> stopped ---(start)---> ready --+--> running ---+
 | ||||||
|  | 	// 				^							 |				 |
 | ||||||
|  | 	// 				+--------(stop)--------------+---------------+
 | ||||||
|  | 	//
 | ||||||
|  | 	// NOTE: while .start() and .stop() are both actions and events, 
 | ||||||
|  | 	// 		.done() is not an action, so it is not recommended to call 
 | ||||||
|  | 	// 		it manually...
 | ||||||
|  | 	//
 | ||||||
| 	// XXX should be more informative -- now supports only 'running' and 'stopped'
 | 	// XXX should be more informative -- now supports only 'running' and 'stopped'
 | ||||||
| 	get state(){ | 	get state(){ | ||||||
| 		return this._state || 'stopped' | 		return this._state || 'stopped' | ||||||
| @ -76,7 +86,8 @@ module.QueueActions = actions.Actions({ | |||||||
| 	taskStarted: ['', function(){}], | 	taskStarted: ['', function(){}], | ||||||
| 	taskFailed: ['', function(){}], | 	taskFailed: ['', function(){}], | ||||||
| 	taskDone: ['', function(){}], | 	taskDone: ['', function(){}], | ||||||
| 	allTasksDone: ['', function(){}], | 
 | ||||||
|  | 	done: ['', function(){}], | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 	// Task manipulation actions...
 | 	// Task manipulation actions...
 | ||||||
| @ -225,7 +236,7 @@ module.QueueActions = actions.Actions({ | |||||||
| 			// NOTE: we are not using .forEach(..) here because we need 
 | 			// NOTE: we are not using .forEach(..) here because we need 
 | ||||||
| 			// 		to stop at abstract places and to see the list live...
 | 			// 		to stop at abstract places and to see the list live...
 | ||||||
| 			while(this.__ready && this.__ready.len > 0  | 			while(this.__ready && this.__ready.len > 0  | ||||||
| 					&& this.state == 'running' | 					&& (this.state == 'running' || this.state == 'ready') | ||||||
| 					&& (this.__running && this.__running.len || 0) < size){ (function(){ | 					&& (this.__running && this.__running.len || 0) < size){ (function(){ | ||||||
| 
 | 
 | ||||||
| 				// XXX this might race...
 | 				// XXX this might race...
 | ||||||
| @ -236,13 +247,14 @@ module.QueueActions = actions.Actions({ | |||||||
| 
 | 
 | ||||||
| 				var task = elem[1] | 				var task = elem[1] | ||||||
| 				that.__is_running = true | 				that.__is_running = true | ||||||
|  | 				that._state = 'running' | ||||||
| 
 | 
 | ||||||
| 				that.__running.push(elem) | 				that.__running.push(elem) | ||||||
| 
 | 
 | ||||||
| 				// start the task...
 | 				// start the task...
 | ||||||
| 				// XXX should we run a task in some specific context???
 | 				// XXX should we run a task in some specific context???
 | ||||||
| 				res = task() |  | ||||||
| 				that.taskStarted(elem[0], task) | 				that.taskStarted(elem[0], task) | ||||||
|  | 				res = task() | ||||||
| 
 | 
 | ||||||
| 				// Promise/A+
 | 				// Promise/A+
 | ||||||
| 				if(res && res.then){ | 				if(res && res.then){ | ||||||
| @ -267,9 +279,10 @@ module.QueueActions = actions.Actions({ | |||||||
| 							that._run() | 							that._run() | ||||||
| 
 | 
 | ||||||
| 							// queue empty...
 | 							// queue empty...
 | ||||||
| 							if(this.__ready && this.__ready.len == 0 | 							if(that.__ready && that.__ready.len == 0 | ||||||
| 									&& this.__running && this.__running.len == 0){ | 									&& that.__running && that.__running.len == 0){ | ||||||
| 								this.allTasksDone() | 								that._state = 'ready' | ||||||
|  | 								that.done() | ||||||
| 							} | 							} | ||||||
| 						}) | 						}) | ||||||
| 						// push to done and ._run some more...
 | 						// push to done and ._run some more...
 | ||||||
| @ -287,9 +300,10 @@ module.QueueActions = actions.Actions({ | |||||||
| 							that._run() | 							that._run() | ||||||
| 
 | 
 | ||||||
| 							// queue empty...
 | 							// queue empty...
 | ||||||
| 							if(this.__ready && this.__ready.len == 0 | 							if(that.__ready && that.__ready.len == 0 | ||||||
| 									&& this.__running && this.__running.len == 0){ | 									&& that.__running && that.__running.len == 0){ | ||||||
| 								this.allTasksDone() | 								that._state = 'ready' | ||||||
|  | 								that.done() | ||||||
| 							} | 							} | ||||||
| 						}) | 						}) | ||||||
| 
 | 
 | ||||||
| @ -305,9 +319,10 @@ module.QueueActions = actions.Actions({ | |||||||
| 					that.taskDone(elem[0], task) | 					that.taskDone(elem[0], task) | ||||||
| 
 | 
 | ||||||
| 					// queue empty...
 | 					// queue empty...
 | ||||||
| 					if(this.__ready && this.__ready.len == 0 | 					if(that.__ready && that.__ready.len == 0 | ||||||
| 							&& this.__running && this.__running.len == 0){ | 							&& that.__running && that.__running.len == 0){ | ||||||
| 						this.allTasksDone() | 						that._state = 'ready' | ||||||
|  | 						that.done() | ||||||
| 					} | 					} | ||||||
| 				} | 				} | ||||||
| 			})() } | 			})() } | ||||||
| @ -320,7 +335,7 @@ module.QueueActions = actions.Actions({ | |||||||
| 	// NOTE: we do not need events for these as they are actions...
 | 	// NOTE: we do not need events for these as they are actions...
 | ||||||
| 	start: ['', | 	start: ['', | ||||||
| 		function(){ | 		function(){ | ||||||
| 			this._state = 'running' | 			this._state = 'ready' | ||||||
| 			this._run() | 			this._run() | ||||||
| 		}], | 		}], | ||||||
| 	stop: ['', | 	stop: ['', | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user