Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
galene
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
galene
Commits
dbeb75ee
Commit
dbeb75ee
authored
Jan 16, 2023
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Better progress indicator for file transfer.
parent
645ba5fb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
15 deletions
+64
-15
static/galene.css
static/galene.css
+6
-0
static/galene.js
static/galene.js
+58
-15
No files found.
static/galene.css
View file @
dbeb75ee
...
...
@@ -1331,3 +1331,9 @@ header .collapse:hover {
.contextualMenu
{
z-index
:
2999
;
}
.file-progress
{
accent-color
:
#610a86
;
margin-left
:
10px
;
margin-right
:
10px
;
}
static/galene.js
View file @
dbeb75ee
...
...
@@ -2416,12 +2416,15 @@ function gotFileTransfer(f) {
f
.
cancel
();
};
bno
.
id
=
"
bno-
"
+
f
.
fullid
();
let
status
=
document
.
createElement
(
'
div
'
);
let
status
=
document
.
createElement
(
'
span
'
);
status
.
id
=
'
status-
'
+
f
.
fullid
();
if
(
!
f
.
up
)
{
status
.
textContent
=
'
(Choosing "Accept" will disclose your IP address.)
'
;
}
let
statusp
=
document
.
createElement
(
'
p
'
);
statusp
.
id
=
'
statusp-
'
+
f
.
fullid
();
statusp
.
appendChild
(
status
);
let
div
=
document
.
createElement
(
'
div
'
);
div
.
id
=
'
file-
'
+
f
.
fullid
();
div
.
appendChild
(
p
);
...
...
@@ -2429,7 +2432,7 @@ function gotFileTransfer(f) {
div
.
appendChild
(
byes
);
if
(
bno
)
div
.
appendChild
(
bno
);
div
.
appendChild
(
status
);
div
.
appendChild
(
status
p
);
div
.
classList
.
add
(
'
message
'
);
div
.
classList
.
add
(
'
message-private
'
);
div
.
classList
.
add
(
'
message-row
'
);
...
...
@@ -2441,20 +2444,52 @@ function gotFileTransfer(f) {
/**
* @param {TransferredFile} f
* @param {string} status
* @param {number} [value]
*/
function
setFileStatus
(
f
,
status
)
{
let
statusdiv
=
document
.
getElementById
(
'
status-
'
+
f
.
fullid
());
if
(
!
statusdiv
)
throw
new
Error
(
"
Couldn't find statusdiv
"
);
statusdiv
.
textContent
=
status
;
function
setFileStatus
(
f
,
status
,
value
)
{
let
statuselt
=
document
.
getElementById
(
'
status-
'
+
f
.
fullid
());
if
(
!
statuselt
)
throw
new
Error
(
"
Couldn't find statusp
"
);
statuselt
.
textContent
=
status
;
if
(
value
)
{
let
progress
=
document
.
getElementById
(
'
progress-
'
+
f
.
fullid
());
if
(
!
progress
||
!
(
progress
instanceof
HTMLProgressElement
))
throw
new
Error
(
"
Couldn't find progress element
"
);
progress
.
value
=
value
;
let
label
=
document
.
getElementById
(
'
progresstext-
'
+
f
.
fullid
());
let
percent
=
Math
.
round
(
100
*
value
/
progress
.
max
);
label
.
textContent
=
`
${
percent
}
%`
;
}
}
/**
* @param {TransferredFile} f
* @param {number} [max]
*/
function
createFileProgress
(
f
,
max
)
{
let
statusp
=
document
.
getElementById
(
'
statusp-
'
+
f
.
fullid
());
if
(
!
statusp
)
throw
new
Error
(
"
Couldn't find status div
"
);
/** @type HTMLProgressElement */
let
progress
=
document
.
createElement
(
'
progress
'
);
progress
.
id
=
'
progress-
'
+
f
.
fullid
();
progress
.
classList
.
add
(
'
file-progress
'
);
progress
.
max
=
max
;
progress
.
value
=
0
;
statusp
.
appendChild
(
progress
);
let
progresstext
=
document
.
createElement
(
'
span
'
);
progresstext
.
id
=
'
progresstext-
'
+
f
.
fullid
();
progresstext
.
textContent
=
'
0%
'
;
statusp
.
appendChild
(
progresstext
);
}
/**
* @param {TransferredFile} f
* @param {boolean} delyes
* @param {boolean} delno
* @param {boolean} [delprogress]
*/
function
delFileStatusButtons
(
f
,
delyes
,
delno
)
{
function
delFileStatusButtons
(
f
,
delyes
,
delno
,
delprogress
)
{
let
div
=
document
.
getElementById
(
'
file-
'
+
f
.
fullid
());
if
(
!
div
)
throw
new
Error
(
"
Couldn't find file div
"
);
...
...
@@ -2468,6 +2503,16 @@ function delFileStatusButtons(f, delyes, delno) {
if
(
bno
)
div
.
removeChild
(
bno
);
}
if
(
delprogress
)
{
let
statusp
=
document
.
getElementById
(
'
statusp-
'
+
f
.
fullid
());
let
progress
=
document
.
getElementById
(
'
progress-
'
+
f
.
fullid
());
let
progresstext
=
document
.
getElementById
(
'
progresstext-
'
+
f
.
fullid
());
if
(
progress
)
statusp
.
removeChild
(
progress
);
if
(
progresstext
)
statusp
.
removeChild
(
progresstext
);
}
}
/**
...
...
@@ -2481,17 +2526,15 @@ function gotFileTransferEvent(state, data) {
case
'
inviting
'
:
break
;
case
'
connecting
'
:
delFileStatusButtons
(
f
,
true
);
delFileStatusButtons
(
f
,
true
,
false
);
setFileStatus
(
f
,
'
Connecting...
'
);
createFileProgress
(
f
,
f
.
size
);
break
;
case
'
connected
'
:
if
(
f
.
up
)
setFileStatus
(
f
,
`Sending...
${
f
.
datalen
}
/
${
f
.
size
}
`
);
else
setFileStatus
(
f
,
`Receiving...
${
f
.
datalen
}
/
${
f
.
size
}
`
);
setFileStatus
(
f
,
f
.
up
?
'
Sending...
'
:
'
Receiving...
'
,
f
.
datalen
);
break
;
case
'
done
'
:
delFileStatusButtons
(
f
,
true
,
true
);
delFileStatusButtons
(
f
,
true
,
true
,
true
);
setFileStatus
(
f
,
'
Done.
'
);
if
(
!
f
.
up
)
{
let
url
=
URL
.
createObjectURL
(
data
);
...
...
@@ -2505,7 +2548,7 @@ function gotFileTransferEvent(state, data) {
}
break
;
case
'
cancelled
'
:
delFileStatusButtons
(
f
,
true
,
true
);
delFileStatusButtons
(
f
,
true
,
true
,
true
);
if
(
data
)
setFileStatus
(
f
,
`Cancelled:
${
data
.
toString
()}
.`
);
else
...
...
Write
Preview
Markdown
is supported
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