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
29c5f03e
Commit
29c5f03e
authored
1 year ago
by
Ingrid
Browse files
Options
Downloads
Patches
Plain Diff
la inn sletting av profil
parent
7606aada
No related branches found
Branches containing commit
No related tags found
1 merge request
!21
Merge profilinnstillinger into main
Pipeline
#221989
failed
1 year ago
Stage: build
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/components/EditProfile.vue
+29
-15
29 additions, 15 deletions
src/components/EditProfile.vue
src/util/API.js
+26
-0
26 additions, 0 deletions
src/util/API.js
with
55 additions
and
15 deletions
src/components/EditProfile.vue
+
29
−
15
View file @
29c5f03e
...
...
@@ -16,10 +16,10 @@
<input
type=
"text"
required
v-model=
"this.updatedProfile.upName"
><br>
<br>
<h4>
Brukertype
</h4>
<input
type=
"radio"
id=
"normal"
value=
"false"
v-model=
"this.updatedProfile.upRestricted"
>
<input
type=
"radio"
id=
"normal"
value=
"false"
name=
"restrict"
v-model=
"this.updatedProfile.upRestricted"
>
<label
for=
"normal"
>
Standard
</label><br>
<input
type=
"radio"
id=
"restricted"
value=
"true"
v-model=
"this.updatedProfile.upRestricted"
>
<input
type=
"radio"
id=
"restricted"
value=
"true"
name=
"restrict"
v-model=
"this.updatedProfile.upRestricted"
>
<label
for=
"restricted"
>
Begrenset - Kan ikke redigere ukeplan eller handleliste
</label><br>
<br>
...
...
@@ -39,7 +39,7 @@
<br><br>
<div
id =
"submitbuttonBox"
>
<button
class=
"saveBtn"
@
click=
" saveUserSettings"
>
Lagre profilendringer
</button>
<button
class=
"delBtn"
@
click=
"delete
User
"
>
Slett brukerprofil
</button>
<button
class=
"delBtn"
@
click=
"delete
Profile
"
>
Slett brukerprofil
</button>
</div>
</form>
...
...
@@ -73,34 +73,48 @@ export default {
return
this
.
updatedProfile
.
upImage
.
length
>
0
;
}
},
data
()
{
return
{
deletionConfirmation
:
false
,
}
},
methods
:
{
saveUserSettings
(){
const
id
=
this
.
profile
.
id
;
API
.
updateProfile
(
id
,{
const
numOfProfiles
=
API
.
getProfiles
().
length
if
(
numOfProfiles
===
1
&&
this
.
updatedProfile
.
upRestricted
===
true
){
alert
(
"
Du må ha minst en standardprofil per konto. (ingen endringer er gjort)
"
)
}
else
{
API
.
updateProfile
(
id
,{
name
:
this
.
updatedProfile
.
upName
,
profileImageUrl
:
this
.
updatedProfile
.
upImage
,
restricted
:
this
.
updatedProfile
.
upRestricted
,
}
).
then
((
savedProfile
)
=>
{
}
).
then
((
savedProfile
)
=>
{
useAuthStore
().
setProfile
(
savedProfile
);
alert
(
"
profil oppdatert.
"
)
}).
catch
((
error
)
=>
{
}).
catch
((
error
)
=>
{
console
.
log
(
error
)
})
})
}
},
chooseProfilePicture
(){
alert
(
"
skriv inn bildelenke i feltet, og oppdater innstillinger
"
)
},
changeProfile
(){
router
.
push
(
"
/selectProfile
"
);
}
},
deleteProfile
(){
const
numOfProfiles
=
API
.
getProfiles
().
length
if
(
numOfProfiles
===
1
){
alert
(
"
Du kan ikke slette profilen. Hver Konto må ha minst en profil
"
)
}
else
{
const
id
=
this
.
profile
.
id
;
API
.
deleteProfile
(
id
).
then
(()
=>
{
router
.
push
(
'
/selectProfile
'
)
}).
catch
((
error
)
=>
{
alert
(
"
Det oppsto en feil ved sletting profil:
"
+
error
)
})
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/util/API.js
+
26
−
0
View file @
29c5f03e
...
...
@@ -191,6 +191,32 @@ export const API = {
},
/**
* Deletes a profile from an account
* @param id
* @param request
* @returns {Promise<*>}
*/
deleteProfile
:
async
(
id
)
=>
{
const
authStore
=
useAuthStore
();
if
(
!
authStore
.
isLoggedIn
)
{
throw
new
Error
();
}
return
axios
.
delete
(
`
${
import
.
meta
.
env
.
VITE_BACKEND_URL
}
/profile/
${
id
}
`
,
{
headers
:
{
Authorization
:
`Bearer
${
authStore
.
token
}
`
},
})
.
then
(()
=>
{
router
.
push
(
'
/selectProfile
'
)
})
.
catch
(()
=>
{
throw
new
Error
(
"
Kan ikke slette profil
"
);
});
},
...
...
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