Fix: fixes to etymology: load wikidata on mobile (which uses m.wikidata.org, tripping the CSP); fix 'upload image of the streetsign' parameters
This commit is contained in:
parent
bc37deafb5
commit
480956d45d
6 changed files with 15 additions and 7 deletions
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "mapcomplete",
|
"name": "mapcomplete",
|
||||||
"version": "0.33.10",
|
"version": "0.33.11",
|
||||||
"repository": "https://github.com/pietervdvn/MapComplete",
|
"repository": "https://github.com/pietervdvn/MapComplete",
|
||||||
"description": "A small website to edit OSM easily",
|
"description": "A small website to edit OSM easily",
|
||||||
"bugs": "https://github.com/pietervdvn/MapComplete/issues",
|
"bugs": "https://github.com/pietervdvn/MapComplete/issues",
|
||||||
|
|
|
@ -64,8 +64,11 @@ export class ImageUploadManager {
|
||||||
/**
|
/**
|
||||||
* Uploads the given image, applies the correct title and license for the known user.
|
* Uploads the given image, applies the correct title and license for the known user.
|
||||||
* Will then add this image to the OSM-feature or the OSM-note
|
* Will then add this image to the OSM-feature or the OSM-note
|
||||||
|
* @param file a jpg file to upload
|
||||||
|
* @param tagsStore The tags of the feature
|
||||||
|
* @param targetKey Use this key to save the attribute under. Default: 'image'
|
||||||
*/
|
*/
|
||||||
public async uploadImageAndApply(file: File, tagsStore: UIEventSource<OsmTags>): Promise<void> {
|
public async uploadImageAndApply(file: File, tagsStore: UIEventSource<OsmTags>, targetKey?: string): Promise<void> {
|
||||||
const sizeInBytes = file.size
|
const sizeInBytes = file.size
|
||||||
const tags = tagsStore.data
|
const tags = tagsStore.data
|
||||||
const featureId = <OsmId>tags.id
|
const featureId = <OsmId>tags.id
|
||||||
|
@ -95,7 +98,7 @@ export class ImageUploadManager {
|
||||||
].join("\n")
|
].join("\n")
|
||||||
|
|
||||||
console.log("Upload done, creating ")
|
console.log("Upload done, creating ")
|
||||||
const action = await this.uploadImageWithLicense(featureId, title, description, file)
|
const action = await this.uploadImageWithLicense(featureId, title, description, file, targetKey)
|
||||||
if (!isNaN(Number(featureId))) {
|
if (!isNaN(Number(featureId))) {
|
||||||
// This is a map note
|
// This is a map note
|
||||||
const url = action._url
|
const url = action._url
|
||||||
|
@ -112,7 +115,8 @@ export class ImageUploadManager {
|
||||||
featureId: OsmId,
|
featureId: OsmId,
|
||||||
title: string,
|
title: string,
|
||||||
description: string,
|
description: string,
|
||||||
blob: File
|
blob: File,
|
||||||
|
targetKey: string | undefined
|
||||||
): Promise<LinkImageAction> {
|
): Promise<LinkImageAction> {
|
||||||
this.increaseCountFor(this._uploadStarted, featureId)
|
this.increaseCountFor(this._uploadStarted, featureId)
|
||||||
const properties = this._featureProperties.getStore(featureId)
|
const properties = this._featureProperties.getStore(featureId)
|
||||||
|
@ -132,6 +136,7 @@ export class ImageUploadManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log("Uploading done, creating action for", featureId)
|
console.log("Uploading done, creating action for", featureId)
|
||||||
|
key = targetKey ?? key
|
||||||
const action = new LinkImageAction(featureId, key, value, properties, {
|
const action = new LinkImageAction(featureId, key, value, properties, {
|
||||||
theme: this._layout.id,
|
theme: this._layout.id,
|
||||||
changeType: "add-image",
|
changeType: "add-image",
|
||||||
|
|
|
@ -127,6 +127,7 @@ export default class Wikidata {
|
||||||
"https://www.wikidata.org/",
|
"https://www.wikidata.org/",
|
||||||
"https://wikidata.org/",
|
"https://wikidata.org/",
|
||||||
"https://query.wikidata.org",
|
"https://query.wikidata.org",
|
||||||
|
"https://m.wikidata.org", // Important: a mobile browser will request m.wikidata.org instead of www.wikidata.org ; this URL needs to be listed for the CSP
|
||||||
]
|
]
|
||||||
private static readonly _identifierPrefixes = ["Q", "L"].map((str) => str.toLowerCase())
|
private static readonly _identifierPrefixes = ["Q", "L"].map((str) => str.toLowerCase())
|
||||||
private static readonly _prefixesToRemove = [
|
private static readonly _prefixesToRemove = [
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
import { GeoLocationState } from "../../Logic/State/GeoLocationState"
|
import { GeoLocationState } from "../../Logic/State/GeoLocationState"
|
||||||
import If from "../Base/If.svelte"
|
import If from "../Base/If.svelte"
|
||||||
import { ExclamationTriangleIcon } from "@babeard/svelte-heroicons/mini"
|
import { ExclamationTriangleIcon } from "@babeard/svelte-heroicons/mini"
|
||||||
import { Readable } from "svelte/store"
|
import type { Readable } from "svelte/store"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The theme introduction panel
|
* The theme introduction panel
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
export let state: SpecialVisualizationState
|
export let state: SpecialVisualizationState
|
||||||
|
|
||||||
export let tags: Store<OsmTags>
|
export let tags: Store<OsmTags>
|
||||||
|
export let targetKey: string = undefined
|
||||||
/**
|
/**
|
||||||
* Image to show in the button
|
* Image to show in the button
|
||||||
* NOT the image to upload!
|
* NOT the image to upload!
|
||||||
|
@ -35,7 +36,7 @@
|
||||||
const file = files.item(i)
|
const file = files.item(i)
|
||||||
console.log("Got file", file.name)
|
console.log("Got file", file.name)
|
||||||
try {
|
try {
|
||||||
state.imageUploadManager.uploadImageAndApply(file, tags)
|
state.imageUploadManager.uploadImageAndApply(file, tags, targetKey)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
alert(e)
|
alert(e)
|
||||||
}
|
}
|
||||||
|
|
|
@ -691,8 +691,9 @@ export default class SpecialVisualizations {
|
||||||
return new SvelteUIElement(UploadImage, {
|
return new SvelteUIElement(UploadImage, {
|
||||||
state,
|
state,
|
||||||
tags,
|
tags,
|
||||||
|
targetKey: args[0],
|
||||||
labelText: args[1],
|
labelText: args[1],
|
||||||
image: args[0],
|
image: args[2],
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue