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