diff --git a/flatisfy/filters/metadata.py b/flatisfy/filters/metadata.py
index 2bbaca2..9c7c4a6 100644
--- a/flatisfy/filters/metadata.py
+++ b/flatisfy/filters/metadata.py
@@ -379,7 +379,7 @@ def compute_travel_times(flats_list, config):
if time_to_place:
LOGGER.info(
"Travel time between %s and flat %s is %ds.",
- place_name, flat["id"], time_to_place
+ place_name, flat["id"], time_to_place["time"]
)
flat["flatisfy"]["time_to"][place_name] = time_to_place
return flats_list
diff --git a/flatisfy/tools.py b/flatisfy/tools.py
index ecc78e4..91e6a71 100644
--- a/flatisfy/tools.py
+++ b/flatisfy/tools.py
@@ -235,8 +235,8 @@ def get_travel_time_between(latlng_from, latlng_to, config):
:param latlng_from: A tuple of (latitude, longitude) for the starting
point.
:param latlng_to: A tuple of (latitude, longitude) for the destination.
- :return: The travel time in seconds. Returns ``None`` if it could not fetch
- it.
+ :return: A dict of the travel time in seconds and sections of the journey
+ with GeoJSON paths. Returns ``None`` if it could not fetch it.
.. note :: Uses the Navitia API. Requires a ``navitia_api_key`` field to be
filled-in in the ``config``.
@@ -258,7 +258,28 @@ def get_travel_time_between(latlng_from, latlng_to, config):
auth=(config["navitia_api_key"], "")
)
req.raise_for_status()
- time = req.json()["journeys"][0]["durations"]["total"]
+
+ journeys = req.json()["journeys"][0]
+ time = journeys["durations"]["total"]
+ sections = []
+ for section in journeys["sections"]:
+ if section["type"] == "public_transport":
+ # Public transport
+ sections.append({
+ "geojson": section["geojson"],
+ "color": (
+ section["display_informations"].get("color", None)
+ )
+ })
+ elif section["type"] == "street_network":
+ # Walking
+ sections.append({
+ "geojson": section["geojson"],
+ "color": None
+ })
+ else:
+ # Skip anything else
+ continue
except (requests.exceptions.RequestException,
ValueError, IndexError, KeyError) as exc:
# Ignore any possible exception
@@ -272,4 +293,10 @@ def get_travel_time_between(latlng_from, latlng_to, config):
"No API key available for travel time lookup. Please provide "
"a Navitia API key. Skipping travel time lookup."
)
- return time
+ if time:
+ return {
+ "time": time,
+ "sections": sections
+ }
+ else:
+ return None
diff --git a/flatisfy/web/js_src/components/app.vue b/flatisfy/web/js_src/components/app.vue
index c147d32..4125db6 100644
--- a/flatisfy/web/js_src/components/app.vue
+++ b/flatisfy/web/js_src/components/app.vue
@@ -4,9 +4,8 @@
diff --git a/flatisfy/web/js_src/components/flatsmap.vue b/flatisfy/web/js_src/components/flatsmap.vue
index 1a844a7..e6d18d4 100644
--- a/flatisfy/web/js_src/components/flatsmap.vue
+++ b/flatisfy/web/js_src/components/flatsmap.vue
@@ -12,6 +12,9 @@
+
+
+
@@ -30,6 +33,13 @@ import Vue2Leaflet from 'vue2-leaflet'
export default {
data () {
return {
+ defaultGeoJSONOptions: {
+ weight: 5,
+ color: '#000',
+ opacity: 1,
+ fillColor: '#e4ce7f',
+ fillOpacity: 1
+ },
center: null,
zoom: {
defaultZoom: 13,
@@ -59,7 +69,8 @@ export default {
'v-tilelayer': Vue2Leaflet.TileLayer,
'v-marker': Vue2Leaflet.Marker,
'v-tooltip': Vue2Leaflet.Tooltip,
- 'v-popup': Vue2Leaflet.Popup
+ 'v-popup': Vue2Leaflet.Popup,
+ 'v-geojson-layer': Vue2Leaflet.GeoJSON
},
computed: {
@@ -77,7 +88,7 @@ export default {
}
},
- props: ['flats', 'places']
+ props: ['flats', 'places', 'journeys']
// TODO: Add a switch to display a layer with isochrones
}
diff --git a/flatisfy/web/js_src/i18n/en/index.js b/flatisfy/web/js_src/i18n/en/index.js
index 0d483b6..c34b8a1 100644
--- a/flatisfy/web/js_src/i18n/en/index.js
+++ b/flatisfy/web/js_src/i18n/en/index.js
@@ -21,8 +21,7 @@ export default {
menu: {
'available_flats': 'Available flats',
'followed_flats': 'Followed flats',
- 'ignored_flats': 'Ignored flats',
- 'user_deleted_flats': 'User deleted flats'
+ 'by_status': 'Flats by status'
},
flatsDetails: {
'Title': 'Title',
@@ -49,7 +48,8 @@ export default {
'new': 'new',
'followed': 'followed',
'ignored': 'ignored',
- 'user_deleted': 'user deleted'
+ 'user_deleted': 'user deleted',
+ 'duplicate': 'duplicate'
},
slider: {
'Fullscreen_photo': 'Fullscreen photo'
diff --git a/flatisfy/web/js_src/router/index.js b/flatisfy/web/js_src/router/index.js
index 00e7246..bbad873 100644
--- a/flatisfy/web/js_src/router/index.js
+++ b/flatisfy/web/js_src/router/index.js
@@ -11,9 +11,7 @@ export default new VueRouter({
routes: [
{ path: '/', component: Home, name: 'home' },
{ path: '/new', redirect: '/' },
- { path: '/followed', component: Status, name: 'followed' },
- { path: '/ignored', component: Status, name: 'ignored' },
- { path: '/user_deleted', component: Status, name: 'user_deleted' },
+ { path: '/status/:status', component: Status, name: 'status' },
{ path: '/flat/:id', component: Details, name: 'details' }
]
})
diff --git a/flatisfy/web/js_src/views/details.vue b/flatisfy/web/js_src/views/details.vue
index 268f627..39b8352 100644
--- a/flatisfy/web/js_src/views/details.vue
+++ b/flatisfy/web/js_src/views/details.vue
@@ -84,7 +84,7 @@
-
- {{ place }}: {{ time_to }}
+ {{ place }}: {{ time_to["time"] }}
@@ -98,7 +98,7 @@
{{ $t("flatsDetails.Location") }}
-
+
@@ -195,6 +195,24 @@ export default {
flat () {
return this.$store.getters.flat(this.$route.params.id)
},
+ journeys () {
+ if (Object.keys(this.flat.flatisfy_time_to).length > 0) {
+ const journeys = []
+ for (const place in this.flat.flatisfy_time_to) {
+ this.flat.flatisfy_time_to[place].sections.forEach(
+ section => journeys.push({
+ geojson: section.geojson,
+ options: {
+ color: section.color ? ('#' + section.color) : '#2196f3',
+ dashArray: section.color ? 'none' : '2, 10'
+ }
+ })
+ )
+ }
+ return journeys
+ }
+ return []
+ },
displayedStations () {
if (this.flat.flatisfy_stations.length > 0) {
const stationsNames = this.flat.flatisfy_stations.map(station => station.name)
diff --git a/flatisfy/web/js_src/views/status.vue b/flatisfy/web/js_src/views/status.vue
index 03841e5..f8da751 100644
--- a/flatisfy/web/js_src/views/status.vue
+++ b/flatisfy/web/js_src/views/status.vue
@@ -1,6 +1,18 @@
-
{{ capitalize($t("status." + $route.name)) }}
+
+
+
+
{{ postal_code_data.name }} ({{ postal_code }}) - {{ postal_code_data.flats.length }} {{ $tc("common.flats", 42) }}
@@ -19,6 +31,19 @@ import { capitalize } from '../tools'
import FlatsTable from '../components/flatstable.vue'
export default {
+ data () {
+ return {
+ 'isDropdownVisible': false,
+ 'available_status': [
+ 'new',
+ 'followed',
+ 'ignored',
+ 'duplicate',
+ 'user_deleted'
+ ]
+ }
+ },
+
components: {
FlatsTable
},
@@ -28,14 +53,114 @@ export default {
this.$store.dispatch('getAllFlats')
},
+ mounted () {
+ window.addEventListener('click', event => {
+ if (event.target !== this.$refs.dropdownToggle) {
+ this.isDropdownVisible = false
+ }
+ })
+ },
+
computed: {
postalCodesFlatsBuckets () {
- return this.$store.getters.postalCodesFlatsBuckets(flat => flat.status === this.$route.name)
+ return this.$store.getters.postalCodesFlatsBuckets(flat => flat.status === this.$route.params.status)
}
},
methods: {
+ toggleDropdown () {
+ this.isDropdownVisible = !this.isDropdownVisible
+ },
capitalize: capitalize
}
}
+
+