Skip to content

Commit

Permalink
Finish typing (#1069)
Browse files Browse the repository at this point in the history
### Summary
Finish typing

### Changelist 
<!-- Give a list of the changes covered in this PR. This will help both
you and the reviewer keep this PR within scope. -->

### Testing Done
<!-- Outline the testing that was done to demonstrate the changes are
solid. This could be unit tests, integration tests, testing on the car,
etc. Include relevant code snippets, screenshots, etc as needed. -->

### Resolved Issues
<!-- Link any issues that this PR resolved like so: `Resolves #1, #2,
and #5` (Note: Using this format, Github will automatically close the
issue(s) when this PR is merged in). -->

### Checklist
*Please change `[ ]` to `[x]` when you are ready.*
- [ ] I have read and followed the code conventions detailed in
[README.md](../README.md) (*This will save time for both you and the
reviewer!*).
- [ ] If this pull request is longer then **500** lines, I have provided
*explicit* justification in the summary above explaining why I *cannot*
break this up into multiple pull requests (*Small PR's are faster and
less painful for everyone involved!*).
  • Loading branch information
Evanyl authored Nov 4, 2023
1 parent ef4d7df commit a662e81
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 19 deletions.
7 changes: 4 additions & 3 deletions software/tracksight/frontend/src/app/components/graph.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
'use client';

import { useState, useEffect, Dispatch, MouseEventHandler, SetStateAction } from 'react';
import Plotly, { PlotRelayoutEvent } from 'plotly.js';
import createPlotlyComponent from "react-plotly.js/factory";
const Plot = createPlotlyComponent(Plotly);
import dynamic from "next/dynamic";
const Plot = dynamic(() => import("react-plotly.js"), { ssr: false, })
import { PlotRelayoutEvent } from 'plotly.js';

import { Card, Button } from 'antd';

import QueryData from './query_data';
Expand Down
10 changes: 3 additions & 7 deletions software/tracksight/frontend/src/app/components/query_data.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,11 @@ const QueryData = (props: QueryDataProps) => {
props.messageApi.open({type: "error", content: "Please fill out all fields properly"});
return;
}

let urlWithSearchParams = new URLSearchParams(props.url + "/query");
urlWithSearchParams.append('measurement', measurement[0]);
const newParams = new URLSearchParams({measurement: measurement[0], start_epoch: startEpoch, end_epoch: endEpoch });
for (const field in fields) {
urlWithSearchParams.append('fields', field);
newParams.append('fields', fields[field]);
}
urlWithSearchParams.append('start_epoch', startEpoch);
urlWithSearchParams.append('end_epoch', endEpoch);
fetch(urlWithSearchParams.toString())
fetch(props.url + "/query?" + newParams)
.then((response) => {
if (!response.ok) {
return response.json().then(json => {throw new Error(json["error"])});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
import { useState, useEffect } from 'react';
import { useState, useEffect, SetStateAction, Dispatch } from 'react';
import type { Dayjs } from 'dayjs';
import { DatePicker, Space, TimePicker } from 'antd';

const { RangePicker } = DatePicker;

const TimeStampPicker = (props) => {
export interface TimeStampPickerProps {
setStart: Dispatch<SetStateAction<string>>,
setEnd: Dispatch<SetStateAction<string>>,
}

declare type EventValue<DateType> = DateType | null;
declare type RangeValue<DateType> = [EventValue<DateType>, EventValue<DateType>] | null;

const TimeStampPicker = (props: TimeStampPickerProps) => {
const [dayValue, setDayValue] = useState<Dayjs | null>(null);

const changeDate = (date_pair, _) => {
const startEpoch = date_pair[0].valueOf() + "ms";
const endEpoch = date_pair[1].valueOf() + "ms";
props.setStart(startEpoch);
props.setEnd(endEpoch);
const changeDate = (date_pair: RangeValue<Dayjs>, formatted_dates: [string, string]) => {
if (date_pair) {
const startEpoch = date_pair[0]!.valueOf() + "ms";
const endEpoch = date_pair[1]!.valueOf() + "ms";
props.setStart(startEpoch);
props.setEnd(endEpoch);
}
};

return (
Expand Down
3 changes: 2 additions & 1 deletion software/tracksight/frontend/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Dashboard from './components/dashboard';
import { PlotRelayoutEvent } from 'plotly.js';

const FLASK_URL = "http://evanyl.pythonanywhere.com";
//const FLASK_URL = "http://localhost:3000";

const Home = () => {
const [componentToDisplay, setComponentToDisplay] = useState("visualize");
Expand Down Expand Up @@ -54,7 +55,7 @@ const Home = () => {
<div className="flex-container">
{graphs.map(graphId => (
<Graph
key={graphId} id={graphId} url={FLASK_URL} sync={sync} setZoomData={setZoomData} zoomData={zoomData}
graphid={graphId} id={graphId} url={FLASK_URL} sync={sync} setZoomData={setZoomData} zoomData={zoomData}
onDelete={() => deleteGraph(graphId)} messageApi={messageApi}
/>
))}
Expand Down

0 comments on commit a662e81

Please sign in to comment.