Skip to content

Commit

Permalink
Add longitudeLatitude field to feed - json of 'lng' and 'lat' to make…
Browse files Browse the repository at this point in the history
… it more explicit
  • Loading branch information
skanderm committed Jul 26, 2023
1 parent 6b3873f commit b329c3c
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion server/lib/orcasite/radio_legacy/radio_legacy.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ defmodule Orcasite.RadioLegacy do

import Ecto.Query, warn: false
alias Orcasite.Repo
alias Orcasite.RadioLegacy.{Feed, Detection, Candidate}
alias Orcasite.RadioLegacy.{Detection, Candidate}

def verify_can_submit_detection(
feed_id,
Expand Down
10 changes: 10 additions & 0 deletions server/lib/orcasite_web/graphql/types/feed.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ defmodule OrcasiteWeb.Types.Feed do
end)
end

field :longitude_latitude, non_null(:json) do
resolve(fn
%{location_point: %{coordinates: {lng, lat}}}, _, _ ->
{:ok, %{lng: lng, lat: lat}}

_, _, _ ->
{:ok, %{}}
end)
end

field :thumb_url, non_null(:string) do
resolve(fn %{node_name: node_name}, _, _ ->
{:ok, feed_s3_url(node_name, "thumbnail.png")}
Expand Down
4 changes: 2 additions & 2 deletions ui/src/components/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function Map({
feeds,
}: {
setMap?: (map: LeafletMap) => void
currentFeed?: Pick<Feed, 'slug' | 'locationPoint'>
currentFeed?: Pick<Feed, 'slug' | 'longitudeLatitude'>
feeds: FeedsQuery['feeds']
}) {
const router = useRouter()
Expand Down Expand Up @@ -50,7 +50,7 @@ export default function Map({
{feeds.map((feed) => (
<Marker
key={feed.slug}
position={feed.locationPoint.coordinates}
position={feed.longitudeLatitude}
icon={
feed.slug === currentFeed?.slug
? hydrophoneActiveIcon
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/MapLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function MapLayout({ children }: { children: ReactNode }) {
useEffect(() => {
if (feed && feed.slug !== currentFeed?.slug) {
setCurrentFeed(feed)
map?.panTo(feed.locationPoint.coordinates)
map?.panTo(feed.longitudeLatitude)
}
}, [feed, map, currentFeed])

Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/Player/Player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export default function Player({
</Box>
<Box sx={{ mx: 4, flexGrow: 1, textAlign: 'end' }}>
{currentFeed &&
`${currentFeed.locationPoint.coordinates[0]}, ${currentFeed.locationPoint.coordinates[1]}`}
`${currentFeed.longitudeLatitude["lng"]}, ${currentFeed.longitudeLatitude["lat"]}`}
</Box>
</Box>
)
Expand Down
5 changes: 5 additions & 0 deletions ui/src/graphql/generated/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export type Feed = {
id: Scalars['ID']['output']
introHtml: Scalars['String']['output']
locationPoint: Scalars['Json']['output']
longitudeLatitude: Scalars['Json']['output']
mapUrl: Scalars['String']['output']
name: Scalars['String']['output']
nodeName: Scalars['String']['output']
Expand Down Expand Up @@ -254,6 +255,7 @@ export type FeedQuery = {
slug: string
nodeName: string
locationPoint: any
longitudeLatitude: any
introHtml: string
thumbUrl: string
mapUrl: string
Expand All @@ -271,6 +273,7 @@ export type FeedsQuery = {
slug: string
nodeName: string
locationPoint: any
longitudeLatitude: any
thumbUrl: string
mapUrl: string
}>
Expand Down Expand Up @@ -335,6 +338,7 @@ export const FeedDocument = `
slug
nodeName
locationPoint
longitudeLatitude
introHtml
thumbUrl
mapUrl
Expand Down Expand Up @@ -363,6 +367,7 @@ export const FeedsDocument = `
slug
nodeName
locationPoint
longitudeLatitude
thumbUrl
mapUrl
}
Expand Down
1 change: 1 addition & 0 deletions ui/src/graphql/queries/getFeed.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ query feed($slug: String!) {
slug
nodeName
locationPoint
longitudeLatitude
introHtml
thumbUrl
mapUrl
Expand Down
1 change: 1 addition & 0 deletions ui/src/graphql/queries/listFeeds.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ query feeds {
slug
nodeName
locationPoint
longitudeLatitude
thumbUrl
mapUrl
}
Expand Down

0 comments on commit b329c3c

Please sign in to comment.