WebAdmin active connections: fix active transfer display
Some checks are pending
Code scanning - action / CodeQL-Build (push) Waiting to run
CI / Test and deploy (push) Waiting to run
CI / Test build flags (push) Waiting to run
CI / Test with PgSQL/MySQL/Cockroach (push) Waiting to run
CI / Build Linux packages (push) Waiting to run
CI / golangci-lint (push) Waiting to run
Docker / Build (push) Waiting to run

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino 2024-10-28 20:10:59 +01:00
parent 256e3c1e3e
commit 10e4843a18
No known key found for this signature in database
GPG key ID: 935D2952DEC4EECF

View file

@ -245,22 +245,27 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
render: function (data, type, row) {
if (type === 'display') {
let result = "";
if (row.active_transfers && row.active_transfers.length > 0){
let transfer = row.active_transfers[0];
let path = escapeHTML(transfer.path);
let elapsed = row.current_time - transfer.start_time;
if (elapsed > 0 && transfer.size > 0){
let speed = (transfer.size*1.0) / (elapsed/1000.0);
if (transfer.operation_type === 'upload'){
result = $.t('connections.upload_info', {path: path, size: fileSizeIEC(transfer.size), speed: humanizeSpeed(speed)});
} else {
result = $.t('connections.download_info', {path: path, size: fileSizeIEC(transfer.size), speed: humanizeSpeed(speed)});
if (row.active_transfers && row.active_transfers.length > 0) {
for (let i = 0; i < row.active_transfers.length; i++) {
if (i > 0){
result+=". ";
}
} else {
if (transfer.operation_type === 'upload'){
result = $.t('connections.upload', {path: path});
let transfer = row.active_transfers[i];
let path = escapeHTML(transfer.path);
let elapsed = row.current_time - transfer.start_time;
if (elapsed > 0 && transfer.size > 0) {
let speed = (transfer.size * 1.0) / (elapsed / 1000.0);
if (transfer.operation_type === 'upload') {
result += $.t('connections.upload_info', { path: path, size: fileSizeIEC(transfer.size), speed: humanizeSpeed(speed) });
} else {
result += $.t('connections.download_info', { path: path, size: fileSizeIEC(transfer.size), speed: humanizeSpeed(speed) });
}
} else {
result = $.t('connections.download', {path: path});
if (transfer.operation_type === 'upload') {
result += $.t('connections.upload', { path: path });
} else {
result += $.t('connections.download', { path: path });
}
}
}
}