From 87d17216c1002653871ebc4f5a5def9c8686d5e4 Mon Sep 17 00:00:00 2001 From: dvirlabs Date: Tue, 3 Jun 2025 07:21:21 +0300 Subject: [PATCH] Add form to add new app/section --- backend/__pycache__/main.cpython-313.pyc | Bin 3344 -> 3396 bytes backend/apps.yaml | 1 + backend/main.py | 22 ++++++++-------------- frontend/src/App.jsx | 9 ++++++++- frontend/vite.config.js | 3 ++- 5 files changed, 19 insertions(+), 16 deletions(-) diff --git a/backend/__pycache__/main.cpython-313.pyc b/backend/__pycache__/main.cpython-313.pyc index ac9fb777337dfcfbab6363c2bbe09664f8740264..72a1bb653fefe91ee1d9e8e2eaeb02605775d89f 100644 GIT binary patch delta 970 zcmYjQOKVd>6h3q3zLV4>P15wXrb(I_Zxvgu0c&eTh@e<2b~YA5H6$@sunlul#8nYN zyKvDmi-H>;h%SBo1S<$qs8liDe^7LhntS*|UCh!xz zIdScYy4n#%4_>7^(NYwWK>QYvKu*tK!2qDaoH3nl>;EGOW>EW1I&;CJ5(!ywUC!)M zXebvZ;p3M8@=*W+1fPr0NG>vc=>HsTo!5+zE)pd^jdYL7aVX<5wyifWQ7=XlY(pN4 z5S6NB&DLG*RHc&5SM%F(9?Om>&&IpBat~^z@6Opa1VUSKsAhQYo}qs3qcIKz{{1_< zgF$1E=Z-C@IfY;`Ad#t7R&3SPd6CoeReEcCA2++2Qz}&F7Uo@?uT&+gb#>q19_1>JO2r<$)W zIs)~mFFnU7wM3=$i=xr)is>H{MFLs;^K{pEz@D) z&}U{5*G(|| zE9OVN=Zl{Fs3&Wo?zQu)=WAhWZDw_5ZFY5bD?G3n+P9yjJCFS!y=yJD9SE+ zrj*uL?5Srg*jlnHR~DQq6`j)*`|delp5v5L%tKI&)Yzm|!8Fb!NLED@ z+J%djw{+T5*{+hllM$es6PmvFq20j)0@|jclr(hg#Z8u zAo_-G>UljkiZ^LZLmJYN5An!#1P11!L#l(mJUK`m1! z^=6cS%@isXE6H>dGv?4I9EcN0QitrAql3?F&Z-uwHOpoT#bT+LbeTR!>34uE2bcp6 z1RaPFupe^7x>PRy&Ds{N!a`}TSbJI_y+<86KVLJ=64}aN&%t8ITZDw^=?X~OIbvy^ zBbl>LYa9oq%5pOhek;9^dWR9;HB#F~s_74H)Yt26k&UbSfK~e1E}-gDPbVJS|T{Kd#AH)~3l6_>+85v6;$}RqYOB4rASQTDnT+a_)om y9bb2CoMoZ1S|?u*m6i%9b|vs4usZSu>MhEE#@hJ~AV-G=l&?#)u0R}C62Ae42*?}& diff --git a/backend/apps.yaml b/backend/apps.yaml index d21a950..120f639 100644 --- a/backend/apps.yaml +++ b/backend/apps.yaml @@ -24,3 +24,4 @@ sections: url: https://woodpecker.dvirlabs.com name: Dev-tools + diff --git a/backend/main.py b/backend/main.py index d211f90..51ad3d0 100644 --- a/backend/main.py +++ b/backend/main.py @@ -29,13 +29,16 @@ def get_apps(): with open(APPS_FILE, "r") as f: return yaml.safe_load(f) -class AppEntry(BaseModel): - section: str +class AppData(BaseModel): name: str icon: str description: str url: str +class AppEntry(BaseModel): + section: str + app: AppData + @app.post("/add_app") def add_app(entry: AppEntry): if not APPS_FILE.exists(): @@ -47,22 +50,12 @@ def add_app(entry: AppEntry): # Find or create section for section in current["sections"]: if section["name"] == entry.section: - section["apps"].append({ - "name": entry.name, - "icon": entry.icon, - "description": entry.description, - "url": entry.url, - }) + section["apps"].append(entry.app.dict()) break else: current["sections"].append({ "name": entry.section, - "apps": [{ - "name": entry.name, - "icon": entry.icon, - "description": entry.description, - "url": entry.url, - }] + "apps": [entry.app.dict()] }) with open(APPS_FILE, "w") as f: @@ -70,6 +63,7 @@ def add_app(entry: AppEntry): return {"status": "added"} + if __name__ == "__main__": import uvicorn uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True) \ No newline at end of file diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index ec486ef..adc33df 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -1,19 +1,26 @@ +// src/App.jsx import { useEffect, useState } from 'react'; import './App.css'; import SectionGrid from './components/SectionGrid'; +import ControlPanel from './components/ControlPanel'; function App() { const [sections, setSections] = useState([]); - useEffect(() => { + const fetchSections = () => { fetch('/apps') .then(res => res.json()) .then(data => setSections(data.sections || [])); + }; + + useEffect(() => { + fetchSections(); }, []); return (

🔷 Navix

+ {sections.map((section) => ( ))} diff --git a/frontend/vite.config.js b/frontend/vite.config.js index 5b80504..04886e1 100644 --- a/frontend/vite.config.js +++ b/frontend/vite.config.js @@ -6,7 +6,8 @@ export default defineConfig({ plugins: [react()], server: { proxy: { - '/apps': 'http://localhost:8000' + '/apps': 'http://localhost:8000', + '/add_app': 'http://localhost:8000', } } });