joel-woodfield commited on
Commit
a375433
·
1 Parent(s): 779968d

Fix typescript issues

Browse files
Dockerfile CHANGED
@@ -18,6 +18,4 @@ COPY backend /app/backend
18
  WORKDIR /app/backend
19
  RUN pip install --no-cache-dir -r requirements.txt
20
 
21
- EXPOSE 8765
22
-
23
  CMD ["python", "src/server.py"]
 
18
  WORKDIR /app/backend
19
  RUN pip install --no-cache-dir -r requirements.txt
20
 
 
 
21
  CMD ["python", "src/server.py"]
backend/src/__pycache__/opimization_logic.cpython-313.pyc CHANGED
Binary files a/backend/src/__pycache__/opimization_logic.cpython-313.pyc and b/backend/src/__pycache__/opimization_logic.cpython-313.pyc differ
 
backend/src/__pycache__/optimization_manager.cpython-313.pyc CHANGED
Binary files a/backend/src/__pycache__/optimization_manager.cpython-313.pyc and b/backend/src/__pycache__/optimization_manager.cpython-313.pyc differ
 
backend/src/main.py CHANGED
@@ -3,13 +3,12 @@ from fastapi.staticfiles import StaticFiles
3
  from optimization_manager import OptimizationManager
4
 
5
  app = FastAPI()
6
- PORT = 8765
7
-
8
- app.mount("/", StaticFiles(directory="../frontend/sit", html=True), name="frontend")
9
 
10
 
11
  @app.websocket("/ws")
12
  async def websocket_endpoint(websocket: WebSocket):
 
13
  await websocket.accept()
14
  manager = OptimizationManager()
15
 
@@ -96,6 +95,8 @@ async def send_error(websocket: WebSocket, error_message: str):
96
  })
97
 
98
 
 
 
99
  if __name__ == "__main__":
100
  import uvicorn
101
  uvicorn.run(app, host="0.0.0.0", port=PORT)
 
3
  from optimization_manager import OptimizationManager
4
 
5
  app = FastAPI()
6
+ PORT = 7860
 
 
7
 
8
 
9
  @app.websocket("/ws")
10
  async def websocket_endpoint(websocket: WebSocket):
11
+ print("starting")
12
  await websocket.accept()
13
  manager = OptimizationManager()
14
 
 
95
  })
96
 
97
 
98
+ app.mount("/", StaticFiles(directory="../frontend/dist", html=True), name="frontend")
99
+
100
  if __name__ == "__main__":
101
  import uvicorn
102
  uvicorn.run(app, host="0.0.0.0", port=PORT)
frontend/src/App.tsx CHANGED
@@ -4,7 +4,7 @@ import Sidebar from "./Sidebar.tsx";
4
  import type { Settings } from "./types.ts";
5
  import useApi from "./useApi.ts";
6
 
7
- const API_URL = "ws://localhost:8080/ws";
8
 
9
 
10
  export default function App() {
@@ -63,8 +63,8 @@ export default function App() {
63
  onReset={() => api.sendReset()}
64
  onNextStep={() => api.sendNextStep()}
65
  onPrevStep={() => api.sendPrevStep()}
66
- onPlay={() => api.sendPlay()}
67
- onPause={() => api.sendPause()}
68
  />
69
  </div>
70
  </>
 
4
  import type { Settings } from "./types.ts";
5
  import useApi from "./useApi.ts";
6
 
7
+ const API_URL = "ws://localhost:7860/ws";
8
 
9
 
10
  export default function App() {
 
63
  onReset={() => api.sendReset()}
64
  onNextStep={() => api.sendNextStep()}
65
  onPrevStep={() => api.sendPrevStep()}
66
+ // onPlay={() => api.sendPlay()}
67
+ // onPause={() => api.sendPause()}
68
  />
69
  </div>
70
  </>
frontend/src/OptimizationPlot.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import { useEffect, useRef } from "react";
2
  import Plot from "react-plotly.js";
3
  import type { PlotData } from "./types";
4
 
@@ -38,10 +38,18 @@ export default function OptimizationPlot({ data, xlim, ylim, setAxisLimits }: Op
38
  <Plot
39
  ref={plotRef}
40
  onRelayout={(event) => {
41
- if (event['xaxis.range[0]'] && event['xaxis.range[1]']) {
42
- const newXlim: [number, number] = [event['xaxis.range[0]'], event['xaxis.range[1]']];
43
- const newYlim: [number, number] = [event['yaxis.range[0]'], event['yaxis.range[1]']];
44
- setAxisLimits(newXlim, newYlim);
 
 
 
 
 
 
 
 
45
  }
46
  }}
47
  data={[
@@ -63,8 +71,8 @@ export default function OptimizationPlot({ data, xlim, ylim, setAxisLimits }: Op
63
  hoverinfo: "skip",
64
  },
65
  {
66
- x: [trajX.length > 0 ? trajX.at(-1) : undefined],
67
- y: [trajY.length > 0 ? trajY.at(-1) : undefined],
68
  type: 'scatter',
69
  mode: 'markers',
70
  marker: { color: 'red', size: 12 },
@@ -85,10 +93,18 @@ export default function OptimizationPlot({ data, xlim, ylim, setAxisLimits }: Op
85
  <Plot
86
  ref={plotRef}
87
  onRelayout={(event) => {
88
- if (event['xaxis.range[0]'] && event['xaxis.range[1]']) {
89
- const newXlim: [number, number] = [event['xaxis.range[0]'], event['xaxis.range[1]']];
90
- const newYlim: [number, number] = [event['yaxis.range[0]'], event['yaxis.range[1]']];
91
- setAxisLimits(newXlim, newYlim);
 
 
 
 
 
 
 
 
92
  }
93
  }}
94
  data={[
@@ -100,9 +116,6 @@ export default function OptimizationPlot({ data, xlim, ylim, setAxisLimits }: Op
100
  colorscale: 'Viridis',
101
  hoverinfo: "skip",
102
  contours: {
103
- x: { highlight: false },
104
- y: { highlight: false },
105
- z: { highlight: false },
106
  coloring: "heatmap",
107
  showlines: false,
108
  }
@@ -118,9 +131,9 @@ export default function OptimizationPlot({ data, xlim, ylim, setAxisLimits }: Op
118
  hoverinfo: "skip",
119
  },
120
  {
121
- x: [trajX.at(-1)],
122
- y: [trajY.at(-1)],
123
- z: [trajZ.at(-1)],
124
  type: 'scatter',
125
  mode: 'markers',
126
  marker: { color: 'red', size: 12 },
 
1
+ import { useRef } from "react";
2
  import Plot from "react-plotly.js";
3
  import type { PlotData } from "./types";
4
 
 
38
  <Plot
39
  ref={plotRef}
40
  onRelayout={(event) => {
41
+ const x0 = event['xaxis.range[0]'];
42
+ const x1 = event['xaxis.range[1]'];
43
+ const y0 = event['yaxis.range[0]'];
44
+ const y1 = event['yaxis.range[1]'];
45
+
46
+ if (
47
+ typeof x0 === "number"
48
+ && typeof x1 === "number"
49
+ && typeof y0 === "number"
50
+ && typeof y1 === "number"
51
+ ) {
52
+ setAxisLimits([x0, x1], [y0, y1]);
53
  }
54
  }}
55
  data={[
 
71
  hoverinfo: "skip",
72
  },
73
  {
74
+ x: trajX.length > 0 ? [trajX.at(-1)!] : [],
75
+ y: trajY.length > 0 ? [trajY.at(-1)!] : [],
76
  type: 'scatter',
77
  mode: 'markers',
78
  marker: { color: 'red', size: 12 },
 
93
  <Plot
94
  ref={plotRef}
95
  onRelayout={(event) => {
96
+ const x0 = event['xaxis.range[0]'];
97
+ const x1 = event['xaxis.range[1]'];
98
+ const y0 = event['yaxis.range[0]'];
99
+ const y1 = event['yaxis.range[1]'];
100
+
101
+ if (
102
+ typeof x0 === "number"
103
+ && typeof x1 === "number"
104
+ && typeof y0 === "number"
105
+ && typeof y1 === "number"
106
+ ) {
107
+ setAxisLimits([x0, x1], [y0, y1]);
108
  }
109
  }}
110
  data={[
 
116
  colorscale: 'Viridis',
117
  hoverinfo: "skip",
118
  contours: {
 
 
 
119
  coloring: "heatmap",
120
  showlines: false,
121
  }
 
131
  hoverinfo: "skip",
132
  },
133
  {
134
+ x: trajX.length > 0 ? [trajX.at(-1)!] : [],
135
+ y: trajY.length > 0 ? [trajY.at(-1)!] : [],
136
+ z: trajZ.length > 0 ? [trajZ.at(-1)!] : [],
137
  type: 'scatter',
138
  mode: 'markers',
139
  marker: { color: 'red', size: 12 },
frontend/src/Sidebar.tsx CHANGED
@@ -53,8 +53,8 @@ export default function Sidebar({
53
  onReset,
54
  onNextStep,
55
  onPrevStep,
56
- onPlay,
57
- onPause,
58
  }: SidebarProps) {
59
  const tabs = ["Settings", "Optimize"] as const;
60
  const [activeTab, setActiveTab] = useState<(typeof tabs)[number]>("Settings");
 
53
  onReset,
54
  onNextStep,
55
  onPrevStep,
56
+ // onPlay,
57
+ // onPause,
58
  }: SidebarProps) {
59
  const tabs = ["Settings", "Optimize"] as const;
60
  const [activeTab, setActiveTab] = useState<(typeof tabs)[number]>("Settings");