import React from 'react'; import Typography from 'antd/lib/typography'; import Progress from 'antd/lib/progress'; import Icon from 'antd/lib/icon'; import { Crawler, Browser } from 'test-crawler-core'; import { duration } from 'moment'; import 'moment-duration-format'; import { timestampToString } from '../utils'; import { SwitchStatus } from './SwitchStatus'; import { getViewportName } from '../viewport'; import { ProjectName } from '../projects/ProjectName'; import { StorageType } from '../server/storage.typing'; const { Title } = Typography; const warningStyle = { color: '#faad29', }; const limitStyle = { color: '#999', fontSize: 11, }; interface Props { setCrawler: React.Dispatch>; crawler: Crawler; projectId: string; storageType: StorageType; } // need to flatten props and use react memo export const CrawlerInfo = ({ crawler: { timestamp, url, browser, diffZoneCount, errorCount, status, urlsCount, inQueue, startAt, lastUpdate, limit, viewport, }, projectId, storageType, setCrawler, }: Props) => { const total = urlsCount + inQueue; const percent = Math.floor((urlsCount / total) * 100); const screen = getViewportName(viewport); return ( <> {timestampToString(timestamp)} {(diffZoneCount > 0 || errorCount > 0) && (

)}

URL: {url}

Browser: {browser || Browser.ChromePuppeteer}

Screen: {screen}

URL crawled: {urlsCount} {limit !== undefined && limit > 0 && ( (with limit set to {limit}) )}

Duration:{' '} {duration(lastUpdate - startAt).format( 'h [hrs], m [min], s [sec]', )}

{inQueue > 0 && ( <>

In queue: {inQueue}

)} {errorCount > 0 && (

{errorCount} error(s) founds

)} ); };