-
Notifications
You must be signed in to change notification settings - Fork 0
Maps integration #7
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
Open
AlvieH
wants to merge
8
commits into
master
Choose a base branch
from
maps-integration
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
829955f
blobstore url fetch by script.js and display in html
AlvieH 750aa57
add whitespace at end of files
AlvieH 76971db
upload url to datastore
AlvieH 8af8540
Posts addresses of favorite coffee shops to datastore w/ map integration
AlvieH 4ed25be
remove rogue space in maps.html
AlvieH 7a3ad28
Cafe is now immutable
AlvieH 29c1c07
fixes to Cafe immutability implementation
AlvieH 3913f4e
Merge branch 'master' into maps-integration
AlvieH File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| // Copyright 2020 Google LLC | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // https://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package com.google.sps.data; | ||
|
|
||
| /* Represents a user-uploaded coffee shop at specific address */ | ||
| public final class Cafe { | ||
| private final String address; | ||
| private final boolean isStarbucks; | ||
|
|
||
| private Cafe(String address, boolean isStarbucks) { | ||
| this.address = address; | ||
| this.isStarbucks = isStarbucks; | ||
| } | ||
| } |
59 changes: 59 additions & 0 deletions
59
portfolio/src/main/java/com/google/sps/servlets/ListCafeServlet.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| // Copyright 2020 Google LLC | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // https://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package com.google.sps.servlets; | ||
|
|
||
| import com.google.appengine.api.datastore.DatastoreService; | ||
| import com.google.appengine.api.datastore.DatastoreServiceFactory; | ||
| import com.google.appengine.api.datastore.Entity; | ||
| import com.google.appengine.api.datastore.PreparedQuery; | ||
| import com.google.appengine.api.datastore.Query; | ||
| import com.google.appengine.api.datastore.Query.SortDirection; | ||
| import com.google.gson.Gson; | ||
| import com.google.sps.data.Cafe; | ||
| import java.io.IOException; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import javax.servlet.annotation.WebServlet; | ||
| import javax.servlet.http.HttpServlet; | ||
| import javax.servlet.http.HttpServletRequest; | ||
| import javax.servlet.http.HttpServletResponse; | ||
|
|
||
| /* Servlet responsible for listing coffee shops */ | ||
| @WebServlet("/list-cafe") | ||
| public class ListCafeServlet extends HttpServlet { | ||
|
|
||
| @Override | ||
| public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { | ||
| Query query = new Query("Cafe"); | ||
|
|
||
| DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); | ||
| PreparedQuery results = datastore.prepare(query); | ||
|
|
||
| List<Cafe> cafes = new ArrayList<>(); | ||
| for (Entity entity : results.asIterable()) { | ||
| long id = entity.getKey().getId(); | ||
| String address = (String) entity.getProperty("address"); | ||
| boolean isStarbucks = (boolean) entity.getProperty("starbucks"); | ||
|
|
||
| Cafe cafe = new Cafe(address, isStarbucks); | ||
| cafes.add(cafe); | ||
| } | ||
|
|
||
| Gson gson = new Gson(); | ||
|
|
||
| response.setContentType("application/json;"); | ||
| response.getWriter().println(gson.toJson(cafes)); | ||
| } | ||
| } | ||
43 changes: 43 additions & 0 deletions
43
portfolio/src/main/java/com/google/sps/servlets/NewCafeServlet.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| // Copyright 2020 Google LLC | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // https://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package com.google.sps.servlets; | ||
|
|
||
| import com.google.appengine.api.datastore.DatastoreService; | ||
| import com.google.appengine.api.datastore.DatastoreServiceFactory; | ||
| import com.google.appengine.api.datastore.Entity; | ||
| import java.io.IOException; | ||
| import javax.servlet.annotation.WebServlet; | ||
| import javax.servlet.http.HttpServlet; | ||
| import javax.servlet.http.HttpServletRequest; | ||
| import javax.servlet.http.HttpServletResponse; | ||
|
|
||
| /* Class responsible for uploading new coffee shops to datastore */ | ||
| @WebServlet("/new-cafe") | ||
| public class NewCafeServlet extends HttpServlet { | ||
| @Override | ||
| public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException { | ||
| String address = request.getParameter("address"); | ||
| boolean isStarbucks = request.getParameter("starbucks") != null; | ||
|
|
||
| Entity cafeEntity = new Entity("Cafe"); | ||
| cafeEntity.setProperty("address", address); | ||
| cafeEntity.setProperty("starbucks", isStarbucks); | ||
|
|
||
| DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); | ||
| datastore.put(cafeEntity); | ||
|
|
||
| response.sendRedirect("images.html"); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <title>Alvin Hermans</title> | ||
| <link rel="icon" type="image/png" size="16x16" href="files/images/favicon-16x16.png"></link> | ||
| <link rel="icon" type="image/png" size="32x32" href="files/images/favicon-32x32.png"></link> | ||
| <link rel="stylesheet" href="css/style.css"> | ||
| <link rel="stylesheet" href="css/all.css"> | ||
| <link href="https://fonts.googleapis.com/css2?family=Fira+Sans:wght@400;500&family=Roboto+Condensed:wght@300;400&family=Roboto+Mono:wght@300;400;500&display=swap" | ||
| rel="stylesheet"> | ||
| <script src="script.js"></script> | ||
| <script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCib_0RH1hdeDTEpXE4QDt2EVukkmH3jvI&callback=initMap" | ||
| type="text/javascript"></script> | ||
| </head> | ||
| <header> | ||
| <nav class="nav"> | ||
| <a href="index.html" class="title">alvin_hermans</a> | ||
| <ul class="menu-links"> | ||
| <li><a href="projects.html">projects</a></li> | ||
| <li><a href="resume.html">resume</a></li> | ||
| <li><a href="comments.html">comments</a></li> | ||
| <li><div class="nav-active">maps</div></li> | ||
| </ul> | ||
| <ul class="contact-links"> | ||
| <li><a href="https://github.com/AlvieH"><i class="fab fa-github fa-lg"></i></a></li> | ||
| <li><a href="https://www.linkedin.com/in/aherma"><i class="fab fa-linkedin-in fa-lg"></i></a></li> | ||
| <li><a href="mailto:alvinhermans123@gmail.com"><i class="fas fa-paper-plane fa-lg"></i></a></li> | ||
| </ul> | ||
| </nav> | ||
| </header> | ||
| <body onload="initializeMap();"> | ||
| <form id="map-form" method="POST" action="/new-coffee-shop"> | ||
| <p>Please put in the address of your favorite coffee place:</p> | ||
| <input type="text" name="address"> | ||
| </br> | ||
| <p> Is your coffee place a starbucks?</p> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no space after
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. addressed in latest commit! |
||
| <input type="checkbox" name="starbucks" value="This place is a starbucks"> | ||
| </br></br> | ||
| <button>Submit</button> | ||
| </form> | ||
| <div id="map"> | ||
| </div> | ||
| </body> | ||
| </html> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.