diff --git a/analysis.py b/analysis.py
index 2b21945..48e656b 100644
--- a/analysis.py
+++ b/analysis.py
@@ -1,5 +1,4 @@
from datetime import datetime
-import numpy as np
import io
import base64
from fastapi import APIRouter
@@ -81,19 +80,17 @@ class Params(BaseModel):
font_size: int | None = Field(default=10, alias="fontSize")
arrow_size: int | None = Field(default=20, alias="arrowSize")
edge_width: float | None = Field(default=1, alias="edgeWidth")
+ distance: float | None = 0.2
def sociogram_image(params: Params):
- print(params)
plt.figure(figsize=(16, 10), facecolor="none")
ax = plt.gca()
ax.set_facecolor("none") # Set the axis face color to none (transparent)
ax.axis("off") # Turn off axis ticks and frames
G = sociogram_data()
- pos = nx.spring_layout(
- G, scale=2, k=1 / np.sqrt(G.number_of_edges()), iterations=50, seed=42
- )
+ pos = nx.spring_layout(G, scale=2, k=params.distance, iterations=50, seed=None)
nx.draw_networkx_nodes(
G,
pos,
diff --git a/main.py b/main.py
index d952e9d..1cc2085 100644
--- a/main.py
+++ b/main.py
@@ -10,6 +10,7 @@ from analysis import analysis_router
app = FastAPI(title="cutt")
+api_router = APIRouter(prefix="/api")
origins = [
"*",
"http://localhost",
@@ -80,7 +81,16 @@ def submit_chemistry(chemistry: Chemistry):
session.commit()
-app.include_router(player_router)
-app.include_router(team_router)
-app.include_router(analysis_router)
-app.mount("/", StaticFiles(directory="dist", html=True), name="site")
+class SPAStaticFiles(StaticFiles):
+ async def get_response(self, path: str, scope):
+ response = await super().get_response(path, scope)
+ if response.status_code == 404:
+ response = await super().get_response(".", scope)
+ return response
+
+
+api_router.include_router(player_router)
+api_router.include_router(team_router)
+api_router.include_router(analysis_router)
+app.include_router(api_router)
+app.mount("/", SPAStaticFiles(directory="dist", html=True), name="site")
diff --git a/src/App.css b/src/App.css
index 8d1b595..59bafc3 100644
--- a/src/App.css
+++ b/src/App.css
@@ -60,15 +60,6 @@ h3 {
}
-#control-panel {
- display: flex;
- flex-direction: column;
-
- input {
- margin: auto
- }
-}
-
.container {
display: flex;
flex-wrap: nowrap;
@@ -138,7 +129,43 @@ button {
z-index: 1;
}
+#control-panel {
+ display: grid;
+ overflow: hidden;
+ margin: auto;
+ gap: 16px;
+ grid-template-columns: repeat(3, 1fr);
+}
+
+.opened {
+ max-height: 100vw;
+ transition: max-height 1s ease-in;
+}
+
+.closed {
+ max-height: 0px;
+ transition: max-height 0.5s ease-out;
+}
+
+.control {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ border: 1px solid #404040;
+ padding: 8px;
+}
+
+@media only screen and (max-width: 1000px) {
+ #control-panel {
+ grid-template-columns: repeat(2, 1fr);
+ }
+}
+
@media only screen and (max-width: 768px) {
+ #control-panel {
+ grid-template-columns: 1fr;
+ }
+
.submit_text {
display: none;
}
diff --git a/src/App.tsx b/src/App.tsx
index 3d9367d..41ab79f 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -8,7 +8,7 @@ import { BrowserRouter, Routes, Route } from "react-router-dom";
function App() {
//const [data, setData] = useState({ nodes: [], links: [] } as SociogramData);
//async function loadData() {
- // await fetch(`${baseUrl}analysis/json`, { method: "GET" }).then(resp => resp.json() as unknown as SociogramData).then(json => { setData(json) })
+ // await fetch(`${baseUrl}api/analysis/json`, { method: "GET" }).then(resp => resp.json() as unknown as SociogramData).then(json => { setData(json) })
//}
//useEffect(() => { loadData() }, [])
//
@@ -17,7 +17,7 @@ function App() {
} />
- } />
+ } />
diff --git a/src/Rankings.tsx b/src/Rankings.tsx
index 1c7f3b4..f9b711b 100644
--- a/src/Rankings.tsx
+++ b/src/Rankings.tsx
@@ -272,7 +272,7 @@ export default function Rankings() {
const [openTab, setOpenTab] = useState("Chemistry");
async function loadPlayers() {
- const response = await fetch(`${baseUrl}player/list`, {
+ const response = await fetch(`${baseUrl}api/player/list`, {
method: "GET",
});
const data = await response.json();