Skip to content

Commit

Permalink
feat(frontend): ✨ Add URL field for satellites in Strapi and… (#102)
Browse files Browse the repository at this point in the history
* feat(frontend): ✨ Add URL field for satellites in Strapi and display satellites on map with URL or CAT number

* fix(frontend): 🐛 Fix graphql query to the correct query
  • Loading branch information
luctra02 authored and GitHub committed Feb 22, 2024
1 parent aeeedeb commit 9f1ffe6
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"target": "api::project.project",
"mappedBy": "satellites"
},
"satelliteName": {
"celestrakURL": {
"type": "string"
}
}
Expand Down
2 changes: 1 addition & 1 deletion backend/types/generated/contentTypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,7 @@ export interface ApiSatelliteSatellite extends Schema.CollectionType {
'manyToMany',
'api::project.project'
>;
satelliteName: Attribute.String;
celestrakURL: Attribute.String;
createdAt: Attribute.DateTime;
updatedAt: Attribute.DateTime;
publishedAt: Attribute.DateTime;
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/__generated__/gql.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions frontend/src/__generated__/graphql.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 6 additions & 9 deletions frontend/src/components/map/SatelliteFetcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ const GET_ALL_SATELLITE_DATA = gql(`query Satellites {
satellites {
data {
attributes {
celestrakURL
catalogNumberNORAD
satelliteName
}
}
}
Expand All @@ -43,16 +43,13 @@ export default async function SatelliteFetcher({

const satelliteUrls = graphqlData?.data?.satellites?.data.map(
(satEntity) => {
if (satEntity?.attributes?.catalogNumberNORAD) {
return (
"https://celestrak.org/NORAD/elements/gp.php?CATNR=" +
satEntity?.attributes?.catalogNumberNORAD +
"&FORMAT=TLE"
);
const celestrakURL = satEntity?.attributes?.celestrakURL;
if (celestrakURL) {
return celestrakURL;
}
return (
"https://celestrak.org/NORAD/elements/gp.php?NAME=" +
satEntity?.attributes?.satelliteName +
"https://celestrak.org/NORAD/elements/gp.php?CATNR=" +
satEntity?.attributes?.catalogNumberNORAD +
"&FORMAT=TLE"
);
},
Expand Down

0 comments on commit 9f1ffe6

Please sign in to comment.