2024-07-07 22:11:18 +02:00
|
|
|
import * as React from "bloatless-react";
|
|
|
|
|
|
2024-07-09 14:11:20 +02:00
|
|
|
import {
|
|
|
|
|
cannotConnect,
|
|
|
|
|
cannotDeleteMailbox,
|
|
|
|
|
cannotDisonnect,
|
|
|
|
|
cannotRequestMailbox,
|
2024-07-09 14:18:38 +02:00
|
|
|
cannotResetAddress,
|
2024-07-09 14:11:20 +02:00
|
|
|
connect,
|
|
|
|
|
deleteMailbox,
|
|
|
|
|
disconnect,
|
2024-07-09 20:09:09 +02:00
|
|
|
previousAddresses,
|
2024-07-09 14:11:20 +02:00
|
|
|
requestMailbox,
|
2024-07-09 14:18:38 +02:00
|
|
|
resetAddressInput,
|
2024-07-09 14:11:20 +02:00
|
|
|
serverAddressInput,
|
|
|
|
|
} from "../Model/model";
|
|
|
|
|
|
2024-07-07 22:11:18 +02:00
|
|
|
import { translation } from "../translations";
|
|
|
|
|
|
2024-07-11 00:56:06 +02:00
|
|
|
const addressConverter: React.StateItemConverter<string> = (address) => {
|
2024-07-09 20:09:09 +02:00
|
|
|
return <option>{address}</option>;
|
|
|
|
|
};
|
|
|
|
|
|
2024-07-07 22:11:18 +02:00
|
|
|
export function ConnectionSection() {
|
|
|
|
|
return (
|
2024-07-09 14:11:20 +02:00
|
|
|
<div class="flex-column">
|
2024-07-09 15:15:17 +02:00
|
|
|
<h2>{translation.connection}</h2>
|
|
|
|
|
|
2024-07-09 14:11:20 +02:00
|
|
|
<label class="tile">
|
|
|
|
|
<span class="icon">cell_tower</span>
|
|
|
|
|
<div>
|
|
|
|
|
<span>{translation.serverAddress}</span>
|
|
|
|
|
<input
|
|
|
|
|
bind:value={serverAddressInput}
|
|
|
|
|
on:enter={connect}
|
|
|
|
|
placeholder={translation.serverAddressPlaceholder}
|
2024-07-09 20:09:09 +02:00
|
|
|
list="previous-addresses"
|
2024-07-09 14:11:20 +02:00
|
|
|
></input>
|
2024-07-09 20:09:09 +02:00
|
|
|
<datalist
|
|
|
|
|
hidden
|
|
|
|
|
id="previous-addresses"
|
|
|
|
|
children:append={[previousAddresses, addressConverter]}
|
|
|
|
|
></datalist>
|
2024-07-09 14:11:20 +02:00
|
|
|
</div>
|
|
|
|
|
</label>
|
|
|
|
|
<div class="flex-row width-input justify-end">
|
|
|
|
|
<button
|
2024-07-09 14:18:38 +02:00
|
|
|
class="danger width-100 flex-1 justify-center"
|
2024-07-09 14:11:20 +02:00
|
|
|
aria-label={translation.disconnect}
|
|
|
|
|
on:click={disconnect}
|
|
|
|
|
toggle:disabled={cannotDisonnect}
|
|
|
|
|
>
|
|
|
|
|
<span class="icon">close</span>
|
|
|
|
|
</button>
|
|
|
|
|
<button
|
2024-07-09 14:18:38 +02:00
|
|
|
class="width-100 flex-1 justify-center"
|
2024-07-09 17:23:29 +02:00
|
|
|
aria-label={translation.undoChanges}
|
2024-07-09 14:18:38 +02:00
|
|
|
on:click={resetAddressInput}
|
|
|
|
|
toggle:disabled={cannotResetAddress}
|
2024-07-09 14:11:20 +02:00
|
|
|
>
|
|
|
|
|
<span class="icon">undo</span>
|
|
|
|
|
</button>
|
|
|
|
|
<button
|
2024-07-09 14:18:38 +02:00
|
|
|
class="primary width-100 flex-1 justify-center"
|
2024-07-09 14:11:20 +02:00
|
|
|
aria-label={translation.connectToServer}
|
|
|
|
|
on:click={connect}
|
|
|
|
|
toggle:disabled={cannotConnect}
|
|
|
|
|
>
|
|
|
|
|
<span class="icon">arrow_forward</span>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<hr></hr>
|
|
|
|
|
|
|
|
|
|
<div class="tile">
|
|
|
|
|
<span class="icon">inbox</span>
|
|
|
|
|
<div>
|
|
|
|
|
<b>{translation.mailbox}</b>
|
|
|
|
|
<span class="secondary">{translation.mailboxExplanation}</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="flex-row width-input justify-end">
|
|
|
|
|
<button
|
|
|
|
|
class="danger width-100 flex-1"
|
|
|
|
|
on:click={deleteMailbox}
|
|
|
|
|
toggle:disabled={cannotDeleteMailbox}
|
|
|
|
|
>
|
|
|
|
|
{translation.deleteMailbox}
|
|
|
|
|
</button>
|
|
|
|
|
<button
|
|
|
|
|
class="primary width-100 flex-1"
|
|
|
|
|
on:click={requestMailbox}
|
|
|
|
|
toggle:disabled={cannotRequestMailbox}
|
|
|
|
|
>
|
|
|
|
|
{translation.requestMailbox}
|
|
|
|
|
<span class="icon">arrow_forward</span>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
2024-07-07 22:11:18 +02:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|