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 React app to frontend #3

Open
wants to merge 102 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 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
4bd7bb0
added google places api key to application properties
nyssaaftab Oct 11, 2024
7808d01
made it so api key wasn't hardcoded..oops
nyssaaftab Oct 11, 2024
0608a86
Merge pull request #6 from CS222-UIUC/nyssa
nancywang197 Oct 11, 2024
be0cc6f
Added Restaraunt cards and About Us pages
ejx2 Oct 13, 2024
5bde10c
added rest template bean test case
nancywang197 Oct 15, 2024
5b8ce81
Merge branch 'backend' of https://github.com/CS222-UIUC/Team-5-3-1 in…
nancywang197 Oct 18, 2024
3553563
added ds_store to git ignore
nyssaaftab Oct 18, 2024
5941d64
resolved merge conflicts and fixed test case
nancywang197 Oct 18, 2024
4bdce2e
Merge branch 'main' of https://github.com/CS222-UIUC/Team-5-3-1 into …
nyssaaftab Oct 18, 2024
41ce83e
Merge pull request #7 from CS222-UIUC/nancy
nyssaaftab Oct 18, 2024
7a9fdd2
Merge branch 'backend' of https://github.com/CS222-UIUC/Team-5-3-1 in…
nyssaaftab Oct 18, 2024
f5f964d
added Restaurant class and JSON parsing capabilities in GooglePlaces …
nancywang197 Oct 18, 2024
c5ae53c
Merge pull request #10 from CS222-UIUC/nancy
nyssaaftab Oct 18, 2024
1e88d21
merging changes from nancy's branch
nyssaaftab Oct 18, 2024
543d53d
handle dockerfile
nyssaaftab Oct 18, 2024
ce9c781
added service and controller methods for generating numRestaurants ra…
nyssaaftab Oct 18, 2024
ebd2924
added actuator dependency for seeing endpt mappings
nyssaaftab Oct 18, 2024
f9c6b5a
updated port to 8081
nyssaaftab Oct 18, 2024
b43a683
created GooglePlacesController Test and RestTemplate Test files and t…
nancywang197 Oct 18, 2024
5081869
Merge pull request #11 from CS222-UIUC/nancy
nyssaaftab Oct 18, 2024
5975b28
Merge pull request #12 from CS222-UIUC/nyssa
nancywang197 Oct 18, 2024
1db96b5
added test case for successful request
nyssaaftab Oct 18, 2024
66a3619
Merge pull request #13 from CS222-UIUC/nyssa
nancywang197 Oct 18, 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
e2354c9
added select on restuarant function and corresponding test cases
nancywang197 Oct 22, 2024
df5b41b
Merge pull request #14 from CS222-UIUC/nancy
nyssaaftab Oct 24, 2024
2aac5e3
udpated service and restaurant classes to support price and cuisine f…
nyssaaftab Oct 25, 2024
22ce999
updated controller to support filtering
nyssaaftab Oct 25, 2024
aec88da
test case for filters
nyssaaftab Oct 25, 2024
052c8e5
Added $ label to slider
ejx2 Oct 28, 2024
d8095a5
debugged and added plugin for test coverage
nyssaaftab Oct 29, 2024
7423a14
Merge pull request #15 from CS222-UIUC/nyssa
nancywang197 Oct 29, 2024
2e7f5cc
wrote select one restaurant function
nancywang197 Oct 29, 2024
1ca8dee
Merge branch 'backend' of https://github.com/CS222-UIUC/Team-5-3-1 in…
nancywang197 Oct 29, 2024
b14feb1
change flow of mappings in google places controller
nancywang197 Oct 29, 2024
c7ed9af
debugging and added business status field to restaurant class
nyssaaftab Oct 29, 2024
8323513
Merge pull request #16 from CS222-UIUC/nancy
nyssaaftab Oct 29, 2024
bc38797
Merge branch 'backend' into nyssa
nancywang197 Oct 29, 2024
73e5ce8
Merge pull request #17 from CS222-UIUC/nyssa
nancywang197 Oct 29, 2024
bf2353e
created service test class and added tests
nancywang197 Oct 29, 2024
73327b1
"Merge branch 'backend' of https://github.com/CS222-UIUC/Team-5-3-1 i…
nancywang197 Oct 29, 2024
cd0b1e2
wrote more test cases for service
nancywang197 Nov 5, 2024
60baba8
Merge pull request #18 from CS222-UIUC/nancy
nyssaaftab Nov 5, 2024
4a47628
changed favicon, added restaurants, updated order
ejx2 Nov 5, 2024
b6daa4b
fixed endpoint issues -- api finally works
nyssaaftab Nov 5, 2024
8cfc284
Merge pull request #19 from CS222-UIUC/nyssa
nancywang197 Nov 5, 2024
363cc3b
updated dependencies to support junit and troubleshooted service tests
nyssaaftab Nov 5, 2024
f262ac3
Merge pull request #20 from CS222-UIUC/nyssa
nancywang197 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
a41645a
updated restaurant class and added json mappings, updated controller …
nyssaaftab Nov 12, 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
c3a14a1
Merge pull request #21 from CS222-UIUC/nyssa
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
a9be7c8
add geolocator functionality to front end
nancywang197 Nov 18, 2024
69cf73b
merge conflict resolution
nancywang197 Nov 18, 2024
e8c112d
polishing up
nancywang197 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
7abc5bc
Ignore .DS_Store files
natgaographic Nov 19, 2024
63fcd3a
Trying to resolve merge conflict with DS_Store in frontend-backend-merge
natgaographic 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
5805394
Merge branch 'frontend-backend-merge' of https://github.com/CS222-UIU…
natgaographic Nov 20, 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
a47309f
Merge branch 'frontend-backend-merge' of https://github.com/CS222-UIU…
natgaographic Nov 22, 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
30dc0f4
Pulled frontend directory from frontend-backend-merge
nancywang197 Nov 30, 2024
b7ed514
try to resolve checkout issues
nancywang197 Nov 30, 2024
bf94740
Merge pull request #26 from CS222-UIUC/frontend-merge
nancywang197 Nov 30, 2024
c1ecff3
fixed formatting on result cards
ejx2 Dec 1, 2024
d3e3366
no images for final cards
ejx2 Dec 1, 2024
c6e19d3
Resolve conflict with .DS_Store
natgaographic Dec 3, 2024
f63b49c
Updated About Us page with new features
natgaographic Dec 3, 2024
9b3c88a
Merge branch 'frontend' of https://github.com/CS222-UIUC/Team-5-3-1 i…
natgaographic Dec 4, 2024
ee36a0f
changed button stylings
natgaographic Dec 10, 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
Binary file added backend/.DS_Store
Binary file not shown.
6 changes: 4 additions & 2 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ COPY fivethreeone/.mvn ./.mvn

COPY fivethreeone/target/fivethreeone-0.0.1-SNAPSHOT.jar app.jar

EXPOSE 8080
EXPOSE 8081

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

# docker stop 3e56942ba023


# ./mvnw clean package -DskipTests
# docker build -t backend-springboot .
# docker build -t backend-springboot .
# docker run -d -p 8081:8080 backend-springboot
Binary file added backend/fivethreeone/.DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions backend/fivethreeone/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ build/

### VS Code ###
.vscode/

.DS_Store
33 changes: 33 additions & 0 deletions backend/fivethreeone/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,26 @@
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.9.3</version> <!-- Use the latest version available -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.9.3</version> <!-- Use the latest version available -->
<scope>test</scope>
</dependency>


</dependencies>

<build>
Expand All @@ -53,6 +73,19 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.10</version> <!-- Use the latest version -->
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
Binary file added backend/fivethreeone/src/.DS_Store
Binary file not shown.
Binary file added backend/fivethreeone/src/main/.DS_Store
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package com.cs222.fivethreeone;
import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

@Configuration
public class AppConfig {
@Bean
public RestTemplate restTemplate() {
return new RestTemplate();
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,63 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.PostMapping;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.http.HttpStatus;

import java.util.List;
import java.util.Random;


@RestController
@RequestMapping("/api/restaurants")
public class GooglePlacesController {
private final GooglePlacesService placesService;
private final GooglePlacesService googlePlacesService;

public GooglePlacesController(GooglePlacesService placesService) {
this.placesService = placesService;
public GooglePlacesController(GooglePlacesService googlePlacesService) {
this.googlePlacesService = googlePlacesService;
}

@GetMapping("/api/places")
public String getPlaces(@RequestParam String location, @RequestParam String radius) {
return placesService.getPlaces(location, radius);
@GetMapping("/nearby")
public List<Restaurant> getPlaces(@RequestParam String location, @RequestParam String radius) throws JsonMappingException, JsonProcessingException {
return googlePlacesService.getPlaces(location, radius);
}

//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(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 {
return googlePlacesService.getRandomRestaurants(location, radius, priceLevel, cuisine, numRestaurants);
}


//Receives POST request from client in the form of JSON of the 3 selected restuarants
@PostMapping("/select")
public Restaurant selectOneRestaurant(@RequestBody List<Restaurant> selectedRestaurants) {
if (selectedRestaurants == null || selectedRestaurants.size() < 3) {
throw new IllegalArgumentException("At least 3 restaurants must be selected by user");
}
Random random = new Random();
int index = random.nextInt(selectedRestaurants.size());
return selectedRestaurants.get(index);
}

// Exception handler for IllegalArgumentException
@ExceptionHandler(IllegalArgumentException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
public String handleIllegalArgumentException(IllegalArgumentException ex) {
return ex.getMessage();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,105 @@
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

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


@Service
public class GooglePlacesService {
@Value("${google.places.api.key}")
@Value("${GOOGLE_API_KEY}") //inject API key
private String apiKey;

private final RestTemplate restTemplate;
private final ObjectMapper objectMapper = new ObjectMapper();


public GooglePlacesService(RestTemplate restTemplate) {
this.restTemplate = restTemplate;
}

public String getPlaces(String location, String radius) {
public List<Restaurant> getPlaces(String location, String radius) throws JsonMappingException, JsonProcessingException {
String url = String.format(
"https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=%s&radius=%s&key=%s",
location, radius, apiKey);
return restTemplate.getForObject(url, String.class);
String response = restTemplate.getForObject(url, String.class); //returns raw JSON response
JsonNode root = objectMapper.readTree(response);
JsonNode results = root.path("results");

return objectMapper.convertValue(results, new TypeReference<List<Restaurant>>() {});
}

public List<Restaurant> getRandomRestaurants(String location, String radius, Integer priceLevel, String cuisine, int numRestaurants) throws JsonMappingException, JsonProcessingException {

StringBuilder url = new StringBuilder(
String.format("https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=%s&radius=%s&type=restaurant",
location, radius)
);

if (priceLevel != null) {
url.append("&minprice=").append(priceLevel);
url.append("&maxprice=").append(priceLevel);
}

if (cuisine != null && !cuisine.isEmpty()) {
url.append("&keyword=").append(cuisine);
}

url.append("&key=").append(apiKey);




String response = restTemplate.getForObject(url.toString(), String.class); //returns raw JSON response
JsonNode root = objectMapper.readTree(response);
JsonNode results = root.path("results");

System.out.println("Requesting Google Places API: " + url); // Log the API URL
System.out.println("results: " + response);


List<Restaurant> restaurants = objectMapper.convertValue(results, new TypeReference<List<Restaurant>>() {});
Collections.shuffle(restaurants);

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

if (restaurants.size() > numRestaurants) {
restaurants = restaurants.subList(0, numRestaurants);
}

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

return restaurants;

}

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());
}
}

}
Loading