Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
PUBLIC
/
surfer-okd
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 5c17272a
authored
Oct 08, 2018
by
Johannes Zellner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add upload progress to ui
Fixes #4
1 parent
b3ff26fb
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
5 deletions
frontend/index.html
frontend/js/app.js
frontend/index.html
View file @
5c17272
...
@@ -106,7 +106,7 @@
...
@@ -106,7 +106,7 @@
</el-row>
</el-row>
<el-row
v-else
>
<el-row
v-else
>
<el-col
:span=
"4"
>
<el-col
:span=
"4"
>
Uploading
files ({{ uploadStatus.done }} / {{ uploadStatus.count }}
)
Uploading
{{ uploadStatus.count }} files ({{ Math.round(uploadStatus.done/1000/1000) }}MB / {{ Math.round(uploadStatus.size/1000/1000) }}MB
)
</el-col>
</el-col>
<el-col
:span=
"20"
>
<el-col
:span=
"20"
>
<el-progress
:text-inside=
"true"
:stroke-width=
"18"
:percentage=
"uploadStatus.percentDone"
></el-progress>
<el-progress
:text-inside=
"true"
:stroke-width=
"18"
:percentage=
"uploadStatus.percentDone"
></el-progress>
...
...
frontend/js/app.js
View file @
5c17272
...
@@ -132,23 +132,31 @@ function uploadFiles(files) {
...
@@ -132,23 +132,31 @@ function uploadFiles(files) {
app
.
uploadStatus
.
busy
=
true
;
app
.
uploadStatus
.
busy
=
true
;
app
.
uploadStatus
.
count
=
files
.
length
;
app
.
uploadStatus
.
count
=
files
.
length
;
app
.
uploadStatus
.
size
=
0
;
app
.
uploadStatus
.
done
=
0
;
app
.
uploadStatus
.
done
=
0
;
app
.
uploadStatus
.
percentDone
=
0
;
app
.
uploadStatus
.
percentDone
=
0
;
for
(
var
i
=
0
;
i
<
files
.
length
;
++
i
)
{
app
.
uploadStatus
.
size
+=
files
[
i
].
size
;
}
asyncForEach
(
files
,
function
(
file
,
callback
)
{
asyncForEach
(
files
,
function
(
file
,
callback
)
{
var
path
=
encode
(
sanitize
(
app
.
path
+
'/'
+
(
file
.
webkitRelativePath
||
file
.
name
)));
var
path
=
encode
(
sanitize
(
app
.
path
+
'/'
+
(
file
.
webkitRelativePath
||
file
.
name
)));
var
formData
=
new
FormData
();
var
formData
=
new
FormData
();
formData
.
append
(
'file'
,
file
);
formData
.
append
(
'file'
,
file
);
superagent
.
post
(
'/api/files'
+
path
).
query
({
access_token
:
localStorage
.
accessToken
}).
send
(
formData
).
end
(
function
(
error
,
result
)
{
superagent
.
post
(
'/api/files'
+
path
)
.
query
({
access_token
:
localStorage
.
accessToken
})
.
send
(
formData
)
.
on
(
'progress'
,
function
(
event
)
{
app
.
uploadStatus
.
done
+=
event
.
loaded
;
app
.
uploadStatus
.
percentDone
=
Math
.
round
(
app
.
uploadStatus
.
done
/
app
.
uploadStatus
.
size
*
100
);
}).
end
(
function
(
error
,
result
)
{
if
(
result
&&
result
.
statusCode
===
401
)
return
logout
();
if
(
result
&&
result
.
statusCode
===
401
)
return
logout
();
if
(
result
&&
result
.
statusCode
!==
201
)
return
callback
(
'Error uploading file: '
,
result
.
statusCode
);
if
(
result
&&
result
.
statusCode
!==
201
)
return
callback
(
'Error uploading file: '
,
result
.
statusCode
);
if
(
error
)
return
callback
(
error
);
if
(
error
)
return
callback
(
error
);
app
.
uploadStatus
.
done
+=
1
;
app
.
uploadStatus
.
percentDone
=
Math
.
round
(
app
.
uploadStatus
.
done
/
app
.
uploadStatus
.
count
*
100
);
callback
();
callback
();
});
});
},
function
(
error
)
{
},
function
(
error
)
{
...
@@ -156,6 +164,7 @@ function uploadFiles(files) {
...
@@ -156,6 +164,7 @@ function uploadFiles(files) {
app
.
uploadStatus
.
busy
=
false
;
app
.
uploadStatus
.
busy
=
false
;
app
.
uploadStatus
.
count
=
0
;
app
.
uploadStatus
.
count
=
0
;
app
.
uploadStatus
.
size
=
0
;
app
.
uploadStatus
.
done
=
0
;
app
.
uploadStatus
.
done
=
0
;
app
.
uploadStatus
.
percentDone
=
100
;
app
.
uploadStatus
.
percentDone
=
100
;
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment