Chore: rework image uploading, should work better now

This commit is contained in:
Pieter Vander Vennet 2023-09-25 02:13:24 +02:00
parent 6f5b0622a5
commit 94ba18785d
17 changed files with 548 additions and 238 deletions

View file

@ -1,31 +1,67 @@
<script lang="ts">/**
* Shows an 'upload'-button which will start the upload for this feature
* Shows information about how much images are uploaded for the given feature
*/
import type { SpecialVisualizationState } from "../SpecialVisualization";
import type { Feature } from "geojson";
import { Store } from "../../Logic/UIEventSource";
import type { OsmTags } from "../../Models/OsmFeature";
import { ImageUploader } from "../../Logic/ImageProviders/ImageUploader";
import LoginToggle from "../Base/LoginToggle.svelte";
import Translations from "../i18n/Translations";
import Tr from "../Base/Tr.svelte";
import { ImageUploadManager } from "../../Logic/ImageProviders/ImageUploadManager";
import Loading from "../Base/Loading.svelte";
export let state: SpecialVisualizationState;
export let feature: Feature;
export let tags: Store<OsmTags>;
export let state: SpecialVisualizationState;
export let lon: number;
export let lat: number;
const t = Translations.t.image
const featureId = tags.data.id;
const {
uploadStarted,
uploadFinished,
retried,
failed
} = state.imageUploadManager.getCountsFor(featureId);
const t = Translations.t.image;
</script>
{#if $uploadStarted == 1}
{#if $uploadFinished == 1 }
<Tr cls="thanks" t={t.upload.one.done} />
{:else if $failed == 1}
<div class="flex flex-col alert">
<Tr cls="self-center" t={t.upload.one.failed} />
<Tr t={t.upload.failReasons} />
<Tr t={t.upload.failReasonsAdvanced} />
</div>
{:else if $retried == 1}
<Loading cls="alert">
<Tr t={t.upload.one.retrying} />
</Loading>
{:else }
<Loading cls="alert">
<Tr t={t.upload.one.uploading} />
</Loading>
{/if}
{:else if $uploadStarted > 1}
{#if ($uploadFinished + $failed) == $uploadStarted && $uploadFinished > 0}
<Tr cls="thanks" t={t.upload.multiple.done.Subs({count: $uploadFinished})} />
{:else if $uploadFinished == 0}
<Loading cls="alert">
<Tr t={t.upload.multiple.uploading.Subs({count: $uploadStarted})} />
</Loading>
{:else if $uploadFinished > 0}
<Loading cls="alert">
<Tr t={t.upload.multiple.partiallyDone.Subs({count: $uploadStarted - $uploadFinished, done: $uploadFinished})} />
</Loading>
{/if}
{#if $failed > 0}
<div class="flex flex-col alert">
{#if failed === 1}
<Tr cls="self-center" t={t.upload.one.failed} />
{:else}
<Tr cls="self-center" t={t.upload.multiple.someFailed.Subs({count: $failed})} />
<LoginToggle>
<Tr slot="not-logged-in" t={t.pleaseLogin}/>
</LoginToggle>
{/if}
<Tr t={t.upload.failReasons} />
<Tr t={t.upload.failReasonsAdvanced} />
</div>
{/if}
{/if}