-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #554 from metalizzsas/some-ui-feat
feat: io section with url navigation & full page reload
- Loading branch information
Showing
15 changed files
with
99 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@nuster/ui": patch | ||
--- | ||
|
||
feat: io page is now using url navigation instead of variable navigation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@nuster/ui": patch | ||
--- | ||
|
||
feat: users can now trigger a full page reload in settings |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<script lang="ts"> | ||
import { goto } from "$app/navigation"; | ||
import { page } from "$app/stores"; | ||
import Wrapper from "$lib/components/Wrapper.svelte"; | ||
import SelectableButton from "$lib/components/buttons/SelectableButton.svelte"; | ||
import Flex from "$lib/components/layout/flex.svelte"; | ||
import { ArrowLeftOnRectangle, ArrowRightOnRectangle } from "@steeze-ui/heroicons"; | ||
import { Icon } from "@steeze-ui/svelte-icon"; | ||
import { _ } from "svelte-i18n"; | ||
</script> | ||
|
||
<Flex direction="row" gap={6}> | ||
<div class="shrink-0 drop-shadow-xl"> | ||
<Wrapper> | ||
<Flex direction="col" gap={2}> | ||
<h1 class="leading-8">{$_(`gates.lead`)}</h1> | ||
{#each ["in", "out"] as bus} | ||
<SelectableButton selected={$page.params.bus == bus} on:click={() => goto(`/io/${bus}`)}> | ||
<Flex gap={4} items="center"> | ||
<Icon src={$page.params.bus == "in" ? ArrowLeftOnRectangle: ArrowRightOnRectangle} class="h-4 w-4" /> | ||
<h2>{$_('gates.bus.' + bus)}</h2> | ||
</Flex> | ||
</SelectableButton> | ||
{/each} | ||
</Flex> | ||
</Wrapper> | ||
</div> | ||
|
||
<div class="grow drop-shadow-xl"> | ||
<Wrapper> | ||
<h2 class="leading-10">{$_('gates.bus.' + $page.params.bus)}</h2> | ||
<Flex direction="col" gap={1}> | ||
<slot /> | ||
</Flex> | ||
</Wrapper> | ||
</div> | ||
</Flex> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,7 @@ | ||
import { env } from '$env/dynamic/private'; | ||
import { fail } from '@sveltejs/kit'; | ||
import { redirect } from "@sveltejs/kit" | ||
|
||
export const actions = { | ||
export const load = () => { | ||
|
||
editGateValue: async ({ request, fetch }) => { | ||
return redirect(302, "/io/in"); | ||
|
||
// TODO: This could be replaced by an async send via websocket | ||
|
||
const form = await request.formData(); | ||
|
||
const gate = form.get('gate')?.toString(); | ||
const value = form.get('value')?.toString(); | ||
|
||
if(gate === undefined || value === undefined) | ||
return fail(400, { editGateValue: { error: "Invalid gate update parameters" }}); | ||
|
||
const gateUpdateRequest = await fetch(`http://${env.TURBINE_ADDRESS}/v1/io/${gate.replace("#", "_")}/${value}`, { method: "POST" }); | ||
|
||
if(gateUpdateRequest.status !== 200 || !gateUpdateRequest.ok) | ||
return fail(500, { editGateValue: { error: "Failed to update gate value" }}); | ||
|
||
return { editGateValue: { success: true }}; | ||
|
||
} | ||
} |
This file was deleted.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
packages/ui/src/routes/(connected)/io/[bus]/+page.server.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { env } from '$env/dynamic/private'; | ||
import { fail } from '@sveltejs/kit'; | ||
|
||
export const actions = { | ||
|
||
editGateValue: async ({ request, fetch }) => { | ||
|
||
// TODO: This could be replaced by an async send via websocket | ||
|
||
const form = await request.formData(); | ||
|
||
const gate = form.get('gate')?.toString(); | ||
const value = form.get('value')?.toString(); | ||
|
||
if(gate === undefined || value === undefined) | ||
return fail(400, { editGateValue: { error: "Invalid gate update parameters" }}); | ||
|
||
const gateUpdateRequest = await fetch(`http://${env.TURBINE_ADDRESS}/v1/io/${gate.replace("#", "_")}/${value}`, { method: "POST" }); | ||
|
||
if(gateUpdateRequest.status !== 200 || !gateUpdateRequest.ok) | ||
return fail(500, { editGateValue: { error: "Failed to update gate value" }}); | ||
|
||
return { editGateValue: { success: true }}; | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<script lang="ts"> | ||
import Gate from "$lib/components/io/Gate.svelte"; | ||
import { realtime } from "$lib/utils/stores/nuster"; | ||
import { page } from "$app/stores"; | ||
</script> | ||
|
||
{#each $realtime.io.filter(i => i.bus === $page.params.bus) as iog} | ||
<Gate bind:io={iog} editable={iog.bus === "out"}/> | ||
{/each} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,8 @@ | ||
<script lang="ts"> | ||
import { onMount } from "svelte"; | ||
let time = 0; | ||
onMount(() => { | ||
const interval = setInterval(() => { | ||
if(time >= 5) | ||
window.location.reload(); | ||
time++; | ||
}, 1000); | ||
return clearInterval(interval); | ||
}); | ||
import { page } from '$app/stores'; | ||
</script> | ||
|
||
<h1>Server render error</h1> | ||
<p>Refreshing in {5 - time} seconds.</p> | ||
<p>{$page.error?.message}</p> | ||
|
||
<a href="/">Redirect now</a> | ||
<a href="/">Reload page</a> |