import PropTypes from 'prop-types'; import ExclamationTriangle from '@heroicons/react/24/solid/ExclamationTriangleIcon'; import Signal from '@heroicons/react/24/solid/SignalIcon'; import Image from 'next/image'; import { Avatar, Box, Card, CardContent, LinearProgress, Stack, SvgIcon, Typography } from '@mui/material'; export const OverviewTasksProgress = (props) => { var { value, mtp, sx, type } = props; var valueRaw; if( value !== undefined) { valueRaw = value.substring(1); console.log("rtt:", valueRaw) } const formatMilliseconds = (timeString) => { if (timeString === "") { return ""; } // Regular expression to extract value and unit const regex = /^(\d+(\.\d+)?)\s*([mµ]?s|s)?$/; // Extract value and unit const matches = timeString.match(regex); if (!matches) { return "Invalid time format"; } let value = parseFloat(matches[1]); const unit = matches[3] || "ms"; // Convert units to milliseconds switch (unit) { case "s": value *= 1000; break; case "µs": value /= 1000; break; default: // For "ms", do nothing break; } // Round the number to two decimal places const roundedValue = value.toFixed(2); return `${roundedValue}ms`; } const showIcon = (mtpType) => { if (valueRaw === "") { return } switch (mtpType) { case "mqtt": return case "stomp": return STOMP; case "websocket": return WebSocket; default: return ; } } return ( {mtp} {formatMilliseconds(valueRaw)} {showIcon(type)} ); }; OverviewTasksProgress.propTypes = { value: PropTypes.string.isRequired, sx: PropTypes.object };