Merge branch '942-upload-retry' into 'master'

Resolve "Library Upload: missing retry upload button"

See merge request funkwhale/funkwhale!930
This commit is contained in:
Eliot Berriot 2019-10-17 15:19:08 +02:00
commit cfda280d69
2 changed files with 43 additions and 5 deletions

View File

@ -0,0 +1 @@
Added a retry option for failed uploads (#942)

View File

@ -91,9 +91,20 @@
<table class="ui unstackable table"> <table class="ui unstackable table">
<thead> <thead>
<tr> <tr>
<th><translate translate-context="Content/Library/Table.Label">Filename</translate></th> <th class="ten wide"><translate translate-context="Content/Library/Table.Label">Filename</translate></th>
<th><translate translate-context="Content/*/*/Noun">Size</translate></th> <th><translate translate-context="Content/*/*/Noun">Size</translate></th>
<th><translate translate-context="*/*/*">Status</translate></th> <th><translate translate-context="*/*/*">Status</translate></th>
<th><translate translate-context="*/*/*">Actions</translate></th>
</tr>
<tr v-if="retryableFiles.length > 1">
<th class="ten wide"></th>
<th></th>
<th></th>
<th>
<button class="ui right floated small basic button" @click.prevent="retry(retryableFiles)">
<translate translate-context="Content/Library/Table">Retry failed uploads</translate>
</button>
</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -113,9 +124,20 @@
<translate translate-context="Content/Library/Table" key="2">Uploading</translate> <translate translate-context="Content/Library/Table" key="2">Uploading</translate>
({{ parseInt(file.progress) }}%) ({{ parseInt(file.progress) }}%)
</span> </span>
<template v-else> <span v-else class="ui label"><translate translate-context="Content/Library/*/Short" key="3">Pending</translate></span>
<span class="ui label"><translate translate-context="Content/Library/*/Short" key="3">Pending</translate></span> </td>
<button class="ui tiny basic red icon button" @click.prevent="$refs.upload.remove(file)"><i class="delete icon"></i></button> <td>
<template v-if="file.error">
<button
class="ui tiny basic icon right floated button"
:title="labels.retry"
@click.prevent="retry([file])"
v-if="retryableFiles.indexOf(file) > -1">
<i class="redo icon"></i>
</button>
</template>
<template v-else-if="!file.success">
<button class="ui tiny basic red icon right floated button" @click.prevent="$refs.upload.remove(file)"><i class="delete icon"></i></button>
</template> </template>
</td> </td>
</tr> </tr>
@ -251,6 +273,13 @@ export default {
self.uploads.objects[event.upload.uuid] = event.upload; self.uploads.objects[event.upload.uuid] = event.upload;
self.needsRefresh = true self.needsRefresh = true
}); });
},
retry (files) {
files.forEach((file) => {
this.$refs.upload.update(file, {error: '', progress: '0.00'})
})
this.$refs.upload.active = true;
} }
}, },
computed: { computed: {
@ -274,6 +303,7 @@ export default {
server, server,
network, network,
timeout, timeout,
retry: this.$pgettext('*/*/*/Verb', "Retry"),
extension: this.$gettextInterpolate(extension, { extension: this.$gettextInterpolate(extension, {
extensions: this.supportedExtensions.join(", ") extensions: this.supportedExtensions.join(", ")
}) })
@ -295,6 +325,11 @@ export default {
return f.error; return f.error;
}).length; }).length;
}, },
retryableFiles () {
return this.files.filter(f => {
return f.error;
});
},
processableFiles() { processableFiles() {
return ( return (
this.uploads.pending + this.uploads.pending +
@ -342,7 +377,9 @@ export default {
uploadedSize () { uploadedSize () {
let uploaded = 0 let uploaded = 0
this.files.forEach((f) => { this.files.forEach((f) => {
uploaded += f.size * (f.progress / 100) if (!f.error) {
uploaded += f.size * (f.progress / 100)
}
}) })
return uploaded return uploaded
} }