Skip to main content
Homepage
Explore
Search or go to…
/
Sign in
Explore
Primary navigation
Project
N
Nextcloud mail - PostGuard
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
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Collapse sidebar
Snippets
Groups
Projects
Show more breadcrumbs
Laura Kolijn
Nextcloud mail - PostGuard
Commits
2143e747
Unverified
Commit
2143e747
authored
Mar 8, 2019
by
Christoph Wurst
Committed by
GitHub
Mar 8, 2019
Browse files
Options
Downloads
Plain Diff
Merge pull request #1592 from nextcloud/feature/attachment-upload-progress
Show upload progress for local attachments
parents
62250ecf
749e24a3
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/components/ComposerAttachments.vue
+37
-9
37 additions, 9 deletions
src/components/ComposerAttachments.vue
src/service/AttachmentService.js
+2
-2
2 additions, 2 deletions
src/service/AttachmentService.js
with
39 additions
and
11 deletions
src/components/ComposerAttachments.vue
+
37
−
9
View file @
2143e747
...
...
@@ -31,7 +31,11 @@
</ul>
<button
class=
"button"
:disabled=
"uploading"
@
click=
"onAddLocalAttachment"
>
<span
:class=
"
{'icon-upload': !uploading, 'icon-loading-small': uploading}">
</span>
{{
uploading
?
t
(
'
mail
'
,
'
Uploading …
'
)
:
t
(
'
mail
'
,
'
Upload attachment
'
)
}}
{{
uploading
?
t
(
'
mail
'
,
'
Uploading {percent
}
% …
'
,
{
percent
:
uploadProgress
}
)
:
t
(
'
mail
'
,
'
Upload attachment
'
)
}}
<
/button
>
<
button
class
=
"
button
"
@
click
=
"
onAddCloudAttachment
"
>
<
span
class
=
"
icon-folder
"
/>
...
...
@@ -45,6 +49,7 @@
import
_
from
'
lodash
'
import
{
translate
as
t
}
from
'
nextcloud-server/dist/l10n
'
import
{
pickFileOrDirectory
}
from
'
nextcloud-server/dist/files
'
import
Vue
from
'
vue
'
import
{
uploadLocalAttachment
}
from
'
../service/AttachmentService
'
...
...
@@ -59,8 +64,20 @@ export default {
data
()
{
return
{
uploading
:
false
,
uploads
:
{
}
,
}
}
,
computed
:
{
uploadProgress
()
{
let
uploaded
=
0
let
total
=
0
for
(
let
id
in
this
.
uploads
)
{
uploaded
+=
this
.
uploads
[
id
].
uploaded
total
+=
this
.
uploads
[
id
].
total
}
return
((
uploaded
/
total
)
*
100
).
toFixed
(
1
)
}
,
}
,
methods
:
{
onAddLocalAttachment
()
{
this
.
$refs
.
localAttachments
.
click
()
...
...
@@ -79,14 +96,25 @@ export default {
onLocalAttachmentSelected
(
e
)
{
this
.
uploading
=
true
const
done
=
Promise
.
all
(
_
.
map
(
e
.
target
.
files
,
file
=>
uploadLocalAttachment
(
file
).
then
(({
file
,
id
})
=>
{
Vue
.
set
(
this
,
'
uploads
'
,
{
}
)
const
progress
=
id
=>
(
prog
,
uploaded
)
=>
{
this
.
uploads
[
id
].
uploaded
=
uploaded
}
const
promises
=
_
.
map
(
e
.
target
.
files
,
file
=>
{
Vue
.
set
(
this
.
uploads
,
file
.
name
,
{
total
:
file
.
size
,
uploaded
:
0
,
}
)
return
uploadLocalAttachment
(
file
,
progress
(
file
.
name
)).
then
(({
file
,
id
}
)
=>
{
console
.
info
(
'
uploaded
'
)
return
this
.
emitNewAttachment
(
this
.
fileNameToAttachment
(
file
.
name
,
id
))
}
)
)
)
}
)
const
done
=
Promise
.
all
(
promises
)
.
catch
(
console
.
error
.
bind
(
this
))
.
then
(()
=>
(
this
.
uploading
=
false
))
...
...
...
...
This diff is collapsed.
Click to expand it.
src/service/AttachmentService.js
+
2
−
2
View file @
2143e747
...
...
@@ -46,11 +46,11 @@ export function downloadAttachment(url) {
return
Axios
.
get
(
url
).
then
(
res
=>
res
.
data
)
}
export
const
uploadLocalAttachment
=
file
=>
{
export
const
uploadLocalAttachment
=
(
file
,
progress
)
=>
{
const
url
=
generateUrl
(
'
/apps/mail/api/attachments
'
)
const
data
=
new
FormData
()
const
opts
=
{
onUploadProgress
:
prog
=>
console
.
log
(
prog
,
prog
.
loaded
,
prog
.
total
),
onUploadProgress
:
prog
=>
progress
(
prog
,
prog
.
loaded
,
prog
.
total
),
}
data
.
append
(
'
attachment
'
,
file
)
...
...
...
...
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
sign in
to comment