2018-01-09 17:52:26 +01:00
|
|
|
<template>
|
|
|
|
<v-container>
|
2018-06-06 17:42:53 +02:00
|
|
|
<v-jumbotron
|
2018-07-09 14:19:24 +02:00
|
|
|
:gradient="gradient"
|
|
|
|
src="https://picsum.photos/1200/900"
|
|
|
|
dark
|
|
|
|
v-if="$store.state.user === false"
|
2018-06-06 17:42:53 +02:00
|
|
|
>
|
|
|
|
<v-container fill-height>
|
|
|
|
<v-layout align-center>
|
|
|
|
<v-flex text-xs-center>
|
|
|
|
<h1 class="display-3">Find events you like</h1>
|
|
|
|
<h2>Share it with Eventos</h2>
|
2018-06-27 13:02:00 +02:00
|
|
|
<v-btn :to="{ name: 'Register' }">{{ $t("home.register") }}</v-btn>
|
2018-06-06 17:42:53 +02:00
|
|
|
</v-flex>
|
|
|
|
</v-layout>
|
|
|
|
</v-container>
|
|
|
|
</v-jumbotron>
|
|
|
|
<v-layout>
|
|
|
|
<v-flex xs12 sm8 offset-sm2>
|
2018-07-09 14:19:24 +02:00
|
|
|
<v-layout row wrap>
|
|
|
|
<v-flex xs12 sm6>
|
|
|
|
<h1>Welcome back {{ $store.state.user.actor.username }}</h1>
|
|
|
|
</v-flex>
|
|
|
|
<v-flex xs12 sm6>
|
|
|
|
<v-layout align-center>
|
|
|
|
<span class="events-nearby title">Events nearby </span><v-text-field
|
|
|
|
solo
|
|
|
|
append-icon="place"
|
|
|
|
:value="ipLocation()"
|
|
|
|
></v-text-field>
|
|
|
|
</v-layout>
|
|
|
|
</v-flex>
|
|
|
|
</v-layout>
|
|
|
|
<v-card v-if="events.length > 0">
|
2018-07-04 14:29:17 +02:00
|
|
|
<v-layout row wrap>
|
2018-07-09 14:19:24 +02:00
|
|
|
<v-flex md4 v-for="event in events" :key="event.uuid">
|
2018-07-04 14:29:17 +02:00
|
|
|
<v-card :to="{ name: 'Event', params:{ uuid: event.uuid } }">
|
|
|
|
<v-card-media v-if="!event.image"
|
|
|
|
class="white--text"
|
|
|
|
height="200px"
|
|
|
|
src="https://picsum.photos/g/400/200/"
|
|
|
|
>
|
|
|
|
<v-container fill-height fluid>
|
|
|
|
<v-layout fill-height>
|
|
|
|
<v-flex xs12 align-end flexbox>
|
|
|
|
<span class="headline black--text">{{ event.title }}</span>
|
|
|
|
</v-flex>
|
|
|
|
</v-layout>
|
|
|
|
</v-container>
|
|
|
|
</v-card-media>
|
|
|
|
<v-card-title primary-title>
|
|
|
|
<div>
|
|
|
|
<span class="grey--text">{{ event.begins_on | formatDate }}</span><br>
|
|
|
|
<router-link :to="{name: 'Account', params: { name: event.organizer.username } }">
|
|
|
|
<v-avatar size="25px">
|
|
|
|
<img class="img-circle elevation-7 mb-1"
|
|
|
|
:src="event.organizer.avatar"
|
|
|
|
>
|
|
|
|
</v-avatar>
|
|
|
|
</router-link>
|
2018-07-09 14:19:24 +02:00
|
|
|
<span v-if="event.organizer">Organisé par {{ event.organizer.display_name ? event.organizer.display_name : event.organizer.username }}</span>
|
2018-07-04 14:29:17 +02:00
|
|
|
</div>
|
|
|
|
</v-card-title>
|
|
|
|
</v-card>
|
|
|
|
</v-flex>
|
|
|
|
</v-layout>
|
2018-06-06 17:42:53 +02:00
|
|
|
</v-card>
|
2018-07-09 14:19:24 +02:00
|
|
|
<v-alert v-else :value="true" type="info">
|
|
|
|
No events found nearby {{ ipLocation() }}
|
|
|
|
</v-alert>
|
2018-06-06 17:42:53 +02:00
|
|
|
</v-flex>
|
|
|
|
</v-layout>
|
2018-01-09 17:52:26 +01:00
|
|
|
</v-container>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
|
|
import ngeohash from 'ngeohash';
|
|
|
|
import eventFetch from "../api/eventFetch";
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'Home',
|
|
|
|
data() {
|
|
|
|
return {
|
2018-06-06 17:42:53 +02:00
|
|
|
gradient: 'to top right, rgba(63,81,181, .7), rgba(25,32,72, .7)',
|
2018-01-09 17:52:26 +01:00
|
|
|
user: null,
|
|
|
|
searchTerm: null,
|
|
|
|
location_field: {
|
|
|
|
loading: false,
|
|
|
|
search: null,
|
|
|
|
},
|
|
|
|
locations: [],
|
2018-06-06 17:42:53 +02:00
|
|
|
events: [],
|
2018-07-09 14:19:24 +02:00
|
|
|
city: {name: null},
|
|
|
|
country: {name: null},
|
2018-01-09 17:52:26 +01:00
|
|
|
};
|
|
|
|
},
|
2018-06-06 17:42:53 +02:00
|
|
|
created() {
|
|
|
|
this.fetchData();
|
2018-01-09 17:52:26 +01:00
|
|
|
},
|
2018-01-13 23:33:03 +01:00
|
|
|
computed: {
|
|
|
|
displayed_name: function() {
|
2018-05-19 10:19:21 +02:00
|
|
|
return this.$store.state.user.actor.display_name === null ? this.$store.state.user.actor.username : this.$store.state.user.actor.display_name
|
2018-01-13 23:33:03 +01:00
|
|
|
},
|
|
|
|
},
|
2018-01-09 17:52:26 +01:00
|
|
|
methods: {
|
|
|
|
fetchLocations() {
|
|
|
|
eventFetch('/locations', this.$store)
|
|
|
|
.then((response) => (response.json()))
|
|
|
|
.then((response) => {
|
2018-01-13 23:33:03 +01:00
|
|
|
this.locations = response;
|
2018-01-09 17:52:26 +01:00
|
|
|
});
|
|
|
|
},
|
2018-06-06 17:42:53 +02:00
|
|
|
fetchData() {
|
|
|
|
eventFetch('/events', this.$store)
|
|
|
|
.then(response => response.json())
|
|
|
|
.then((response) => {
|
|
|
|
this.loading = false;
|
|
|
|
this.events = response.data;
|
2018-07-09 14:19:24 +02:00
|
|
|
this.city = response.city;
|
|
|
|
this.country = response.country;
|
2018-06-06 17:42:53 +02:00
|
|
|
});
|
|
|
|
},
|
2018-01-09 17:52:26 +01:00
|
|
|
geoLocalize() {
|
|
|
|
const router = this.$router;
|
|
|
|
if (sessionStorage.getItem('City')) {
|
|
|
|
router.push({name: 'EventList', params: {location: localStorage.getItem('City')}})
|
|
|
|
} else {
|
|
|
|
navigator.geolocation.getCurrentPosition((pos) => {
|
|
|
|
const crd = pos.coords;
|
|
|
|
|
|
|
|
const geohash = ngeohash.encode(crd.latitude, crd.longitude, 11);
|
|
|
|
sessionStorage.setItem('City', geohash);
|
|
|
|
router.push({name: 'EventList', params: {location: geohash}});
|
|
|
|
|
|
|
|
}, (err) => console.warn(`ERROR(${err.code}): ${err.message}`), {
|
|
|
|
enableHighAccuracy: true,
|
|
|
|
timeout: 5000,
|
|
|
|
maximumAge: 0
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
getAddressData: function (addressData) {
|
|
|
|
const geohash = ngeohash.encode(addressData.latitude, addressData.longitude, 11);
|
|
|
|
sessionStorage.setItem('City', geohash);
|
|
|
|
this.$router.push({name: 'EventList', params: {location: geohash}});
|
|
|
|
},
|
2018-06-06 17:42:53 +02:00
|
|
|
viewEvent(event) {
|
|
|
|
this.$router.push({ name: 'Event', params: { uuid: event.uuid } })
|
|
|
|
},
|
2018-07-09 14:19:24 +02:00
|
|
|
ipLocation() {
|
|
|
|
return this.city.name ? this.city.name : this.country.name;
|
|
|
|
}
|
2018-01-09 17:52:26 +01:00
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
|
|
|
<style scoped>
|
|
|
|
.search-autocomplete {
|
|
|
|
border: 1px solid #dbdbdb;
|
|
|
|
color: rgba(0,0,0,.87);
|
|
|
|
}
|
2018-07-09 14:19:24 +02:00
|
|
|
|
|
|
|
.events-nearby {
|
|
|
|
margin-bottom: 25px;
|
|
|
|
}
|
2018-01-09 17:52:26 +01:00
|
|
|
</style>
|