Skip to content

Commit

Permalink
Web WOL
Browse files Browse the repository at this point in the history
  • Loading branch information
Levminer committed Jul 18, 2024
1 parent e09ec2a commit 24c6e42
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
6 changes: 4 additions & 2 deletions platforms/interface/ui/components/dialog.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Dialog.Root bind:open={open}>
<Dialog.Root bind:open>
<Dialog.Trigger class="button">
<slot name="button">
<Plus />
Expand All @@ -19,14 +19,16 @@
<div class="flex flex-col items-start gap-1 pb-11 pt-7">
<slot />
</div>
<div class="flex w-full justify-end">
<div class="flex w-full justify-between">
<slot name="delete" />
<Dialog.Close on:click={action} class="smallButton">
<slot name="button">
<Plus />
Add
</slot>
</Dialog.Close>
</div>

<Dialog.Close
class="focus-visible:ring-foreground focus-visible:ring-offset-background active:scale-98 absolute right-5 top-5 rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2"
>
Expand Down
32 changes: 27 additions & 5 deletions platforms/interface/web/src/routes/(app)/settings/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@
<Pencil />
Edit
</slot>
<slot slot="delete">
<button
class="smallButton border-red-600 bg-red-600 text-white hover:text-red-600"
on:click={() => deleteConnectionCode(item.code)}
>
<Trash2 />
Delete
</button>
</slot>
<div class="flex flex-col flex-wrap gap-3">
<div>
<h5>Name <span class="text-red-500">*</span></h5>
Expand All @@ -85,10 +94,22 @@
</Dialog>
</div>

<button class="button mt-6" on:click={() => deleteConnectionCode(item.code)}>
<Trash2 />
<span>Delete</span>
</button>
{#if $state.state === "connected" && item.mac}
<button
class="button mt-6"
on:click={() => {
console.log(item.mac?.replaceAll(":", ""))

$state.message = JSON.stringify({
type: "wol",
data: item.mac?.replaceAll(":", ""),
})
}}
>
<Power />
<span>Turn on</span>
</button>
{/if}
</div>
</div>
{/each}
Expand Down Expand Up @@ -125,9 +146,10 @@
<script lang="ts">
import { settings } from "ui/stores/settings.ts"
import Dialog from "ui/components/dialog.svelte"
import { Trash2, MonitorSmartphone, Info, Pencil } from "lucide-svelte"
import { Trash2, MonitorSmartphone, Info, Pencil, Power } from "lucide-svelte"
import { version, number, date } from "../../../../../../../build.json"
import { onMount } from "svelte"
import { state } from "../../../stores/state.ts"
$: dialogOpen = false
Expand Down
2 changes: 2 additions & 0 deletions platforms/windows/lib/Commands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ public static void HandleRemoteMessage(string message) {
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
});

Log.Information("Remote message: {@netMessage}", netMessage);

switch (netMessage?.Type) {
case "shutdown":
ExecuteCommand(@"shutdown /s /t 30");
Expand Down

0 comments on commit 24c6e42

Please sign in to comment.