Commit a05dfbe1 authored by quentin.vrel's avatar quentin.vrel

Profile view without edition

parent 038937ad
<template> <template>
<div class="profile"> <div class="profile">
<page-title pagetitle="Profil"/> <page-title pagetitle="Profil"/>
<div class="avatar-area" > <div class="profile-top-area" >
<avatar size=250 :avatar="this.profile.avatar" :username="this.profile.login"/> <avatar size=250 :pathToImage="this.profile.avatar" :username="this.profile.login"/>
<svg-button v-if="editable" id="edit-avatar-button" svg="icons/edit.svg"/> <div>
</div> <p class="profile-login">{{profile.login}}</p>
<div class="login-area"> <p class="profile-mail">{{profile.mail}}</p>
<p>{{profile.login}}</p> </div>
<svg-button v-if="editable" id="edit-login-button" svg="icons/edit.svg"/>
</div>
<div class="mail-area">
<p>{{profile.mail}}</p>
<svg-button v-if="editable" id="edit-mail-button" svg="icons/edit.svg"/>
</div> </div>
<div class="firstname-area"> <div class="profile-bottom-area">
<p class="label">Prénom</p> <div class="profile-name">
<p>{{profile.firstname}}</p> <p class="profile-label">Prénom</p>
<svg-button v-if="editable" id="edit-firstname-button" svg="icons/edit.svg"/> <p>{{profile.firstname}}</p>
</div>
<div class="profile-name">
<p class="profile-label">Nom</p>
<p>{{profile.lastname}}</p>
</div>
</div> </div>
<div class="lastname-area">
<p class="label">Nom</p>
<p>{{profile.lastname}}</p>
<svg-button v-if="editable" id="edit-lastname-button" svg="icons/edit.svg"/>
</div>
<form class="password-area" v-if="editable"> <form action="/">
<pwd-input id="password1" label="Nouveau mot de passe"/>
<pwd-input id="password2" label="Confirmer"/>
<div class="submit-buttons"> <div class="submit-buttons">
<svg-button id="validate" svg="/icons/validate.svg"/>
<svg-button id="back" svg="/icons/back.svg"/> <svg-button id="back" svg="/icons/back.svg"/>
</div> </div>
</form> </form>
...@@ -45,7 +39,6 @@ import Avatar from '../components/Avatar.vue'; ...@@ -45,7 +39,6 @@ import Avatar from '../components/Avatar.vue';
import PageTitle from '../components/PageTitle.vue'; import PageTitle from '../components/PageTitle.vue';
import SvgButton from '../components/SvgButton.vue'; import SvgButton from '../components/SvgButton.vue';
import User from '@/model/user.js' import User from '@/model/user.js'
import PwdInput from '../components/form/PwdInput.vue';
// @ is an alias to /src // @ is an alias to /src
...@@ -57,8 +50,7 @@ export default { ...@@ -57,8 +50,7 @@ export default {
components: { components: {
PageTitle, PageTitle,
Avatar, Avatar,
SvgButton, SvgButton
PwdInput
}, },
methods: { methods: {
getUserInfo: async function(){ getUserInfo: async function(){
...@@ -69,26 +61,42 @@ export default { ...@@ -69,26 +61,42 @@ export default {
this.token = token; this.token = token;
}, },
getProfileInfo: async function (){ getProfileInfo: async function (){
const head = new Headers(); fetch(this.$apiRoot+'/user/'+this.$route.params.id, {method: 'GET'})
head.append('Authorization', this.token); .then(response => response.json())
await fetch(this.$apiRoot+'/user/'+this.$route.params.id, {method: 'GET'}) .then(user => {
.then(res => res.json()) let userJson = user[0];
.then(json => {
let userJson = json[0];
let userObj = new User(userJson.ID_USER, userJson.ID_ROLE, userJson.LOGIN, userJson.AVATAR, userJson.LASTNAME, userJson.FIRSTNAME, userJson.MAIL); let userObj = new User(userJson.ID_USER, userJson.ID_ROLE, userJson.LOGIN, userJson.AVATAR, userJson.LASTNAME, userJson.FIRSTNAME, userJson.MAIL);
this.profile=userObj; console.log(userObj);
console.log(this.profile);
}).catch( (err) => console.log(err)); let props = Object.getOwnPropertyNames(userObj);
let areIdentical = true;
for (let i = 0; i < props.length; i++) {
let propName = props[i];
// If values of same property are not equal,
// objects are not equivalent
if (userObj[propName] !== this.profile[propName]) {
areIdentical = false;
}
}
if(areIdentical){
return;
}
else{
console.log("svp")
this.profile=userObj
}
})
} }
}, },
computed :{ computed :{
editable () {
return this.user.id_user == this.$route.params.id || this.user.id_role == 2
}
}, },
data () { data () {
return { return {
dataLoaded: false,
user: new User(0, 0, '', '', '', '', ''), user: new User(0, 0, '', '', '', '', ''),
token: '', token: '',
profile: new User(0, 0, '', '', '', '', ''), profile: new User(0, 0, '', '', '', '', ''),
...@@ -100,12 +108,67 @@ export default { ...@@ -100,12 +108,67 @@ export default {
this.getProfileInfo(); this.getProfileInfo();
}, },
beforeUpdate() { updated() {
console.log("aidez moi")
this.getProfileInfo(); this.getProfileInfo();
} }
} }
</script> </script>
<style> <style>
.profile *{
//background: rgba(255, 255, 255, 0.1);
justify-content: center;
}
.profile{
color: white;
width: 80%;
margin: 100px auto;
}
.profile-top-area, .bottom-area{
display: flex;
text-align: left;
}
.profile-top-area .profile-login{
font-family: Shojumaru;
font-style: normal;
font-weight: normal;
font-size: 96px;
line-height: 127px;
margin: 0 40px
}
.profile-top-area .profile-mail{
font-style: normal;
font-weight: normal;
font-size: 36px;
line-height: 127px;
margin: 0 40px
}
.profile-bottom-area{
display: flex;
justify-content: center;
margin: 60px 100px 0 100px
}
.profile-bottom-area .profile-label{
color: black;
font-weight: bold;
}
.profile-name{
width: 100%;
display: flex;
font-size: 36px;
justify-content: space-around;
text-align: right;
}
</style> </style>
Markdown is supported
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