Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
AURA
dashboard
Commits
a6a700ed
Commit
a6a700ed
authored
Apr 27, 2020
by
jackie / Andrea Ida Malkah Klaura
Browse files
refactor shows and timeslots from EmissionManager to store
parent
d810ab84
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/components/EmissionManager.vue
View file @
a6a700ed
...
...
@@ -157,8 +157,6 @@ export default {
data
()
{
return
{
currentShow
:
0
,
shows
:
[],
timeslots
:
[],
calendarSlots
:
[],
showChangedAlert
:
{
...
...
@@ -210,6 +208,11 @@ export default {
}
},
computed
:
{
shows
()
{
return
this
.
$store
.
state
.
shows
.
shows
},
timeslots
()
{
return
this
.
$store
.
state
.
shows
.
timeslots
},
},
created
()
{
if
(
this
.
$route
.
query
.
show
)
{
this
.
currentShow
=
this
.
$route
.
query
.
show
...
...
@@ -556,37 +559,27 @@ export default {
loadTimeslots
(
start
,
end
)
{
this
.
loaded
.
timeslots
=
false
let
uri
=
process
.
env
.
VUE_APP_API_STEERING
+
'
timeslots?start=
'
+
start
+
'
&end=
'
+
end
axios
.
get
(
uri
,
{
withCredentials
:
true
,
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
this
.
$parent
.
user
.
access_token
}
}).
then
(
response
=>
{
this
.
timeslots
=
response
.
data
this
.
loaded
.
timeslots
=
true
this
.
loadCalendarSlots
()
}).
catch
(
error
=>
{
this
.
$log
.
error
(
error
.
response
.
status
+
'
'
+
error
.
response
.
statusText
)
this
.
$log
.
error
(
error
.
response
)
alert
(
'
Error: could not load timeslots. See console for details.
'
)
this
.
$store
.
dispatch
(
'
shows/fetchTimeslots
'
,
{
start
:
start
,
end
:
end
,
callback
:
()
=>
{
this
.
$log
.
debug
(
'
loadTimeslots callback executed
'
)
this
.
loaded
.
timeslots
=
true
this
.
loadCalendarSlots
()
}
})
},
loadShows
()
{
this
.
loaded
.
shows
=
false
let
uri
=
process
.
env
.
VUE_APP_API_STEERING
+
'
shows
'
axios
.
get
(
uri
,
{
withCredentials
:
true
,
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
this
.
$parent
.
user
.
access_token
}
}).
then
(
response
=>
{
this
.
shows
=
response
.
data
this
.
loaded
.
shows
=
true
let
start
=
this
.
$refs
.
calendar
.
fireMethod
(
'
getView
'
).
start
.
format
()
let
end
=
this
.
$refs
.
calendar
.
fireMethod
(
'
getView
'
).
end
.
format
()
this
.
loadTimeslots
(
start
,
end
)
}).
catch
(
error
=>
{
this
.
$log
.
error
(
error
.
response
.
status
+
'
'
+
error
.
response
.
statusText
)
this
.
$log
.
error
(
error
.
response
)
alert
(
'
Error: could not load shows. See console for details.
'
)
this
.
$store
.
dispatch
(
'
shows/fetchShows
'
,
{
callback
:
()
=>
{
this
.
$log
.
debug
(
'
firing calendar method getView
'
)
this
.
loaded
.
shows
=
true
let
start
=
this
.
$refs
.
calendar
.
fireMethod
(
'
getView
'
).
start
.
format
()
let
end
=
this
.
$refs
.
calendar
.
fireMethod
(
'
getView
'
).
end
.
format
()
this
.
loadTimeslots
(
start
,
end
)
}
})
},
...
...
src/store/modules/shows.js
View file @
a6a700ed
import
axios
from
'
axios
'
import
handleApiError
from
'
../handleApiError
'
const
state
=
{
items
:
[],
shows
:
[],
timeslots
:
[],
loaded
:
{
shows
:
false
,
timeslots
:
false
,
}
}
const
getters
=
{
items
:
state
=>
state
.
items
,
itemCount
:
state
=>
state
.
items
.
length
,
shows
:
state
=>
state
.
shows
,
}
const
actions
=
{
addItem
({
commit
},
item
)
{
commit
(
'
addItem
'
,
item
)
const
mutations
=
{
loading
(
state
,
item
)
{
state
.
loaded
[
item
]
=
false
},
finishLoading
(
state
,
item
)
{
state
.
loaded
[
item
]
=
true
},
setShows
(
state
,
shows
)
{
state
.
shows
=
shows
},
setTimeslots
(
state
,
slots
)
{
state
.
timeslots
=
slots
}
}
const
mutations
=
{
addItem
(
state
,
item
)
{
state
.
items
.
push
(
item
)
}
const
actions
=
{
fetchShows
(
ctx
,
data
)
{
ctx
.
commit
(
'
loading
'
,
'
shows
'
)
let
uri
=
process
.
env
.
VUE_APP_API_STEERING
+
'
shows
'
axios
.
get
(
uri
,
{
withCredentials
:
true
,
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
ctx
.
rootState
.
auth
.
user
.
access_token
}
}).
then
(
response
=>
{
ctx
.
commit
(
'
setShows
'
,
response
.
data
)
ctx
.
commit
(
'
finishLoading
'
,
'
shows
'
)
if
(
data
&&
typeof
(
data
.
callback
)
===
'
function
'
)
{
data
.
callback
()
}
}).
catch
(
error
=>
{
handleApiError
(
this
,
error
,
'
could not load shows
'
)
})
},
fetchTimeslots
(
ctx
,
data
)
{
ctx
.
commit
(
'
loading
'
,
'
timeslots
'
)
let
uri
=
process
.
env
.
VUE_APP_API_STEERING
+
'
timeslots?start=
'
+
data
.
start
+
'
&end=
'
+
data
.
end
axios
.
get
(
uri
,
{
withCredentials
:
true
,
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
ctx
.
rootState
.
auth
.
user
.
access_token
}
}).
then
(
response
=>
{
ctx
.
commit
(
'
setTimeslots
'
,
response
.
data
)
ctx
.
commit
(
'
finishLoading
'
,
'
timeslots
'
)
if
(
data
&&
typeof
(
data
.
callback
)
===
'
function
'
)
{
data
.
callback
()
}
}).
catch
(
error
=>
{
handleApiError
(
this
,
error
,
'
could not load timeslots
'
)
})
},
}
export
default
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment