Experiment: more finetuning of the filepickers, see #2202

This commit is contained in:
Pieter Vander Vennet 2024-11-25 18:00:30 +01:00
parent 86baf130f3
commit 6900dedd3e
4 changed files with 17 additions and 11 deletions

View file

@ -588,7 +588,7 @@
"translationMode": "Toggle translation mode on or off" "translationMode": "Toggle translation mode on or off"
}, },
"image": { "image": {
"addPicture": "Add picture", "addPicture": "Take a picture",
"currentLicense": "Your images will be published under {license}", "currentLicense": "Your images will be published under {license}",
"doDelete": "Remove image", "doDelete": "Remove image",
"dontDelete": "Cancel", "dontDelete": "Cancel",
@ -622,6 +622,7 @@
"pleaseLogin": "Please log in to add a picture", "pleaseLogin": "Please log in to add a picture",
"processing": "The server is processing your image", "processing": "The server is processing your image",
"respectPrivacy": "Do not upload from Google Maps, Google Streetview or other copyrighted sources.", "respectPrivacy": "Do not upload from Google Maps, Google Streetview or other copyrighted sources.",
"selectFile": "Select a picture from your device",
"toBig": "Your image is too large as it is {actual_size}. Please use images of at most {max_size}", "toBig": "Your image is too large as it is {actual_size}. Please use images of at most {max_size}",
"unlink": { "unlink": {
"button": "Unlink picture", "button": "Unlink picture",

View file

@ -157,14 +157,15 @@ export class ImageUploadManager {
blob: File, blob: File,
targetKey: string | undefined, targetKey: string | undefined,
noblur: boolean, noblur: boolean,
feature?: Feature feature?: Feature,
ignoreGps: boolean = false
): Promise<UploadResult> { ): Promise<UploadResult> {
this.increaseCountFor(this._uploadStarted, featureId) this.increaseCountFor(this._uploadStarted, featureId)
let key: string let key: string
let value: string let value: string
let absoluteUrl: string let absoluteUrl: string
let location: [number, number] = undefined let location: [number, number] = undefined
if (this._gps.data) { if (this._gps.data && !ignoreGps) {
location = [this._gps.data.longitude, this._gps.data.latitude] location = [this._gps.data.longitude, this._gps.data.latitude]
} }
if (location === undefined || location?.some((l) => l === undefined)) { if (location === undefined || location?.some((l) => l === undefined)) {

View file

@ -3,6 +3,7 @@
import { twMerge } from "tailwind-merge" import { twMerge } from "tailwind-merge"
export let accept: string | undefined export let accept: string | undefined
export let capture: string | undefined = undefined
export let multiple: boolean = true export let multiple: boolean = true
const dispatcher = createEventDispatcher<{ submit: FileList }>() const dispatcher = createEventDispatcher<{ submit: FileList }>()
@ -98,5 +99,6 @@
{multiple} {multiple}
name="file-input" name="file-input"
type="file" type="file"
{capture}
/> />
</form> </form>

View file

@ -38,7 +38,7 @@
let errors = new UIEventSource<Translation[]>([]) let errors = new UIEventSource<Translation[]>([])
async function handleFiles(files: FileList) { async function handleFiles(files: FileList, ignoreGps: boolean= false) {
const errs = [] const errs = []
for (let i = 0; i < files.length; i++) { for (let i = 0; i < files.length; i++) {
const file = files.item(i) const file = files.item(i)
@ -57,7 +57,8 @@
file, file,
"image", "image",
noBlur, noBlur,
feature feature,
ignoreGps
) )
if (!uploadResult) { if (!uploadResult) {
return return
@ -97,7 +98,8 @@
<Tr t={error} cls="alert" /> <Tr t={error} cls="alert" />
{/each} {/each}
<FileSelector <FileSelector
accept=".jpg,.jpeg" accept="image/*"
capture="environment"
cls="button border-2 flex flex-col" cls="button border-2 flex flex-col"
multiple={true} multiple={true}
on:submit={(e) => handleFiles(e.detail)} on:submit={(e) => handleFiles(e.detail)}
@ -112,7 +114,7 @@
{labelText} {labelText}
{:else} {:else}
<div class="flex flex-col"> <div class="flex flex-col">
<Tr t={t.addPicture} /> <Tr t={t.addPicture}/>
{#if noBlur} {#if noBlur}
<span class="subtle text-sm"> <span class="subtle text-sm">
<Tr t={t.upload.noBlur} /> <Tr t={t.upload.noBlur} />
@ -123,12 +125,12 @@
</div> </div>
</FileSelector> </FileSelector>
<FileSelector <FileSelector
accept={undefined} accept=".jpg, .jpeg"
cls="subtle as-link flex justify-center md:hidden" cls="flex justify-center md:hidden button"
multiple={true} multiple={true}
on:submit={(e) => handleFiles(e.detail)} on:submit={(e) => handleFiles(e.detail, true)}
> >
Use the file selector dialog <Tr t={t.selectFile}/>
</FileSelector> </FileSelector>
<div class="subtle text-xs italic"> <div class="subtle text-xs italic">
<Tr t={Translations.t.general.attribution.panoramaxLicenseCCBYSA} /> <Tr t={Translations.t.general.attribution.panoramaxLicenseCCBYSA} />