Skip to content
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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

hudson-newey
Copy link
Member

@hudson-newey hudson-newey commented Feb 3, 2023

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

  • Adds a baw-site-map to the home page
  • Adds a baw-site-map to the project and list pages that displays all sites in the filter (if the filter is updated, the sites update)
  • Adds tests for maps on home, project & region list pages
  • Fixes a bug where if a used clicked on a non-clickable map, it'd throw a JavaScript console error

Problems

Pending design review

Issues

Fixes: #2027

Visual Changes

Project and list site pages:
image

Home Page:
image

Final Checklist

  • Assign reviewers if you have permission
  • Assign labels if you have permission
  • Link issues related to PR
  • Ensure project linter is not producing any warnings (npm run lint)
  • Ensure build is passing on all browsers (npm run test:all)
  • Ensure CI build is passing
  • Ensure docker container is passing (docs)

@hudson-newey hudson-newey self-assigned this Feb 3, 2023
@hudson-newey hudson-newey added bug Something isn't working enhancement New feature or request design A change to the design/look of the website or a component labels Feb 3, 2023
@hudson-newey hudson-newey marked this pull request as ready for review February 3, 2023 09:02
Copy link
Member

@atruskie atruskie left a 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>

src/app/components/home/home.component.html Show resolved Hide resolved
Comment on lines +239 to +240
it("should handle taking both projects and regions", async () => {
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

empty test?

Comment on lines +138 to +140
const sites: Observable<Region[] | Project[]> = settings.hideProjects
? this.regionApi.filter(filter)
: this.projectApi.filter(filter);
Copy link
Member

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?

Comment on lines +128 to +163
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>;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some notes:

Copy link
Member

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

@hudson-newey hudson-newey added the work in progress Pull request that is currently a WIP label Mar 8, 2023
@hudson-newey hudson-newey removed the request for review from peichins October 30, 2023 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working design A change to the design/look of the website or a component enhancement New feature or request work in progress Pull request that is currently a WIP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add more maps
2 participants