Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
DTTerastar committed Sep 29, 2024
1 parent 2257ab2 commit 8e45c00
Show file tree
Hide file tree
Showing 14 changed files with 215 additions and 259 deletions.
12 changes: 9 additions & 3 deletions src/Controllers/NodeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@ namespace ESPresense.Controllers;
public class NodeController(NodeSettingsStore nodeSettingsStore, State state) : ControllerBase
{
[HttpGet("{id}/settings")]
public NodeSettingsDetails Get(string id)
public NodeSettings Get(string id)
{
var nodeSettings = nodeSettingsStore.Get(id);
return nodeSettings ?? new Models.NodeSettings(id);
}

[HttpGet("{id}/details")]
public IList<KeyValuePair<string, string>> Details(string id)
{
var details = new List<KeyValuePair<string, string>>();
if (nodeSettings?.Id != null && state.Nodes.TryGetValue(id, out var node))
if (state.Nodes.TryGetValue(id, out var node))
details.AddRange(node.GetDetails());
return new NodeSettingsDetails(nodeSettings ?? new Models.NodeSettings(id), details);
return details;
}

[HttpPut("{id}/settings")]
Expand Down
155 changes: 0 additions & 155 deletions src/ui/src/lib/GlobalSettings.svelte

This file was deleted.

12 changes: 9 additions & 3 deletions src/ui/src/lib/NodeActions.svelte
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<script lang="ts">
import { base } from '$app/paths';
import link from '$lib/images/link.svg';
import type { Node } from '$lib/types';
import { getModalStore, getToastStore, type ToastSettings } from '@skeletonlabs/skeleton';
import { updateMethod, flavor, version, artifact, flavorNames } from '$lib/firmware';
import Firmware from '$lib/modals/Firmware.svelte';
import { restartNode, updateNodeSelf } from '$lib/node';
import { restartNode, updateNode } from '$lib/node';
import { gotoSettings } from '$lib/urls';
const modalStore = getModalStore();
const toastStore = getToastStore();
Expand All @@ -20,6 +20,10 @@
}
}
function onSettings(i: Node) {
gotoSettings(i.id);
}
function onUpdate(i: Node) {
var f = $flavor;
if (f == '-') f = i.flavor?.value;
Expand All @@ -44,7 +48,7 @@
});
} else {
if (i) {
updateNodeSelf(i.id)
updateNode(i.id)
.then(() => {
const t: ToastSettings = { message: (i.name ?? i.id) + ' asked to update itself', background: 'variant-filled-primary' };
toastStore.trigger(t);
Expand All @@ -71,6 +75,8 @@
<button on:click={() => onRestart(row)} class="btn btn-sm variant-filled">Restart</button>
{/if}

<button on:click={() => onSettings(row)} class="btn btn-sm variant-filled">Settings</button>

{#if row.telemetry?.ip}
<a href="http://{row.telemetry?.ip}" target="_blank" class="btn btn-sm variant-filled">
<span>Visit</span>
Expand Down
Loading

0 comments on commit 8e45c00

Please sign in to comment.