From 3b11b1d9d33349a0f002f2f313cc482d46267ae6 Mon Sep 17 00:00:00 2001 From: Panayiotis Lipiridis Date: Sun, 7 Feb 2021 12:11:59 +0200 Subject: [PATCH] minor fixes --- src/components/Stats.scss | 1 + src/locales/en.json | 8 ++++---- src/networkStats.ts | 17 +++++++++-------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/components/Stats.scss b/src/components/Stats.scss index 84864f933..a7a449f85 100644 --- a/src/components/Stats.scss +++ b/src/components/Stats.scss @@ -31,6 +31,7 @@ } tr { td:nth-child(2) { + padding-left: 8px; min-width: 24px; text-align: right; } diff --git a/src/locales/en.json b/src/locales/en.json index 18a88878e..b9612a4bc 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -227,9 +227,12 @@ }, "stats": { "angle": "Angle", + "collaboration": "Collaboration", + "collaborators": "Collaborators", "element": "Element", "elements": "Elements", "height": "Height", + "networkSpeed": "Network speed", "scene": "Scene", "selected": "Selected", "storage": "Storage", @@ -238,10 +241,7 @@ "version": "Version", "versionCopy": "Click to copy", "versionNotAvailable": "Version not available", - "width": "Width", - "collaboration": "Collaboration", - "networkSpeed": "Network Speed", - "collaborators": "Collaborators" + "width": "Width" }, "toast": { "copyStyles": "Copied styles.", diff --git a/src/networkStats.ts b/src/networkStats.ts index 1e359508a..db51b4498 100644 --- a/src/networkStats.ts +++ b/src/networkStats.ts @@ -1,16 +1,17 @@ -const IMAGE_URL = "https://portal.excalidraw.com/test128.png"; -const IMAGE_SIZE = 35747; // in bytes +const IMAGE_URL = `${process.env.REACT_APP_SOCKET_SERVER_URL}/test128.png`; +const IMAGE_SIZE_BYTES = 35747; + const calculateSpeed = (startTime: number, endTime: number) => { const duration = (endTime - startTime) / 1000; - const imageSizeInBits = IMAGE_SIZE * 8; + const imageSizeInBits = IMAGE_SIZE_BYTES * 8; let speed = imageSizeInBits / duration; - const suffix = ["bps", "kbps", "mbps", "gbps"]; + const suffix = ["B/s", "kB/s", "MB/s", "GB/s"]; let index = 0; - while (speed > 1024) { + while (speed > 1000) { 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 => { @@ -28,7 +29,7 @@ const processImage = (): Promise => { }; 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 => {