Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
idatt2106_2024_02_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 - Gruppe 2
idatt2106_2024_02_frontend
Commits
3b8ead28
Commit
3b8ead28
authored
11 months ago
by
Trygve Jørgensen
Browse files
Options
Downloads
Patches
Plain Diff
feat(goal): user can now create saving goals
parent
dd317406
No related branches found
No related tags found
Loading
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/services/authInterceptor.ts
+5
-2
5 additions, 2 deletions
src/services/authInterceptor.ts
src/views/ManageGoalView.vue
+7
-12
7 additions, 12 deletions
src/views/ManageGoalView.vue
with
12 additions
and
14 deletions
src/services/authInterceptor.ts
+
5
−
2
View file @
3b8ead28
...
...
@@ -3,7 +3,10 @@ import axios, { AxiosError } from 'axios'
import
router
from
'
@/router
'
const
authInterceptor
=
axios
.
create
({
baseURL
:
'
http://localhost:8080
'
baseURL
:
'
http://localhost:8080
'
,
headers
:
{
'
Content-Type
'
:
'
application/json
'
}
})
authInterceptor
.
interceptors
.
request
.
use
(
...
...
@@ -25,7 +28,7 @@ authInterceptor.interceptors.response.use(
},
async
(
error
)
=>
{
const
originalRequest
=
error
.
config
if
(
error
.
response
.
status
===
40
3
&&
!
originalRequest
.
_retry
)
{
if
(
error
.
response
.
status
===
40
1
&&
!
originalRequest
.
_retry
)
{
originalRequest
.
_retry
=
true
const
refreshToken
=
localStorage
.
getItem
(
'
refreshToken
'
)
axios
...
...
This diff is collapsed.
Click to expand it.
src/views/ManageGoalView.vue
+
7
−
12
View file @
3b8ead28
...
...
@@ -3,17 +3,18 @@ import { useRouter } from 'vue-router'
import
{
computed
,
onMounted
,
ref
,
watch
}
from
'
vue
'
import
type
{
Goal
}
from
'
@/types/goal
'
import
ProgressBar
from
'
@/components/ProgressBar.vue
'
import
a
xios
from
'
axios
'
import
a
uthInterceptor
from
'
@/services/authInterceptor
'
const
router
=
useRouter
()
const
oneWeekFromNow
=
new
Date
()
oneWeekFromNow
.
setDate
(
oneWeekFromNow
.
getDate
()
+
7
)
const
minDate
=
oneWeekFromNow
.
toISOString
()
const
minDate
=
oneWeekFromNow
.
toISOString
().
slice
(
0
,
16
)
console
.
log
(
minDate
)
const
thirtyDaysFromNow
=
new
Date
()
thirtyDaysFromNow
.
setDate
(
thirtyDaysFromNow
.
getDate
()
+
30
)
const
maxDate
=
thirtyDaysFromNow
.
toISOString
()
const
maxDate
=
thirtyDaysFromNow
.
toISOString
()
.
slice
(
0
,
16
)
const
goalInstance
=
ref
<
Goal
>
({
id
:
0
,
...
...
@@ -74,8 +75,6 @@ const submitAction = () => {
}
onMounted
(()
=>
{
console
.
log
(
minDate
,
maxDate
)
let
id
=
null
if
(
isEdit
.
value
)
{
...
...
@@ -92,12 +91,8 @@ onMounted(() => {
const
createGoal
=
()
=>
{
console
.
log
(
'
Creating goal
'
,
goalInstance
.
value
)
axios
.
post
(
'
http://localhost:8080/users/me/goals
'
,
goalInstance
.
value
,
{
headers
:
{
Authorization
:
`Bearer
${
sessionStorage
.
getItem
(
'
accessToken
'
)}
`
}
})
authInterceptor
.
post
(
'
/users/me/goals
'
,
goalInstance
.
value
,
{})
.
then
((
response
)
=>
{
console
.
log
(
response
.
data
)
return
router
.
push
({
name
:
'
goals
'
})
...
...
@@ -110,7 +105,7 @@ const createGoal = () => {
const
updateGoal
=
()
=>
{
console
.
log
(
'
Updating goal
'
,
goalInstance
.
value
)
a
xios
a
uthInterceptor
.
put
(
`http://localhost:8080/users/me/goals/
${
goalInstance
.
value
.
id
}
`
,
goalInstance
.
value
,
{
headers
:
{
Authorization
:
`Bearer
${
sessionStorage
.
getItem
(
'
accessToken
'
)}
`
...
...
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