Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IDATT2106 Scrum Team 02
Frontend
Commits
e2968efc
Commit
e2968efc
authored
2 years ago
by
Ingrid Martinsheimen Egge
Browse files
Options
Downloads
Plain Diff
Merge branch 'profilbilde' into 'main'
Profilbilde See merge request
!25
parents
808577b9
55b7ccc8
No related branches found
Branches containing commit
No related tags found
1 merge request
!25
Profilbilde
Pipeline
#225684
passed
2 years ago
Stage: build
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/components/EditProfile.vue
+38
-19
38 additions, 19 deletions
src/components/EditProfile.vue
src/components/FridgeItem.vue
+2
-2
2 additions, 2 deletions
src/components/FridgeItem.vue
with
40 additions
and
21 deletions
src/components/EditProfile.vue
+
38
−
19
View file @
e2968efc
<
template
>
<h2>
Profilinnstillinger
</h2>
<div
v-if=
"hasProfileImage"
id =
"profilepicture-container"
>
<img
width=
"100"
:src=
"this.updatedProfile.upImage"
alt=
"profile picture"
>
</div>
<div
v-else
id=
"#placeholder"
>
<Icon
icon=
"material-symbols:person"
:color=
iconColor
:style=
"
{ fontSize: '500px'}" />
<div
id =
"profilepicture-container"
>
<img
width=
"100"
:src=
"image"
alt=
"profile picture"
>
</div>
<h3>
{{
this
.
profile
.
name
}}
</h3>
<button
@
click=
"changeProfile"
id=
"changeUserBtn"
class=
"redBtn"
>
Bytt bruker
</button>
...
...
@@ -26,16 +22,14 @@
<h3>
Profilbilde
</h3><br>
<div
id=
"changeUserImage"
>
<div
v-if=
"hasProfileImage"
id =
"profilepicture-container"
>
<img
width=
"50"
:src=
"this.updatedProfile.upImage"
alt=
"profile picture"
>
<div
id =
"profilepicture-container"
>
<img
width=
"50"
:src=
"image"
id =
"profile_img_preview"
alt=
"profile picture"
>
</div>
<div
v-else
id =
"profilepicture-container"
>
<
Icon
icon=
"material-symbols:person"
:color=
iconColor
:style=
"
{ fontSize: '30px'}" /
>
<div>
<
input
@
change=
"updateImg"
type=
"file"
accept=
".jpeg, .jpg"
id=
"profile_img"
name=
"profile_img"
><br><br
>
</div>
<label
for=
"chooseImageUrl"
>
Bilde-URL:
</label><br>
<!--
<input
type=
"file"
id=
"chooseImage"
v-on:change=
"updateImage"
>
-->
<input
type=
"text"
id=
"chooseImageUrl"
v-model=
"this.updatedProfile.upImage"
>
</div>
<br><br>
...
...
@@ -64,6 +58,7 @@ export default {
alertMsg
:
''
,
initialName
:
''
,
//used to compare with updated values
initialRestriction
:
''
,
image
:
"
profile/default_avatar.png
"
,
}
},
computed
:
{
...
...
@@ -73,24 +68,32 @@ export default {
return
{
upName
:
this
.
profile
.
name
,
upRestricted
:
this
.
profile
.
restricted
,
upImage
:
this
.
profile
.
profileImageUrl
,
upImage
:
"
profile
/default_avatar.png
"
,
}
},
iconColor
()
{
return
"
#D9D9D9
"
},
hasProfileImage
()
{
return
false
;
}
},
beforeMount
()
{
//used to compare with changed values
this
.
initialName
=
this
.
profile
.
name
;
this
.
initialRestriction
=
this
.
profile
.
restricted
;
if
(
this
.
profile
.
profileImageUrl
!==
''
){
this
.
image
=
this
.
profile
.
profileImageUrl
;
}
},
methods
:
{
changeProfile
(){
router
.
push
(
"
/selectProfile
"
);
},
updateImg
()
{
let
file
=
document
.
getElementById
(
"
profile_img
"
).
files
[
0
];
let
reader
=
new
FileReader
();
reader
.
onload
=
function
(
ev
)
{
document
.
getElementById
(
"
profile_img_preview
"
).
src
=
ev
.
target
.
result
;
};
reader
.
readAsDataURL
(
file
);
},
async
deleteProfile
()
{
const
id
=
this
.
profile
.
id
;
API
.
deleteProfile
(
id
).
then
(()
=>
{
...
...
@@ -115,11 +118,27 @@ export default {
API
.
updateProfile
(
id
,{
name
:
newName
,
profileImageUrl
:
this
.
updatedProfile
.
upImage
,
profileImageUrl
:
null
,
isRestricted
:
newRestricted
,
}
).
then
((
savedProfile
)
=>
{
useAuthStore
().
setProfile
(
savedProfile
);
const
id
=
this
.
profile
.
id
;
let
image
=
document
.
getElementById
(
"
profile_img
"
).
files
[
0
];
if
(
typeof
image
!==
'
undefined
'
)
{
API
.
uploadProfileImage
(
image
,
id
)
.
then
((
updatedProfile
)
=>
{
useAuthStore
().
setProfile
(
updatedProfile
);
}).
catch
(()
=>
{
this
.
alertMsg
=
"
Bilde kunne ikke bli oppdatert (bildekrav: JPEG mindre enn 512kB)
"
});
}
else
{
useAuthStore
().
setProfile
(
savedProfile
);
this
.
alertMsg
=
"
Profil oppdatert.
"
return
;
}
this
.
alertMsg
=
"
Profil oppdatert.
"
}).
catch
(
error
=>
{
console
.
log
(
error
)
...
...
This diff is collapsed.
Click to expand it.
src/components/FridgeItem.vue
+
2
−
2
View file @
e2968efc
...
...
@@ -96,8 +96,8 @@ export default {
formatDate
(){
//formats expiration date as dd.mm.yyyy
let
fullExpirationDate
=
new
Date
(
this
.
fridgeItem
.
exp_date
);
let
day
=
fullExpirationDate
.
getDate
();
let
month
=
(
fullExpirationDate
.
getMonth
()
+
1
).
toString
();
let
year
=
fullExpirationDate
.
getFullYear
().
toString
();
let
month
=
(
fullExpirationDate
.
getMonth
()
+
1
).
toString
()
.
padStart
(
2
,
'
0
'
)
;
let
year
=
fullExpirationDate
.
getFullYear
().
toString
()
.
padStart
(
2
,
'
0
'
)
;
return
day
+
"
.
"
+
month
+
"
.
"
+
year
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment