Add upload failed message; fix pump icon

This commit is contained in:
Pieter Vander Vennet 2020-07-21 22:50:54 +02:00
parent 1ed9467221
commit 33a1e47af2
4 changed files with 24 additions and 10 deletions

View file

@ -70,7 +70,7 @@ export default class BikeStations extends LayerDefinition {
if (isOperational) { if (isOperational) {
iconName = "pump.svg" iconName = "pump.svg"
} else { } else {
iconName = "pump_broken.svg" iconName = "broken_pump.svg"
} }
} }
} else { } else {

View file

@ -8,6 +8,7 @@ export class Imgur {
title: string, description: string, blobs: FileList, title: string, description: string, blobs: FileList,
handleSuccessfullUpload: ((imageURL: string) => void), handleSuccessfullUpload: ((imageURL: string) => void),
allDone: (() => void), allDone: (() => void),
onFail: ((reason: string) => void),
offset:number = 0) { offset:number = 0) {
if (blobs.length == offset) { if (blobs.length == offset) {
@ -24,7 +25,8 @@ export class Imgur {
handleSuccessfullUpload, handleSuccessfullUpload,
allDone, allDone,
offset + 1); offset + 1);
} },
onFail
); );
@ -74,7 +76,8 @@ export class Imgur {
} }
static uploadImage(title: string, description: string, blob, 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 apiUrl = 'https://api.imgur.com/3/image';
const apiKey = '7070e7167f0a25a'; const apiKey = '7070e7167f0a25a';
@ -105,7 +108,8 @@ export class Imgur {
response = JSON.parse(response); response = JSON.parse(response);
handleSuccessfullUpload(response.data.link); handleSuccessfullUpload(response.data.link);
}).fail((reason) => { }).fail((reason) => {
console.log("Uploading to IMGUR failed", reason) console.log("Uploading to IMGUR failed", reason);
onFail(reason)
}); });
} }

View file

@ -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 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 ### Searching images
Images are fetched from: Images are fetched from:

View file

@ -11,12 +11,13 @@ export class ImageUploadFlow extends UIElement {
private _licensePicker: UIElement; private _licensePicker: UIElement;
private _selectedLicence: UIEventSource<string>; private _selectedLicence: UIEventSource<string>;
private _isUploading: UIEventSource<number> = new UIEventSource<number>(0) 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 _uploadOptions: (license: string) => { title: string; description: string; handleURL: (url: string) => void; allDone: (() => void) };
private _userdetails: UIEventSource<UserDetails>; private _userdetails: UIEventSource<UserDetails>;
constructor( constructor(
userInfo: UIEventSource<UserDetails>, userInfo: UIEventSource<UserDetails>,
preferedLicense : UIEventSource<string>, preferedLicense: UIEventSource<string>,
uploadOptions: ((license: string) => uploadOptions: ((license: string) =>
{ {
title: string, title: string,
@ -30,6 +31,7 @@ export class ImageUploadFlow extends UIElement {
this.ListenTo(userInfo); this.ListenTo(userInfo);
this._uploadOptions = uploadOptions; this._uploadOptions = uploadOptions;
this.ListenTo(this._isUploading); this.ListenTo(this._isUploading);
this.ListenTo(this._didFail);
const licensePicker = new DropDown(Translations.t.image.willBePublished, const licensePicker = new DropDown(Translations.t.image.willBePublished,
[ [
@ -60,6 +62,10 @@ export class ImageUploadFlow extends UIElement {
uploadingMessage = "<b>Uploading multiple pictures, " + this._isUploading.data + " left...</b>" 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 "" + return "" +
"<div class='imageflow'>" + "<div class='imageflow'>" +
@ -68,7 +74,7 @@ export class ImageUploadFlow extends UIElement {
"<div class='imageflow-file-input-wrapper'>" + "<div class='imageflow-file-input-wrapper'>" +
"<img src='./assets/camera-plus.svg' alt='upload image'/> " + "<img src='./assets/camera-plus.svg' alt='upload image'/> " +
`<span class='imageflow-add-picture'>${Translations.t.image.addPicture.R()}</span>` + `<span class='imageflow-add-picture'>${Translations.t.image.addPicture.R()}</span>` +
"<div class='break'></div>"+ "<div class='break'></div>" +
"</div>" + "</div>" +
this._licensePicker.Render() + "<br/>" + this._licensePicker.Render() + "<br/>" +
@ -116,11 +122,12 @@ export class ImageUploadFlow extends UIElement {
function () { function () {
console.log("All uploads completed") console.log("All uploads completed")
opts.allDone(); opts.allDone();
},
function(failReason) {
} }
) )
} }
} }
} }
} }