From d51833a6c0ac19246e21e7369f16af9916564b25 Mon Sep 17 00:00:00 2001 From: nidhal-labidi Date: Wed, 12 Mar 2025 15:14:53 +0100 Subject: [PATCH] feat: use FlottformFileInput classes to show an example of bidirectional file exchange Signed-off-by: nidhal-labidi --- servers/demo/src/api.ts | 8 + .../components/FileExchangeProgress.svelte | 27 ++ .../lib/components/ReceivedFilesList.svelte | 38 +++ servers/demo/src/routes/+page.svelte | 5 + .../[endpointId]/+page.svelte | 192 ++++++++++++++ .../flottform-file-sharing/+page.svelte | 247 ++++++++++++++++++ 6 files changed, 517 insertions(+) create mode 100644 servers/demo/src/lib/components/FileExchangeProgress.svelte create mode 100644 servers/demo/src/lib/components/ReceivedFilesList.svelte create mode 100644 servers/demo/src/routes/flottform-file-sharing-client/[endpointId]/+page.svelte create mode 100644 servers/demo/src/routes/flottform-file-sharing/+page.svelte diff --git a/servers/demo/src/api.ts b/servers/demo/src/api.ts index 526a36b..67c1cfe 100644 --- a/servers/demo/src/api.ts +++ b/servers/demo/src/api.ts @@ -21,3 +21,11 @@ export const createExpenseReportClientUrl = async ({ endpointId }: { endpointId: export const createDeExpenseReportClientUrl = async ({ endpointId }: { endpointId: string }) => { return `${window.location.origin}${base}/belegeinreichung-client/${endpointId}`; }; + +export const createFlottformFileSharingClientUrl = async ({ + endpointId +}: { + endpointId: string; +}) => { + return `${window.location.origin}${base}/flottform-file-sharing-client/${endpointId}`; +}; diff --git a/servers/demo/src/lib/components/FileExchangeProgress.svelte b/servers/demo/src/lib/components/FileExchangeProgress.svelte new file mode 100644 index 0000000..19d260c --- /dev/null +++ b/servers/demo/src/lib/components/FileExchangeProgress.svelte @@ -0,0 +1,27 @@ + + +
+

+ {fileExchangeType === 'sending' ? 'sending' : 'receiving'} ({exchangeFilesMetaData.currentFileProgress}%): + {exchangeFilesMetaData.fileName} +

+ +
+
+
+

+ {exchangeFilesMetaData.fileIndex} of {exchangeFilesMetaData.totalFileCount} files +

+
diff --git a/servers/demo/src/lib/components/ReceivedFilesList.svelte b/servers/demo/src/lib/components/ReceivedFilesList.svelte new file mode 100644 index 0000000..183a939 --- /dev/null +++ b/servers/demo/src/lib/components/ReceivedFilesList.svelte @@ -0,0 +1,38 @@ + + +
+ {#each receivedFiles as file, index} +
  • + {file.name} +
    + + Download + + +
    +
  • + {/each} +
    diff --git a/servers/demo/src/routes/+page.svelte b/servers/demo/src/routes/+page.svelte index 0ba96a6..8b553dd 100644 --- a/servers/demo/src/routes/+page.svelte +++ b/servers/demo/src/routes/+page.svelte @@ -64,5 +64,10 @@ title="Customized default UI" description="See how you can tailor Flottform's default UI to better match your design, while still retaining all the powerful features of the original interface. This demo lets you explore how easy it is to adapt the default elements to fit seamlessly with your brand's style." /> + diff --git a/servers/demo/src/routes/flottform-file-sharing-client/[endpointId]/+page.svelte b/servers/demo/src/routes/flottform-file-sharing-client/[endpointId]/+page.svelte new file mode 100644 index 0000000..a15c6b4 --- /dev/null +++ b/servers/demo/src/routes/flottform-file-sharing-client/[endpointId]/+page.svelte @@ -0,0 +1,192 @@ + + +
    +
    +

    Flottform File Sharing - Client

    +
    + {#if connectionStatus === 'init'} +

    Connecting to the host...

    + {:else if connectionStatus === 'connected'} +
    +

    File Sharing

    + +
    +

    Send one or multiple File

    +
    + + +
    + {#if sendingFilesMetaData.sending} + + {/if} +
    + + +
    +

    Received Files

    +
      + {#if receivedFiles.length === 0} +

      ---No Files Received Yet---

      + {:else} + + {/if} +
    + {#if receivingFilesMetaData.receiving} + + {/if} +
    + +
    + {:else if connectionStatus === 'disconnected'} +
    +

    Channel is disconnected!

    +

    + Do want to connect one more time? Scan the QR code or copy the link from the other + device! +

    +
    + {:else if connectionStatus === 'error'} +
    +

    + Connection Channel Failed with the following error: {error} +

    +
    + {/if} +
    +
    +
    diff --git a/servers/demo/src/routes/flottform-file-sharing/+page.svelte b/servers/demo/src/routes/flottform-file-sharing/+page.svelte new file mode 100644 index 0000000..66fb1f3 --- /dev/null +++ b/servers/demo/src/routes/flottform-file-sharing/+page.svelte @@ -0,0 +1,247 @@ + + + + Flottform DEMO + + +
    +
    +

    Flottform File Sharing - Host

    +
    + {#if connectionStatus === 'new'} +
    +

    + Start a new connection to exchange files with someone else! +

    + +
    + {:else if connectionStatus === 'endpoint-created'} +
    +
    + QR Code +
    +

    + Scan the QR code or use the link below to connect your device +

    +
    + {connectionInfo.link} + +
    + +
    + {:else if connectionStatus === 'connected'} +
    +

    File Sharing

    + +
    +

    Send one or multiple File

    +
    + + +
    + {#if sendingFilesMetaData.sending} + + {/if} +
    + + +
    +

    Received Files

    +
      + {#if receivedFiles.length === 0} +

      ---No Files Received Yet---

      + {:else} + + {/if} +
    + {#if receivingFilesMetaData.receiving} + + {/if} +
    + +
    + {:else if connectionStatus === 'disconnected'} +
    +

    Channel is disconnected!

    +

    Do want to connect one more time? Click the button below!

    + +
    + {:else if connectionStatus === 'error'} +
    +

    + Connection Channel Failed with the following error: {error} +

    + +
    + {/if} +
    +
    +