Fix styling and run only two uploads in parallel
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
25
package-lock.json
generated
25
package-lock.json
generated
@@ -7503,6 +7503,11 @@
|
|||||||
"resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz",
|
||||||
"integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs="
|
"integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs="
|
||||||
},
|
},
|
||||||
|
"eventemitter3": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-qerSRB0p+UDEssxTtm6EDKcE7W4OaoisfIMl4CngyEhjpYglocpNg6UEqCvemdGhosAsg4sO2dXJOdyBifPGCg=="
|
||||||
|
},
|
||||||
"events": {
|
"events": {
|
||||||
"version": "3.1.0",
|
"version": "3.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/events/-/events-3.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/events/-/events-3.1.0.tgz",
|
||||||
@@ -13258,8 +13263,7 @@
|
|||||||
"p-finally": {
|
"p-finally": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz",
|
||||||
"integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=",
|
"integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"p-is-promise": {
|
"p-is-promise": {
|
||||||
"version": "2.1.0",
|
"version": "2.1.0",
|
||||||
@@ -13285,6 +13289,23 @@
|
|||||||
"p-limit": "^1.1.0"
|
"p-limit": "^1.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"p-queue": {
|
||||||
|
"version": "6.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/p-queue/-/p-queue-6.3.0.tgz",
|
||||||
|
"integrity": "sha512-fg5dJlFpd5+3CgG3/0ogpVZUeJbjiyXFg0nu53hrOYsybqSiDyxyOpad0Rm6tAiGjgztAwkyvhlYHC53OiAJOA==",
|
||||||
|
"requires": {
|
||||||
|
"eventemitter3": "^4.0.0",
|
||||||
|
"p-timeout": "^3.1.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"p-timeout": {
|
||||||
|
"version": "3.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/p-timeout/-/p-timeout-3.2.0.tgz",
|
||||||
|
"integrity": "sha512-rhIwUycgwwKcP9yTOOFK/AKsAopjjCakVqLHePO3CC6Mir1Z99xT+R63jZxAT5lFZLa2inS5h+ZS2GvR99/FBg==",
|
||||||
|
"requires": {
|
||||||
|
"p-finally": "^1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"p-try": {
|
"p-try": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz",
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
"blueimp-md5": "^2.13.0",
|
"blueimp-md5": "^2.13.0",
|
||||||
"dompurify": "^2.0.8",
|
"dompurify": "^2.0.8",
|
||||||
"nextcloud-vue-collections": "^0.7.2",
|
"nextcloud-vue-collections": "^0.7.2",
|
||||||
|
"p-queue": "^6.3.0",
|
||||||
"url-search-params-polyfill": "^8.0.0",
|
"url-search-params-polyfill": "^8.0.0",
|
||||||
"vue": "^2.6.11",
|
"vue": "^2.6.11",
|
||||||
"vue-at": "^2.5.0-beta.2",
|
"vue-at": "^2.5.0-beta.2",
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ export default {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
const files = event.dataTransfer.files
|
const files = event.dataTransfer.files
|
||||||
for (let file of files) {
|
for (const file of files) {
|
||||||
this.onLocalAttachmentSelected(file)
|
this.onLocalAttachmentSelected(file)
|
||||||
}
|
}
|
||||||
event.dataTransfer.value = ''
|
event.dataTransfer.value = ''
|
||||||
|
|||||||
@@ -32,14 +32,20 @@
|
|||||||
@change="handleUploadFile">
|
@change="handleUploadFile">
|
||||||
<div class="attachment-list">
|
<div class="attachment-list">
|
||||||
<ul>
|
<ul>
|
||||||
<li v-for="attachment in uploadQueue">
|
<li v-for="attachment in uploadQueue" :key="attachment.name" class="attachment">
|
||||||
{{ attachment.name }}
|
<a class="fileicon" :style="mimetypeForAttachment('none')" />
|
||||||
<progress :value="attachment.progress" max="100"></progress>
|
<div class="details">
|
||||||
|
<a>
|
||||||
|
<div class="filename">
|
||||||
|
<span class="basename">{{ attachment.name }}</span>
|
||||||
|
</div>
|
||||||
|
<progress :value="attachment.progress" max="100" />
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li v-for="attachment in attachments"
|
<li v-for="attachment in attachments"
|
||||||
:key="attachment.id"
|
:key="attachment.id"
|
||||||
class="attachment"
|
class="attachment">
|
||||||
style="display: flex;">
|
|
||||||
<a class="fileicon" :style="mimetypeForAttachment(attachment.extendedData.mimetype)" :href="attachmentUrl(attachment)" />
|
<a class="fileicon" :style="mimetypeForAttachment(attachment.extendedData.mimetype)" :href="attachmentUrl(attachment)" />
|
||||||
<div class="details">
|
<div class="details">
|
||||||
<a :href="attachmentUrl(attachment)" target="_blank">
|
<a :href="attachmentUrl(attachment)" target="_blank">
|
||||||
@@ -114,7 +120,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
attachments() {
|
attachments() {
|
||||||
return this.$store.getters.attachmentsByCard(this.card.id).sort((a, b) => b.id - a.id)
|
return [...this.$store.getters.attachmentsByCard(this.card.id)].sort((a, b) => b.id - a.id)
|
||||||
},
|
},
|
||||||
formattedFileSize() {
|
formattedFileSize() {
|
||||||
return (filesize) => formatFileSize(filesize)
|
return (filesize) => formatFileSize(filesize)
|
||||||
@@ -141,7 +147,7 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
handleUploadFile(event) {
|
handleUploadFile(event) {
|
||||||
const files = event.target.files ?? []
|
const files = event.target.files ?? []
|
||||||
for (let file of files) {
|
for (const file of files) {
|
||||||
this.onLocalAttachmentSelected(file)
|
this.onLocalAttachmentSelected(file)
|
||||||
}
|
}
|
||||||
event.target.value = ''
|
event.target.value = ''
|
||||||
@@ -208,6 +214,7 @@ export default {
|
|||||||
li.attachment {
|
li.attachment {
|
||||||
display: flex;
|
display: flex;
|
||||||
padding: 3px;
|
padding: 3px;
|
||||||
|
min-height: 44px;
|
||||||
|
|
||||||
&.deleted {
|
&.deleted {
|
||||||
opacity: .5;
|
opacity: .5;
|
||||||
|
|||||||
@@ -21,6 +21,9 @@
|
|||||||
*/
|
*/
|
||||||
import { showError } from '@nextcloud/dialogs'
|
import { showError } from '@nextcloud/dialogs'
|
||||||
import { formatFileSize } from '@nextcloud/files'
|
import { formatFileSize } from '@nextcloud/files'
|
||||||
|
import PQueue from 'p-queue'
|
||||||
|
|
||||||
|
const queue = new PQueue({ concurrency: 2 })
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
@@ -39,11 +42,12 @@ export default {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$set(this.uploadQueue, file.name, { name: file.name, progress: 0})
|
this.$set(this.uploadQueue, file.name, { name: file.name, progress: 0 })
|
||||||
const bodyFormData = new FormData()
|
const bodyFormData = new FormData()
|
||||||
bodyFormData.append('cardId', this.cardId)
|
bodyFormData.append('cardId', this.cardId)
|
||||||
bodyFormData.append('type', 'deck_file')
|
bodyFormData.append('type', 'deck_file')
|
||||||
bodyFormData.append('file', file)
|
bodyFormData.append('file', file)
|
||||||
|
await queue.add(async() => {
|
||||||
try {
|
try {
|
||||||
await this.$store.dispatch('createAttachment', { cardId: this.cardId,
|
await this.$store.dispatch('createAttachment', { cardId: this.cardId,
|
||||||
formData: bodyFormData,
|
formData: bodyFormData,
|
||||||
@@ -51,7 +55,7 @@ export default {
|
|||||||
const percentCompleted = Math.round((e.loaded * 100) / e.total)
|
const percentCompleted = Math.round((e.loaded * 100) / e.total)
|
||||||
console.debug(percentCompleted)
|
console.debug(percentCompleted)
|
||||||
this.$set(this.uploadQueue[file.name], 'progress', percentCompleted)
|
this.$set(this.uploadQueue[file.name], 'progress', percentCompleted)
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.response.data.status === 409) {
|
if (err.response.data.status === 409) {
|
||||||
@@ -62,6 +66,8 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.$delete(this.uploadQueue, file.name)
|
this.$delete(this.uploadQueue, file.name)
|
||||||
|
})
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
overrideAttachment() {
|
overrideAttachment() {
|
||||||
|
|||||||
Reference in New Issue
Block a user