Add progress percent to export table

This commit is contained in:
JonnyWong16 2020-10-15 21:56:20 -07:00
parent 39d6edd581
commit 44c643d7da
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
5 changed files with 72 additions and 16 deletions

View file

@ -336,6 +336,18 @@ String.prototype.toProperCase = function () {
});
};
function getPercent(value1, value2) {
value1 = parseFloat(value1) | 0
value2 = parseFloat(value2) | 0
var percent = 0;
if (value1 !== 0 && value2 !== 0) {
percent = (value1 / value2) * 100
}
return Math.round(percent)
}
function millisecondsToMinutes(ms, roundToMinute) {
if (ms > 0) {
var minutes = Math.floor(ms / 60000);

View file

@ -167,7 +167,8 @@ export_table_options = {
var icon = (rowData['thumb_level'] || rowData['art_level'] || rowData['individual_files']) ? 'fa-file-archive' : 'fa-file-download';
$(td).html('<button class="btn btn-xs btn-success pull-left" data-id="' + rowData['export_id'] + '"><span data-toggle="tooltip" data-placement="left" title="' + tooltip_title + '"><i class="fa ' + icon + ' fa-fw"></i> Download</span></button>');
} else if (cellData === 0) {
$(td).html('<span class="btn btn-xs btn-dark pull-left export-processing" data-id="' + rowData['export_id'] + '" disabled><i class="fa fa-spinner fa-spin fa-fw"></i> Processing</span>');
var percent = Math.min(getPercent(rowData['exported_items'], rowData['total_items']), 99)
$(td).html('<span class="btn btn-xs btn-dark pull-left export-processing" data-id="' + rowData['export_id'] + '" disabled><i class="fa fa-spinner fa-spin fa-fw"></i> ' + percent + '%</span>');
} else if (cellData === -1) {
$(td).html('<span class="btn btn-xs btn-dark pull-left" data-id="' + rowData['export_id'] + '" disabled><i class="fa fa-exclamation-circle fa-fw"></i> Failed</span>');
} else {