From 33c9f4d72e9b0dd400b3d604513a6437caba04b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C5=91rik=20Levente?= <33373714+Levminer@users.noreply.github.com> Date: Sat, 31 Aug 2024 17:34:11 +0200 Subject: [PATCH] Web remote connections improvements --- .../ui/components/connectionDropdown.svelte | 194 ++++++++++++++---- .../ui/components/modularDialog.svelte | 44 ++++ .../ui/components/powerDropdown.svelte | 16 +- .../web/src/components/connect.svelte | 56 ++++- .../src/routes/(app)/settings/+page.svelte | 175 ++++------------ 5 files changed, 305 insertions(+), 180 deletions(-) create mode 100644 platforms/interface/ui/components/modularDialog.svelte diff --git a/platforms/interface/ui/components/connectionDropdown.svelte b/platforms/interface/ui/components/connectionDropdown.svelte index 0052d41..1932d80 100644 --- a/platforms/interface/ui/components/connectionDropdown.svelte +++ b/platforms/interface/ui/components/connectionDropdown.svelte @@ -1,56 +1,174 @@ - - - - -
- - + {#if mode === "header"} + + + +
+ + {:else} + + +

Connections

+
+ {/if} + - {#if $settings.connectionCodes.length === 0} - -
- -
-
-

No connections

-
Go to settings
-
-
- {/if} {#each $settings.connectionCodes as item, i} {#if i > 0} - + {/if} - { - connect(item.code) - }} - class="flex cursor-pointer select-none items-center gap-3 rounded-xl p-2 duration-200 ease-in-out data-[highlighted]:bg-gray-600" - > -
- -
+

{item.name}

crs_********{item.code.slice(-2)}
- +
+ + + + + + + + { + editConnectionCode(item.code) + }} + class="smallButton" + > + + Edit + + + + + +
+
+
Name *
+ +
+ +
+
Connection code *
+ +
+ +
+
MAC address
+ +
+
+
+ +
+
{/each} - - +
+ + + Add connection + + + addConnectionCode()} class="smallButton"> + + Add + + +
+
+
Name *
+ +
+ +
+
Connection code *
+ +
+ +
+
MAC address
+ +
+
+
+
+
+ diff --git a/platforms/interface/ui/components/modularDialog.svelte b/platforms/interface/ui/components/modularDialog.svelte new file mode 100644 index 0000000..772c150 --- /dev/null +++ b/platforms/interface/ui/components/modularDialog.svelte @@ -0,0 +1,44 @@ + + + + + + + {title} + + + {description} + +
+ +
+
+ + +
+ + +
+ + Close +
+
+
+
+
+ + diff --git a/platforms/interface/ui/components/powerDropdown.svelte b/platforms/interface/ui/components/powerDropdown.svelte index b59f014..4c1e0be 100644 --- a/platforms/interface/ui/components/powerDropdown.svelte +++ b/platforms/interface/ui/components/powerDropdown.svelte @@ -6,7 +6,7 @@ @@ -14,7 +14,7 @@ on:click={() => { action("disconnect") }} - class="flex cursor-pointer select-none items-center gap-3 rounded-xl p-2 duration-200 ease-in-out data-[highlighted]:bg-gray-600" + class="flex cursor-pointer select-none items-center gap-3 p-3 px-5 duration-200 ease-in-out data-[highlighted]:bg-gray-500" >
@@ -23,12 +23,12 @@

Disconnect

- + { action("sleep") }} - class="flex cursor-pointer select-none items-center gap-3 rounded-xl p-2 duration-200 ease-in-out data-[highlighted]:bg-gray-600" + class="flex cursor-pointer select-none items-center gap-3 p-3 px-5 duration-200 ease-in-out data-[highlighted]:bg-gray-500" >
@@ -37,12 +37,12 @@

Sleep

- + { action("shutdown") }} - class="flex cursor-pointer select-none items-center gap-3 rounded-xl p-2 duration-200 ease-in-out data-[highlighted]:bg-gray-600" + class="flex cursor-pointer select-none items-center gap-3 p-3 px-5 duration-200 ease-in-out data-[highlighted]:bg-gray-500" >
@@ -51,12 +51,12 @@

Shut down

- + { action("restart") }} - class="flex cursor-pointer select-none items-center gap-3 rounded-xl p-2 duration-200 ease-in-out data-[highlighted]:bg-gray-600" + class="flex cursor-pointer select-none items-center gap-3 p-3 px-5 duration-200 ease-in-out data-[highlighted]:bg-gray-500" >
diff --git a/platforms/interface/web/src/components/connect.svelte b/platforms/interface/web/src/components/connect.svelte index 0277e53..0b486e5 100644 --- a/platforms/interface/web/src/components/connect.svelte +++ b/platforms/interface/web/src/components/connect.svelte @@ -10,7 +10,7 @@
{/each} - Add connection + + + Add connection + + + addConnectionCode()} class="smallButton"> + + Add + + +
+
+
Name *
+ +
+ +
+
Connection code *
+ +
+ +
+
MAC address
+ +
+
+
@@ -32,4 +58,30 @@ import { Plug } from "lucide-svelte" import { goto } from "$app/navigation" import { state } from "../stores/state.ts" + import ModularDialog from "ui/components/modularDialog.svelte" + import { Plus } from "lucide-svelte" + import { Dialog } from "bits-ui" + + const addConnectionCode = () => { + const nameInput = document.getElementById("name") as HTMLInputElement + const codeInput = document.getElementById("code") as HTMLInputElement + const macInput = document.getElementById("mac") as HTMLInputElement + + if (nameInput.value === "") { + return alert("Please enter a name for your connection") + } + + if (!codeInput.value.startsWith("crs_")) { + return alert("Invalid connection code! The connection code must start with: crs_") + } + + $settings.connectionCodes = [ + ...$settings.connectionCodes, + { + name: nameInput.value, + code: codeInput.value, + mac: macInput.value, + }, + ] + } diff --git a/platforms/interface/web/src/routes/(app)/settings/+page.svelte b/platforms/interface/web/src/routes/(app)/settings/+page.svelte index d06d743..9fc2428 100644 --- a/platforms/interface/web/src/routes/(app)/settings/+page.svelte +++ b/platforms/interface/web/src/routes/(app)/settings/+page.svelte @@ -1,118 +1,54 @@
- -
+ + + + +
- +
-

Remote connections

+

Feedback

-

Get your connection code from the Cores desktop app.

+

Thank you for providing feedback! Please report issues or feature requests on GitHub or by Email (cores@levminer.com).

-
- + -
- -
- {#each $settings.connectionCodes as item} -
-
-
-
Name
- -
- -
-
Connection code
- -
-
- -
-
- { - editConnectionCode(item.code) - }} - > - - - Edit - - - - -
-
-
Name *
- -
- -
-
Connection code *
- -
- -
-
MAC address
- -
-
-
-
- - {#if $state.state === "connected" && item.mac} - - {/if} -
-
- {/each} + + GitHub +
@@ -146,7 +82,7 @@