mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-31 03:10:07 +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 this also requires images...
 | ||||
| 	// XXX cache order???
 | ||||
| 	sortImages: ['Sort/', | ||||
| 		function(method){  | ||||
| 			if(this.images){ | ||||
| 				// select method...
 | ||||
| 				this.data.order = this.images.sortImages().reverse() | ||||
| 			} | ||||
| 			this.data.updateImagePositions() | ||||
| 		}], | ||||
| 
 | ||||
| 	// basic image editing...
 | ||||
|  | ||||
| @ -56,6 +56,8 @@ var FileSystemLoaderActions = actions.Actions({ | ||||
| 
 | ||||
| 		'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 
 | ||||
| 		// 		without merging...
 | ||||
| 		'load-first-index-only': false, | ||||
| @ -220,13 +222,38 @@ var FileSystemLoaderActions = actions.Actions({ | ||||
| 				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){ | ||||
| 					console.log('!!!!', err) | ||||
| 				}) | ||||
| 				/* | ||||
| 				.on('match', function(img){ | ||||
| 					// XXX stat stuff...
 | ||||
| 					fse.statSync(img) | ||||
| 				}) | ||||
| 				*/ | ||||
| 				.on('end', function(lst){  | ||||
| 					that.loadURLs(lst | ||||
| 						.map(function(p){ return util.normalizePath(p) }), path) | ||||
| 					that.loadURLs(lst, 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
 | ||||
| 					// 		before it starts loading...
 | ||||
|  | ||||
| @ -279,6 +279,9 @@ var MetadataUIActions = actions.Actions({ | ||||
| 			// base
 | ||||
| 			'GID',  | ||||
| 			'File Name', 'Parent Directory', 'Full Path', | ||||
| 			'Date file created', 'Date file modified', 'Date file accessed', | ||||
| 
 | ||||
| 			'Index (ribbon)', 'Index (crop)', 'Index (global)', | ||||
| 
 | ||||
| 			// metadata...
 | ||||
| 			'Make', 'Camera Model Name', 'Lens ID', 'Lens', 'Lens Profile Name', 'Focal Length', | ||||
| @ -321,9 +324,9 @@ var MetadataUIActions = actions.Actions({ | ||||
| 
 | ||||
| 			// helpers...
 | ||||
| 			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 | ||||
| 				b = field_order.indexOf(b[0].replace(/: $/, '')) | ||||
| 				b = field_order.indexOf(b[0].replace(/^- |: $/g, '')) | ||||
| 				b = b == -1 ? x : b | ||||
| 				return a - b | ||||
| 			} | ||||
| @ -374,6 +377,10 @@ var MetadataUIActions = actions.Actions({ | ||||
| 							_dirname((img.base_path || '.') +'/'+ img.path)], | ||||
| 						['Full 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...
 | ||||
|  | ||||
| @ -625,6 +625,7 @@ module.ViewerActions = actions.Actions({ | ||||
| 
 | ||||
| 	reverseImages: [ reloadAfter() ], | ||||
| 	reverseRibbons: [ reloadAfter() ], | ||||
| 	sortImages: [ reloadAfter() ], | ||||
| 
 | ||||
| 
 | ||||
| 	// basic image editing...
 | ||||
|  | ||||
| @ -51,10 +51,20 @@ module.QueueActions = actions.Actions({ | ||||
| 	set length(val){}, | ||||
| 
 | ||||
| 	// can be:
 | ||||
| 	// 	- running
 | ||||
| 	// 	- ready
 | ||||
| 	// 	- done
 | ||||
| 	// 	- ...
 | ||||
| 	// 	- stopped 	- (initial)
 | ||||
| 	// 	- ready		- right after .start()
 | ||||
| 	// 	- 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'
 | ||||
| 	get state(){ | ||||
| 		return this._state || 'stopped' | ||||
| @ -76,7 +86,8 @@ module.QueueActions = actions.Actions({ | ||||
| 	taskStarted: ['', function(){}], | ||||
| 	taskFailed: ['', function(){}], | ||||
| 	taskDone: ['', function(){}], | ||||
| 	allTasksDone: ['', function(){}], | ||||
| 
 | ||||
| 	done: ['', function(){}], | ||||
| 
 | ||||
| 
 | ||||
| 	// Task manipulation actions...
 | ||||
| @ -225,7 +236,7 @@ module.QueueActions = actions.Actions({ | ||||
| 			// NOTE: we are not using .forEach(..) here because we need 
 | ||||
| 			// 		to stop at abstract places and to see the list live...
 | ||||
| 			while(this.__ready && this.__ready.len > 0  | ||||
| 					&& this.state == 'running' | ||||
| 					&& (this.state == 'running' || this.state == 'ready') | ||||
| 					&& (this.__running && this.__running.len || 0) < size){ (function(){ | ||||
| 
 | ||||
| 				// XXX this might race...
 | ||||
| @ -236,13 +247,14 @@ module.QueueActions = actions.Actions({ | ||||
| 
 | ||||
| 				var task = elem[1] | ||||
| 				that.__is_running = true | ||||
| 				that._state = 'running' | ||||
| 
 | ||||
| 				that.__running.push(elem) | ||||
| 
 | ||||
| 				// start the task...
 | ||||
| 				// XXX should we run a task in some specific context???
 | ||||
| 				res = task() | ||||
| 				that.taskStarted(elem[0], task) | ||||
| 				res = task() | ||||
| 
 | ||||
| 				// Promise/A+
 | ||||
| 				if(res && res.then){ | ||||
| @ -267,9 +279,10 @@ module.QueueActions = actions.Actions({ | ||||
| 							that._run() | ||||
| 
 | ||||
| 							// queue empty...
 | ||||
| 							if(this.__ready && this.__ready.len == 0 | ||||
| 									&& this.__running && this.__running.len == 0){ | ||||
| 								this.allTasksDone() | ||||
| 							if(that.__ready && that.__ready.len == 0 | ||||
| 									&& that.__running && that.__running.len == 0){ | ||||
| 								that._state = 'ready' | ||||
| 								that.done() | ||||
| 							} | ||||
| 						}) | ||||
| 						// push to done and ._run some more...
 | ||||
| @ -287,9 +300,10 @@ module.QueueActions = actions.Actions({ | ||||
| 							that._run() | ||||
| 
 | ||||
| 							// queue empty...
 | ||||
| 							if(this.__ready && this.__ready.len == 0 | ||||
| 									&& this.__running && this.__running.len == 0){ | ||||
| 								this.allTasksDone() | ||||
| 							if(that.__ready && that.__ready.len == 0 | ||||
| 									&& that.__running && that.__running.len == 0){ | ||||
| 								that._state = 'ready' | ||||
| 								that.done() | ||||
| 							} | ||||
| 						}) | ||||
| 
 | ||||
| @ -305,9 +319,10 @@ module.QueueActions = actions.Actions({ | ||||
| 					that.taskDone(elem[0], task) | ||||
| 
 | ||||
| 					// queue empty...
 | ||||
| 					if(this.__ready && this.__ready.len == 0 | ||||
| 							&& this.__running && this.__running.len == 0){ | ||||
| 						this.allTasksDone() | ||||
| 					if(that.__ready && that.__ready.len == 0 | ||||
| 							&& that.__running && that.__running.len == 0){ | ||||
| 						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...
 | ||||
| 	start: ['', | ||||
| 		function(){ | ||||
| 			this._state = 'running' | ||||
| 			this._state = 'ready' | ||||
| 			this._run() | ||||
| 		}], | ||||
| 	stop: ['', | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user