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

pushing place details to backend #25

Open
wants to merge 44 commits into
base: backend
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
b976cf6
Add React app to frontend
ejx2 Oct 4, 2024
3e32545
Add home page setup
ejx2 Oct 6, 2024
8682823
More home page setup
ejx2 Oct 6, 2024
f3979f3
added roboto font and new image
natgaographic Oct 8, 2024
b0ae095
Added login page
ejx2 Oct 8, 2024
a15c310
added link menu and changed login page
natgaographic Oct 8, 2024
be0cc6f
Added Restaraunt cards and About Us pages
ejx2 Oct 13, 2024
b679eb2
Edited restaurants page
ejx2 Oct 20, 2024
d3601ec
Added start page, adjusted navigation bar and restaurant header
natgaographic Oct 20, 2024
337c32e
Resolved merge conflict with Restaurants.js
natgaographic Oct 20, 2024
052c8e5
Added $ label to slider
ejx2 Oct 28, 2024
4a47628
changed favicon, added restaurants, updated order
ejx2 Nov 5, 2024
bb5337f
fixed restaurant page formatting, updated about us page with pictures…
natgaographic Nov 5, 2024
e263121
added nancy's picture
natgaographic Nov 5, 2024
4e44a0f
working to connect front and back
ejx2 Nov 6, 2024
48344d1
Merge remote-tracking branch 'origin/frontend' into frontend-backend-…
nancywang197 Nov 8, 2024
dc15659
Merge branch 'frontend' of https://github.com/CS222-UIUC/Team-5-3-1 i…
nancywang197 Nov 8, 2024
d58e6de
Working on connection - edited Start.js to take backend calls
ejx2 Nov 12, 2024
8e320e8
Merge branch 'frontend' of https://github.com/CS222-UIUC/Team-5-3-1 i…
nancywang197 Nov 12, 2024
1fbec69
Changed start again to include filters hardcoded
ejx2 Nov 12, 2024
beaea54
Added dietary preferences
ejx2 Nov 13, 2024
3700b7d
Merge branch 'frontend' of https://github.com/CS222-UIUC/Team-5-3-1 i…
nancywang197 Nov 18, 2024
e93aa1f
Added restaurant card to appear after generating, added location + ra…
ejx2 Nov 18, 2024
49ba0d0
Mfunction FilterPage() {
nancywang197 Nov 18, 2024
2a122f1
Merge branch 'backend' of https://github.com/CS222-UIUC/Team-5-3-1 in…
nancywang197 Nov 18, 2024
0d6c30c
integrated front end and back end. currently able to generate and dis…
nancywang197 Nov 18, 2024
743ee44
Start.js changes
ejx2 Nov 18, 2024
d9622ea
logic for 3 restaurants and 1
ejx2 Nov 18, 2024
38b9eaf
deleted unnecessary page
ejx2 Nov 18, 2024
1736a0c
Starting logic for selecting 3 restaurants
ejx2 Nov 19, 2024
4731e22
added method for making place details request and updated restaurant …
nyssaaftab Nov 19, 2024
8fc3a24
mergeMerge branch 'frontend-backend-merge' of https://github.com/CS22…
nyssaaftab Nov 19, 2024
81121cf
Fixed restaurant card page clicking issue
ejx2 Nov 19, 2024
90f4cd9
changed font color for cards to white
ejx2 Nov 19, 2024
4fa3fb1
Merge branch 'frontend' of https://github.com/CS222-UIUC/Team-5-3-1 i…
nancywang197 Nov 21, 2024
23b3f51
resolve merge conflict
nancywang197 Nov 21, 2024
7a27b36
fixed 3 to 1
ejx2 Nov 24, 2024
015c4b3
testing .env file
nancywang197 Nov 30, 2024
2a421ee
Merge branch 'frontend-backend-merge' of https://github.com/CS222-UIU…
nancywang197 Nov 30, 2024
8569f91
update location button and location search functionality
nancywang197 Nov 30, 2024
c1ecff3
fixed formatting on result cards
ejx2 Dec 1, 2024
d3e3366
no images for final cards
ejx2 Dec 1, 2024
c2860a6
Replaced backend folder with version from new-branch
ejx2 Dec 11, 2024
430b1ae
fixed restaurant cards and location search on my end
ejx2 Dec 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
Binary file modified backend/.DS_Store
Binary file not shown.
11 changes: 8 additions & 3 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,14 @@ EXPOSE 8081

CMD ["java", "-jar", "app.jar"]

# docker stop 3e56942ba023

# set up API as environment variable

# in fivethree one directiory run:
# ./mvnw clean package -DskipTests

# in team-5-3-1 directory run:
# docker build -t backend-springboot .
# docker run -d -p 8081:8080 backend-springboot
# docker run -d -p 8081:8080 backend-springboot

# when done run:
# docker stop 3e56942ba023
Binary file modified backend/fivethreeone/.DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ public List<Restaurant> getPlaces(@RequestParam String location, @RequestParam S

//http://localhost:8081/api/restaurants/random?location=40.10996616819772, -88.23113574620692&radius=1000&numRestaurants=5&priceLevel=2&cuisine=italian
@GetMapping("/random")
public List<Restaurant> getRandomRestaurants(@RequestParam String location, @RequestParam String radius, @RequestParam(defaultValue = "5") int numRestaurants,
public List<Restaurant> getRandomRestaurants(
@RequestParam(defaultValue = "40.1106,-88.2073") String location, // Default to latitude,longitude
@RequestParam(defaultValue = "1500") String radius,
@RequestParam(defaultValue = "5") int numRestaurants,
@RequestParam(required = false) Integer priceLevel,
@RequestParam(required = false) String cuisine)
throws JsonMappingException, JsonProcessingException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@

import java.util.List;
import java.util.Collections;

import java.util.HashSet;
import java.util.ArrayList;
import java.util.Set;

@Service
public class GooglePlacesService {
Expand Down Expand Up @@ -71,14 +73,45 @@ public List<Restaurant> getRandomRestaurants(String location, String radius, Int

if (restaurants.isEmpty()) {
return Collections.emptyList(); // Return an empty list if no restaurants found
}
}

if (restaurants.size() > numRestaurants) {
return restaurants.subList(0, numRestaurants);
} else {
return restaurants;
Set<String> seen = new HashSet<>();
List<Restaurant> unique = new ArrayList<>();
for (Restaurant restaurant : restaurants) {
if (seen.add(restaurant.getName())) {
unique.add(restaurant);
}
if (unique.size() == numRestaurants) {
break;
}
}

for (Restaurant r : unique) {
getDetails(r);
}

return unique;

}

private void getDetails(Restaurant restaurant) throws JsonProcessingException {
String detailsUrl = String.format(
"https://maps.googleapis.com/maps/api/place/details/json?fields=editorial_summary,website,formatted_phone_number&place_id=%s&key=%s",
restaurant.getID(), apiKey);

String detailsResponse = restTemplate.getForObject(detailsUrl, String.class);
JsonNode detailsRoot = objectMapper.readTree(detailsResponse);
JsonNode detailsResult = detailsRoot.path("result");

if (detailsResult.has("editorial_summary")) {
restaurant.setOverview(detailsResult.path("editorial_summary").path("overview").asText());
}
if (detailsResult.has("website")) {
restaurant.setWebsite(detailsResult.path("website").asText());
}
if (detailsResult.has("formatted_phone_number")) {
restaurant.setPhone(detailsResult.path("formatted_phone_number").asText());
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ public class Restaurant {
@JsonProperty("icon")
private String iconUrl;

@JsonProperty("place_id")
private String id;

@JsonProperty("editorial_overview")
private String overview;

private String website;

@JsonProperty("formatted_phone_number")
private String phone;

public static class OpeningHours {
@JsonProperty("open_now")
private Boolean openNow;
Expand All @@ -42,6 +53,8 @@ public void setOpenNow(Boolean openNow) {
}




public Restaurant(String name, String distance, String address, Integer priceLevel, String cuisine) { //String businessStatus) {
this.name = name;
this.distance = distance;
Expand All @@ -51,13 +64,13 @@ public Restaurant(String name, String distance, String address, Integer priceLev

}

public Restaurant(String name, String distance, String address) { //String businessStatus) {
public Restaurant(String name, String distance, String address) {
this.name = name;
this.distance = distance;
this.address = address;
this.priceLevel = null;
this.cuisine = null;
//this.businessStatus = businessStatus;

}

public Restaurant() {
Expand All @@ -71,6 +84,8 @@ public void setName(String name) {
this.name = name;
}



public String getDistance() {
return distance;
}
Expand All @@ -93,12 +108,6 @@ public void setPriceLevel(Integer priceLevel) {
this.priceLevel = priceLevel;
}

public String getCuisine() {
return cuisine;
}
public void setCuisine(String cuisine) {
this.cuisine = cuisine;
}

public Double getRating() {
return rating;
Expand All @@ -116,13 +125,6 @@ public void numRatings(Integer numRatings) {
this.numRatings = numRatings;
}

public String getIconUrl() {
return iconUrl;
}

public void setIconUrl(String iconUrl) {
this.iconUrl = iconUrl;
}

public OpeningHours getOpeningHours() {
return openingHours;
Expand All @@ -136,4 +138,22 @@ public void setOpeningHours(OpeningHours openingHours) {
public Boolean isOpenNow() {
return this.openingHours != null ? openingHours.getOpenNow() : null;
}

public String getID() {
return id;
}

public void setID(String id) {
this.id = id;
}

public String getOverview() { return overview; }
public void setOverview(String overview) { this.overview = overview; }

public String getWebsite() { return website; }
public void setWebsite(String website) { this.website = website; }

public String getPhone() { return phone; }
public void setPhone(String phone) { this.phone = phone; }

}
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ public void testGetNearbyRestaurantsSuccess() throws Exception {
.andExpect(jsonPath("$").isArray())
.andExpect(jsonPath("$[0].name").value("Taco Bell"))
.andExpect(jsonPath("$[0].distance").value("500m"))
.andExpect(jsonPath("$[0].address").value("321 Green St"))
.andExpect(jsonPath("$[0].vicinity").value("321 Green St"))
.andExpect(jsonPath("$[1].name").value("Canes"))
.andExpect(jsonPath("$[1].distance").value("1200m"))
.andExpect(jsonPath("$[1].address").value("658 E Healey St"));
.andExpect(jsonPath("$[1].vicinity").value("658 E Healey St"));
}

@Test
Expand Down Expand Up @@ -127,10 +127,10 @@ public void testGetFilteredRestaurants() throws Exception {
.andExpect(jsonPath("$").isArray())
.andExpect(jsonPath("$[0].name").value("Taco Bell"))
.andExpect(jsonPath("$[0].distance").value("500m"))
.andExpect(jsonPath("$[0].address").value("321 Green St"))
.andExpect(jsonPath("$[0].vicinity").value("321 Green St"))
.andExpect(jsonPath("$[1].name").value("Canes"))
.andExpect(jsonPath("$[1].distance").value("1200m"))
.andExpect(jsonPath("$[1].address").value("658 E Healey St"));
.andExpect(jsonPath("$[1].vicinity").value("658 E Healey St"));
}


Expand Down
25 changes: 25 additions & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*

.env
70 changes: 70 additions & 0 deletions frontend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Getting Started with Create React App

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).

## Available Scripts

In the project directory, you can run:

### `npm start`

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.

The page will reload when you make changes.\
You may also see any lint errors in the console.

### `npm test`

Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

### `npm run build`

Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `npm run eject`

**Note: this is a one-way operation. Once you `eject`, you can't go back!**

If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.

You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.

## Learn More

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).

### Code Splitting

This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)

### Analyzing the Bundle Size

This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)

### Making a Progressive Web App

This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)

### Advanced Configuration

This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)

### Deployment

This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)

### `npm run build` fails to minify

This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
Loading