F #3951: Add more info to ds, vnet and host cards (#957)

This commit is contained in:
Sergio Betanzos authored and GitHub committed 2021-03-12 11:38:31 +01:00
1 parent d22d34da4e
commit f5a9aafd76
14 files changed
+426 -255

No files matched your search

@@ -4,25 +4,43 @@ import PropTypes from 'prop-types'
import { makeStyles, Typography } from '@material-ui/core'
import DatastoreIcon from '@material-ui/icons/FolderOpen'
import SelectCard from 'client/components/Cards/SelectCard'
import { StatusBadge, StatusChip } from 'client/components/Status'
import SelectCard, { Action } from 'client/components/Cards/SelectCard'
import { StatusBadge, StatusChip, LinearProgressWithLabel } from 'client/components/Status'
import { prettyBytes } from 'client/utils'
import Datastore from 'client/constants/datastore'
const useStyles = makeStyles(() => ({
title: { display: 'flex', gap: '0.5rem' }
const useStyles = makeStyles(({
title: {
display: 'flex',
gap: '0.5rem'
},
content: {
padding: '2em',
display: 'flex',
flexFlow: 'column',
gap: '1em'
}
}))
const DatastoreCard = memo(
({ value, isSelected, handleClick, actions }) => {
const classes = useStyles()
const { ID, NAME, TYPE, STATE } = value
const { ID, NAME, TYPE, STATE, TOTAL_MB, USED_MB } = value
const type = Datastore.TYPES[TYPE]
const state = Datastore.STATES[STATE]
const percentOfUsed = +USED_MB * 100 / +TOTAL_MB || 0
const usedBytes = prettyBytes(+USED_MB, 'MB')
const totalBytes = prettyBytes(+TOTAL_MB, 'MB')
const percentLabel = `${usedBytes} / ${totalBytes} (${Math.round(percentOfUsed)}%)`
return (
<SelectCard
stylesProps={{ minHeight: 160 }}
action={actions?.map(action =>
<Action key={action?.cy} {...action} />
)}
icon={
<StatusBadge stateColor={state.color}>
<DatastoreIcon />
@@ -39,8 +57,11 @@ const DatastoreCard = memo(
subheader={`#${ID}`}
isSelected={isSelected}
handleClick={handleClick}
actions={actions}
/>
>
<div className={classes.content}>
<LinearProgressWithLabel value={percentOfUsed} label={percentLabel} />
</div>
</SelectCard>
)
},
(prev, next) => (
@@ -54,7 +75,10 @@ DatastoreCard.propTypes = {
ID: PropTypes.string.isRequired,
NAME: PropTypes.string.isRequired,
TYPE: PropTypes.string,
STATE: PropTypes.string
STATE: PropTypes.string,
TOTAL_MB: PropTypes.string,
FREE_MB: PropTypes.string,
USED_MB: PropTypes.string
}),
isSelected: PropTypes.bool,
handleClick: PropTypes.func,
@@ -4,31 +4,53 @@ import PropTypes from 'prop-types'
import { makeStyles, Typography } from '@material-ui/core'
import { Computer as HostIcon } from '@material-ui/icons'
import SelectCard from 'client/components/Cards/SelectCard'
import { StatusBadge, StatusChip } from 'client/components/Status'
import SelectCard, { Action } from 'client/components/Cards/SelectCard'
import { StatusBadge, StatusChip, LinearProgressWithLabel } from 'client/components/Status'
import { prettyBytes } from 'client/utils'
import Host from 'client/constants/host'
const useStyles = makeStyles(() => ({
title: { display: 'flex', gap: '0.5rem' }
}))
const useStyles = makeStyles({
title: {
display: 'flex',
gap: '0.5rem'
},
content: {
padding: '2em',
display: 'flex',
flexFlow: 'column',
gap: '1em'
}
})
const HostCard = memo(
({ value, isSelected, handleClick, actions }) => {
const classes = useStyles()
const { ID, NAME, STATE, IM_MAD: imMad, VM_MAD: vmMad } = value
const { ID, NAME, STATE, IM_MAD, VM_MAD, HOST_SHARE } = value
const { CPU_USAGE, TOTAL_CPU, MEM_USAGE, TOTAL_MEM } = HOST_SHARE
const percentCpuUsed = +CPU_USAGE * 100 / +TOTAL_CPU || 0
const percentCpuLabel = `${CPU_USAGE} / ${TOTAL_CPU} (${Math.round(percentCpuUsed)}%)`
const percentMemUsed = +MEM_USAGE * 100 / +TOTAL_MEM || 0
const usedMemBytes = prettyBytes(+MEM_USAGE)
const totalMemBytes = prettyBytes(+TOTAL_MEM)
const percentMemLabel = `${usedMemBytes} / ${totalMemBytes} (${Math.round(percentMemUsed)}%)`
const state = Host.STATES[STATE]
const mad = imMad === vmMad ? imMad : `${imMad}/${vmMad}`
const mad = IM_MAD === VM_MAD ? IM_MAD : `${IM_MAD}/${VM_MAD}`
return (
<SelectCard
stylesProps={{ minHeight: 160 }}
action={actions?.map(action =>
<Action key={action?.cy} {...action} />
)}
icon={
<StatusBadge title={state?.name} stateColor={state.color}>
<HostIcon />
</StatusBadge>
}
title={
<span className={classes.title}>
<Typography title={NAME} noWrap component='span'>
@@ -40,8 +62,12 @@ const HostCard = memo(
subheader={`#${ID}`}
isSelected={isSelected}
handleClick={handleClick}
actions={actions}
/>
>
<div className={classes.content}>
<LinearProgressWithLabel value={percentCpuUsed} label={percentCpuLabel} />
<LinearProgressWithLabel value={percentMemUsed} label={percentMemLabel} />
</div>
</SelectCard>
)
},
(prev, next) => (
@@ -57,7 +83,13 @@ HostCard.propTypes = {
TYPE: PropTypes.string,
STATE: PropTypes.string,
IM_MAD: PropTypes.string,
VM_MAD: PropTypes.string
VM_MAD: PropTypes.string,
HOST_SHARE: PropTypes.shape({
CPU_USAGE: PropTypes.string,
TOTAL_CPU: PropTypes.string,
MEM_USAGE: PropTypes.string,
TOTAL_MEM: PropTypes.string
})
}),
isSelected: PropTypes.bool,
handleClick: PropTypes.func,
@@ -2,22 +2,35 @@ import React, { memo } from 'react'
import PropTypes from 'prop-types'
import NetworkIcon from '@material-ui/icons/AccountTree'
import SelectCard from 'client/components/Cards/SelectCard'
import SelectCard, { Action } from 'client/components/Cards/SelectCard'
import { LinearProgressWithLabel } from 'client/components/Status'
const NetworkCard = memo(
({ value, isSelected, handleClick, actions }) => {
const { ID, NAME } = value
const { ID, NAME, USED_LEASES = '', AR_POOL } = value
const addresses = [AR_POOL?.AR ?? []].flat()
const totalLeases = addresses.reduce((res, ar) => +ar.SIZE + res, 0)
const percentOfUsed = +USED_LEASES * 100 / +totalLeases || 0
const percentLabel = `${USED_LEASES} / ${totalLeases} (${Math.round(percentOfUsed)}%)`
return (
<SelectCard
stylesProps={{ minHeight: 120 }}
action={actions?.map(action =>
<Action key={action?.cy} {...action} />
)}
icon={<NetworkIcon />}
title={NAME}
subheader={`#${ID}`}
isSelected={isSelected}
handleClick={handleClick}
actions={actions}
/>
>
<div style={{ padding: '2em' }}>
<LinearProgressWithLabel value={percentOfUsed} label={percentLabel} />
</div>
</SelectCard>
)
},
(prev, next) => prev.isSelected === next.isSelected
@@ -28,7 +41,11 @@ NetworkCard.propTypes = {
ID: PropTypes.string.isRequired,
NAME: PropTypes.string.isRequired,
TYPE: PropTypes.string,
STATE: PropTypes.string
STATE: PropTypes.string,
USED_LEASES: PropTypes.string,
AR_POOL: PropTypes.shape({
AR: PropTypes.oneOfType([PropTypes.object, PropTypes.array])
})
}),
isSelected: PropTypes.bool,
handleClick: PropTypes.func,
@@ -4,8 +4,7 @@ import PropTypes from 'prop-types'
import ProviderIcon from '@material-ui/icons/Public'
import ProvisionIcon from '@material-ui/icons/Cloud'
import SelectCard from 'client/components/Cards/SelectCard'
import Action from 'client/components/Cards/SelectCard/Action'
import SelectCard, { Action } from 'client/components/Cards/SelectCard'
import { StatusBadge } from 'client/components/Status'
import Image from 'client/components/Image'
import { isExternalURL } from 'client/utils'
@@ -0,0 +1,210 @@
import React, { memo } from 'react'
import PropTypes from 'prop-types'
import clsx from 'clsx'
import {
Card, CardActionArea, CardHeader, CardActions, CardMedia
} from '@material-ui/core'
import { Skeleton } from '@material-ui/lab'
import useNearScreen from 'client/hooks/useNearScreen'
import ConditionalWrap from 'client/components/HOC/ConditionalWrap'
import { Action } from 'client/components/Cards/SelectCard'
import selectCardStyles from 'client/components/Cards/SelectCard/styles'
const SelectCard = memo(({
action,
actions,
cardActionsProps,
cardHeaderProps,
cardProps,
cardActionAreaProps,
children,
dataCy,
disableFilterImage,
handleClick,
icon,
isSelected,
mediaProps,
observerOff,
stylesProps,
subheader,
title
}) => {
const classes = selectCardStyles({ ...stylesProps, isSelected, disableFilterImage })
const { isNearScreen, fromRef } = useNearScreen({
distance: '100px'
})
return (
<ConditionalWrap
condition={!observerOff}
wrap={children => <span ref={fromRef}>{children}</span>}>
{observerOff || isNearScreen ? (
<Card
{...cardProps}
className={clsx(classes.root, cardProps?.className, {
[classes.actionArea]: !handleClick
})}
data-cy={dataCy ? `${dataCy}-card` : undefined}
>
{/* CARD ACTION AREA */}
<ConditionalWrap
condition={handleClick && !action}
wrap={children =>
<CardActionArea
{...cardActionAreaProps}
className={clsx(classes.actionArea, cardActionAreaProps?.className)}
onClick={handleClick}
data-cy={(dataCy && isSelected) && `${dataCy}-card-selected`}
>
{children}
</CardActionArea>
}
>
{/* CARD HEADER */}
{(title || subheader || icon || action) && (
<CardHeader
{...cardHeaderProps}
action={action}
avatar={icon}
classes={{
root: classes.headerRoot,
content: classes.headerContent,
avatar: classes.headerAvatar
}}
title={title}
titleTypographyProps={{
variant: 'body1',
noWrap: true,
className: classes.header,
title: typeof title === 'string' ? title : undefined,
...(dataCy) && { 'data-cy': `${dataCy}-card-title` }
}}
subheader={subheader}
subheaderTypographyProps={{
variant: 'body2',
noWrap: true,
className: classes.subheader,
title: typeof subheader === 'string' ? subheader : undefined,
...(dataCy) && { 'data-cy': `${dataCy}-card-subheader` }
}}
{...cardHeaderProps}
/>
)}
{/* CARD CONTENT */}
{children}
{/* CARD MEDIA */}
{mediaProps && (
<ConditionalWrap
condition={handleClick && action}
wrap={children =>
<CardActionArea
className={classes.mediaActionArea}
onClick={handleClick}
>
{children}
</CardActionArea>
}
>
<CardMedia className={classes.media} {...mediaProps} />
</ConditionalWrap>
)}
{/* CARD ACTIONS */}
{actions?.length > 0 && (
<CardActions {...cardActionsProps}>
{actions?.map(action => (
<Action key={action?.cy} {...action} />
))}
</CardActions>
)}
</ConditionalWrap>
</Card>
) : (
<Skeleton
variant="rect"
width="100%"
height={140}
/>
)}
</ConditionalWrap>
)
})
SelectCard.propTypes = {
stylesProps: PropTypes.object,
action: PropTypes.node,
actions: PropTypes.arrayOf(
PropTypes.shape({
handleClick: PropTypes.func.isRequired,
icon: PropTypes.node.isRequired,
cy: PropTypes.string
})
),
cardActionsProps: PropTypes.shape({
className: PropTypes.string,
style: PropTypes.object
}),
icon: PropTypes.oneOfType([
PropTypes.string,
PropTypes.object
]),
title: PropTypes.oneOfType([
PropTypes.string,
PropTypes.object
]),
subheader: PropTypes.oneOfType([
PropTypes.string,
PropTypes.object
]),
cardHeaderProps: PropTypes.object,
mediaProps: PropTypes.shape({
classes: PropTypes.object,
className: PropTypes.string,
component: PropTypes.elementType,
image: PropTypes.string,
src: PropTypes.string,
style: PropTypes.object
}),
isSelected: PropTypes.bool,
handleClick: PropTypes.func,
cardProps: PropTypes.object,
cardActionAreaProps: PropTypes.object,
observerOff: PropTypes.bool,
children: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.node),
PropTypes.node,
PropTypes.string
]),
dataCy: PropTypes.string,
disableFilterImage: PropTypes.bool
}
SelectCard.defaultProps = {
action: undefined,
actions: undefined,
cardActionsProps: undefined,
cardHeaderProps: undefined,
cardProps: {},
cardActionAreaProps: {},
children: undefined,
dataCy: undefined,
disableFilterImage: false,
handleClick: undefined,
icon: undefined,
isSelected: false,
mediaProps: undefined,
observerOff: false,
stylesProps: undefined,
subheader: undefined,
title: undefined
}
SelectCard.displayName = 'SelectCard'
export default SelectCard
@@ -1,209 +1,6 @@
import React, { memo } from 'react'
import PropTypes from 'prop-types'
import clsx from 'clsx'
import {
Card, CardActionArea, CardHeader, CardActions, CardMedia
} from '@material-ui/core'
import { Skeleton } from '@material-ui/lab'
import useNearScreen from 'client/hooks/useNearScreen'
import ConditionalWrap from 'client/components/HOC/ConditionalWrap'
import SelectCard from 'client/components/Cards/SelectCard/SelectCard'
import Action from 'client/components/Cards/SelectCard/Action'
import selectCardStyles from 'client/components/Cards/SelectCard/styles'
const SelectCard = memo(({
action,
actions,
cardActionsProps,
cardHeaderProps,
cardProps,
cardActionAreaProps,
children,
dataCy,
disableFilterImage,
handleClick,
icon,
isSelected,
mediaProps,
observerOff,
stylesProps,
subheader,
title
}) => {
const classes = selectCardStyles({ ...stylesProps, isSelected, disableFilterImage })
const { isNearScreen, fromRef } = useNearScreen({
distance: '100px'
})
return (
<ConditionalWrap
condition={!observerOff}
wrap={children => <span ref={fromRef}>{children}</span>}>
{observerOff || isNearScreen ? (
<Card
{...cardProps}
className={clsx(classes.root, cardProps?.className, {
[classes.actionArea]: !handleClick
})}
data-cy={dataCy ? `${dataCy}-card` : undefined}
>
{/* CARD ACTION AREA */}
<ConditionalWrap
condition={handleClick && !action}
wrap={children =>
<CardActionArea
{...cardActionAreaProps}
className={clsx(classes.actionArea, cardActionAreaProps?.className)}
onClick={handleClick}
data-cy={(dataCy && isSelected) && `${dataCy}-card-selected`}
>
{children}
</CardActionArea>
}
>
{/* CARD HEADER */}
{(title || subheader || icon || action) && (
<CardHeader
{...cardHeaderProps}
action={action}
avatar={icon}
classes={{
root: classes.headerRoot,
content: classes.headerContent,
avatar: classes.headerAvatar
}}
title={title}
titleTypographyProps={{
variant: 'body1',
noWrap: true,
className: classes.header,
title: typeof title === 'string' ? title : undefined,
...(dataCy) && { 'data-cy': `${dataCy}-card-title` }
}}
subheader={subheader}
subheaderTypographyProps={{
variant: 'body2',
noWrap: true,
className: classes.subheader,
title: typeof subheader === 'string' ? subheader : undefined,
...(dataCy) && { 'data-cy': `${dataCy}-card-subheader` }
}}
{...cardHeaderProps}
/>
)}
{/* CARD CONTENT */}
{children}
{/* CARD MEDIA */}
{mediaProps && (
<ConditionalWrap
condition={handleClick && action}
wrap={children =>
<CardActionArea
className={classes.mediaActionArea}
onClick={handleClick}
>
{children}
</CardActionArea>
}
>
<CardMedia className={classes.media} {...mediaProps} />
</ConditionalWrap>
)}
{/* CARD ACTIONS */}
{actions?.length > 0 && (
<CardActions {...cardActionsProps}>
{actions?.map(action => (
<Action key={action?.cy} {...action} />
))}
</CardActions>
)}
</ConditionalWrap>
</Card>
) : (
<Skeleton
variant="rect"
width="100%"
height={stylesProps?.minHeight ?? 140}
/>
)}
</ConditionalWrap>
)
})
SelectCard.propTypes = {
stylesProps: PropTypes.object,
action: PropTypes.node,
actions: PropTypes.arrayOf(
PropTypes.shape({
handleClick: PropTypes.func.isRequired,
icon: PropTypes.node.isRequired,
cy: PropTypes.string
})
),
cardActionsProps: PropTypes.shape({
className: PropTypes.string,
style: PropTypes.object
}),
icon: PropTypes.oneOfType([
PropTypes.string,
PropTypes.object
]),
title: PropTypes.oneOfType([
PropTypes.string,
PropTypes.object
]),
subheader: PropTypes.oneOfType([
PropTypes.string,
PropTypes.object
]),
cardHeaderProps: PropTypes.object,
mediaProps: PropTypes.shape({
classes: PropTypes.object,
className: PropTypes.string,
component: PropTypes.elementType,
image: PropTypes.string,
src: PropTypes.string,
style: PropTypes.object
}),
isSelected: PropTypes.bool,
handleClick: PropTypes.func,
cardProps: PropTypes.object,
cardActionAreaProps: PropTypes.object,
observerOff: PropTypes.bool,
children: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.node),
PropTypes.node,
PropTypes.string
]),
dataCy: PropTypes.string,
disableFilterImage: PropTypes.bool
}
SelectCard.defaultProps = {
action: undefined,
actions: undefined,
cardActionsProps: undefined,
cardHeaderProps: undefined,
cardProps: {},
cardActionAreaProps: {},
children: undefined,
dataCy: undefined,
disableFilterImage: false,
handleClick: undefined,
icon: undefined,
isSelected: false,
mediaProps: undefined,
observerOff: false,
stylesProps: undefined,
subheader: undefined,
title: undefined
}
SelectCard.displayName = 'SelectCard'
export { Action }
export default SelectCard
@@ -0,0 +1,35 @@
import React, { memo } from 'react'
import PropTypes from 'prop-types'
import { withStyles } from '@material-ui/core/styles'
import { Typography, LinearProgress } from '@material-ui/core'
const BorderLinearProgress = withStyles(({ palette }) => ({
root: {
height: 15,
borderRadius: 5
},
colorPrimary: {
backgroundColor: palette.grey[palette.type === 'light' ? 200 : 700]
},
bar: {
borderRadius: 5,
backgroundColor: palette.primary.main
}
}))(LinearProgress)
const LinearProgressWithLabel = memo(({ value, label }) => (
<div style={{ textAlign: 'end' }}>
<Typography component='span' variant='body2'>{label}</Typography>
<BorderLinearProgress variant='determinate' value={value} />
</div>
), (prev, next) => prev.value === next.value && prev.label === next.label)
LinearProgressWithLabel.propTypes = {
value: PropTypes.number.isRequired,
label: PropTypes.string.isRequired
}
LinearProgressWithLabel.displayName = 'LinearProgressWithLabel'
export default LinearProgressWithLabel
@@ -1,7 +1,9 @@
import StatusBadge from 'client/components/Status/Badge'
import StatusChip from 'client/components/Status/Chip'
import LinearProgressWithLabel from 'client/components/Status/LinearProgressWithLabel'
export {
StatusBadge,
StatusChip
StatusChip,
LinearProgressWithLabel
}
@@ -18,8 +18,13 @@ import React, { useState, useEffect, memo } from 'react'
import { Button, makeStyles } from '@material-ui/core'
import { useSocket } from 'client/hooks'
const useStyles = makeStyles(() => ({
sticky: { position: 'sticky', top: 0, backgroundColor: '#fafafa' },
const useStyles = makeStyles(theme => ({
sticky: {
position: 'sticky',
top: 0,
padding: '1em',
backgroundColor: theme.palette.background.paper
},
loading: {
'&::after': {
overflow: 'hidden',
+20 -7
View File
@@ -3,8 +3,21 @@ import {
FormatListBulleted as TemplatesIcons,
Apps as InstancesIcons
} from '@material-ui/icons'
import loadable from '@loadable/component'
const Login = loadable(() => import('client/containers/Login'), { ssr: false })
const Dashboard = loadable(() => import('client/containers/Dashboard'), { ssr: false })
const Settings = loadable(() => import('client/containers/Settings'), { ssr: false })
const ApplicationsTemplates = loadable(() => import('client/containers/ApplicationsTemplates'), { ssr: false })
const ApplicationsInstances = loadable(() => import('client/containers/ApplicationsInstances'), { ssr: false })
const ApplicationsTemplatesFormCreate = loadable(
() => import('client/containers/ApplicationsTemplates/Form/Create'),
{ ssr: false }
)
export const PATH = {
LOGIN: '/',
DASHBOARD: '/dashboard',
@@ -24,7 +37,7 @@ export const ENDPOINTS = [
label: 'Login',
path: PATH.LOGIN,
authenticated: false,
Component: loadable(() => import('client/containers/Login'))
Component: Login
},
{
label: 'Dashboard',
@@ -32,14 +45,14 @@ export const ENDPOINTS = [
authenticated: true,
sidebar: true,
icon: DashboardIcon,
Component: loadable(() => import('client/containers/Dashboard'))
Component: Dashboard
},
{
label: 'Settings',
path: PATH.SETTINGS,
authenticated: true,
header: true,
Component: loadable(() => import('client/containers/Settings'), { ssr: false })
Component: Settings
},
{
label: 'Templates',
@@ -47,19 +60,19 @@ export const ENDPOINTS = [
authenticated: true,
sidebar: true,
icon: TemplatesIcons,
Component: loadable(() => import('client/containers/ApplicationsTemplates'), { ssr: false })
Component: ApplicationsTemplates
},
{
label: 'Create Application template',
path: PATH.APPLICATIONS_TEMPLATES.CREATE,
authenticated: true,
Component: loadable(() => import('client/containers/ApplicationsTemplates/Form/Create'), { ssr: false })
Component: ApplicationsTemplatesFormCreate
},
{
label: 'Edit Application template',
path: PATH.APPLICATIONS_TEMPLATES.EDIT,
authenticated: true,
Component: loadable(() => import('client/containers/ApplicationsTemplates/Form/Create'), { ssr: false })
Component: ApplicationsTemplatesFormCreate
},
{
label: 'Instances',
@@ -67,7 +80,7 @@ export const ENDPOINTS = [
authenticated: true,
sidebar: true,
icon: InstancesIcons,
Component: loadable(() => import('client/containers/ApplicationsInstances'), { ssr: false })
Component: ApplicationsInstances
}
]
+4 -1
View File
@@ -71,7 +71,10 @@ Router.propTypes = {
authenticated: PropTypes.bool.isRequired,
sidebar: PropTypes.bool,
icon: PropTypes.object,
Component: PropTypes.func.isRequired
Component: PropTypes.oneOfType([
PropTypes.func,
PropTypes.object
]).isRequired
})
)
})
+21 -9
View File
@@ -4,8 +4,20 @@ import {
SettingsSystemDaydream as ProvisionsIcon,
Settings as SettingsIcon
} from '@material-ui/icons'
import loadable from '@loadable/component'
const Login = loadable(() => import('client/containers/Login'), { ssr: false })
const Dashboard = loadable(() => import('client/containers/Dashboard/Provision'), { ssr: false })
const Providers = loadable(() => import('client/containers/Providers'), { ssr: false })
const ProvidersFormCreate = loadable(() => import('client/containers/Providers/Form/Create'), { ssr: false })
const Provisions = loadable(() => import('client/containers/Provisions'), { ssr: false })
const ProvisionsFormCreate = loadable(() => import('client/containers/Provisions/Form/Create'), { ssr: false })
const Settings = loadable(() => import('client/containers/Settings'), { ssr: false })
export const PATH = {
LOGIN: '/',
DASHBOARD: '/dashboard',
@@ -28,7 +40,7 @@ export const ENDPOINTS = [
label: 'Login',
path: PATH.LOGIN,
authenticated: false,
Component: loadable(() => import('client/containers/Login'))
Component: Login
},
{
label: 'Dashboard',
@@ -36,7 +48,7 @@ export const ENDPOINTS = [
authenticated: true,
sidebar: true,
icon: DashboardIcon,
Component: loadable(() => import('client/containers/Dashboard/Provision'))
Component: Dashboard
},
{
label: 'Providers',
@@ -44,19 +56,19 @@ export const ENDPOINTS = [
authenticated: true,
sidebar: true,
icon: ProvidersIcon,
Component: loadable(() => import('client/containers/Providers'), { ssr: false })
Component: Providers
},
{
label: 'Create Provider',
path: PATH.PROVIDERS.CREATE,
authenticated: true,
Component: loadable(() => import('client/containers/Providers/Form/Create'), { ssr: false })
Component: ProvidersFormCreate
},
{
label: 'Edit Provider template',
path: PATH.PROVIDERS.EDIT,
authenticated: true,
Component: loadable(() => import('client/containers/Providers/Form/Create'), { ssr: false })
Component: ProvidersFormCreate
},
{
label: 'Provisions',
@@ -64,19 +76,19 @@ export const ENDPOINTS = [
authenticated: true,
sidebar: true,
icon: ProvisionsIcon,
Component: loadable(() => import('client/containers/Provisions'), { ssr: false })
Component: Provisions
},
{
label: 'Create Provision',
path: PATH.PROVISIONS.CREATE,
authenticated: true,
Component: loadable(() => import('client/containers/Provisions/Form/Create'), { ssr: false })
Component: ProvisionsFormCreate
},
{
label: 'Edit Provision template',
path: PATH.PROVISIONS.EDIT,
authenticated: true,
Component: loadable(() => import('client/containers/Provisions/Form/Create'), { ssr: false })
Component: ProvisionsFormCreate
},
{
label: 'Settings',
@@ -84,7 +96,7 @@ export const ENDPOINTS = [
authenticated: true,
sidebar: true,
icon: SettingsIcon,
Component: loadable(() => import('client/containers/Settings'), { ssr: false })
Component: Settings
}
]
+22
View File
@@ -11,6 +11,28 @@ export function sanitize (strings, ...values) {
return DOMPurify.sanitize(dirty)
}
/**
* Converts a long string of units into a readable format e.g KB, MB, GB, TB, YB
*
* @param {Int} value The quantity of units.
* @param {String} unit The unit of value.
* @param {Int} fractionDigits — Number of digits after the decimal point. Must be in the range 0 - 20, inclusive
*/
export const prettyBytes = (value, unit = 'KB', fractionDigits = 0) => {
const UNITS = ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
if (Math.abs(value) === 0) return `${value} ${UNITS[0]}`
let idxUnit = UNITS.indexOf(unit)
while (value > 1024) {
value /= 1024
idxUnit += 1
}
return `${value.toFixed(fractionDigits)} ${UNITS[idxUnit]}`
}
export const addOpacityToColor = (color, opacity) => {
const opacityHex = Math.round(opacity * 255).toString(16)
return `${color}${opacityHex}`
@@ -32,7 +32,7 @@ const router = Router()
router.get('*', (req, res) => {
let app = 'dev'
let title = 'fireedge'
let title = 'FireEdge'
const context = {}
let store = ''
let component = ''