2026-04-18 11:55:01 +00:00
|
|
|
import "./homePage.css";
|
|
|
|
|
import { StringToOption } from "./Components/option";
|
|
|
|
|
import { HomePageButton } from "./Components/homePageButton";
|
2024-07-20 14:16:26 +02:00
|
|
|
import { ChatViewModelToChatEntry } from "./Components/chatEntry";
|
2026-09-23 00:09:09 +02:00
|
|
|
import * as React from "../react";
|
2024-07-22 19:52:08 +02:00
|
|
|
import StorageViewModel from "../ViewModel/Global/storageViewModel";
|
2026-04-18 11:55:01 +00:00
|
|
|
import SettingsViewModel from "../ViewModel/Global/settingsViewModel";
|
|
|
|
|
import FileTransferViewModel from "../ViewModel/Global/fileTransferViewModel";
|
2026-04-08 09:56:37 +00:00
|
|
|
import CoreViewModel from "../ViewModel/Global/coreViewModel";
|
2026-04-18 11:55:01 +00:00
|
|
|
import ConnectionViewModel from "../ViewModel/Global/connectionViewModel";
|
|
|
|
|
import ChatListViewModel from "../ViewModel/Chat/chatListViewModel";
|
2024-07-19 23:45:07 +02:00
|
|
|
|
2024-07-20 02:18:15 +02:00
|
|
|
export function HomePage(
|
2026-04-09 16:48:22 +00:00
|
|
|
coreViewModel: CoreViewModel,
|
2026-04-01 08:29:39 +00:00
|
|
|
storageViewModel: StorageViewModel,
|
|
|
|
|
settingsViewModel: SettingsViewModel,
|
|
|
|
|
connectionViewModel: ConnectionViewModel,
|
|
|
|
|
fileTransferViewModel: FileTransferViewModel,
|
|
|
|
|
chatListViewModel: ChatListViewModel,
|
2024-07-20 02:18:15 +02:00
|
|
|
) {
|
2026-04-01 08:29:39 +00:00
|
|
|
// sections
|
2026-09-24 22:07:36 +02:00
|
|
|
const updateText = React.createProxyState([coreViewModel.latestVersion], ()=>coreViewModel.translations.homePage.updateButton(coreViewModel.latestVersion.value));
|
|
|
|
|
|
2026-04-01 08:29:39 +00:00
|
|
|
const overviewSection = (
|
2026-09-24 22:07:36 +02:00
|
|
|
<div id="overview-section">
|
|
|
|
|
<h2>{coreViewModel.translations.homePage.overviewHeadline}</h2>
|
2026-04-01 08:29:39 +00:00
|
|
|
|
2026-09-24 22:07:36 +02:00
|
|
|
<label class="tile flex-no">
|
|
|
|
|
<span class="icon">cell_tower</span>
|
|
|
|
|
<div>
|
|
|
|
|
<span>
|
|
|
|
|
{coreViewModel.translations.homePage.serverAddress}
|
|
|
|
|
</span>
|
|
|
|
|
<input
|
|
|
|
|
list="previous-connection-list"
|
|
|
|
|
placeholder={
|
|
|
|
|
coreViewModel.translations.homePage
|
|
|
|
|
.serverAddressPlaceholder
|
|
|
|
|
}
|
|
|
|
|
bind:value={connectionViewModel.serverAddressInput}
|
|
|
|
|
on:enter={connectionViewModel.connect}
|
|
|
|
|
></input>
|
|
|
|
|
<datalist
|
|
|
|
|
hidden
|
|
|
|
|
id="previous-connection-list"
|
|
|
|
|
children:append={[
|
|
|
|
|
connectionViewModel.previousAddresses,
|
|
|
|
|
StringToOption,
|
|
|
|
|
]}
|
|
|
|
|
></datalist>
|
|
|
|
|
</div>
|
|
|
|
|
</label>
|
|
|
|
|
|
|
|
|
|
<div class="flex-row">
|
|
|
|
|
<button
|
|
|
|
|
class="danger flex justify-center"
|
|
|
|
|
aria-label={
|
|
|
|
|
coreViewModel.translations.homePage.disconnectAudioLabel
|
|
|
|
|
}
|
|
|
|
|
on:click={connectionViewModel.disconnect}
|
|
|
|
|
toggle:disabled={connectionViewModel.cannotDisonnect}
|
|
|
|
|
>
|
|
|
|
|
<span class="icon">link_off</span>
|
|
|
|
|
</button>
|
|
|
|
|
<button
|
|
|
|
|
class="flex justify-center"
|
|
|
|
|
aria-label={
|
|
|
|
|
coreViewModel.translations.homePage
|
|
|
|
|
.manageConnectionsAudioLabel
|
|
|
|
|
}
|
|
|
|
|
on:click={connectionViewModel.showConnectionModal}
|
|
|
|
|
toggle:disabled={
|
|
|
|
|
connectionViewModel.hasNoPreviousConnections
|
|
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
<span class="icon">history</span>
|
|
|
|
|
</button>
|
|
|
|
|
<button
|
|
|
|
|
class="primary flex justify-center"
|
|
|
|
|
aria-label={
|
|
|
|
|
coreViewModel.translations.homePage.connectAudioLabel
|
|
|
|
|
}
|
|
|
|
|
on:click={connectionViewModel.connect}
|
|
|
|
|
toggle:disabled={connectionViewModel.cannotConnect}
|
|
|
|
|
>
|
|
|
|
|
<span class="icon">link</span>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<hr></hr>
|
|
|
|
|
|
|
|
|
|
<label class="tile flex-no">
|
|
|
|
|
<span class="icon">account_circle</span>
|
|
|
|
|
<div>
|
|
|
|
|
<span>
|
|
|
|
|
{coreViewModel.translations.homePage.yourNameLabel}
|
|
|
|
|
</span>
|
|
|
|
|
<input
|
|
|
|
|
placeholder={
|
|
|
|
|
coreViewModel.translations.homePage
|
|
|
|
|
.yourNamePlaceholder
|
|
|
|
|
}
|
|
|
|
|
bind:value={settingsViewModel.usernameInput}
|
|
|
|
|
on:enter={settingsViewModel.setName}
|
|
|
|
|
></input>
|
|
|
|
|
</div>
|
|
|
|
|
</label>
|
|
|
|
|
<div class="flex-row justify-end">
|
|
|
|
|
<button
|
|
|
|
|
class="width-50"
|
|
|
|
|
on:click={settingsViewModel.setName}
|
|
|
|
|
toggle:disabled={settingsViewModel.cannotSetName}
|
|
|
|
|
aria-label={
|
|
|
|
|
coreViewModel.translations.homePage
|
|
|
|
|
.setNameButtonAudioLabel
|
|
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
{coreViewModel.translations.general.setButton}
|
|
|
|
|
<span class="icon">check</span>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<hr></hr>
|
|
|
|
|
|
|
|
|
|
{HomePageButton(
|
|
|
|
|
settingsViewModel.showSettingsModal,
|
|
|
|
|
coreViewModel.translations.homePage.settingsButton,
|
|
|
|
|
"settings",
|
|
|
|
|
)}
|
|
|
|
|
{HomePageButton(
|
|
|
|
|
fileTransferViewModel.showDirectionSelectionModal,
|
|
|
|
|
coreViewModel.translations.homePage.transferDataButton,
|
|
|
|
|
"sync_alt",
|
|
|
|
|
)}
|
|
|
|
|
{HomePageButton(
|
|
|
|
|
storageViewModel.showStorageModal,
|
|
|
|
|
coreViewModel.translations.homePage.manageStorageButton,
|
|
|
|
|
"hard_drive",
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
<button
|
|
|
|
|
class="primary"
|
|
|
|
|
on:click={coreViewModel.update}
|
|
|
|
|
toggle:hidden={coreViewModel.noUpdateAvailable}
|
|
|
|
|
>
|
|
|
|
|
<span
|
|
|
|
|
subscribe:innerText={updateText}
|
|
|
|
|
></span>
|
|
|
|
|
<span class="icon">update</span>
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
|
|
<div class="mobile-only">
|
|
|
|
|
<hr></hr>
|
|
|
|
|
|
|
|
|
|
<div class="flex-row justify-end">
|
|
|
|
|
<button class="ghost width-50" on:click={scrollToChat}>
|
|
|
|
|
{coreViewModel.translations.homePage.scrollToChatButton}
|
|
|
|
|
<span class="icon">arrow_forward</span>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const chatSection = (
|
|
|
|
|
<div id="chat-section">
|
|
|
|
|
<h2>{coreViewModel.translations.homePage.chatsHeadline}</h2>
|
|
|
|
|
|
|
|
|
|
<div class="flex-row width-input">
|
|
|
|
|
<input
|
|
|
|
|
placeholder={
|
|
|
|
|
coreViewModel.translations.homePage.addChatPlaceholder
|
|
|
|
|
}
|
|
|
|
|
aria-label={
|
|
|
|
|
coreViewModel.translations.homePage.addChatAudioLabel
|
|
|
|
|
}
|
|
|
|
|
bind:value={chatListViewModel.newChatPrimaryChannel}
|
|
|
|
|
on:enter={chatListViewModel.createChat}
|
|
|
|
|
></input>
|
|
|
|
|
<button
|
|
|
|
|
class="primary"
|
|
|
|
|
aria-label={
|
|
|
|
|
coreViewModel.translations.homePage.addChatButton
|
|
|
|
|
}
|
|
|
|
|
on:click={chatListViewModel.createChat}
|
|
|
|
|
toggle:disabled={chatListViewModel.cannotCreateChat}
|
|
|
|
|
>
|
|
|
|
|
<span class="icon">add</span>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div
|
|
|
|
|
id="chat-grid"
|
|
|
|
|
children:append={[
|
|
|
|
|
chatListViewModel.chatViewModels,
|
|
|
|
|
ChatViewModelToChatEntry,
|
|
|
|
|
]}
|
|
|
|
|
></div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// methods
|
|
|
|
|
function scrollToChat() {
|
|
|
|
|
chatSection.scrollIntoView();
|
|
|
|
|
}
|
2026-04-01 08:29:39 +00:00
|
|
|
|
2026-09-24 22:07:36 +02:00
|
|
|
// final
|
|
|
|
|
return (
|
|
|
|
|
<article id="home-page">
|
|
|
|
|
<div>
|
|
|
|
|
{overviewSection}
|
|
|
|
|
{chatSection}
|
|
|
|
|
</div>
|
|
|
|
|
</article>
|
2026-04-01 08:29:39 +00:00
|
|
|
);
|
2024-07-19 23:45:07 +02:00
|
|
|
}
|