forked from MapComplete/MapComplete
UX: add proper delete dialog, add option to report images
This commit is contained in:
parent
8690ad35bb
commit
5b618dc367
18 changed files with 334 additions and 176 deletions
|
@ -66,8 +66,9 @@ export default class AllImageProviders {
|
|||
return AllImageProviders.genericImageProvider
|
||||
}
|
||||
|
||||
private static readonly _cachedImageStores: Record<string, Store<ProvidedImage[]>> = {}
|
||||
/**
|
||||
* Tries to extract all image data for this image
|
||||
* Tries to extract all image data for this image. Cachedon tags?.data?.id
|
||||
*/
|
||||
public static LoadImagesFor(
|
||||
tags: Store<Record<string, string>>,
|
||||
|
@ -76,6 +77,10 @@ export default class AllImageProviders {
|
|||
if (tags?.data?.id === undefined) {
|
||||
return undefined
|
||||
}
|
||||
const id = tags?.data?.id
|
||||
if(this._cachedImageStores[id]){
|
||||
return this._cachedImageStores[id]
|
||||
}
|
||||
|
||||
const source = new UIEventSource([])
|
||||
const allSources: Store<ProvidedImage[]>[] = []
|
||||
|
@ -93,6 +98,7 @@ export default class AllImageProviders {
|
|||
source.set(dedup)
|
||||
})
|
||||
}
|
||||
this._cachedImageStores[id] = source
|
||||
return source
|
||||
}
|
||||
|
||||
|
|
|
@ -88,4 +88,12 @@ export default abstract class ImageProvider {
|
|||
}): Promise<LicenseInfo>
|
||||
|
||||
public abstract apiUrls(): string[]
|
||||
|
||||
public static async offerImageAsDownload(image: ProvidedImage){
|
||||
const response = await fetch(image.url_hd ?? image.url)
|
||||
const blob = await response.blob()
|
||||
Utils.offerContentsAsDownloadableFile(blob, new URL(image.url).pathname.split("/").at(-1), {
|
||||
mimetype: "image/jpg",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -138,11 +138,12 @@ export default class PanoramaxImageProvider extends ImageProvider {
|
|||
}
|
||||
return data?.some(
|
||||
(img) =>
|
||||
img?.status !== undefined && img?.status !== "ready" && img?.status !== "broken"
|
||||
img?.status !== undefined && img?.status !== "ready" && img?.status !== "broken" && img?.status !== "hidden"
|
||||
)
|
||||
}
|
||||
|
||||
Stores.Chronic(1500, () => hasLoading(source.data)).addCallback((_) => {
|
||||
console.log("Testing panoramax URLS again as some were loading", source.data, hasLoading(source.data))
|
||||
super.getRelevantUrlsFor(tags, prefixes).then((data) => {
|
||||
source.set(data)
|
||||
return !hasLoading(data)
|
||||
|
@ -168,6 +169,17 @@ export default class PanoramaxImageProvider extends ImageProvider {
|
|||
public apiUrls(): string[] {
|
||||
return ["https://panoramax.mapcomplete.org", "https://panoramax.xyz"]
|
||||
}
|
||||
|
||||
public static getPanoramaxInstance (host: string){
|
||||
host = new URL(host).host
|
||||
if(new URL(this.defaultPanoramax.host).host === host){
|
||||
return this.defaultPanoramax
|
||||
}
|
||||
if(new URL(this.xyz.host).host === host){
|
||||
return this.xyz
|
||||
}
|
||||
return new Panoramax(host)
|
||||
}
|
||||
}
|
||||
|
||||
export class PanoramaxUploader implements ImageUploader {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue