2024-07-27 19:13:59 +02:00
|
|
|
import * as React from "bloatless-react";
|
|
|
|
|
|
|
|
|
|
import FileTransferViewModel, {
|
2024-07-28 00:02:17 +02:00
|
|
|
FileTransferModal,
|
2024-07-27 19:13:59 +02:00
|
|
|
FileTransferOption,
|
|
|
|
|
} from "../../ViewModel/Global/fileTransferViewModel";
|
|
|
|
|
|
|
|
|
|
import StorageModel from "../../Model/Global/storageModel";
|
2024-07-28 02:27:09 +02:00
|
|
|
import { StringToTextSpan } from "../Components/textSpan";
|
2024-07-28 03:46:08 +02:00
|
|
|
import { reload } from "../utility";
|
2024-07-27 19:13:59 +02:00
|
|
|
import { translations } from "../translations";
|
|
|
|
|
|
2024-07-28 00:02:17 +02:00
|
|
|
export function DataTransferModalWrapper(
|
2024-07-27 19:13:59 +02:00
|
|
|
fileTransferViewModel: FileTransferViewModel
|
|
|
|
|
) {
|
2024-07-28 00:02:17 +02:00
|
|
|
return (
|
|
|
|
|
<div>
|
|
|
|
|
{DirectionSelectionModal(fileTransferViewModel)}
|
|
|
|
|
{FileSelectionModal(fileTransferViewModel)}
|
2024-07-28 00:25:51 +02:00
|
|
|
{TransferDataDisplayModal(fileTransferViewModel)}
|
2024-07-28 02:27:09 +02:00
|
|
|
{TransferDisplayModal(fileTransferViewModel)}
|
2024-07-28 03:46:08 +02:00
|
|
|
{TransferDataInputModal(fileTransferViewModel)}
|
|
|
|
|
{DataReceptionModal(fileTransferViewModel)}
|
2024-07-28 00:02:17 +02:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function DirectionSelectionModal(fileTransferViewModel: FileTransferViewModel) {
|
|
|
|
|
const isPresented = React.createProxyState(
|
|
|
|
|
[fileTransferViewModel.presentedModal],
|
|
|
|
|
() =>
|
|
|
|
|
fileTransferViewModel.presentedModal.value ==
|
|
|
|
|
FileTransferModal.DirectionSelection
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div class="modal" toggle:open={isPresented}>
|
|
|
|
|
<div>
|
|
|
|
|
<main>
|
|
|
|
|
<h2>{translations.dataTransferModal.transferDataHeadline}</h2>
|
|
|
|
|
|
|
|
|
|
<div class="flex-column gap content-margin-bottom">
|
|
|
|
|
<button
|
|
|
|
|
class="tile"
|
|
|
|
|
on:click={fileTransferViewModel.showFileSelectionModal}
|
|
|
|
|
>
|
|
|
|
|
<span class="icon">upload</span>
|
|
|
|
|
<div>
|
|
|
|
|
<b>{translations.dataTransferModal.fromThisDeviceButton}</b>
|
|
|
|
|
</div>
|
|
|
|
|
<span class="icon">arrow_forward</span>
|
|
|
|
|
</button>
|
2024-07-28 03:46:08 +02:00
|
|
|
<button
|
|
|
|
|
class="tile"
|
|
|
|
|
on:click={fileTransferViewModel.showTransferDataInputModal}
|
|
|
|
|
>
|
2024-07-28 00:02:17 +02:00
|
|
|
<span class="icon">download</span>
|
|
|
|
|
<div>
|
|
|
|
|
<b>{translations.dataTransferModal.toThisDeviceButton}</b>
|
|
|
|
|
</div>
|
|
|
|
|
<span class="icon">arrow_forward</span>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</main>
|
|
|
|
|
<button on:click={fileTransferViewModel.hideModal}>
|
|
|
|
|
{translations.general.closeButton}
|
|
|
|
|
<span class="icon">close</span>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function FileSelectionModal(fileTransferViewModel: FileTransferViewModel) {
|
|
|
|
|
// option
|
2024-07-27 19:40:16 +02:00
|
|
|
const OptionConverter: React.StateItemConverter<FileTransferOption> = (
|
|
|
|
|
fileOption: FileTransferOption
|
|
|
|
|
) => {
|
2024-07-27 23:45:36 +02:00
|
|
|
return OptionEntry(fileOption, fileTransferViewModel);
|
2024-07-27 19:40:16 +02:00
|
|
|
};
|
|
|
|
|
|
2024-07-28 00:02:17 +02:00
|
|
|
function OptionEntry(
|
|
|
|
|
fileOption: FileTransferOption,
|
|
|
|
|
fileTransferViewModel: FileTransferViewModel
|
|
|
|
|
) {
|
|
|
|
|
const isSelected = new React.State(false);
|
2024-07-28 00:25:51 +02:00
|
|
|
if (fileTransferViewModel.selectedPaths.value.has(fileOption.path)) {
|
|
|
|
|
isSelected.value = true;
|
|
|
|
|
}
|
2024-07-28 00:02:17 +02:00
|
|
|
isSelected.subscribeSilent((isSelected) => {
|
|
|
|
|
if (isSelected == true) {
|
|
|
|
|
fileTransferViewModel.selectedPaths.add(fileOption.path);
|
|
|
|
|
} else {
|
|
|
|
|
fileTransferViewModel.selectedPaths.remove(fileOption.path);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
function toggle() {
|
|
|
|
|
isSelected.value = !isSelected.value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<button class="tile" toggle:selected={isSelected} on:click={toggle}>
|
|
|
|
|
<div>
|
|
|
|
|
<b class="ellipsis">{fileOption.label}</b>
|
|
|
|
|
<span class="secondary ellipsis">
|
|
|
|
|
{StorageModel.pathComponentsToString(...fileOption.path)}
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
</button>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// state
|
|
|
|
|
const isPresented = React.createProxyState(
|
|
|
|
|
[fileTransferViewModel.presentedModal],
|
|
|
|
|
() =>
|
|
|
|
|
fileTransferViewModel.presentedModal.value ==
|
|
|
|
|
FileTransferModal.FileSelection
|
|
|
|
|
);
|
|
|
|
|
|
2024-07-27 19:13:59 +02:00
|
|
|
return (
|
2024-07-28 00:02:17 +02:00
|
|
|
<div class="modal" toggle:open={isPresented}>
|
2024-07-27 19:13:59 +02:00
|
|
|
<div>
|
|
|
|
|
<main>
|
2024-07-27 23:45:36 +02:00
|
|
|
<h2>{translations.dataTransferModal.transferDataHeadline}</h2>
|
2024-07-27 19:13:59 +02:00
|
|
|
<span class="secondary">
|
2024-07-27 23:45:36 +02:00
|
|
|
{translations.dataTransferModal.selectionDescription}
|
2024-07-27 19:13:59 +02:00
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
<hr></hr>
|
|
|
|
|
|
2024-07-27 23:45:36 +02:00
|
|
|
<h3>{translations.dataTransferModal.generalHeadline}</h3>
|
2024-07-27 19:13:59 +02:00
|
|
|
<div
|
|
|
|
|
class="flex-column gap content-margin-bottom"
|
|
|
|
|
children:append={[
|
|
|
|
|
fileTransferViewModel.generalFileOptions,
|
2024-07-27 19:40:16 +02:00
|
|
|
OptionConverter,
|
2024-07-27 19:13:59 +02:00
|
|
|
]}
|
|
|
|
|
></div>
|
|
|
|
|
|
2024-07-27 23:45:36 +02:00
|
|
|
<h3>{translations.dataTransferModal.chatsHeadline}</h3>
|
2024-07-27 19:13:59 +02:00
|
|
|
<div
|
|
|
|
|
class="flex-column gap"
|
|
|
|
|
children:append={[
|
|
|
|
|
fileTransferViewModel.chatFileOptions,
|
2024-07-27 19:40:16 +02:00
|
|
|
OptionConverter,
|
2024-07-27 19:13:59 +02:00
|
|
|
]}
|
|
|
|
|
></div>
|
|
|
|
|
</main>
|
|
|
|
|
<div class="flex-row width-100">
|
|
|
|
|
<button
|
|
|
|
|
class="flex"
|
2024-07-28 00:02:17 +02:00
|
|
|
on:click={fileTransferViewModel.showDirectionSelectionModal}
|
2024-07-27 19:13:59 +02:00
|
|
|
>
|
2024-07-28 00:02:17 +02:00
|
|
|
{translations.general.backButton}
|
2024-07-27 19:13:59 +02:00
|
|
|
</button>
|
|
|
|
|
<button
|
|
|
|
|
class="primary flex"
|
2024-07-28 00:25:51 +02:00
|
|
|
on:click={fileTransferViewModel.showTransferDataModal}
|
2024-07-28 00:02:17 +02:00
|
|
|
toggle:disabled={fileTransferViewModel.hasNoPathsSelected}
|
2024-07-27 19:13:59 +02:00
|
|
|
>
|
|
|
|
|
{translations.general.continueButton}
|
|
|
|
|
<span class="icon">arrow_forward</span>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
2024-07-28 00:25:51 +02:00
|
|
|
|
|
|
|
|
function TransferDataDisplayModal(
|
|
|
|
|
fileTransferViewModel: FileTransferViewModel
|
|
|
|
|
) {
|
|
|
|
|
const isPresented = React.createProxyState(
|
|
|
|
|
[fileTransferViewModel.presentedModal],
|
|
|
|
|
() =>
|
|
|
|
|
fileTransferViewModel.presentedModal.value ==
|
|
|
|
|
FileTransferModal.TransferDataDisplay
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div class="modal" toggle:open={isPresented}>
|
|
|
|
|
<div>
|
|
|
|
|
<main>
|
|
|
|
|
<h2>{translations.dataTransferModal.transferDataHeadline}</h2>
|
|
|
|
|
|
2024-07-28 02:27:09 +02:00
|
|
|
<span class="secondary">
|
|
|
|
|
{translations.dataTransferModal.dataEntryDescription}
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
<hr></hr>
|
|
|
|
|
|
2024-07-28 00:25:51 +02:00
|
|
|
<div class="flex-column gap content-margin-bottom">
|
|
|
|
|
<div class="tile">
|
|
|
|
|
<span class="icon">forum</span>
|
|
|
|
|
<div>
|
|
|
|
|
<span class="secondary">
|
|
|
|
|
{translations.dataTransferModal.transferChannelHeadline}
|
|
|
|
|
</span>
|
|
|
|
|
<b
|
|
|
|
|
subscribe:innerText={fileTransferViewModel.transferChannel}
|
|
|
|
|
></b>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="tile">
|
|
|
|
|
<span class="icon">key</span>
|
|
|
|
|
<div>
|
|
|
|
|
<span class="secondary">
|
|
|
|
|
{translations.dataTransferModal.transferKeyHeadline}
|
|
|
|
|
</span>
|
|
|
|
|
<b subscribe:innerText={fileTransferViewModel.transferKey}></b>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</main>
|
|
|
|
|
<div class="flex-row width-100">
|
|
|
|
|
<button
|
|
|
|
|
class="flex"
|
|
|
|
|
on:click={fileTransferViewModel.showFileSelectionModal}
|
|
|
|
|
>
|
|
|
|
|
{translations.general.backButton}
|
|
|
|
|
</button>
|
2024-07-28 02:27:09 +02:00
|
|
|
<button
|
|
|
|
|
class="primary flex"
|
|
|
|
|
on:click={fileTransferViewModel.initiateTransfer}
|
|
|
|
|
>
|
|
|
|
|
{translations.dataTransferModal.sendButton}
|
2024-07-28 00:25:51 +02:00
|
|
|
<span class="icon">arrow_forward</span>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
2024-07-28 02:27:09 +02:00
|
|
|
|
|
|
|
|
function TransferDisplayModal(fileTransferViewModel: FileTransferViewModel) {
|
|
|
|
|
const isPresented = React.createProxyState(
|
|
|
|
|
[fileTransferViewModel.presentedModal],
|
|
|
|
|
() =>
|
|
|
|
|
fileTransferViewModel.presentedModal.value ==
|
|
|
|
|
FileTransferModal.TransferDisplay
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div class="modal" toggle:open={isPresented}>
|
|
|
|
|
<div>
|
|
|
|
|
<main>
|
|
|
|
|
<h2>{translations.dataTransferModal.transferDataHeadline}</h2>
|
|
|
|
|
|
|
|
|
|
<p
|
|
|
|
|
class="secondary"
|
|
|
|
|
subscribe:innerText={fileTransferViewModel.filesSentText}
|
|
|
|
|
></p>
|
|
|
|
|
|
2024-07-28 03:46:08 +02:00
|
|
|
<p
|
|
|
|
|
class="secondary"
|
|
|
|
|
toggle:hidden={fileTransferViewModel.didNotFinishSending}
|
|
|
|
|
>
|
|
|
|
|
{translations.dataTransferModal.allFilesSent}
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<hr></hr>
|
|
|
|
|
|
2024-07-28 02:27:09 +02:00
|
|
|
<div
|
|
|
|
|
class="tile flex-column align-start"
|
|
|
|
|
children:append={[
|
|
|
|
|
fileTransferViewModel.filePathsSent,
|
|
|
|
|
StringToTextSpan,
|
|
|
|
|
]}
|
|
|
|
|
></div>
|
|
|
|
|
</main>
|
2024-07-28 19:32:04 +02:00
|
|
|
<div class="flex-row width-100">
|
|
|
|
|
<button
|
|
|
|
|
class="flex"
|
|
|
|
|
on:click={fileTransferViewModel.initiateTransfer}
|
|
|
|
|
>
|
|
|
|
|
{translations.dataTransferModal.sendAgainButton}
|
|
|
|
|
<span class="icon">restart_alt</span>
|
|
|
|
|
</button>
|
|
|
|
|
<button
|
|
|
|
|
class="flex"
|
|
|
|
|
on:click={fileTransferViewModel.hideModal}
|
|
|
|
|
toggle:disabled={fileTransferViewModel.didNotFinishSending}
|
|
|
|
|
>
|
|
|
|
|
{translations.general.closeButton}
|
|
|
|
|
<span class="icon">close</span>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
2024-07-28 02:27:09 +02:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
2024-07-28 03:46:08 +02:00
|
|
|
|
|
|
|
|
function TransferDataInputModal(fileTransferViewModel: FileTransferViewModel) {
|
|
|
|
|
const isPresented = React.createProxyState(
|
|
|
|
|
[fileTransferViewModel.presentedModal],
|
|
|
|
|
() =>
|
|
|
|
|
fileTransferViewModel.presentedModal.value ==
|
|
|
|
|
FileTransferModal.TransferDataInput
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div class="modal" toggle:open={isPresented}>
|
|
|
|
|
<div>
|
|
|
|
|
<main>
|
|
|
|
|
<h2>{translations.dataTransferModal.transferDataHeadline}</h2>
|
|
|
|
|
|
|
|
|
|
<span class="secondary">
|
|
|
|
|
{translations.dataTransferModal.dataEntryInputDescription}
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
<hr></hr>
|
|
|
|
|
|
|
|
|
|
<div class="flex-column gap content-margin-bottom">
|
|
|
|
|
<label class="tile">
|
|
|
|
|
<span class="icon">forum</span>
|
|
|
|
|
<div>
|
|
|
|
|
<span class="secondary">
|
|
|
|
|
{translations.dataTransferModal.transferChannelHeadline}
|
|
|
|
|
</span>
|
|
|
|
|
<input
|
|
|
|
|
bind:value={fileTransferViewModel.receivingTransferChannel}
|
|
|
|
|
></input>
|
|
|
|
|
</div>
|
|
|
|
|
</label>
|
|
|
|
|
<label class="tile">
|
|
|
|
|
<span class="icon">key</span>
|
|
|
|
|
<div>
|
|
|
|
|
<span class="secondary">
|
|
|
|
|
{translations.dataTransferModal.transferKeyHeadline}
|
|
|
|
|
</span>
|
|
|
|
|
<input
|
|
|
|
|
bind:value={fileTransferViewModel.receivingTransferKey}
|
|
|
|
|
></input>
|
|
|
|
|
</div>
|
|
|
|
|
</label>
|
|
|
|
|
</div>
|
|
|
|
|
</main>
|
|
|
|
|
<div class="flex-row width-100">
|
|
|
|
|
<button
|
|
|
|
|
class="flex"
|
|
|
|
|
on:click={fileTransferViewModel.showDirectionSelectionModal}
|
|
|
|
|
>
|
|
|
|
|
{translations.general.backButton}
|
|
|
|
|
</button>
|
|
|
|
|
<button
|
|
|
|
|
class="primary flex"
|
|
|
|
|
on:click={fileTransferViewModel.prepareReceivingData}
|
|
|
|
|
toggle:disabled={fileTransferViewModel.cannotPrepareToReceive}
|
|
|
|
|
>
|
|
|
|
|
{translations.general.continueButton}
|
|
|
|
|
<span class="icon">arrow_forward</span>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function DataReceptionModal(fileTransferViewModel: FileTransferViewModel) {
|
|
|
|
|
const isPresented = React.createProxyState(
|
|
|
|
|
[fileTransferViewModel.presentedModal],
|
|
|
|
|
() =>
|
|
|
|
|
fileTransferViewModel.presentedModal.value ==
|
|
|
|
|
FileTransferModal.ReceptionDisplay
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div class="modal" toggle:open={isPresented}>
|
|
|
|
|
<div>
|
|
|
|
|
<main>
|
|
|
|
|
<h2>{translations.dataTransferModal.transferDataHeadline}</h2>
|
|
|
|
|
|
|
|
|
|
<p class="secondary">
|
|
|
|
|
{translations.dataTransferModal.readyToReceiveDescription}
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<p
|
|
|
|
|
class="secondary"
|
|
|
|
|
subscribe:innerText={fileTransferViewModel.filesReceivedText}
|
|
|
|
|
></p>
|
|
|
|
|
|
|
|
|
|
<hr></hr>
|
|
|
|
|
|
|
|
|
|
<div
|
|
|
|
|
class="tile flex-column align-start"
|
|
|
|
|
children:append={[
|
|
|
|
|
fileTransferViewModel.filePathsReceived,
|
|
|
|
|
StringToTextSpan,
|
|
|
|
|
]}
|
|
|
|
|
></div>
|
|
|
|
|
</main>
|
|
|
|
|
<button on:click={reload}>
|
|
|
|
|
{translations.general.reloadAppButton}
|
|
|
|
|
<span class="icon">refresh</span>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|