-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introducing layerinfo and placeinfo with router setup
- Loading branch information
Showing
5 changed files
with
233 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<template> | ||
<div class="overlay" v-if="layerData"> | ||
<h2>{{ layerData.layer.title }}</h2> | ||
<p>ID: {{ layerData.layer.id }}</p> | ||
<div v-if="layerData.layer.text">{{ layerData.layer.text }}</div> | ||
|
||
<figcaption v-if="layerData.layer.image_link"> | ||
<img :src="layerData.layer.image_link" alt="layerData.layer.title"> | ||
</figcaption> | ||
|
||
|
||
|
||
|
||
|
||
<h4>Places in this layer:</h4> | ||
<ul> | ||
<li v-for="place in layerData.layer.places" :key="place.id"> | ||
<router-link :to="{ name: 'placeInfo', params: { layerId, placeId: place.id } }"> | ||
{{ place.title }} | ||
</router-link> | ||
</li> | ||
</ul> | ||
<button @click="closeOverlay">Close</button> | ||
</div> | ||
<div v-else class="overlay"><p>Loading...</p></div> | ||
</template> | ||
|
||
<script> | ||
import { ref, onMounted } from 'vue'; | ||
import { useRouter } from 'vue-router'; | ||
export default { | ||
props: { | ||
layerId: { | ||
type: String, | ||
required: true | ||
} | ||
}, | ||
setup(props) { | ||
const router = useRouter(); | ||
const layerData = ref(null); | ||
const fetchLayerData = async (id) => { | ||
try { | ||
// Replace with your actual API call | ||
const response = await fetch(`https://orte-backend.a-thousand-channels.xyz/public/maps/histoprojekt-hamburg/layers/${id}`); | ||
const data = await response.json(); | ||
layerData.value = data; | ||
} catch (error) { | ||
console.error('Error fetching layer data:', error); | ||
} | ||
}; | ||
onMounted(() => { | ||
fetchLayerData(props.layerId); | ||
}); | ||
const closeOverlay = () => { | ||
router.push({ name: 'home' }); | ||
}; | ||
return { layerData, closeOverlay }; | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
.overlay { | ||
position: fixed; | ||
overflow: scroll; | ||
top: 5vh; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
background-color: rgba(0, 0, 0, 0.8); | ||
color: white; | ||
padding: 48px 18px; | ||
} | ||
.overlay img { | ||
width: 100%; | ||
max-width: 300px; | ||
height: auto; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
|
||
|
||
<template> | ||
<div class="overlay" v-if="placeData"> | ||
<h2>{{ placeData.name }}</h2> | ||
<p>Place ID: {{ placeData.id }}</p> | ||
<p>Layer ID: {{ layerId }}</p> | ||
<p>Subtitle: {{ place.subtitle }}</p> | ||
<p>Teaser: {{ place.teaser }}</p> | ||
<p>Description: {{ place.text }}</p> | ||
<p>Source: {{ place.source }}</p> | ||
<button @click="closeOverlay">Close</button> | ||
</div> | ||
<div v-else class="overlay"><p>... (Infos zu einem einzelnen Orte können derzeit noch nicht angezeigt werden.)</p><button @click="closeOverlay">Close</button></div> | ||
</template> | ||
|
||
<script> | ||
import { ref, onMounted } from 'vue'; | ||
import { useRouter } from 'vue-router'; | ||
export default { | ||
props: { | ||
layerId: { | ||
type: String, | ||
required: true | ||
}, | ||
placeId: { | ||
type: String, | ||
required: true | ||
} | ||
}, | ||
setup(props) { | ||
const router = useRouter(); | ||
const placeData = ref(null); | ||
const fetchPlaceData = async (layerId, placeId) => { | ||
try { | ||
// Replace with your actual API call | ||
const response = await fetch(`https://api.example.com/layer/${layerId}/place/${placeId}`); | ||
const data = await response.json(); | ||
placeData.value = data; | ||
} catch (error) { | ||
console.error('Error fetching place data:', error); | ||
} | ||
}; | ||
onMounted(() => { | ||
fetchPlaceData(props.layerId, props.placeId); | ||
}); | ||
const closeOverlay = () => { | ||
router.push({ name: 'home' }); | ||
}; | ||
return { placeData, closeOverlay }; | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
.overlay { | ||
position: fixed; | ||
overflow: scroll; | ||
top: 5vh; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
background-color: rgba(0, 0, 0, 0.8); | ||
color: white; | ||
padding: 48px 18px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters