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
a3147fc7
Commit
a3147fc7
authored
Jun 03, 2019
by
jackie / Andrea Ida Malkah Klaura
Browse files
FIX
#11
: check for 409 Conflict when deleting files
parent
114c0c31
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/components/FileManager.vue
View file @
a3147fc7
...
...
@@ -1005,20 +1005,37 @@ export default {
}
},
// Deletes a file with a specific
,
calling the AuRa tank API and afterwards
// Deletes a file with a specific
ID
calling the AuRa tank API and afterwards
// fetching a fresh list of files from it.
deleteFile
:
function
(
id
)
{
var
uri
=
process
.
env
.
VUE_APP_API_TANK
+
'
shows/
'
+
this
.
shows
[
this
.
currentShow
].
slug
+
'
/files/
'
+
id
let
uri
=
process
.
env
.
VUE_APP_API_TANK
+
'
shows/
'
+
this
.
shows
[
this
.
currentShow
].
slug
+
'
/files/
'
+
id
// TODO: add mechanism to indicate the running delete request in the files table
axios
.
delete
(
uri
,
{
withCredentials
:
true
,
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
this
.
$parent
.
user
.
access_token
},
}).
then
(
}).
then
(()
=>
{
this
.
$log
.
debug
(
`Fetching files for show
${
this
.
shows
[
this
.
currentShow
].
slug
}
(ID:
${
id
}
)`
)
this
.
fetchFiles
(
this
.
shows
[
this
.
currentShow
].
slug
)
).
catch
(
error
=>
{
this
.
$log
.
error
(
error
.
response
.
status
+
'
'
+
error
.
response
.
statusText
)
this
.
$log
.
error
(
error
.
response
)
alert
(
'
Error: could not delete file. See console for details.
'
)
}).
catch
(
error
=>
{
// if there was a 409 Conflict response it means, that this file is
// still used in one or more playlists.
if
(
error
.
response
.
status
===
409
)
{
let
pls
=
error
.
response
.
data
.
details
.
playlists
.
length
let
msg
=
'
Cannot delete file. Still used in
'
+
pls
+
'
playlists:
\n\n
'
for
(
let
pl
of
error
.
response
.
data
.
details
.
playlists
)
{
msg
+=
'
ID:
'
+
pl
.
id
if
(
pl
.
description
)
{
msg
+=
'
(
'
+
pl
.
description
+
'
)
'
}
msg
+=
'
\n
'
}
msg
+=
'
\n
If you want to delete the file, remove it from those playlists first.
'
alert
(
msg
)
}
else
{
this
.
$log
.
error
(
error
.
response
.
status
+
'
'
+
error
.
response
.
statusText
)
this
.
$log
.
error
(
error
.
response
)
alert
(
'
Error: could not delete file. See console for details.
'
)
}
})
},
...
...
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