2018-01-09 17:52:26 +01:00
|
|
|
<template>
|
|
|
|
<v-container>
|
|
|
|
<v-layout row>
|
|
|
|
<v-flex xs12 sm6 offset-sm3>
|
2018-01-16 19:45:09 +01:00
|
|
|
<span v-if="error">Error : event not found</span>
|
2018-01-09 17:52:26 +01:00
|
|
|
<v-progress-circular v-if="loading" indeterminate color="primary"></v-progress-circular>
|
2018-01-16 19:45:09 +01:00
|
|
|
<v-card v-if="!loading && !error">
|
2018-01-09 17:52:26 +01:00
|
|
|
<v-layout column class="media">
|
|
|
|
<v-card-title>
|
|
|
|
<v-btn icon @click="$router.go(-1)">
|
|
|
|
<v-icon>chevron_left</v-icon>
|
|
|
|
</v-btn>
|
|
|
|
<v-spacer></v-spacer>
|
2018-05-19 10:19:21 +02:00
|
|
|
<v-btn icon class="mr-3" v-if="event.organizer.id === $store.state.user.actor.id" :to="{ name: 'EditEvent', params: {id: event.id}}">
|
2018-01-09 17:52:26 +01:00
|
|
|
<v-icon>edit</v-icon>
|
|
|
|
</v-btn>
|
|
|
|
<v-menu bottom left>
|
|
|
|
<v-btn icon slot="activator">
|
|
|
|
<v-icon>more_vert</v-icon>
|
|
|
|
</v-btn>
|
|
|
|
<v-list>
|
|
|
|
<v-list-tile @click="downloadIcsEvent()">
|
|
|
|
<v-list-tile-title>Download</v-list-tile-title>
|
|
|
|
</v-list-tile>
|
2018-05-19 10:19:21 +02:00
|
|
|
<v-list-tile @click="deleteEvent()" v-if="$store.state.user.actor.id === event.organizer.id">
|
2018-01-09 17:52:26 +01:00
|
|
|
<v-list-tile-title>Delete</v-list-tile-title>
|
|
|
|
</v-list-tile>
|
|
|
|
</v-list>
|
|
|
|
</v-menu>
|
|
|
|
</v-card-title>
|
2018-06-06 17:42:53 +02:00
|
|
|
<v-container grid-list-md text-xs-center>
|
|
|
|
<v-card-media
|
|
|
|
src="https://picsum.photos/600/400/"
|
|
|
|
height="200px"
|
|
|
|
>
|
|
|
|
|
|
|
|
</v-card-media>
|
|
|
|
<v-layout row wrap>
|
|
|
|
<v-flex xs6>
|
2018-01-09 17:52:26 +01:00
|
|
|
<v-spacer></v-spacer>
|
2018-06-06 17:42:53 +02:00
|
|
|
<span class="subheading grey--text">{{ event.begins_on | formatDay }}</span>
|
|
|
|
<h1 class="display-2">{{ event.title }}</h1>
|
|
|
|
<div>
|
|
|
|
<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-04 14:29:17 +02:00
|
|
|
<span v-if="event.organizer">Organisé par {{ event.organizer.display_name ? event.organizer.display_name : event.organizer.username }}</span>
|
2018-06-06 17:42:53 +02:00
|
|
|
</div>
|
|
|
|
<p>
|
2018-07-04 14:29:17 +02:00
|
|
|
<vue-markdown :source="event.description" v-if="event.description" />
|
2018-06-06 17:42:53 +02:00
|
|
|
</p>
|
2018-01-16 19:45:09 +01:00
|
|
|
<!--<p><router-link :to="{ name: 'Account', params: {id: event.organizer.id} }"><span class="grey--text">{{ event.organizer.username }}</span></router-link> organises {{ event.title }} <span v-if="event.address.addressLocality">in {{ event.address.addressLocality }}</span> on the {{ event.startDate | formatDate }}.</p>
|
|
|
|
<v-card-text v-if="event.description"><vue-markdown :source="event.description"></vue-markdown></v-card-text>-->
|
2018-06-06 17:42:53 +02:00
|
|
|
</v-flex>
|
|
|
|
<v-flex xs6>
|
|
|
|
<v-card-actions>
|
|
|
|
<v-btn color="success" v-if="!event.participants.map(participant => participant.id).includes($store.state.user.actor.id)" @click="joinEvent" class="btn btn-primary"><v-icon>check</v-icon> Join</v-btn>
|
|
|
|
<v-btn v-if="event.participants.map(participant => participant.id).includes($store.state.user.actor.id)" @click="leaveEvent" class="btn btn-primary">Leave</v-btn>
|
|
|
|
</v-card-actions>
|
|
|
|
</v-flex>
|
|
|
|
</v-layout>
|
|
|
|
</v-container>
|
2018-01-16 19:45:09 +01:00
|
|
|
<v-container fluid grid-list-md>
|
2018-01-09 17:52:26 +01:00
|
|
|
<v-subheader>Membres</v-subheader>
|
|
|
|
<v-layout row>
|
2018-06-06 17:42:53 +02:00
|
|
|
<v-flex xs2 v-for="actor in event.participants" :key="actor.uuid">
|
|
|
|
<router-link :to="{name: 'Account', params: { name: actor.username }}">
|
2018-01-09 17:52:26 +01:00
|
|
|
<v-avatar size="75px">
|
2018-06-06 17:42:53 +02:00
|
|
|
<img v-if="!actor.avatar"
|
2018-01-09 17:52:26 +01:00
|
|
|
class="img-circle elevation-7 mb-1"
|
2018-06-06 17:42:53 +02:00
|
|
|
src="https://picsum.photos/125/125/"
|
2018-01-09 17:52:26 +01:00
|
|
|
>
|
|
|
|
<img v-else
|
|
|
|
class="img-circle elevation-7 mb-1"
|
2018-06-06 17:42:53 +02:00
|
|
|
:src="actor.avatar"
|
2018-01-09 17:52:26 +01:00
|
|
|
>
|
|
|
|
</v-avatar>
|
|
|
|
</router-link>
|
2018-05-19 10:19:21 +02:00
|
|
|
<span>{{ actor.username }}</span>
|
2018-01-09 17:52:26 +01:00
|
|
|
</v-flex>
|
2018-06-06 17:42:53 +02:00
|
|
|
<span v-if="event.participants.length === 0">No participants yet.</span>
|
2018-01-09 17:52:26 +01:00
|
|
|
</v-layout>
|
|
|
|
</v-container>
|
|
|
|
</v-layout>
|
|
|
|
</v-card>
|
|
|
|
</v-flex>
|
|
|
|
</v-layout>
|
|
|
|
</v-container>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import eventFetch from '@/api/eventFetch';
|
|
|
|
import VueMarkdown from 'vue-markdown';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'Home',
|
|
|
|
components: {
|
|
|
|
VueMarkdown,
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
loading: true,
|
2018-01-16 19:45:09 +01:00
|
|
|
error: false,
|
2018-01-09 17:52:26 +01:00
|
|
|
event: {
|
2018-06-06 17:42:53 +02:00
|
|
|
name: '',
|
|
|
|
slug: '',
|
2018-01-09 17:52:26 +01:00
|
|
|
title: '',
|
2018-06-06 17:42:53 +02:00
|
|
|
uuid: this.uuid,
|
2018-01-09 17:52:26 +01:00
|
|
|
description: '',
|
|
|
|
organizer: {
|
|
|
|
id: null,
|
|
|
|
username: null,
|
|
|
|
},
|
|
|
|
participants: [],
|
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
deleteEvent() {
|
|
|
|
const router = this.$router;
|
2018-06-06 17:42:53 +02:00
|
|
|
eventFetch(`/events/${this.uuid}`, this.$store, { method: 'DELETE' })
|
2018-01-09 17:52:26 +01:00
|
|
|
.then(() => router.push({'name': 'EventList'}));
|
|
|
|
},
|
|
|
|
fetchData() {
|
2018-06-06 17:42:53 +02:00
|
|
|
eventFetch(`/events/${this.uuid}`, this.$store)
|
2018-01-09 17:52:26 +01:00
|
|
|
.then(response => response.json())
|
|
|
|
.then((data) => {
|
|
|
|
this.loading = false;
|
2018-01-16 19:45:09 +01:00
|
|
|
this.event = data.data;
|
|
|
|
}).catch((res) => {
|
|
|
|
Promise.resolve(res).then((data) => {
|
|
|
|
console.log(data);
|
|
|
|
this.error = true;
|
|
|
|
this.loading = false;
|
|
|
|
})
|
|
|
|
});
|
2018-01-09 17:52:26 +01:00
|
|
|
},
|
|
|
|
joinEvent() {
|
2018-06-06 17:42:53 +02:00
|
|
|
eventFetch(`/events/${this.uuid}/join`, this.$store)
|
2018-01-09 17:52:26 +01:00
|
|
|
.then(response => response.json())
|
|
|
|
.then((data) => {
|
|
|
|
console.log(data);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
leaveEvent() {
|
2018-06-06 17:42:53 +02:00
|
|
|
eventFetch(`/events/${this.uuid}/leave`, this.$store)
|
2018-01-09 17:52:26 +01:00
|
|
|
.then(response => response.json())
|
|
|
|
.then((data) => {
|
|
|
|
console.log(data);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
downloadIcsEvent() {
|
2018-06-06 17:42:53 +02:00
|
|
|
eventFetch(`/events/${this.uuid}/ics`, this.$store, {responseType: 'arraybuffer'})
|
2018-01-09 17:52:26 +01:00
|
|
|
.then((response) => response.text())
|
|
|
|
.then(response => {
|
|
|
|
const blob = new Blob([response],{type: 'text/calendar'});
|
|
|
|
const link = document.createElement('a');
|
|
|
|
link.href = window.URL.createObjectURL(blob);
|
|
|
|
link.download = `${this.event.title}.ics`;
|
|
|
|
document.body.appendChild(link);
|
|
|
|
link.click();
|
|
|
|
document.body.removeChild(link);
|
|
|
|
})
|
|
|
|
},
|
|
|
|
},
|
2018-05-19 10:19:21 +02:00
|
|
|
props: {
|
2018-06-06 17:42:53 +02:00
|
|
|
uuid: {
|
2018-05-19 10:19:21 +02:00
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
2018-01-09 17:52:26 +01:00
|
|
|
created() {
|
|
|
|
this.fetchData();
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
|
|
|
<style scoped>
|
|
|
|
|
|
|
|
</style>
|