From bf6802aaa6a26942e6351c93f7607148ebb6a12d Mon Sep 17 00:00:00 2001 From: zomco Date: Mon, 19 Aug 2024 22:22:13 +0800 Subject: [PATCH] refactor --- .idea/workspace.xml | 24 ++-- app/install-button.tsx | 155 +++++++++++------------- app/release.json | 23 ++-- public/release/r60abd1/a4/0_0_19.json | 6 +- public/release/r60abd1/zero/0_0_19.json | 6 +- tsconfig.json | 2 +- types.d.ts | 4 + 7 files changed, 106 insertions(+), 114 deletions(-) create mode 100644 types.d.ts diff --git a/.idea/workspace.xml b/.idea/workspace.xml index d070885..f6889c9 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,18 +5,13 @@ - - - - - - - - - - - - + + + + + + + diff --git a/app/install-button.tsx b/app/install-button.tsx index 928abd4..a792bdc 100644 --- a/app/install-button.tsx +++ b/app/install-button.tsx @@ -34,27 +34,45 @@ import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group" import { Bold, Italic, Underline } from "lucide-react" import Releases from './release.json'; +const radars: [ManiFestInfo] = Releases.values.map(radar => ({ name: radar.name, values: radar.values })); export default function InstallButton() { + const [versions, updateVersions] = useState<[ManiFestInfo]>([]); + const [models, updateModels] = useState<[ManiFestInfo]>([]); const [version, updateVersion] = useState(""); const [radar, updateRadar] = useState(""); - const [radars, updateRadars] = useState<[]>([]) const [model, updateModel] = useState(""); - return
+ const [manifest, updateManifest] = useState(""); + + return
-
Welcome to the OwRadar web installer!
-
Plug in your ESP to a USB port. We will install OwRadar 0.15.0-b4 to it.
-
Hit "Install" and select the correct COM port.
-
Get OwRadar installed and connected in less than 3 minutes!
+
1. Welcome to the OwRadar web installer!
+
2. Choose your radar module {radar} and board model {model}.
+
3. Plug in your ESP to a USB port. We will install OwRadar {version} to it.
+
4. Hit "Install" and select the correct COM port.
+
5. Get OwRadar installed and connected in less than 3 minutes!
- updateRadar(value)}> + { + updateRadar(value); + updateModels(radars.find(radar => radar.name === value)?.values || []); + updateModel(""); + updateVersions([]); + updateVersion(""); + updateManifest(""); + }}> { - Releases.radars.map((radar, index) => { + radars.map((radar, index) => { return
- - - Zero - - - A4 - + { + updateModel(value); + updateVersions(models.find(model => model.name === value)?.values || []); + updateVersion(""); + updateManifest(""); + }} + > + { + models.map((model, index) => { + return + {model.name} + + }) + }
- { + updateVersion(value); + const file = versions.find(version => version.name === value)?.values[0] as string; + updateManifest(file); + }} + > - + - -
- -
-

- Neural{" "} - - Genesis - -

-

- Our fastest model for general use cases. -

-
-
-
- -
- -
-

- Neural{" "} - - Explorer - -

-

- Performance and speed for efficiency. -

-
-
-
- -
- -
-

- Neural{" "} - - Quantum - -

-

- The most powerful model for complex - computations. -

-
-
-
+ { + versions.map((version, index) => { + return {version.name} + }) + }
- - - - - Error - - Browser does not work - - - - - Error - - HTTPS not allowed - - + +
diff --git a/app/release.json b/app/release.json index 277a559..5f1d6c8 100644 --- a/app/release.json +++ b/app/release.json @@ -1,18 +1,23 @@ { "date": "2024.08.15", - "radars": [{ - "name": "r60abd1", - "models": [{ - "name": "a4", - "versions": [{ + "values": [{ + "name": "R60ABD1", + "desc": "https://www.micradar.cn/", + "values": [{ + "name": "A4", + "desc": "https://owradar.owkor.com/", + "values": [{ "name": "0.0.19", - "value": "/release/r60abd1/a4/0_0_19.json" + "desc": "0.0.19", + "values": ["/release/r60abd1/a4/0_0_19.json"] }] }, { - "name": "zero", - "versions": [{ + "name": "ZERO", + "desc": "https://owradar.owkor.com/", + "values": [{ "name": "0.0.19", - "value": "/release/r60abd1/zero/0_0_19.json" + "desc": "0.0.19", + "values": ["/release/r60abd1/zero/0_0_19.json"] }] }] }] diff --git a/public/release/r60abd1/a4/0_0_19.json b/public/release/r60abd1/a4/0_0_19.json index b3eb2c5..83479b5 100644 --- a/public/release/r60abd1/a4/0_0_19.json +++ b/public/release/r60abd1/a4/0_0_19.json @@ -1,14 +1,14 @@ { "name": "OwRadar", - "version": "0.0.19", + "version": "0.0.19-a+20240819", "home_assistant_domain": "owradar", "funding_url": "https://owradar.owkor.com/guides/supporters.html", "new_install_prompt_erase": false, "builds": [ { - "chipFamily": "ESP32C3", + "chipFamily": "ESP32-C3", "parts": [ - { "path": "https://github.com/zomco/owradar-site/releases/download/0.0.19-a%2B4/merge-esp32c3-r60abd1-a4.bin", "offset": 0 } + { "path": "https://github.com/zomco/owradar-firmware/releases/download/0.0.19-a%2B20240819/merge-esp32c3-r60abd1-a4.bin", "offset": 0 } ] } ] diff --git a/public/release/r60abd1/zero/0_0_19.json b/public/release/r60abd1/zero/0_0_19.json index dd76bcb..eb4c955 100644 --- a/public/release/r60abd1/zero/0_0_19.json +++ b/public/release/r60abd1/zero/0_0_19.json @@ -1,14 +1,14 @@ { "name": "OwRadar", - "version": "0.0.19", + "version": "0.0.19-a+20240819", "home_assistant_domain": "owradar", "funding_url": "https://owradar.owkor.com/guides/supporters.html", "new_install_prompt_erase": false, "builds": [ { - "chipFamily": "ESP32C3", + "chipFamily": "ESP32-C3", "parts": [ - { "path": "https://github.com/zomco/owradar-site/releases/download/0.0.19-a%2B4/merge-esp32c3-r60abd1-zero.bin", "offset": 0 } + { "path": "https://github.com/zomco/owradar-firmware/releases/download/0.0.19-a%2B20240819/merge-esp32c3-r60abd1-zero.bin", "offset": 0 } ] } ] diff --git a/tsconfig.json b/tsconfig.json index 70c7042..e42b8f2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -22,6 +22,6 @@ "@/*": ["./*"] } }, - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], + "include": ["next-env.d.ts", "types.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], "exclude": ["node_modules"] } diff --git a/types.d.ts b/types.d.ts new file mode 100644 index 0000000..332869f --- /dev/null +++ b/types.d.ts @@ -0,0 +1,4 @@ +interface ManiFestInfo { + name: string; + values: ManiFestInfo[]; +} \ No newline at end of file