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

Refactoring/tobias 117 convert leaflet to js #137

Merged
merged 54 commits into from
Jan 11, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
d8bf402
Start working on refactoring to js
JulianEgbert Jan 6, 2022
8a0d448
Refactor map elements to js
JulianEgbert Jan 6, 2022
ae9162c
Remove style from head
JulianEgbert Jan 6, 2022
65fae76
removed brackets as suggested
JulianEgbert Jan 6, 2022
a64fed5
Fix variable erroneously dumped to page
laugengebaeck Jan 6, 2022
a60da05
Restore package-lock.json and other feedback
JulianEgbert Jan 6, 2022
c29d2cf
First steps on new js conversion
JulianEgbert Jan 7, 2022
c56ff7c
Refactor routing display
JulianEgbert Jan 7, 2022
38007b1
Add Route to its own layer
JulianEgbert Jan 7, 2022
54b2b66
Trying to fix tests with js
JulianEgbert Jan 7, 2022
4319ac8
Comment on old magic constant
JulianEgbert Jan 7, 2022
c6f9eff
Adapt tests for routing
JulianEgbert Jan 7, 2022
2e9980a
linting stuff
JulianEgbert Jan 7, 2022
2265a8a
Remove test for targets, minor fixes
JulianEgbert Jan 8, 2022
37153ec
[CodeFactor] Apply fixes
code-factor Jan 8, 2022
371eeba
Merge branch 'dev' into refactoring/tobias_117_convert_leaflet_to_js
JulianEgbert Jan 8, 2022
1a82f10
Remove old map from locations, needs more fixing
JulianEgbert Jan 9, 2022
a5ad752
Extra js file for leaflet Map
JulianEgbert Jan 10, 2022
4af5885
prepare locations show
JulianEgbert Jan 10, 2022
75b542c
Remove map from location page
JulianEgbert Jan 10, 2022
543afa2
add debugging help to routing tests
JulianEgbert Jan 10, 2022
776ae89
add waiting time for routing
JulianEgbert Jan 10, 2022
1eab688
remove unnecessary code
JulianEgbert Jan 10, 2022
8ce15e3
adding wait_for_ajax to route tests
JulianEgbert Jan 10, 2022
eda4a02
Merge branch 'dev' into refactoring/tobias_117_convert_leaflet_to_js
JulianEgbert Jan 10, 2022
71a1e7f
Remove old unused code (Commented for target)
JulianEgbert Jan 10, 2022
e717412
tag tests and improve backend routes
JulianEgbert Jan 10, 2022
63ed5ac
improved tagging to new syntax
JulianEgbert Jan 10, 2022
6138956
exclude tests with the tag "local_only"
JulianEgbert Jan 10, 2022
974f469
add jQuery as requested
JulianEgbert Jan 10, 2022
4443c89
code cleanup for jQuery
JulianEgbert Jan 10, 2022
b5f25c6
enable indoor rooms from hg
JulianEgbert Jan 10, 2022
aa4485c
add target marker functionality
JulianEgbert Jan 10, 2022
8777472
remove old variable on index
JulianEgbert Jan 10, 2022
a96f51b
[CodeFactor] Apply fixes
code-factor Jan 10, 2022
4a75617
a try on fixing tests
JulianEgbert Jan 10, 2022
2435fb9
[CodeFactor] Apply fixes
code-factor Jan 10, 2022
3b597a5
fix CodeFactor issue
JulianEgbert Jan 10, 2022
08339e3
improve tests with find and waiting time
JulianEgbert Jan 11, 2022
ee0035b
edit tags for tests
JulianEgbert Jan 11, 2022
98d559e
remove parallel execution in js
JulianEgbert Jan 11, 2022
06517dc
remove wait_for_ajax
JulianEgbert Jan 11, 2022
5a447c4
run route tests only local
JulianEgbert Jan 11, 2022
a3aa0ad
restore yarn.lock
JulianEgbert Jan 11, 2022
fac6fff
add newline to yarn.lock
JulianEgbert Jan 11, 2022
27e8287
Code improvements
JulianEgbert Jan 11, 2022
008eecb
[CodeFactor] Apply fixes
code-factor Jan 11, 2022
048d980
Fix magic string
JulianEgbert Jan 11, 2022
d162876
possible fix for routing tests
JulianEgbert Jan 11, 2022
6705a7b
Parallelize ajax requests
JulianEgbert Jan 11, 2022
3829594
reverse changes for parallel ajax
JulianEgbert Jan 11, 2022
0fdfe85
add comment about race condition
JulianEgbert Jan 11, 2022
6a57af1
Paralize ajax requests WITH tests
JulianEgbert Jan 11, 2022
a0aa143
remove tests for routing (race condition)
JulianEgbert Jan 11, 2022
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
3 changes: 0 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ gem 'tod'
# Libraries
#

# Leaflet for map functionality
gem 'leaflet-rails', git: "git://github.com/Finn-HPI/leaflet-rails.git"

#
# Gems that are loaded depending on the environment (development/test/production)
#
Expand Down
8 changes: 0 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
GIT
remote: git://github.com/Finn-HPI/leaflet-rails.git
revision: 340f65cbc163dcc3523c43592831d43a65381296
specs:
leaflet-rails (1.7.4)
rails (>= 4.2.0)

GEM
remote: https://rubygems.org/
specs:
Expand Down Expand Up @@ -369,7 +362,6 @@ DEPENDENCIES
factory_bot_rails
httparty
jbuilder (~> 2.7)
leaflet-rails!
listen (~> 3.3)
omniauth
omniauth_openid_connect
Expand Down
4 changes: 2 additions & 2 deletions app/assets/constants/buildings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,9 @@ def self.transform_leaflet_letters(hpi_letters)
hpi_letters.map do |hpi_letter|
{
latlng: hpi_letter[:coordinate],
div_icon: {
divIcon: {
html: hpi_letter[:letter],
class_name: "building-icon"
className: "building-icon"
}
}
end
Expand Down
2 changes: 0 additions & 2 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ $fa-font-path: "@fortawesome/fontawesome-free/webfonts";
// CSS partials
@import "components/navbar";

@import "leaflet";

body {
padding-top: 4rem;
}
Expand Down
8 changes: 4 additions & 4 deletions app/helpers/routing_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ def self.transform_route_to_time_marker(route)
start = route["geometry"]["coordinates"][0]
[{
latlng: [start.second, start.first],
div_icon: {
divIcon: {
html: walking_time,
class_name: "time-icon"
className: "time-icon"
}
}]
end
Expand All @@ -68,9 +68,9 @@ def self.transform_target_to_marker(point)

[{
latlng: coordinates,
div_icon: {
divIcon: {
html: "<img src='/assets/pin.png'>",
class_name: "target-pin"
className: "target-pin"
}
}]
end
Expand Down
3 changes: 2 additions & 1 deletion app/javascript/packs/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import 'bootstrap';
// Fontawesome: https://fontawesome.com/
import "@fortawesome/fontawesome-free/js/all";

import * as L from "leaflet"
import * as L from "leaflet";
Dassderdie marked this conversation as resolved.
Show resolved Hide resolved
import "leaflet/dist/leaflet.css";

Rails.start()
Turbolinks.start()
Expand Down
38 changes: 32 additions & 6 deletions app/views/building_map/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,40 @@
</datalist>

<div class="container-fluid">
<%= map(
center: BuildingMapHelper.leaflet_center(@start),
polygons: BuildingMapHelper.leaflet_polygons,
polylines: BuildingMapHelper.leaflet_polylines(@route),
markers: BuildingMapHelper.leaflet_markers(@route, @target))
%>
<div id="map"></div>
</div>

<script>
JulianEgbert marked this conversation as resolved.
Show resolved Hide resolved
const view = <%= raw BuildingMapHelper.leaflet_center(@start).to_json %>;
const polygons = <%= raw BuildingMapHelper.leaflet_polygons.to_json %>;
const markers = <%= raw BuildingMapHelper.leaflet_markers(@route, @target).to_json %>;
const polylines = <%= raw BuildingMapHelper.leaflet_polylines(@route).to_json %>;

const map = L.map('map').setView(view["latlng"], view["zoom"]);

L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>',
maxZoom: 19,
}).addTo(map);

markers.forEach((marker) => {
JulianEgbert marked this conversation as resolved.
Show resolved Hide resolved
marker['divIcon']['iconSize'] = [];
marker['divIcon']['iconAnchor'] = [0, 0];
marker['divIcon']['popupAnchor'] = [0, 0];
var icon = L.divIcon(marker['divIcon']);
JulianEgbert marked this conversation as resolved.
Show resolved Hide resolved
L.marker(marker['latlng'], {icon: icon}).addTo(map);
});

polygons.forEach(polygon => {
L.polygon(polygon['latlngs'], polygon['options']).addTo(map);
});

polylines.forEach(polyline => {
L.polyline(polyline['latlngs'], polyline['options']).addTo(map);
});

</script>

<script>
let currentLocation;

Expand Down
3 changes: 0 additions & 3 deletions config/initializers/leaflet.rb

This file was deleted.

Loading