forked from MapComplete/MapComplete
		
	Various cleanups
This commit is contained in:
		
							parent
							
								
									fd2ed950cc
								
							
						
					
					
						commit
						3ac7a3c59e
					
				
					 5 changed files with 3 additions and 54 deletions
				
			
		| 
						 | 
					@ -1,11 +1,9 @@
 | 
				
			||||||
import ImageProvider, {ProvidedImage} from "./ImageProvider";
 | 
					import ImageProvider, {ProvidedImage} from "./ImageProvider";
 | 
				
			||||||
import BaseUIElement from "../../UI/BaseUIElement";
 | 
					import BaseUIElement from "../../UI/BaseUIElement";
 | 
				
			||||||
import {UIEventSource} from "../UIEventSource";
 | 
					 | 
				
			||||||
import Svg from "../../Svg";
 | 
					import Svg from "../../Svg";
 | 
				
			||||||
import {Utils} from "../../Utils";
 | 
					import {Utils} from "../../Utils";
 | 
				
			||||||
import {LicenseInfo} from "./LicenseInfo";
 | 
					import {LicenseInfo} from "./LicenseInfo";
 | 
				
			||||||
import Constants from "../../Models/Constants";
 | 
					import Constants from "../../Models/Constants";
 | 
				
			||||||
import {fail} from "assert";
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
export class Mapillary extends ImageProvider {
 | 
					export class Mapillary extends ImageProvider {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -13,7 +11,7 @@ export class Mapillary extends ImageProvider {
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    public static readonly singleton = new Mapillary();
 | 
					    public static readonly singleton = new Mapillary();
 | 
				
			||||||
    private static readonly valuePrefix = "https://a.mapillary.com"
 | 
					    private static readonly valuePrefix = "https://a.mapillary.com"
 | 
				
			||||||
    public static readonly valuePrefixes = [Mapillary.valuePrefix, "http://mapillary.com","https://mapillary.com"]
 | 
					    public static readonly valuePrefixes = [Mapillary.valuePrefix, "http://mapillary.com","https://mapillary.com","http://www.mapillary.com","https://www.mapillary.com"]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private static ExtractKeyFromURL(value: string, failIfNoMath = false): {
 | 
					    private static ExtractKeyFromURL(value: string, failIfNoMath = false): {
 | 
				
			||||||
        key: string,
 | 
					        key: string,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,7 +8,6 @@ import Svg from "../../Svg";
 | 
				
			||||||
import Img from "../../UI/Base/Img";
 | 
					import Img from "../../UI/Base/Img";
 | 
				
			||||||
import {Utils} from "../../Utils";
 | 
					import {Utils} from "../../Utils";
 | 
				
			||||||
import {OsmObject} from "./OsmObject";
 | 
					import {OsmObject} from "./OsmObject";
 | 
				
			||||||
import LayoutConfig from "../../Models/ThemeConfig/LayoutConfig";
 | 
					 | 
				
			||||||
import {Changes} from "./Changes";
 | 
					import {Changes} from "./Changes";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default class UserDetails {
 | 
					export default class UserDetails {
 | 
				
			||||||
| 
						 | 
					@ -97,7 +96,6 @@ export class OsmConnection {
 | 
				
			||||||
                self.AttemptLogin()
 | 
					                self.AttemptLogin()
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
        this.isLoggedIn.addCallbackAndRunD(li => console.log("User is logged in!", li))
 | 
					 | 
				
			||||||
        this._dryRun = options.dryRun;
 | 
					        this._dryRun = options.dryRun;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.updateAuthObject();
 | 
					        this.updateAuthObject();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -66,9 +66,7 @@ export abstract class OsmObject {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const url = `${OsmObject.backendURL}api/0.6/${id}`;
 | 
					        const url = `${OsmObject.backendURL}api/0.6/${id}`;
 | 
				
			||||||
        const rawData = await Utils.downloadJsonCached(url, 1000)
 | 
					        const rawData = await Utils.downloadJsonCached(url, 1000)
 | 
				
			||||||
        const tags = rawData.elements[0].tags
 | 
					        return rawData.elements[0].tags
 | 
				
			||||||
        console.log("Tags are", tags)
 | 
					 | 
				
			||||||
        return tags
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    static async DownloadObjectAsync(id: string): Promise<OsmObject> {
 | 
					    static async DownloadObjectAsync(id: string): Promise<OsmObject> {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,45 +0,0 @@
 | 
				
			||||||
import {UIEventSource} from "../../Logic/UIEventSource";
 | 
					 | 
				
			||||||
import BaseUIElement from "../BaseUIElement";
 | 
					 | 
				
			||||||
import {VariableUiElement} from "../Base/VariableUIElement";
 | 
					 | 
				
			||||||
import Translations from "../i18n/Translations";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Shows that 'images are uploading', 'all images are uploaded' as relevant...
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
export default class UploadFlowStateUI extends VariableUiElement {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    constructor(queue: UIEventSource<string[]>, failed: UIEventSource<string[]>, success: UIEventSource<string[]>) {
 | 
					 | 
				
			||||||
        const t = Translations.t.image;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        super(
 | 
					 | 
				
			||||||
            queue.map(queue => {
 | 
					 | 
				
			||||||
                const failedReasons = failed.data
 | 
					 | 
				
			||||||
                const successCount = success.data.length
 | 
					 | 
				
			||||||
                const pendingCount = queue.length - successCount - failedReasons.length;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                let stateMessages: BaseUIElement[] = []
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                if (pendingCount == 1) {
 | 
					 | 
				
			||||||
                    stateMessages.push(t.uploadingPicture.Clone().SetClass("alert"))
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                if (pendingCount > 1) {
 | 
					 | 
				
			||||||
                    stateMessages.push(t.uploadingMultiple.Subs({count: "" + pendingCount}).SetClass("alert"))
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                if (failedReasons.length > 0) {
 | 
					 | 
				
			||||||
                    stateMessages.push(t.uploadFailed.Clone().SetClass("alert"))
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                if (successCount > 0 && pendingCount == 0) {
 | 
					 | 
				
			||||||
                    stateMessages.push(t.uploadDone.SetClass("thanks"))
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                stateMessages.forEach(msg => msg.SetStyle("display: block ruby"))
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                return stateMessages
 | 
					 | 
				
			||||||
            }, [failed, success])
 | 
					 | 
				
			||||||
        );
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
							
								
								
									
										2
									
								
								Utils.ts
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								Utils.ts
									
										
									
									
									
								
							| 
						 | 
					@ -330,7 +330,7 @@ export class Utils {
 | 
				
			||||||
                return cached.promise
 | 
					                return cached.promise
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        const promise = Utils.downloadJson(url, headers)
 | 
					        const promise = /*NO AWAIT as we work with the promise directly */Utils.downloadJson(url, headers)
 | 
				
			||||||
        Utils._download_cache.set(url, {promise, timestamp: new Date().getTime()})
 | 
					        Utils._download_cache.set(url, {promise, timestamp: new Date().getTime()})
 | 
				
			||||||
        return await promise
 | 
					        return await promise
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue