This repository has been archived by the owner on Sep 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* backend implementation and UT (-integration test @ DinerRepo) * change table name * refactor rename * add IT * add gmaps column * stash * alter table and add City enum * fix compile * fix test:compile * fix UT * add City enum-1 * backend finished * init FE * backend selesai * integrate FE and BE * add current location * fix and add UT * coverage-off
- Loading branch information
1 parent
728627d
commit e1fca0d
Showing
25 changed files
with
667 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -9,3 +9,6 @@ project | |
/.settings | ||
docker/storage/.minio.sys | ||
/RUNNING_PID | ||
/.bloop | ||
/.metals | ||
/.vscode |
This file contains 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 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 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 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,17 @@ | ||
package com.seanmcapp.repository | ||
|
||
import com.seanmcapp.repository.seanmcmamen.StallRepoImpl | ||
import org.scalatest.matchers.should.Matchers | ||
import org.scalatest.wordspec.AsyncWordSpec | ||
|
||
class StallRepoSpec extends AsyncWordSpec with Matchers { | ||
|
||
// "should return all stalls" in { | ||
// val response = StallRepoImpl.getAll | ||
// response.map { res => | ||
// res.size shouldEqual 4 | ||
// res.map(_.name) shouldEqual List("Ayam Suharti", "Rm. Sederhana", "Warteg Bahari", "Sate Madura Pak Kumis") | ||
// } | ||
// } | ||
|
||
} |
This file contains 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 |
---|---|---|
|
@@ -55,4 +55,6 @@ twitter { | |
token = ${?TWITTER_ACCESS_TOKEN} | ||
secret = ${?TWITTER_ACCESS_SECRET} | ||
} | ||
} | ||
} | ||
|
||
google.key = ${?GOOGLE_KEY} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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,106 @@ | ||
window.initMap = initMap; | ||
|
||
let map; | ||
var openedInfoWindow = null; | ||
|
||
function initMap() { | ||
// Default to Jakarta | ||
const defaultLatLng = { | ||
lat: -6.172018, | ||
lng: 106.801848 | ||
}; | ||
|
||
map = new google.maps.Map(document.getElementById("map"), { | ||
zoom: 13, | ||
center: defaultLatLng, | ||
}); | ||
|
||
renderMap(); | ||
} | ||
|
||
function renderMap() { | ||
google.maps.event.addListener(map, "click", function(event) { | ||
if (openedInfoWindow) openedInfoWindow.close() | ||
}); | ||
|
||
google.maps.event.addListener(map, "idle", function() { | ||
const nw = { | ||
lat: map.getBounds().getNorthEast().lat(), | ||
lng: map.getBounds().getNorthEast().lng() | ||
} | ||
const se = { | ||
lat: map.getBounds().getSouthWest().lat(), | ||
lng: map.getBounds().getSouthWest().lng() | ||
} | ||
|
||
fetchStalls(nw, se); | ||
}); | ||
} | ||
|
||
async function fetchStalls(nw, se) { | ||
fetch('/api/mamen', { | ||
method: 'POST', | ||
headers: { | ||
'Accept': '*/*', | ||
}, | ||
body: JSON.stringify({filter: {geo: {nw: nw, se: se}}}), | ||
}) | ||
.then(res => res.json()) | ||
.then(stalls => { | ||
placeMarkersAndInfoWindows(stalls) | ||
}); | ||
} | ||
|
||
function placeMarkersAndInfoWindows(stalls) { | ||
stalls.forEach( function(stall) { | ||
const marker = new google.maps.Marker({ | ||
position: { | ||
lat: stall.latitude, | ||
lng: stall.longitude | ||
}, | ||
map, | ||
}); | ||
|
||
const contentString = | ||
'<div class="cell-12">' + | ||
'<p><b>'+stall.name+'</b></p>' + | ||
'<div class="row" style="text-align: center">' + | ||
'<div class="cell-6">' + | ||
'<a class="button" href="'+stall.gmapsUrl+'" role="button square" style="background-color: transparent">' + | ||
'<img src="/assets/images/gmaps.svg"></a></div>' + | ||
'<div class="cell-6">' + | ||
'<a class="button" href="'+stall.youtubeUrl+'" role="button square" style="background-color: transparent">' + | ||
'<img src="/assets/images/youtube.svg"></a></div>' + | ||
'</div>' + | ||
'</div>' | ||
|
||
marker.addListener("click", () => { | ||
if (openedInfoWindow) { | ||
openedInfoWindow.close(); | ||
} | ||
const infoWindow = new google.maps.InfoWindow({ | ||
content: contentString, | ||
}); | ||
openedInfoWindow = infoWindow; | ||
infoWindow.open({ | ||
anchor: marker, | ||
map | ||
}); | ||
}); | ||
}); | ||
} | ||
|
||
function initGeolocation() { | ||
if(navigator.geolocation) { | ||
navigator.geolocation.getCurrentPosition( (position) => { | ||
map.setCenter({ | ||
lat: position.coords.latitude, | ||
lng: position.coords.longitude | ||
}); | ||
}, () => { | ||
alert('Failed to get your location.') | ||
}); | ||
} else { | ||
alert('Geolocation is not available.') | ||
} | ||
} |
This file contains 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,15 @@ | ||
#map { | ||
height: 100%; | ||
} | ||
|
||
body, html { | ||
height: 100%; | ||
} | ||
|
||
#map-container { | ||
height: 100%; | ||
} | ||
|
||
#map-row { | ||
height: 80%; | ||
} |
This file contains 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 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 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 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 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,3 @@ | ||
package com.seanmcapp.external | ||
|
||
case class LatLng(lat: Double, lng: Double) |
This file contains 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,22 @@ | ||
package com.seanmcapp.external | ||
|
||
import com.seanmcapp.GoogleConf | ||
|
||
import java.net.URLEncoder | ||
|
||
case class GeocodeGeometry(location: LatLng) | ||
case class GeocodeResult(geometry: GeocodeGeometry) | ||
case class GeocodeResponse(results: List[GeocodeResult]) | ||
class GoogleClient(httpClient: HttpRequestClient) { | ||
|
||
private val apiKey = GoogleConf.apply().key | ||
|
||
def fetchLatLng(plusCode: String): (Option[Double], Option[Double]) = { | ||
val url = s"https://maps.googleapis.com/maps/api/geocode/json?key=$apiKey&address=${URLEncoder.encode(plusCode, "UTF-8")}" | ||
val response = httpClient.sendGetRequest(url) | ||
decode[GeocodeResponse](response).results.headOption.map { geo => | ||
(geo.geometry.location.lat, geo.geometry.location.lng) | ||
}.unzip | ||
} | ||
|
||
} |
This file contains 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,5 @@ | ||
package com.seanmcapp.external | ||
|
||
case class GeoFilter(nw: LatLng, se: LatLng) | ||
case class MamenFilter(name: Option[String] = None, cityId: Option[Int] = None, geo: Option[GeoFilter] = None) | ||
case class MamenRequest(filter: MamenFilter) |
Oops, something went wrong.