minor fixes

This commit is contained in:
Panayiotis Lipiridis 2021-02-07 12:11:59 +02:00
parent b778035854
commit 3b11b1d9d3
3 changed files with 14 additions and 12 deletions

View File

@ -31,6 +31,7 @@
} }
tr { tr {
td:nth-child(2) { td:nth-child(2) {
padding-left: 8px;
min-width: 24px; min-width: 24px;
text-align: right; text-align: right;
} }

View File

@ -227,9 +227,12 @@
}, },
"stats": { "stats": {
"angle": "Angle", "angle": "Angle",
"collaboration": "Collaboration",
"collaborators": "Collaborators",
"element": "Element", "element": "Element",
"elements": "Elements", "elements": "Elements",
"height": "Height", "height": "Height",
"networkSpeed": "Network speed",
"scene": "Scene", "scene": "Scene",
"selected": "Selected", "selected": "Selected",
"storage": "Storage", "storage": "Storage",
@ -238,10 +241,7 @@
"version": "Version", "version": "Version",
"versionCopy": "Click to copy", "versionCopy": "Click to copy",
"versionNotAvailable": "Version not available", "versionNotAvailable": "Version not available",
"width": "Width", "width": "Width"
"collaboration": "Collaboration",
"networkSpeed": "Network Speed",
"collaborators": "Collaborators"
}, },
"toast": { "toast": {
"copyStyles": "Copied styles.", "copyStyles": "Copied styles.",

View File

@ -1,16 +1,17 @@
const IMAGE_URL = "https://portal.excalidraw.com/test128.png"; const IMAGE_URL = `${process.env.REACT_APP_SOCKET_SERVER_URL}/test128.png`;
const IMAGE_SIZE = 35747; // in bytes const IMAGE_SIZE_BYTES = 35747;
const calculateSpeed = (startTime: number, endTime: number) => { const calculateSpeed = (startTime: number, endTime: number) => {
const duration = (endTime - startTime) / 1000; const duration = (endTime - startTime) / 1000;
const imageSizeInBits = IMAGE_SIZE * 8; const imageSizeInBits = IMAGE_SIZE_BYTES * 8;
let speed = imageSizeInBits / duration; let speed = imageSizeInBits / duration;
const suffix = ["bps", "kbps", "mbps", "gbps"]; const suffix = ["B/s", "kB/s", "MB/s", "GB/s"];
let index = 0; let index = 0;
while (speed > 1024) { while (speed > 1000) {
index++; index++;
speed = speed / 1024; speed = speed / 1000;
} }
return `${speed.toFixed(2)} ${suffix[index]}`; return `${speed.toFixed(index > 1 ? 1 : 0)} ${suffix[index]}`;
}; };
const processImage = (): Promise<string> => { const processImage = (): Promise<string> => {
@ -28,7 +29,7 @@ const processImage = (): Promise<string> => {
}; };
const startTime = new Date().getTime(); const startTime = new Date().getTime();
image.src = `${IMAGE_URL}?t=${startTime}`; // start time acts as a cache buster so everytime new url is requested image.src = `${IMAGE_URL}?t=${startTime}`;
}); });
}; };
export const getNetworkSpeed = async (): Promise<string> => { export const getNetworkSpeed = async (): Promise<string> => {