import React from 'react'; import PropTypes from 'prop-types'; import { CCard, CCardBody, CCardHeader, CCol, CPopover, CRow, CSpinner, CWidgetIcon, } from '@coreui/react'; import { CChartBar, CChartHorizontalBar, CChartPie } from '@coreui/react-chartjs'; import { cilClock, cilInfo, cilMedicalCross, cilThumbUp, cilWarning } from '@coreui/icons'; import CIcon from '@coreui/icons-react'; import { FormattedDate } from 'ucentral-libs'; import styles from './index.module.scss'; const getColor = (health) => { const numberHealth = health ? Number(health.replace('%', '')) : 0; if (numberHealth >= 90) return 'success'; if (numberHealth >= 60) return 'warning'; return 'danger'; }; const getIcon = (health) => { const numberHealth = health ? Number(health.replace('%', '')) : 0; if (numberHealth >= 90) return ; if (numberHealth >= 60) return ; return ; }; const DeviceDashboard = ({ t, data, loading }) => (
:

-

} color="info" iconPadding={false} >
{t('common.overall_health')}
} header={

{data.overallHealth}

} color={getColor(data.overallHealth)} iconPadding={false} > {getIcon(data.overallHealth)}
{t('common.devices')}
} header={

{data.numberOfDevices}

} color="primary" iconPadding={false} > {t('common.device_status')} ds.labels[item[0].index], label: (item, ds) => `${ds.datasets[0].data[item.index]} devices, (${ data.statusDevices[ds.datasets[0].data[item.index]] }%)`, }, }, legend: { display: true, position: 'right', }, }} />
{t('common.device_health')}
ds.labels[item[0].index], label: (item, ds) => `${ds.datasets[0].data[item.index]} connected devices (${ data.healthDevices[ds.datasets[0].data[item.index]] }%)`, }, }, legend: { display: true, position: 'right', }, }} />
{data.totalAssociations}{' '} {data.totalAssociations === 1 ? t('wifi_analysis.association') : t('wifi_analysis.associations')} ds.labels[item[0].index], label: (item, ds) => `${ds.datasets[0].data[item.index]} associations (${ data.associationData[ds.datasets[0].data[item.index]] }%)`, }, }, legend: { display: true, position: 'right', }, }} /> {t('common.vendors')} ds.labels[item[0].index], label: (item, ds) => `${ds.datasets[0].data[item.index]} ${t('common.devices')}`, }, }, hover: { mode: 'index', intersect: false, }, legend: { display: false, position: 'right', }, scales: { xAxes: [ { ticks: { maxTicksLimit: 5, beginAtZero: true, stepSize: 1, }, }, ], yAxes: [ { ticks: { callback: (value) => value.split(' ')[0], }, }, ], }, }} /> {t('firmware.device_types')} ds.labels[item[0].index], label: (item, ds) => `${ds.datasets[0].data[item.index]} ${t('common.devices')}`, }, }, legend: { display: true, position: 'right', }, }} />
{t('common.uptimes')}
ds.labels[item[0].index], label: (item, ds) => `${ds.datasets[0].data[item.index]} ${t('common.devices')}`, }, }, hover: { mode: 'index', intersect: false, }, legend: { display: false, position: 'right', }, scales: { yAxes: [ { ticks: { maxTicksLimit: 5, beginAtZero: true, stepSize: 1, }, }, ], }, }} />
{t('common.certificates')}
ds.labels[item[0].index], label: (item, ds) => `${ds.datasets[0].data[item.index]} connected devices (${ data.certificateData[ds.datasets[0].data[item.index]] }%)`, }, }, legend: { display: true, position: 'right', }, }} />
{t('common.commands')}
{t('common.memory_used')}
{loading ? (
) : null} ); DeviceDashboard.propTypes = { t: PropTypes.func.isRequired, data: PropTypes.instanceOf(Object).isRequired, loading: PropTypes.bool.isRequired, }; export default React.memo(DeviceDashboard);