upload start flag

This commit is contained in:
waltem01 2024-02-16 11:27:26 +01:00
parent 9ab5ceaa88
commit 5248c09267

View File

@ -17,6 +17,7 @@
let imageURL: string | null, lastImage: File; let imageURL: string | null, lastImage: File;
let uploadData: UploadData, matrix: Matrix; let uploadData: UploadData, matrix: Matrix;
let uploadStarted = false;
async function updateMatrix() { async function updateMatrix() {
await fetch('/api/redirect?endpoint=update'); await fetch('/api/redirect?endpoint=update');
@ -117,26 +118,28 @@
<input type="file" name="image" accept="image/*" on:change={uploadImage} /> <input type="file" name="image" accept="image/*" on:change={uploadImage} />
{#if imageURL} {#if imageURL}
<img src={imageURL} alt="User uploaded" /> <img src={imageURL} alt="User uploaded" />
{#await fileAsDataURL(lastImage, matrix.width, matrix.height)} {#if uploadStarted}
<p>Loading image data . . .</p> {#await fileAsDataURL(lastImage, matrix.width, matrix.height)}
<p>{uploadData.elapsed} seconds elapsed.</p> <p>Loading image data . . .</p>
{:then dataUrl}
{#await sendImage(dataUrl)}
<p>Sending image . . .</p>
<p>{uploadData.elapsed} seconds elapsed.</p> <p>{uploadData.elapsed} seconds elapsed.</p>
{:then} {:then dataUrl}
{#await placeImage()} {#await sendImage(dataUrl)}
<p>Placing image . . .</p> <p>Sending image . . .</p>
<p>{uploadData.elapsed} seconds elapsed.</p> <p>{uploadData.elapsed} seconds elapsed.</p>
{:then} {:then}
{#await updateMatrix()} {#await placeImage()}
<p>Updating matrix . . .</p> <p>Placing image . . .</p>
<p>{uploadData.elapsed} seconds elapsed.</p> <p>{uploadData.elapsed} seconds elapsed.</p>
{:then} {:then}
<p>Done!</p> {#await updateMatrix()}
<p>{uploadData.elapsed} seconds elapsed.</p> <p>Updating matrix . . .</p>
<p>{uploadData.elapsed} seconds elapsed.</p>
{:then}
<p>Done!</p>
<p>{uploadData.elapsed} seconds elapsed.</p>
{/await}
{/await} {/await}
{/await} {/await}
{/await} {/await}
{/await} {/if}
{/if} {/if}