Commit 0568c0b9 authored by Jonatan Zint's avatar Jonatan Zint
Browse files

adjust for new schedule json format

parent d4ae95a5
Pipeline #11023 passed with stages
in 45 seconds
......@@ -10,6 +10,7 @@
"@quasar/extras": "^1.13.6",
"axios": "^0.18.0",
"jquery": "^3.4.1",
"lodash-es": "^4.17.21",
"moment": "^2.24.0",
"pinch-zoom-js": "^2.3.4",
"quasar": "^1.18.10",
......@@ -12389,6 +12390,11 @@
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
"dev": true
},
"node_modules/lodash-es": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.21.tgz",
"integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw=="
},
"node_modules/lodash._reinterpolate": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz",
......@@ -31709,6 +31715,11 @@
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
"dev": true
},
"lodash-es": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.21.tgz",
"integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw=="
},
"lodash._reinterpolate": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz",
......@@ -74,9 +74,9 @@ module.exports = function(ctx) {
env: {
PRETALX_URL: "https://pretalx.hedonist-international.org/",
SCHEDULE_URL:
"https://pretalx.hedonist-international.org/worldcongress-2022/schedule/export/schedule.json",
"http://localhost:8000/democon/schedule/export/schedule.json",
SPEAKERS_URL:
"https://pretalx.hedonist-international.org/api/events/worldcongress-2022/speakers/"
"http://localhost:8000/api/events/democon/speakers/?limit=1000"
}
},
......
<template lang="pug">
#q-app
q-pull-to-refresh(@refresh="sync")
router-view
router-view(v-if="ready")
</template>
<script>
import { SYNC_RESOURCES } from "./store/types";
import { READY, SYNC_RESOURCES } from './store/types'
export default {
name: "App",
......@@ -19,6 +18,11 @@ export default {
console.warn("Failed to refresh resources");
}
},
computed: {
ready() {
return this.$store.getters[READY];
}
},
methods: {
async sync(done) {
try {
......
......@@ -11,7 +11,7 @@
h5 Speakers
ul
li.speaker-event(v-for="speaker in speakers")
router-link(:to="{name: 'speaker', params: {id: speaker.id}}") {{ speaker.full_public_name }}
router-link(:to="{name: 'speaker', params: {id: speaker.id}}") {{ speaker.public_name }}
</template>
<style lang="stylus" scoped>
......@@ -30,25 +30,19 @@
<script>
import moment from "moment";
import urljoin from "urljoin";
import { GET_SPEAKER, GET_EVENT } from "../store/types";
import { GET_EVENT } from "../store/types";
export default {
name: "EventPage",
data() {
return {
event: this.$store.getters[GET_EVENT](this.$route.params.id)
};
},
computed: {
date() {
return moment(this.event.date).format("DD.MM.YYYY HH:mm");
},
event() {
return this.$store.getters[GET_EVENT](parseInt(this.$route.params.id))
},
speakers() {
const speakers = [];
for (let speaker of this.event.persons) {
speakers.push(this.$store.getters[GET_SPEAKER](speaker.id));
}
return speakers;
return this.event.persons
}
},
methods: {
......
<template lang="pug">
.speaker
h4.headline Speaker: {{ speaker.full_public_name }}
h4.headline Speaker: {{ speaker.public_name }}
.image
img.responsive(:src="frabLink(speaker.image)", v-if="speaker.image")
img.responsive(:src="speaker.avatar", v-if="speaker.avatar")
.details
p {{ speaker.abstract }}
.events(v-if="speaker.events.length > 0")
p {{ speaker.biography }}
.events(v-if="events.length > 0")
h5 Events
ul
li.speaker-event(v-for="event in speaker.events")
li.speaker-event(v-for="event in events")
router-link(:to="{ name: 'event', params: { id: event.id }}") {{ event.title }}
</template>
......@@ -26,13 +26,19 @@
<script>
import moment from "moment";
import urljoin from "urljoin";
import { GET_SPEAKER } from "../store/types";
import { GET_SPEAKER, LIST_EVENTS } from "../store/types";
export default {
name: "SpeakerDetailPage",
computed: {
speaker() {
return this.$store.getters[GET_SPEAKER](parseInt(this.$route.params.id));
},
events() {
const events = this.$store.getters[LIST_EVENTS];
return events.filter(({ persons }) => {
return persons.map(person => person.id).includes(this.speaker.id);
});
}
},
methods: {
......
......@@ -32,6 +32,10 @@ export default class Schedule {
return this.getAllEvents().find(({ id }) => findId === id);
}
getEventByIds(findIds) {
return this.getAllEvents().find(({ id }) => findIds.includes(id));
}
getAllRooms() {
let roomsObj = {};
this.conference.days.map(({ rooms }) => {
......
export default class Speakers {
constructor(speakerData) {
this.speakers = speakerData.schedule_speakers.speakers;
this.speakers = speakerData;
}
getAllSpeakers() {
......
import Schedule from "../../serivces/Schedule";
import Speakers from "../../serivces/Speakers";
import axios from "axios";
import { uniqBy } from "lodash-es";
import {
INITIALIZE_SPEAKERS,
......@@ -18,9 +19,9 @@ import {
START_DATE,
TIMESLOT_WIDTH,
FETCH_SCHEDULE,
FETCH_SPEAKERS,
READY,
SYNC_RESOURCES
SYNC_RESOURCES,
GET_EVENTS
} from "../types";
export default {
......@@ -62,7 +63,13 @@ export default {
[GET_EVENT](state) {
return findId => {
return state.schedule.getEventById(parseInt(findId));
return state.schedule.getEventById(findId);
};
},
[GET_EVENTS](state) {
return findIds => {
return state.schedule.getEventByIds(findIds);
};
},
......@@ -104,49 +111,45 @@ export default {
[INITIALIZE_SCHEDULES](state, scheduleData) {
state.schedule = new Schedule(scheduleData);
},
[INITIALIZE_SPEAKERS](state, speakerData) {
state.speakers = new Speakers(speakerData);
[INITIALIZE_SPEAKERS](state, scheduleData) {
const extractedSpeakers = uniqBy(
scheduleData.conference.days
.map(({ rooms }) => Object.values(rooms))
.flat()
.flat()
.map(({ persons }) => persons)
.flat(),
"id"
);
state.speakers = new Speakers(extractedSpeakers);
}
},
actions: {
async [SYNC_RESOURCES]({ commit, dispatch, state }) {
if (state.scheduleData != null && state.speakerData != null) {
async [SYNC_RESOURCES]({ commit, dispatch, state }, force = false) {
if ((state.scheduleData != null && state.speakerData != null) || force) {
// use cached version
commit(INITIALIZE_SCHEDULES, state.scheduleData);
commit(INITIALIZE_SPEAKERS, state.speakerData);
commit(READY, true);
} else {
await Promise.all([dispatch(FETCH_SCHEDULE)]);
commit(READY, true);
}
await Promise.all([dispatch(FETCH_SCHEDULE), dispatch(FETCH_SPEAKERS)]);
commit(READY, true);
},
async [FETCH_SCHEDULE]({ state, commit }) {
let response;
try {
response = await axios.get(process.env.SCHEDULE_FAR);
response = await axios.get(process.env.SCHEDULE_URL);
} catch (e) {
console.error("Could not reach far schedule");
console.error("Could not reach schedule");
console.error(e);
throw new Error("Failed to fetch schedule");
}
state.scheduleDate = new Date();
state.scheduleData = response.data.schedule;
commit(INITIALIZE_SCHEDULES, response.data.schedule);
},
async [FETCH_SPEAKERS]({ state, commit }) {
let response;
try {
response = await axios.get(process.env.SPEAKERS_FAR);
} catch (e) {
console.error("Could not reach far speakers");
console.error(e);
throw new Error("Failed to fetch speakers");
}
state.speakersDate = new Date();
state.speakerData = response.data;
commit(INITIALIZE_SPEAKERS, response.data);
commit(INITIALIZE_SPEAKERS, response.data.schedule);
}
}
};
export const INITIALIZE_SPEAKERS = "INITIALIZE_SPEAKERS";
export const INITIALIZE_SCHEDULES = "INITIALIZE_SCHEDULES";
export const FETCH_SCHEDULE = "FETCH_SCHEDULE";
export const FETCH_SPEAKERS = "FETCH_SPEAKERS";
export const TIMESLOT_WIDTH = "TIMESLOT_WIDTH";
export const START_DATE = "START_DATE";
export const END_DATE = "END_DATE";
......@@ -16,3 +15,4 @@ export const LIST_SPEAKERS = "LIST_SPEAKERS";
export const GET_SPEAKER = "GET_SPEAKER";
export const READY = "READY";
export const SYNC_RESOURCES = "SYNC_RESOURCES";
export const GET_EVENTS = "GET_EVENTS";
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment