-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add more maps #2038
base: master
Are you sure you want to change the base?
Add more maps #2038
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok my main feedback is in this comment: #2027 (comment)
I think we can vastly simplify the site-map component. Change the query to a GET /sites
which by default shows all sites. Then add projects
and regions
filter inputs (possibly even just ids) which filter the fetch all for the sites. This would satisfy every use case:
- show one site
<baw-site-map [sites]=[sites] ></baw-site-map>
- show sites in a region
<baw-site-map [regions]=[regions] ></baw-site-map>
- show sites in a project
<baw-site-map [projects]=[projects] ></baw-site-map>
- show all sites
<baw-site-map ></baw-site-map>
it("should handle taking both projects and regions", async () => { | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
empty test?
const sites: Observable<Region[] | Project[]> = settings.hideProjects | ||
? this.regionApi.filter(filter) | ||
: this.projectApi.filter(filter); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why don't we just query for all sites?
public fetchAllSiteLocations(): Observable<List<Project | Region>> { | ||
const settings = this.config.settings; | ||
|
||
let pageNumber = 1; | ||
// Get the first page of points. This will also provide information on the max page length to search through | ||
let maxPageNumber = 1; | ||
|
||
while (pageNumber <= maxPageNumber) { | ||
const filter = { paging: { page: pageNumber } }; | ||
|
||
const sites: Observable<Region[] | Project[]> = settings.hideProjects | ||
? this.regionApi.filter(filter) | ||
: this.projectApi.filter(filter); | ||
|
||
this.allSites$ = sites.pipe( | ||
map((models) => List<Project | Region>(models)), | ||
takeUntil(this.unsubscribe) | ||
); | ||
|
||
// find the max page number from the metadata | ||
this.allSites$ | ||
.pipe(takeUntil(this.unsubscribe)) | ||
.subscribe((site) => maxPageNumber = site.toArray()?.shift()?.getMetadata()?.paging?.maxPage); | ||
pageNumber++; | ||
} | ||
|
||
return this.allSites$; | ||
} | ||
|
||
public projects(sites: List<Project | Region>): List<Project> { | ||
return sites?.filter((location) => location.kind === "Project") as List<Project>; | ||
} | ||
|
||
public regions(sites: List<Project | Region>): List<Region> { | ||
return sites?.filter((location) => location.kind === "Region") as List<Region>; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some notes:
- just select all sites
- you can disable paging on the request using the
disable_paging
option https://github.com/QutEcoacoustics/baw-server/wiki/API:-Spec#specialized-patterns - you must not pull back full sized site objects. Use the projection API filters to only pull back the values you need (id, name, lat/long).
- you'll need a custom service method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I think we can strip all this logic and my suggestions out and move it into the component
Add more maps
Users have expressed a lack of geographical information from the list and home pages. Therefore, to show more geographical information, I have added a map to the home page and list pages.
Changes
baw-site-map
to the home pagebaw-site-map
to the project and list pages that displays all sites in the filter (if the filter is updated, the sites update)Problems
Pending design review
Issues
Fixes: #2027
Visual Changes
Project and list site pages:
Home Page:
Final Checklist
npm run lint
)npm run test:all
)