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

update thumbnails src format and add user_permissions fetch

parent aa36b8d8
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,7 @@ store.dispatch("GET_ALL_PROJECTS"),
store.dispatch("GET_STATIC_PAGES"),
store.dispatch("GET_USER_LEVEL_PROJECTS"),
store.dispatch("map/GET_LAYERS"),
store.dispatch("GET_USER_LEVEL_PERMISSIONS"),
]).then(axios.spread(function () {
new Vue({
router,
......
......@@ -38,7 +38,8 @@ export default new Vuex.Store({
last_comments: [],
staticPages: null,
SSO_SETTED: false,
USER_LEVEL_PROJECTS: null
USER_LEVEL_PROJECTS: null,
user_permissions: null,
},
mutations: {
......@@ -75,6 +76,9 @@ export default new Vuex.Store({
SET_PROJECT_COMMENTS(state, last_comments) {
state.last_comments = last_comments
},
SET_USER_PERMISSIONS(state, userPermissions) {
state.user_permissions = userPermissions
},
},
getters: {
......@@ -139,18 +143,18 @@ export default new Vuex.Store({
if (response && response.status === 200) {
const user = response.data.user;
commit("SET_USER", user);
window.localStorage.setItem("user", JSON.stringify(user));
window.localStorage.setItem("user", JSON.stringify(user)); //? toujours nécessaire ?
}
}) // todo: ajouter au localestorage
})
.catch(() => {
router.push({ name: "login" });
});
},
LOGOUT({ commit }) { // ? logout bien dans django ?
LOGOUT({ commit }) { // ? logout se fait bien dans django ?
axios
.get(`${DJANGO_API_BASE}logout/`)
.then((response) => { // todo: check status
.then((response) => {
if (response && response.status === 200) {
commit("SET_USER", false); // ? better false or null
commit("SET_USER_LEVEL_PROJECTS", null);
......@@ -175,6 +179,19 @@ export default new Vuex.Store({
});
},
GET_USER_LEVEL_PERMISSIONS({ commit }) {
axios
.get(`${DJANGO_API_BASE}user-permissions/`)
.then((response) => {
if (response && response.status === 200) {
commit("SET_USER_PERMISSIONS", response.data)
}
})
.catch((error) => {
throw error;
});
},
GET_PROJECT_INFO({ commit, dispatch }, slug) {
commit("SET_PROJECT_SLUG", slug);
dispatch("GET_PROJECT_LAST_MESSAGES", slug);
......
......@@ -19,7 +19,7 @@
<div class="item">
<div class="right floated content">
<div class="description">
{{ user.get_full_name }}
{{ userFullname }}
</div>
</div>
<div class="content">Nom complet</div>
......@@ -56,7 +56,7 @@
:src="
project.thumbnail.includes('default')
? require('@/assets/img/default.png')
: project.thumbnail
: DJANGO_BASE_URL + project.thumbnail + refreshId()
"
height="200"
/>
......@@ -288,6 +288,18 @@ export default {
computed: {
// todo : filter projects to user
...mapState(["user", "projects", "USER_LEVEL_PROJECTS"]),
DJANGO_BASE_URL: () => process.env.VUE_APP_DJANGO_BASE,
userFullname: function () {
if (this.user.first_name || this.user.last_name)
return this.user.first_name + " " + this.user.last_name;
return null;
},
},
methods: {
refreshId() {
return "?ver=" + Math.random();
},
},
};
</script>
\ No newline at end of file
......@@ -7,7 +7,13 @@
<div class="ui divided items">
<div v-for="project in project_types" :key="project.slug" class="item">
<div class="ui tiny image">
<img :src="project.thumbnail" />
<img
:src="
project.thumbnail.includes('default')
? require('@/assets/img/default.png')
: DJANGO_BASE_URL + project.thumbnail + refreshId()
"
/>
</div>
<div class="middle aligned content">
<div class="description">
......@@ -67,6 +73,13 @@ export default {
computed: {
...mapGetters(["project_types"]),
DJANGO_BASE_URL: () => process.env.VUE_APP_DJANGO_BASE,
},
methods: {
refreshId() {
return "?ver=" + Math.random();
},
},
};
</script>
\ No newline at end of file
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