[mirotalksfu] - add receive file info & progress

هذا الالتزام موجود في:
Miroslav Pejic
2021-10-05 20:31:43 +02:00
الأصل 91fbb4dc28
التزام 7cd75595f2
3 ملفات معدلة مع 38 إضافات و23 حذوفات

عرض الملف

@@ -187,6 +187,12 @@ access to use this app.
<button id="sendAbortBtn" class="fas fa-stop-circle">&nbsp; Abort</button> <button id="sendAbortBtn" class="fas fa-stop-circle">&nbsp; Abort</button>
</div> </div>
<div id="receiveFileDiv" class="fadein center">
<div id="receiveFileInfo"></div>
<div id="receiveFilePercentage"></div>
<progress id="receiveProgress" max="0" value="0"></progress>
</div>
<section id="participants" class="fadein center hidden"> <section id="participants" class="fadein center hidden">
<header id="participantsHeader" class="participants-header"> <header id="participantsHeader" class="participants-header">
<div id="participantsTitle" class="participants-header-title"></div> <div id="participantsTitle" class="participants-header-title"></div>

عرض الملف

@@ -92,6 +92,12 @@ body {
color: white; color: white;
background: rgba(0, 0, 0, 0.4); background: rgba(0, 0, 0, 0.4);
border-radius: 10px; border-radius: 10px;
/* pulsate */
animation: pulsate 5s ease-out;
animation-iteration-count: infinite;
-webkit-animation: pulsate 5s ease-out;
-webkit-animation-iteration-count: infinite;
opacity: 0.5;
} }
.sidenav { .sidenav {
@@ -581,7 +587,8 @@ button:hover {
# Send File # Send File
--------------------------------------------------------------*/ --------------------------------------------------------------*/
#sendFileDiv { #sendFileDiv,
#receiveFileDiv {
z-index: 7; z-index: 7;
display: none; display: none;
padding: 10px; padding: 10px;

عرض الملف

@@ -1682,41 +1682,40 @@ class RoomClient {
let fileToReceiveInfo = let fileToReceiveInfo =
' From: ' + ' From: ' +
this.incomingFileInfo.peer_name + this.incomingFileInfo.peer_name +
'\n' + html.newline +
' incoming file: ' + ' Incoming file: ' +
this.incomingFileInfo.fileName + this.incomingFileInfo.fileName +
'\n' + html.newline +
' size: ' + ' File type: ' +
this.bytesToSize(this.incomingFileInfo.fileSize) + this.incomingFileInfo.fileType +
'\n' + html.newline +
' type: ' + ' File size: ' +
this.incomingFileInfo.fileType; this.bytesToSize(this.incomingFileInfo.fileSize);
console.log(fileToReceiveInfo); receiveFileInfo.innerHTML = fileToReceiveInfo;
receiveFileDiv.style.display = 'inline';
receiveProgress.max = this.incomingFileInfo.fileSize;
this.userLog('info', fileToReceiveInfo, 'top-end'); this.userLog('info', fileToReceiveInfo, 'top-end');
} }
sendFileData() { sendFileData() {
console.log( console.log('Send file ', {
'Send file ' + name: this.fileToSend.name,
this.fileToSend.name + size: this.bytesToSize(this.fileToSend.size),
' size ' + type: this.fileToSend.type,
this.bytesToSize(this.fileToSend.size) + });
' type ' +
this.fileToSend.type,
);
this.sendInProgress = true; this.sendInProgress = true;
sendFileInfo.innerHTML = sendFileInfo.innerHTML =
'File name: ' + 'File name: ' +
this.fileToSend.name + this.fileToSend.name +
'<br>' + html.newline +
'File type: ' + 'File type: ' +
this.fileToSend.type + this.fileToSend.type +
'<br>' + html.newline +
'File size: ' + 'File size: ' +
this.bytesToSize(this.fileToSend.size) + this.bytesToSize(this.fileToSend.size) +
'<br>'; html.newline;
sendFileDiv.style.display = 'inline'; sendFileDiv.style.display = 'inline';
sendProgress.max = this.fileToSend.size; sendProgress.max = this.fileToSend.size;
@@ -1770,6 +1769,7 @@ class RoomClient {
this.receiveBuffer = []; this.receiveBuffer = [];
this.incomingFileData = []; this.incomingFileData = [];
this.receivedSize = 0; this.receivedSize = 0;
receiveFileDiv.style.display = 'none';
console.log(data.peer_name + ' aborted the file transfer'); console.log(data.peer_name + ' aborted the file transfer');
userLog('info', data.peer_name + ' ⚠️ aborted the file transfer', 'top-end'); userLog('info', data.peer_name + ' ⚠️ aborted the file transfer', 'top-end');
} }
@@ -1777,9 +1777,11 @@ class RoomClient {
handleFile(data) { handleFile(data) {
this.receiveBuffer.push(data); this.receiveBuffer.push(data);
this.receivedSize += data.byteLength; this.receivedSize += data.byteLength;
// let getPercentage = ((receivedSize / this.incomingFileInfo.fileSize) * 100).toFixed(2); receiveProgress.value = this.receivedSize;
// console.log("Received progress: " + getPercentage + "%"); receiveFilePercentage.innerHTML =
'Receive progress: ' + ((this.receivedSize / this.incomingFileInfo.fileSize) * 100).toFixed(2) + '%';
if (this.receivedSize === this.incomingFileInfo.fileSize) { if (this.receivedSize === this.incomingFileInfo.fileSize) {
receiveFileDiv.style.display = 'none';
this.incomingFileData = this.receiveBuffer; this.incomingFileData = this.receiveBuffer;
this.receiveBuffer = []; this.receiveBuffer = [];
this.endFileDownload(); this.endFileDownload();