Try to fix saved diagrams
This commit is contained in:
parent
1b5d7735ce
commit
32b6740669
Binary file not shown.
@ -1,19 +0,0 @@
|
||||
{
|
||||
"nodes": [
|
||||
{
|
||||
"id": "1",
|
||||
"type": "custom",
|
||||
"data": {
|
||||
"label": "Node 1",
|
||||
"icon": "https://s3.dvirlabs.com/lab-icons/infra/cloudflare.svg"
|
||||
},
|
||||
"position": {
|
||||
"x": 19.293138020977764,
|
||||
"y": 245.65982158849926
|
||||
},
|
||||
"width": 103,
|
||||
"height": 103
|
||||
}
|
||||
],
|
||||
"edges": []
|
||||
}
|
||||
@ -12,16 +12,14 @@ app = FastAPI()
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["*"], # בהמשך תוכל לצמצם לכתובת הפרונטאנד
|
||||
allow_origins=["*"],
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
# Static icon info
|
||||
BASE_URL = "https://s3.dvirlabs.com/lab-icons"
|
||||
S3_INDEX_URL = "https://s3.dvirlabs.com/lab-icons/?list-type=2"
|
||||
|
||||
# Directory for storing diagrams
|
||||
BASE_DIR = Path(__file__).parent.resolve()
|
||||
DATA_DIR = BASE_DIR / "diagrams"
|
||||
DATA_DIR.mkdir(exist_ok=True)
|
||||
@ -40,6 +38,8 @@ def fetch_diagram(name: str):
|
||||
|
||||
@app.post("/diagram/save")
|
||||
def save_diagram(name: str, payload: DiagramItem):
|
||||
if not name:
|
||||
raise HTTPException(status_code=400, detail="Missing diagram name")
|
||||
try:
|
||||
path = DATA_DIR / f"diagram_{name}.json"
|
||||
with open(path, "w") as f:
|
||||
@ -68,14 +68,6 @@ def delete_diagram(name: str):
|
||||
|
||||
@app.get("/icons", response_model=Dict[str, List[str]])
|
||||
def list_icons():
|
||||
"""
|
||||
Returns a dictionary of available icons grouped by folder (category).
|
||||
Example:
|
||||
{
|
||||
"dev-tools": [ "https://s3.dvirlabs.com/lab-icons/dev-tools/gitea.svg", ... ],
|
||||
"observability": [ ... ]
|
||||
}
|
||||
"""
|
||||
resp = requests.get(S3_INDEX_URL)
|
||||
if resp.status_code != 200:
|
||||
raise HTTPException(status_code=500, detail="Failed to fetch icon list from S3")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user