-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: basic ui * feat: first websocket implementation * feat: front: websocket open & receive messages * feat: back: fix websocket * feat: satellite name in API response & polar view * feat: show sat visibility in tracking response * fix: fix prop-types for PolarView * feat: satellite tracking by it's catalog number & basic error handling * fix: eslint * fix: eslint & prettier
- Loading branch information
Showing
27 changed files
with
4,849 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
database/local.db | ||
sattrack | ||
data | ||
public |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,26 @@ | ||
# SatTrack | ||
|
||
Modern satellite tracking solution | ||
Modern satellite tracking solution (currently WIP) | ||
|
||
![](img/home.png) | ||
|
||
## TODO | ||
|
||
### Backend | ||
|
||
- [ ] Custom validation messages | ||
- [ ] Check for performance issues & missing best practises | ||
- [ ] API documentation | ||
- [ ] Rate-limiting | ||
|
||
### Frontend | ||
|
||
- [ ] Migrate to Typescript | ||
- [ ] About page | ||
- [ ] Custom UI (Currently using Bootstrap 💀) + enhancements | ||
- [ ] More functionalities (pass prediction, elevation/azimuth graph) | ||
- [ ] GitHub action for ESLint | ||
|
||
### Docker | ||
|
||
- [ ] Dockerhub tag (currently it is only tagging with 'latest') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"env": { | ||
"browser": true, | ||
"es2021": true | ||
}, | ||
"extends": [ | ||
"airbnb", | ||
"plugin:react/recommended", | ||
"plugin:react/jsx-runtime", | ||
"plugin:react-hooks/recommended", | ||
"prettier" | ||
], | ||
"parserOptions": { | ||
"ecmaFeatures": { | ||
"jsx": true | ||
}, | ||
"ecmaVersion": 12, | ||
"sourceType": "module" | ||
}, | ||
"plugins": ["react", "react-hooks", "prettier"], | ||
"rules": { | ||
"prettier/prettier": "error", | ||
"react/jsx-props-no-spreading": 0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { useState } from 'react'; | ||
|
||
function useLocation() { | ||
const [initialized, setInitialized] = useState(false); | ||
const [location, setLocation] = useState({ | ||
lat: null, | ||
lng: null, | ||
alt: null, | ||
}); | ||
|
||
const getLocation = () => { | ||
if (typeof navigator === 'undefined' || !('geolocation' in navigator)) { | ||
return; | ||
} | ||
|
||
navigator.geolocation.getCurrentPosition( | ||
(position) => { | ||
const { latitude, longitude, altitude } = position.coords; | ||
setLocation({ | ||
lat: Number(latitude.toFixed(2)), | ||
lng: Number(longitude.toFixed(2)), | ||
alt: altitude ? Number(altitude.toFixed(2)) : null, | ||
}); | ||
setInitialized(true); | ||
}, | ||
() => null, | ||
); | ||
}; | ||
|
||
return { | ||
initialized, | ||
location, | ||
getLocation, | ||
}; | ||
} | ||
|
||
export default useLocation; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { useRef, useState } from 'react'; | ||
|
||
function useWebsocket() { | ||
const [opened, setOpened] = useState(false); | ||
const [message, setMessage] = useState(null); | ||
const [error, setError] = useState(null); | ||
const [isOpening, setIsOpening] = useState(false); | ||
const [isClosing, setIsClosing] = useState(false); | ||
const websocket = useRef(null); | ||
|
||
/** | ||
* @param {MessageEvent} event | ||
*/ | ||
const handleMessage = (event) => { | ||
const receivedMessage = JSON.parse(event.data); | ||
if (receivedMessage?.Status && receivedMessage.Status !== 200) { | ||
setError({ | ||
status: receivedMessage.Status, | ||
message: receivedMessage.Message, | ||
}); | ||
return; | ||
} | ||
if (error) { | ||
setError(null); | ||
} | ||
setMessage(receivedMessage); | ||
websocket.current.send('ok'); | ||
}; | ||
|
||
const handleClose = () => { | ||
setOpened(false); | ||
setIsClosing(false); | ||
}; | ||
|
||
const handleOpen = () => { | ||
setOpened(true); | ||
setIsOpening(false); | ||
}; | ||
|
||
const closeConnection = () => { | ||
websocket.current.close(); | ||
setIsClosing(true); | ||
}; | ||
|
||
/** | ||
* @param {String} baseUrl | ||
* @param {Number} catNbr | ||
* @param {{ lat: Number, lng: Number, alt: Number }} location | ||
*/ | ||
const openConnection = (baseUrl, catNbr, location) => { | ||
const url = new URL(baseUrl); | ||
url.searchParams.append('catnbr', catNbr); | ||
Object.keys(location).forEach((item) => { | ||
url.searchParams.append(item, location[item]); | ||
}); | ||
|
||
websocket.current = new WebSocket(url); | ||
websocket.current.onclose = handleClose; | ||
websocket.current.onopen = handleOpen; | ||
websocket.current.onmessage = handleMessage; | ||
websocket.current.onerror = closeConnection; | ||
setIsOpening(true); | ||
}; | ||
|
||
return { | ||
isOpening, | ||
isClosing, | ||
opened, | ||
message, | ||
error, | ||
openConnection, | ||
closeConnection, | ||
}; | ||
} | ||
|
||
export default useWebsocket; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/src/favicon.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Vite App</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/main.jsx"></script> | ||
</body> | ||
</html> | ||
|
||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/src/favicon.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>SatTrack</title> | ||
</head> | ||
|
||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/main.jsx"></script> | ||
</body> | ||
|
||
</html> |
Oops, something went wrong.