forked from MapComplete/MapComplete
		
	Add upload failed message; fix pump icon
This commit is contained in:
		
							parent
							
								
									1ed9467221
								
							
						
					
					
						commit
						33a1e47af2
					
				
					 4 changed files with 24 additions and 10 deletions
				
			
		|  | @ -70,7 +70,7 @@ export default class BikeStations extends LayerDefinition { | |||
|                     if (isOperational) { | ||||
|                         iconName = "pump.svg" | ||||
|                     } else { | ||||
|                         iconName = "pump_broken.svg" | ||||
|                         iconName = "broken_pump.svg" | ||||
|                     } | ||||
|                 } | ||||
|             } else { | ||||
|  |  | |||
|  | @ -8,6 +8,7 @@ export class Imgur { | |||
|         title: string, description: string, blobs: FileList, | ||||
|         handleSuccessfullUpload: ((imageURL: string) => void), | ||||
|         allDone: (() => void), | ||||
|         onFail: ((reason: string) => void), | ||||
|         offset:number = 0) { | ||||
| 
 | ||||
|         if (blobs.length == offset) { | ||||
|  | @ -24,7 +25,8 @@ export class Imgur { | |||
|                     handleSuccessfullUpload, | ||||
|                     allDone, | ||||
|                     offset + 1); | ||||
|             } | ||||
|             }, | ||||
|             onFail | ||||
|         ); | ||||
| 
 | ||||
| 
 | ||||
|  | @ -74,7 +76,8 @@ export class Imgur { | |||
|     } | ||||
| 
 | ||||
|     static uploadImage(title: string, description: string, blob, | ||||
|                        handleSuccessfullUpload: ((imageURL: string) => void)) { | ||||
|                        handleSuccessfullUpload: ((imageURL: string) => void), | ||||
|                        onFail: (reason:string) => void) { | ||||
| 
 | ||||
|         const apiUrl = 'https://api.imgur.com/3/image'; | ||||
|         const apiKey = '7070e7167f0a25a'; | ||||
|  | @ -105,7 +108,8 @@ export class Imgur { | |||
|             response = JSON.parse(response); | ||||
|             handleSuccessfullUpload(response.data.link); | ||||
|         }).fail((reason) => { | ||||
|             console.log("Uploading to IMGUR failed", reason) | ||||
|             console.log("Uploading to IMGUR failed", reason); | ||||
|             onFail(reason) | ||||
|         }); | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -56,6 +56,9 @@ When a map feature is clicked, a popup shows the information, images and questio | |||
| The answers given by the user are sent (after a few seconds) to OpenStreetMap directly - if the user is logged in. If not logged in, the user is prompted to do so.  | ||||
| 
 | ||||
| 
 | ||||
| The UI-event-source is a class where the entire system is built upon, it acts as an observable object: another object can register for changes to update when needed. | ||||
| 
 | ||||
| 
 | ||||
| ### Searching images | ||||
| 
 | ||||
| Images are fetched from: | ||||
|  |  | |||
|  | @ -11,12 +11,13 @@ export class ImageUploadFlow extends UIElement { | |||
|     private _licensePicker: UIElement; | ||||
|     private _selectedLicence: UIEventSource<string>; | ||||
|     private _isUploading: UIEventSource<number> = new UIEventSource<number>(0) | ||||
|     private _didFail: UIEventSource<boolean> = new UIEventSource<boolean>(false); | ||||
|     private _uploadOptions: (license: string) => { title: string; description: string; handleURL: (url: string) => void; allDone: (() => void) }; | ||||
|     private _userdetails: UIEventSource<UserDetails>; | ||||
| 
 | ||||
|     constructor( | ||||
|         userInfo: UIEventSource<UserDetails>, | ||||
|         preferedLicense : UIEventSource<string>, | ||||
|         preferedLicense: UIEventSource<string>, | ||||
|         uploadOptions: ((license: string) => | ||||
|             { | ||||
|                 title: string, | ||||
|  | @ -30,6 +31,7 @@ export class ImageUploadFlow extends UIElement { | |||
|         this.ListenTo(userInfo); | ||||
|         this._uploadOptions = uploadOptions; | ||||
|         this.ListenTo(this._isUploading); | ||||
|         this.ListenTo(this._didFail); | ||||
| 
 | ||||
|         const licensePicker = new DropDown(Translations.t.image.willBePublished, | ||||
|             [ | ||||
|  | @ -59,6 +61,10 @@ export class ImageUploadFlow extends UIElement { | |||
|         if (this._isUploading.data > 0) { | ||||
|             uploadingMessage = "<b>Uploading multiple pictures, " + this._isUploading.data + " left...</b>" | ||||
|         } | ||||
|          | ||||
|         if(this._didFail.data){ | ||||
|             uploadingMessage += "<b>Some images failed to upload. Imgur migth be down or you might block third-party API's (e.g. by using Brave or UMatrix)</b><br/>" | ||||
|         } | ||||
| 
 | ||||
|         return "" + | ||||
|             "<div class='imageflow'>" + | ||||
|  | @ -68,20 +74,20 @@ export class ImageUploadFlow extends UIElement { | |||
|             "<div class='imageflow-file-input-wrapper'>" + | ||||
|             "<img src='./assets/camera-plus.svg' alt='upload image'/> " + | ||||
|             `<span class='imageflow-add-picture'>${Translations.t.image.addPicture.R()}</span>` + | ||||
|             "<div class='break'></div>"+ | ||||
|             "<div class='break'></div>" + | ||||
|             "</div>" + | ||||
| 
 | ||||
|             this._licensePicker.Render() + "<br/>" + | ||||
|             uploadingMessage + | ||||
| 
 | ||||
|             "</label>" + | ||||
|              | ||||
| 
 | ||||
|             "<input id='fileselector-" + this.id + "' " + | ||||
|             "type='file' " + | ||||
|             "class='imageflow-file-input' " + | ||||
|             "accept='image/*' name='picField' size='24' multiple='multiple' alt=''" + | ||||
|             "/>" + | ||||
|              | ||||
| 
 | ||||
|             "</div>" | ||||
|             ; | ||||
|     } | ||||
|  | @ -116,11 +122,12 @@ export class ImageUploadFlow extends UIElement { | |||
|                     function () { | ||||
|                         console.log("All uploads completed") | ||||
|                         opts.allDone(); | ||||
|                     }, | ||||
|                     function(failReason) { | ||||
|                      | ||||
|                     } | ||||
|                 ) | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue