Skip to content
Snippets Groups Projects
Commit 994f5585 authored by Timothee P's avatar Timothee P :sunflower:
Browse files

display attachments in feature_detail

parent 5f7b96c3
No related branches found
No related tags found
No related merge requests found
import axios from 'axios';
import store from '../store'
const baseUrl = store.state.configuration.VUE_APP_DJANGO_API_BASE;
const featureAPI = {
async getFeatureAttachments(featureId) {
const response = await axios.get(
`${baseUrl}features/${featureId}/attachments/`
);
if (
response.status === 200 &&
response.data
) {
return response.data;
} else {
return null;
}
},
/* async subscribeProject({ projectSlug, suscribe }) {
const response = await axios.put(
`${baseUrl}projects/${projectSlug}/subscription/`,
{ is_suscriber: suscribe }
);
if (
response.status === 200 &&
response.data
) {
return response.data;
} else {
return null;
}
}, */
}
export default featureAPI;
......@@ -183,18 +183,15 @@
target="_blank"
:href="pj.attachment_file.url"
>
<img
v-if="pj.extension === '.pdf'"
src="{% static 'geocontrib/img/pdf.png' %}"
/>
<!-- // ? que faire ? -->
<img v-else :src="pj.attachment_file.url" />
<!-- // ? que faire avec un pdf ? -->
<img v-if="pj.extension === '.pdf'" src="@/assets/img/pdf.png" />
<img v-else :src="DJANGO_BASE_URL + pj.attachment_file" />
</a>
<div class="middle aligned content">
<a
class="header"
target="_blank"
:href="pj.attachment_file.url"
:href="DJANGO_BASE_URL + pj.attachment_file.url"
>{{ pj.title }}</a
>
<div class="description">
......@@ -382,6 +379,7 @@
import frag from "vue-frag";
import { mapState } from "vuex";
import { mapUtil } from "@/assets/js/map-util.js";
import featureAPI from "@/services/feature-api";
const axios = require("axios");
export default {
......@@ -407,18 +405,8 @@ export default {
},
}, */
],
attachments: [
// TODO : Récupérer depuis l'api
/* {
attachment_file: {
url: "http://localhost:8000/media/user_1/albinoscom.jpg",
},
extension: "jpg",
title: "albinos",
info: "Drôle de bête",
}, */
],
// TODO : Récupérer depuis l'api
attachments: [],
// TODO : Récupérer events depuis l'api
events: [],
comment_form: {
attachment_file: {
......@@ -444,6 +432,9 @@ export default {
computed: {
...mapState(["user"]),
DJANGO_BASE_URL: function () {
return this.$store.state.configuration.VUE_APP_DJANGO_BASE;
},
feature: function () {
return (
this.$store.state.feature.features.find(
......@@ -564,6 +555,9 @@ export default {
"feature_type/SET_CURRENT_FEATURE_TYPE_SLUG",
this.$route.params.slug_type_signal
);
featureAPI
.getFeatureAttachments(this.$route.params.slug_signal)
.then((data) => (this.attachments = data));
},
mounted() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment