-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/feature/new-web-ui' into dev
- Loading branch information
Showing
60 changed files
with
1,963 additions
and
137 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
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,24 @@ | ||
# build output | ||
dist/ | ||
|
||
# generated types | ||
.astro/ | ||
|
||
# dependencies | ||
node_modules/ | ||
|
||
# logs | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
|
||
# environment variables | ||
.env | ||
.env.production | ||
|
||
# macOS-specific files | ||
.DS_Store | ||
|
||
# jetbrains setting folder | ||
.idea/ |
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,4 @@ | ||
{ | ||
"recommendations": ["astro-build.astro-vscode"], | ||
"unwantedRecommendations": [] | ||
} |
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,11 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"command": "./node_modules/.bin/astro dev", | ||
"name": "Development server", | ||
"request": "launch", | ||
"type": "node-terminal" | ||
} | ||
] | ||
} |
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,54 @@ | ||
# Astro Starter Kit: Basics | ||
|
||
```sh | ||
npm create astro@latest -- --template basics | ||
``` | ||
|
||
[](https://stackblitz.com/github/withastro/astro/tree/latest/examples/basics) | ||
[](https://codesandbox.io/p/sandbox/github/withastro/astro/tree/latest/examples/basics) | ||
[](https://codespaces.new/withastro/astro?devcontainer_path=.devcontainer/basics/devcontainer.json) | ||
|
||
> 🧑🚀 **Seasoned astronaut?** Delete this file. Have fun! | ||
 | ||
|
||
## 🚀 Project Structure | ||
|
||
Inside of your Astro project, you'll see the following folders and files: | ||
|
||
```text | ||
/ | ||
├── public/ | ||
│ └── favicon.svg | ||
├── src/ | ||
│ ├── components/ | ||
│ │ └── Card.astro | ||
│ ├── layouts/ | ||
│ │ └── Layout.astro | ||
│ └── pages/ | ||
│ └── index.astro | ||
└── package.json | ||
``` | ||
|
||
Astro looks for `.astro` or `.md` files in the `src/pages/` directory. Each page is exposed as a route based on its file name. | ||
|
||
There's nothing special about `src/components/`, but that's where we like to put any Astro/React/Vue/Svelte/Preact components. | ||
|
||
Any static assets, like images, can be placed in the `public/` directory. | ||
|
||
## 🧞 Commands | ||
|
||
All commands are run from the root of the project, from a terminal: | ||
|
||
| Command | Action | | ||
| :------------------------ | :----------------------------------------------- | | ||
| `npm install` | Installs dependencies | | ||
| `npm run dev` | Starts local dev server at `localhost:4321` | | ||
| `npm run build` | Build your production site to `./dist/` | | ||
| `npm run preview` | Preview your build locally, before deploying | | ||
| `npm run astro ...` | Run CLI commands like `astro add`, `astro check` | | ||
| `npm run astro -- --help` | Get help using the Astro CLI | | ||
|
||
## 👀 Want to learn more? | ||
|
||
Feel free to check [our documentation](https://docs.astro.build) or jump into our [Discord server](https://astro.build/chat). |
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,13 @@ | ||
// @ts-check | ||
import { defineConfig } from "astro/config"; | ||
|
||
import tailwind from "@astrojs/tailwind"; | ||
|
||
import preact from "@astrojs/preact"; | ||
|
||
// https://astro.build/config | ||
export default defineConfig({ | ||
output: process.env.NODE_ENV === "production" ? "static" : "server", | ||
outDir: "../spiffs_image/www", | ||
integrations: [tailwind(), preact({ compat: true })], | ||
}); |
Binary file not shown.
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,12 @@ | ||
import eslintPluginAstro from "eslint-plugin-astro"; | ||
export default [ | ||
// add more generic rule sets here, such as: | ||
// js.configs.recommended, | ||
...eslintPluginAstro.configs.recommended, | ||
{ | ||
rules: { | ||
// override/add rules settings here, such as: | ||
// "astro/no-set-html-directive": "error" | ||
}, | ||
}, | ||
]; |
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,36 @@ | ||
{ | ||
"name": "", | ||
"version": "0.0.1", | ||
"dependencies": { | ||
"@astrojs/check": "^0.9.4", | ||
"@astrojs/preact": "^3.5.3", | ||
"@astrojs/tailwind": "^5.1.2", | ||
"@nanostores/persistent": "^0.10.2", | ||
"@nanostores/preact": "^0.5.2", | ||
"astro": "^4.16.10", | ||
"daisyui": "^4.12.14", | ||
"nanostores": "^0.11.3", | ||
"preact": "^10.24.3", | ||
"tailwindcss": "^3.4.14", | ||
"typescript": "^5.6.3" | ||
}, | ||
"scripts": { | ||
"dev": "astro dev", | ||
"start": "astro dev", | ||
"build": "astro check && astro build", | ||
"preview": "astro preview", | ||
"astro": "astro", | ||
"lint": "eslint .", | ||
"format": "prettier . --write" | ||
}, | ||
"type": "module", | ||
"devDependencies": { | ||
"@tailwindcss/typography": "^0.5.15", | ||
"@types/node": "^22.9.0", | ||
"@typescript-eslint/parser": "^8.13.0", | ||
"eslint": "^9.14.0", | ||
"eslint-plugin-astro": "^1.3.1", | ||
"prettier": "^3.3.3", | ||
"prettier-plugin-astro": "^0.14.1" | ||
} | ||
} |
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,12 @@ | ||
/** @type {import("prettier").Config} */ | ||
export default { | ||
plugins: ["prettier-plugin-astro"], | ||
overrides: [ | ||
{ | ||
files: "*.astro", | ||
options: { | ||
parser: "astro", | ||
}, | ||
}, | ||
], | ||
}; |
Binary file not shown.
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,82 @@ | ||
import { useStore } from "@nanostores/preact"; | ||
import { $favorites, type FavoritePreset } from "../stores/favoritesStore"; | ||
import { useEffect, useState } from "preact/hooks"; | ||
|
||
export interface EditFavoriteProps { | ||
num: number; | ||
favoriteData?: FavoritePreset; | ||
} | ||
|
||
export default function EditCurrrentFavorite({ | ||
num, | ||
favoriteData, | ||
}: EditFavoriteProps) { | ||
const favorites = useStore($favorites); | ||
const currentFavorite = favoriteData ?? favorites.at(num); | ||
const [name, setName] = useState<string>(""); | ||
const [ustring, setUstring] = useState<string>(""); | ||
|
||
useEffect(() => { | ||
if (currentFavorite) { | ||
setName(currentFavorite.name); | ||
setUstring(currentFavorite.ustring); | ||
} | ||
}, [currentFavorite]); | ||
|
||
const handleSave = async () => { | ||
if (!currentFavorite) { | ||
return; | ||
} | ||
|
||
const data: FavoritePreset = { | ||
...currentFavorite, | ||
name, | ||
ustring, | ||
}; | ||
|
||
const response = await fetch(`/api/v1/favorites/store/${num}`, { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify(data), | ||
}); | ||
|
||
if (response.ok) { | ||
favorites[num] = data; | ||
$favorites.set(favorites); | ||
} | ||
}; | ||
|
||
return ( | ||
<div> | ||
<label className="form-control w-full max-w-xs"> | ||
<div className="label"> | ||
<span className="label-text">Name</span> | ||
</div> | ||
<input | ||
type="text" | ||
className="input input-bordered w-full max-w-xs" | ||
value={name} | ||
onChange={(e) => setName(e.currentTarget.value)} | ||
/> | ||
</label> | ||
|
||
<label className="form-control w-full max-w-xs"> | ||
<div className="label"> | ||
<span className="label-text">User String</span> | ||
</div> | ||
<input | ||
type="text" | ||
className="input input-bordered w-full max-w-xs" | ||
value={ustring} | ||
onChange={(e) => setUstring(e.currentTarget.value)} | ||
/> | ||
</label> | ||
|
||
<button className="btn" onClick={handleSave}> | ||
Save | ||
</button> | ||
</div> | ||
); | ||
} |
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,47 @@ | ||
import { useStore } from "@nanostores/preact"; | ||
import { $currentFavoriteNum } from "../stores/favoritesStore"; | ||
import { $activePlugins, type Plugin } from "../stores/pluginsStore"; | ||
|
||
export default function FavoritesButtons() { | ||
const currentFavorite = useStore($currentFavoriteNum); | ||
|
||
const handleRecall = async () => { | ||
const response = await fetch( | ||
`/api/v1/favorites/recall/${currentFavorite}`, | ||
{ method: "POST" }, | ||
); | ||
|
||
if (!response.ok) { | ||
return; | ||
} | ||
|
||
const channelOneFetch = fetch("/api/v1/getActivePlugin/0") | ||
.then((r) => r.json()) | ||
.then(({ id }: Pick<Plugin, "id">) => $activePlugins.setKey("0", { id })); | ||
const channelTwoFetch = fetch("/api/v1/getActivePlugin/1") | ||
.then((r) => r.json()) | ||
.then(({ id }: Pick<Plugin, "id">) => $activePlugins.setKey("1", { id })); | ||
|
||
await Promise.all([channelOneFetch, channelTwoFetch]); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<button className="btn" onClick={handleRecall}> | ||
Recall | ||
</button> | ||
<a role="button" className="btn" href={`/fav/${currentFavorite}/snap`}> | ||
Snap | ||
</a> | ||
<a role="button" className="btn" href={`/fav/${currentFavorite}/edit`}> | ||
Edit | ||
</a> | ||
<button className="btn" onClick={handleRecall}> | ||
Export | ||
</button> | ||
<button className="btn" onClick={handleRecall}> | ||
Import | ||
</button> | ||
</div> | ||
); | ||
} |
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,27 @@ | ||
import { useStore } from "@nanostores/preact"; | ||
import { $currentFavoriteNum, $favorites } from "../stores/favoritesStore"; | ||
|
||
export default function FavoritesSelect() { | ||
const favorites = useStore($favorites); | ||
const currentFavorite = useStore($currentFavoriteNum); | ||
|
||
return ( | ||
<select | ||
class="select w-full max-w-xs" | ||
value={currentFavorite} | ||
onChange={(event) => { | ||
const newFavorite = Number.parseInt(event.currentTarget.value, 10); | ||
|
||
if (!Number.isNaN(newFavorite)) { | ||
$currentFavoriteNum.set(newFavorite); | ||
} | ||
}} | ||
> | ||
{favorites.map((favorite, i) => ( | ||
<option value={i}> | ||
{i}: {favorite.name} | ||
</option> | ||
))} | ||
</select> | ||
); | ||
} |
Oops, something went wrong.