mirror of
https://github.com/OpenNebula/one.git
synced 2026-12-06 15:13:39 +09:00
1 parent
701b9e30a7
commit
e49cb9694a
30 files changed
+562
-695
No files matched your search
@@ -4,10 +4,7 @@ import PropTypes from 'prop-types'
|
||||
import {
|
||||
makeStyles,
|
||||
Box,
|
||||
Fade,
|
||||
Button,
|
||||
Card,
|
||||
CardHeader,
|
||||
CardContent,
|
||||
CardActions,
|
||||
Chip
|
||||
@@ -16,29 +13,12 @@ import FileIcon from '@material-ui/icons/Description'
|
||||
|
||||
import { Tr } from 'client/components/HOC'
|
||||
import { APPLICATION_STATES } from 'client/constants/states'
|
||||
import SelectCard from './SelectCard'
|
||||
|
||||
const useStyles = makeStyles(theme => ({
|
||||
root: {
|
||||
height: '100%',
|
||||
minHeight: 140,
|
||||
display: 'flex',
|
||||
flexDirection: 'column'
|
||||
},
|
||||
header: {
|
||||
overflowX: 'hidden',
|
||||
flexGrow: 1
|
||||
},
|
||||
subheader: {
|
||||
overflow: 'hidden',
|
||||
textOverflow: 'ellipsis',
|
||||
whiteSpace: 'initial',
|
||||
display: '-webkit-box',
|
||||
lineClamp: 2,
|
||||
boxOrient: 'vertical'
|
||||
},
|
||||
content: {
|
||||
display: 'flex',
|
||||
gap: theme.typography.pxToRem(12)
|
||||
gap: theme.spacing(1)
|
||||
}
|
||||
}))
|
||||
|
||||
@@ -51,49 +31,33 @@ const ApplicationCard = memo(
|
||||
const stateInfo = APPLICATION_STATES[state]
|
||||
|
||||
return (
|
||||
<Fade in unmountOnExit={false}>
|
||||
<Card className={classes.root}>
|
||||
<CardHeader
|
||||
avatar={<FileIcon />}
|
||||
className={classes.header}
|
||||
classes={{ content: classes.headerContent }}
|
||||
title={`${ID} - ${NAME}`}
|
||||
titleTypographyProps={{
|
||||
variant: 'body2',
|
||||
noWrap: true,
|
||||
title: NAME
|
||||
}}
|
||||
subheader={description}
|
||||
subheaderTypographyProps={{
|
||||
variant: 'body2',
|
||||
noWrap: true,
|
||||
className: classes.subheader,
|
||||
title: description
|
||||
}}
|
||||
/>
|
||||
<CardContent>
|
||||
<Box className={classes.content}>
|
||||
<Chip
|
||||
size="small"
|
||||
label={stateInfo?.name}
|
||||
style={{ backgroundColor: stateInfo?.color }}
|
||||
/>
|
||||
</Box>
|
||||
</CardContent>
|
||||
<CardActions>
|
||||
{handleShow && (
|
||||
<Button variant="contained" size="small" onClick={handleShow} disableElevation>
|
||||
{Tr('Info')}
|
||||
</Button>
|
||||
)}
|
||||
{handleRemove && (
|
||||
<Button size="small" onClick={handleRemove} disableElevation>
|
||||
{Tr('Remove')}
|
||||
</Button>
|
||||
)}
|
||||
</CardActions>
|
||||
</Card>
|
||||
</Fade>
|
||||
<SelectCard
|
||||
icon={<FileIcon />}
|
||||
title={`${ID} - ${NAME}`}
|
||||
subheader={description}
|
||||
>
|
||||
<CardContent>
|
||||
<Box className={classes.content}>
|
||||
<Chip
|
||||
size="small"
|
||||
label={stateInfo?.name}
|
||||
style={{ backgroundColor: stateInfo?.color }}
|
||||
/>
|
||||
</Box>
|
||||
</CardContent>
|
||||
<CardActions>
|
||||
{handleShow && (
|
||||
<Button variant="contained" size="small" onClick={handleShow} disableElevation>
|
||||
{Tr('Info')}
|
||||
</Button>
|
||||
)}
|
||||
{handleRemove && (
|
||||
<Button size="small" onClick={handleRemove} disableElevation>
|
||||
{Tr('Remove')}
|
||||
</Button>
|
||||
)}
|
||||
</CardActions>
|
||||
</SelectCard>
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
@@ -4,11 +4,8 @@ import PropTypes from 'prop-types'
|
||||
import {
|
||||
makeStyles,
|
||||
Box,
|
||||
Fade,
|
||||
Badge,
|
||||
Button,
|
||||
Card,
|
||||
CardHeader,
|
||||
CardContent,
|
||||
CardActions
|
||||
} from '@material-ui/core'
|
||||
@@ -17,32 +14,13 @@ import VideogameAssetIcon from '@material-ui/icons/VideogameAsset'
|
||||
import AccountTreeIcon from '@material-ui/icons/AccountTree'
|
||||
|
||||
import { Tr } from 'client/components/HOC'
|
||||
import SelectCard from './SelectCard'
|
||||
|
||||
const useStyles = makeStyles(theme => ({
|
||||
root: {
|
||||
height: '100%',
|
||||
minHeight: 140,
|
||||
display: 'flex',
|
||||
flexDirection: 'column'
|
||||
},
|
||||
header: {
|
||||
overflowX: 'hidden',
|
||||
flexGrow: 1
|
||||
},
|
||||
subheader: {
|
||||
overflow: 'hidden',
|
||||
textOverflow: 'ellipsis',
|
||||
whiteSpace: 'initial',
|
||||
display: '-webkit-box',
|
||||
lineClamp: 2,
|
||||
boxOrient: 'vertical'
|
||||
},
|
||||
badgesWrapper: {
|
||||
display: 'flex',
|
||||
gap: theme.typography.pxToRem(12)
|
||||
},
|
||||
badge: {},
|
||||
icon: {}
|
||||
}
|
||||
}))
|
||||
|
||||
const ApplicationTemplateCard = memo(
|
||||
@@ -57,74 +35,73 @@ const ApplicationTemplateCard = memo(
|
||||
const badgePosition = { vertical: 'top', horizontal: 'right' }
|
||||
|
||||
return (
|
||||
<Fade in unmountOnExit={false}>
|
||||
<Card className={classes.root}>
|
||||
<CardHeader
|
||||
avatar={<FileIcon />}
|
||||
className={classes.header}
|
||||
classes={{ content: classes.headerContent }}
|
||||
title={NAME}
|
||||
titleTypographyProps={{
|
||||
variant: 'body2',
|
||||
noWrap: true,
|
||||
title: NAME
|
||||
}}
|
||||
subheader={description}
|
||||
subheaderTypographyProps={{
|
||||
variant: 'body2',
|
||||
noWrap: true,
|
||||
className: classes.subheader,
|
||||
title: description
|
||||
}}
|
||||
/>
|
||||
<CardContent>
|
||||
<Box className={classes.badgesWrapper}>
|
||||
<Badge
|
||||
showZero
|
||||
title={Tr('Tiers')}
|
||||
classes={{ badge: classes.badge }}
|
||||
color="primary"
|
||||
badgeContent={numberOfTiers}
|
||||
anchorOrigin={badgePosition}
|
||||
>
|
||||
<VideogameAssetIcon />
|
||||
</Badge>
|
||||
<Badge
|
||||
showZero
|
||||
title={Tr('Networks')}
|
||||
classes={{ badge: classes.badge }}
|
||||
color="primary"
|
||||
badgeContent={numberOfNetworks}
|
||||
anchorOrigin={badgePosition}
|
||||
>
|
||||
<AccountTreeIcon />
|
||||
</Badge>
|
||||
</Box>
|
||||
</CardContent>
|
||||
<CardActions>
|
||||
{handleEdit && (
|
||||
<Button variant="contained" size="small" onClick={handleEdit} disableElevation>
|
||||
{Tr('Edit')}
|
||||
</Button>
|
||||
)}
|
||||
{handleDeploy && (
|
||||
<Button variant="contained" size="small" onClick={handleDeploy} disableElevation>
|
||||
{Tr('Deploy')}
|
||||
</Button>
|
||||
)}
|
||||
{handleShow && (
|
||||
<Button variant="contained" size="small" onClick={handleShow} disableElevation>
|
||||
{Tr('Info')}
|
||||
</Button>
|
||||
)}
|
||||
{handleRemove && (
|
||||
<Button size="small" onClick={handleRemove} disableElevation>
|
||||
{Tr('Remove')}
|
||||
</Button>
|
||||
)}
|
||||
</CardActions>
|
||||
</Card>
|
||||
</Fade>
|
||||
<SelectCard
|
||||
icon={<FileIcon />}
|
||||
title={NAME}
|
||||
subheader={description}
|
||||
>
|
||||
<CardContent>
|
||||
<Box className={classes.badgesWrapper}>
|
||||
<Badge
|
||||
showZero
|
||||
title={Tr('Tiers')}
|
||||
classes={{ badge: 'badge' }}
|
||||
color="primary"
|
||||
badgeContent={numberOfTiers}
|
||||
anchorOrigin={badgePosition}
|
||||
>
|
||||
<VideogameAssetIcon />
|
||||
</Badge>
|
||||
<Badge
|
||||
showZero
|
||||
title={Tr('Networks')}
|
||||
classes={{ badge: 'badge' }}
|
||||
color="primary"
|
||||
badgeContent={numberOfNetworks}
|
||||
anchorOrigin={badgePosition}
|
||||
>
|
||||
<AccountTreeIcon />
|
||||
</Badge>
|
||||
</Box>
|
||||
</CardContent>
|
||||
<CardActions>
|
||||
{handleEdit && (
|
||||
<Button
|
||||
variant="contained"
|
||||
size="small"
|
||||
onClick={handleEdit}
|
||||
disableElevation
|
||||
>
|
||||
{Tr('Edit')}
|
||||
</Button>
|
||||
)}
|
||||
{handleDeploy && (
|
||||
<Button
|
||||
variant="contained"
|
||||
size="small"
|
||||
onClick={handleDeploy}
|
||||
disableElevation
|
||||
>
|
||||
{Tr('Deploy')}
|
||||
</Button>
|
||||
)}
|
||||
{handleShow && (
|
||||
<Button
|
||||
variant="contained"
|
||||
size="small"
|
||||
onClick={handleShow}
|
||||
disableElevation
|
||||
>
|
||||
{Tr('Info')}
|
||||
</Button>
|
||||
)}
|
||||
{handleRemove && (
|
||||
<Button size="small" onClick={handleRemove} disableElevation>
|
||||
{Tr('Remove')}
|
||||
</Button>
|
||||
)}
|
||||
</CardActions>
|
||||
</SelectCard>
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React, { memo } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
|
||||
import { makeStyles, Badge, Box } from '@material-ui/core'
|
||||
import { makeStyles, Badge, Box, CardContent } from '@material-ui/core'
|
||||
import StorageIcon from '@material-ui/icons/Storage'
|
||||
import VideogameAssetIcon from '@material-ui/icons/VideogameAsset'
|
||||
import AccountTreeIcon from '@material-ui/icons/AccountTree'
|
||||
@@ -35,38 +35,40 @@ const ClusterCard = memo(
|
||||
isSelected={isSelected}
|
||||
handleClick={handleClick}
|
||||
>
|
||||
<Box className={classes.badgesWrapper}>
|
||||
<Badge
|
||||
showZero
|
||||
title={Tr('Hosts')}
|
||||
classes={{ badge: 'badge' }}
|
||||
color="primary"
|
||||
badgeContent={hosts.length}
|
||||
anchorOrigin={badgePosition}
|
||||
>
|
||||
<VideogameAssetIcon />
|
||||
</Badge>
|
||||
<Badge
|
||||
showZero
|
||||
title={Tr('Virtual networks')}
|
||||
classes={{ badge: 'badge' }}
|
||||
color="primary"
|
||||
badgeContent={vnets.length}
|
||||
anchorOrigin={badgePosition}
|
||||
>
|
||||
<AccountTreeIcon />
|
||||
</Badge>
|
||||
<Badge
|
||||
showZero
|
||||
title={Tr('Datastores')}
|
||||
classes={{ badge: 'badge' }}
|
||||
color="primary"
|
||||
badgeContent={datastores.length}
|
||||
anchorOrigin={badgePosition}
|
||||
>
|
||||
<FolderOpenIcon />
|
||||
</Badge>
|
||||
</Box>
|
||||
<CardContent>
|
||||
<Box className={classes.badgesWrapper}>
|
||||
<Badge
|
||||
showZero
|
||||
title={Tr('Hosts')}
|
||||
classes={{ badge: 'badge' }}
|
||||
color="primary"
|
||||
badgeContent={hosts.length}
|
||||
anchorOrigin={badgePosition}
|
||||
>
|
||||
<VideogameAssetIcon />
|
||||
</Badge>
|
||||
<Badge
|
||||
showZero
|
||||
title={Tr('Virtual networks')}
|
||||
classes={{ badge: 'badge' }}
|
||||
color="primary"
|
||||
badgeContent={vnets.length}
|
||||
anchorOrigin={badgePosition}
|
||||
>
|
||||
<AccountTreeIcon />
|
||||
</Badge>
|
||||
<Badge
|
||||
showZero
|
||||
title={Tr('Datastores')}
|
||||
classes={{ badge: 'badge' }}
|
||||
color="primary"
|
||||
badgeContent={datastores.length}
|
||||
anchorOrigin={badgePosition}
|
||||
>
|
||||
<FolderOpenIcon />
|
||||
</Badge>
|
||||
</Box>
|
||||
</CardContent>
|
||||
</SelectCard>
|
||||
)
|
||||
},
|
||||
|
||||
@@ -1,80 +1,31 @@
|
||||
import React, { memo } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
|
||||
import clsx from 'clsx'
|
||||
import {
|
||||
makeStyles,
|
||||
Fade,
|
||||
Card,
|
||||
CardHeader,
|
||||
CardActionArea,
|
||||
CardContent,
|
||||
Typography
|
||||
} from '@material-ui/core'
|
||||
import { CardContent, Typography } from '@material-ui/core'
|
||||
import ProvidersIcon from '@material-ui/icons/Public'
|
||||
|
||||
const useStyles = makeStyles(theme => ({
|
||||
root: {
|
||||
height: '100%',
|
||||
minHeight: 140
|
||||
},
|
||||
selected: {
|
||||
color: theme.palette.primary.contrastText,
|
||||
backgroundColor: theme.palette.primary.main,
|
||||
'& $badge': {
|
||||
color: theme.palette.primary.main,
|
||||
backgroundColor: theme.palette.common.white
|
||||
}
|
||||
},
|
||||
actionArea: {
|
||||
height: '100%',
|
||||
display: 'flex',
|
||||
flexDirection: 'column'
|
||||
},
|
||||
header: {
|
||||
overflowX: 'hidden',
|
||||
width: '100%'
|
||||
},
|
||||
content: {
|
||||
width: '100%',
|
||||
flexGrow: 1
|
||||
}
|
||||
}))
|
||||
import SelectCard from './SelectCard'
|
||||
|
||||
const LocationCard = memo(
|
||||
({ value, isSelected, handleClick }) => {
|
||||
const classes = useStyles()
|
||||
const { key, properties } = value
|
||||
|
||||
return (
|
||||
<Fade in unmountOnExit={false}>
|
||||
<Card
|
||||
className={clsx(classes.root, { [classes.selected]: isSelected })}
|
||||
>
|
||||
<CardActionArea
|
||||
className={classes.actionArea}
|
||||
onClick={handleClick}
|
||||
>
|
||||
<CardHeader
|
||||
avatar={<ProvidersIcon />}
|
||||
className={classes.header}
|
||||
title={key}
|
||||
titleTypographyProps={{
|
||||
variant: 'body2',
|
||||
noWrap: true,
|
||||
title: key
|
||||
}}
|
||||
/>
|
||||
{properties && <CardContent className={classes.content}>
|
||||
{Object.entries(properties)?.map(([pKey, pVal]) => (
|
||||
<Typography key={pKey} variant="body2">
|
||||
<b>{pKey}</b>{` - ${pVal}`}
|
||||
</Typography>
|
||||
))}
|
||||
</CardContent>}
|
||||
</CardActionArea>
|
||||
</Card>
|
||||
</Fade>
|
||||
<SelectCard
|
||||
title={key}
|
||||
avatar={<ProvidersIcon />}
|
||||
isSelected={isSelected}
|
||||
handleClick={handleClick}
|
||||
>
|
||||
<CardContent>
|
||||
{properties && Object.entries(properties)
|
||||
?.map(([pKey, pVal]) => (
|
||||
<Typography key={pKey} variant="body2">
|
||||
<b>{pKey}</b>{` - ${pVal}`}
|
||||
</Typography>
|
||||
))}
|
||||
</CardContent>
|
||||
</SelectCard>
|
||||
)
|
||||
},
|
||||
(prev, next) => prev.isSelected === next.isSelected
|
||||
|
||||
@@ -1,88 +1,59 @@
|
||||
import React from 'react'
|
||||
import React, { memo } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
|
||||
import {
|
||||
makeStyles,
|
||||
Card,
|
||||
Button,
|
||||
CardHeader,
|
||||
CardActions,
|
||||
Fade
|
||||
} from '@material-ui/core'
|
||||
import { Button, CardActions } from '@material-ui/core'
|
||||
|
||||
import { Tr } from 'client/components/HOC'
|
||||
import SelectCard from './SelectCard'
|
||||
|
||||
const useStyles = makeStyles(theme => ({
|
||||
root: {
|
||||
height: '100%',
|
||||
minHeight: 140,
|
||||
display: 'flex',
|
||||
flexDirection: 'column'
|
||||
},
|
||||
header: {
|
||||
overflowX: 'hidden',
|
||||
flexGrow: 1
|
||||
},
|
||||
subheader: {
|
||||
overflow: 'hidden',
|
||||
textOverflow: 'ellipsis',
|
||||
whiteSpace: 'initial',
|
||||
display: '-webkit-box',
|
||||
lineClamp: 2,
|
||||
boxOrient: 'vertical'
|
||||
},
|
||||
remove: {
|
||||
backgroundColor: theme.palette.error.dark
|
||||
}
|
||||
}))
|
||||
const NetworkCard = memo(({
|
||||
value,
|
||||
isSelected,
|
||||
handleClick,
|
||||
handleEdit,
|
||||
handleClone,
|
||||
handleRemove
|
||||
}) => {
|
||||
const { mandatory, name, description } = value
|
||||
|
||||
const NetworkCard = React.memo(
|
||||
({ value, handleEdit, handleClone, handleRemove }) => {
|
||||
const classes = useStyles()
|
||||
const { mandatory, name, description } = value
|
||||
|
||||
return (
|
||||
<Fade in unmountOnExit={false}>
|
||||
<Card className={classes.root}>
|
||||
<CardHeader
|
||||
avatar={mandatory ? 'M' : ''}
|
||||
className={classes.header}
|
||||
classes={{ content: classes.headerContent }}
|
||||
title={name}
|
||||
titleTypographyProps={{
|
||||
variant: 'body2',
|
||||
noWrap: true,
|
||||
title: name
|
||||
}}
|
||||
subheader={description}
|
||||
subheaderTypographyProps={{
|
||||
variant: 'body2',
|
||||
noWrap: true,
|
||||
className: classes.subheader,
|
||||
title: description
|
||||
}}
|
||||
/>
|
||||
<CardActions>
|
||||
{handleEdit && (
|
||||
<Button variant="contained" size="small" onClick={handleEdit} disableElevation>
|
||||
{Tr('Edit')}
|
||||
</Button>
|
||||
)}
|
||||
{handleClone && (
|
||||
<Button variant="contained" size="small" onClick={handleClone} disableElevation>
|
||||
{Tr('Clone')}
|
||||
</Button>
|
||||
)}
|
||||
{handleRemove && (
|
||||
<Button size="small" onClick={handleRemove} disableElevation>
|
||||
{Tr('Remove')}
|
||||
</Button>
|
||||
)}
|
||||
</CardActions>
|
||||
</Card>
|
||||
</Fade>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<SelectCard
|
||||
icon={mandatory ? 'M' : ''}
|
||||
title={name}
|
||||
subheader={description}
|
||||
isSelected={isSelected}
|
||||
handleClick={handleClick}
|
||||
>
|
||||
<CardActions>
|
||||
{handleEdit && (
|
||||
<Button
|
||||
variant="contained"
|
||||
size="small"
|
||||
onClick={handleEdit}
|
||||
disableElevation
|
||||
>
|
||||
{Tr('Edit')}
|
||||
</Button>
|
||||
)}
|
||||
{handleClone && (
|
||||
<Button
|
||||
variant="contained"
|
||||
size="small"
|
||||
onClick={handleClone}
|
||||
disableElevation
|
||||
>
|
||||
{Tr('Clone')}
|
||||
</Button>
|
||||
)}
|
||||
{handleRemove && (
|
||||
<Button size="small" onClick={handleRemove} disableElevation>
|
||||
{Tr('Remove')}
|
||||
</Button>
|
||||
)}
|
||||
</CardActions>
|
||||
</SelectCard>
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
NetworkCard.propTypes = {
|
||||
@@ -94,6 +65,8 @@ NetworkCard.propTypes = {
|
||||
id: PropTypes.string,
|
||||
extra: PropTypes.string
|
||||
}),
|
||||
isSelected: PropTypes.bool,
|
||||
handleClick: PropTypes.func,
|
||||
handleEdit: PropTypes.func,
|
||||
handleClone: PropTypes.func,
|
||||
handleRemove: PropTypes.func
|
||||
@@ -101,6 +74,8 @@ NetworkCard.propTypes = {
|
||||
|
||||
NetworkCard.defaultProps = {
|
||||
value: {},
|
||||
isSelected: false,
|
||||
handleClick: undefined,
|
||||
handleEdit: undefined,
|
||||
handleClone: undefined,
|
||||
handleRemove: undefined
|
||||
|
||||
@@ -1,68 +1,36 @@
|
||||
import React, { memo } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
|
||||
import {
|
||||
makeStyles,
|
||||
Fade,
|
||||
Button,
|
||||
Card,
|
||||
CardHeader,
|
||||
CardActions
|
||||
} from '@material-ui/core'
|
||||
import { Button, CardActions } from '@material-ui/core'
|
||||
import FileIcon from '@material-ui/icons/Description'
|
||||
|
||||
import { Tr } from 'client/components/HOC'
|
||||
|
||||
const useStyles = makeStyles(theme => ({
|
||||
root: {
|
||||
height: '100%',
|
||||
minHeight: 140,
|
||||
display: 'flex',
|
||||
flexDirection: 'column'
|
||||
},
|
||||
header: {
|
||||
overflowX: 'hidden',
|
||||
flexGrow: 1
|
||||
},
|
||||
content: {
|
||||
display: 'flex',
|
||||
gap: theme.typography.pxToRem(12)
|
||||
}
|
||||
}))
|
||||
import SelectCard from './SelectCard'
|
||||
|
||||
const ProviderCard = memo(
|
||||
({ value, handleShow, handleRemove }) => {
|
||||
const classes = useStyles()
|
||||
const { ID, NAME } = value
|
||||
|
||||
return (
|
||||
<Fade in unmountOnExit={false}>
|
||||
<Card className={classes.root}>
|
||||
<CardHeader
|
||||
avatar={<FileIcon />}
|
||||
className={classes.header}
|
||||
classes={{ content: classes.headerContent }}
|
||||
title={`${ID} - ${NAME}`}
|
||||
titleTypographyProps={{
|
||||
variant: 'body2',
|
||||
noWrap: true,
|
||||
title: NAME
|
||||
}}
|
||||
/>
|
||||
<CardActions>
|
||||
{handleShow && (
|
||||
<Button variant="contained" size="small" onClick={handleShow} disableElevation>
|
||||
{Tr('Info')}
|
||||
</Button>
|
||||
)}
|
||||
{handleRemove && (
|
||||
<Button size="small" onClick={handleRemove} disableElevation>
|
||||
{Tr('Remove')}
|
||||
</Button>
|
||||
)}
|
||||
</CardActions>
|
||||
</Card>
|
||||
</Fade>
|
||||
<SelectCard title={`${ID} - ${NAME}`} icon={<FileIcon />}>
|
||||
<CardActions>
|
||||
{handleShow && (
|
||||
<Button
|
||||
variant="contained"
|
||||
size="small"
|
||||
onClick={handleShow}
|
||||
disableElevation
|
||||
>
|
||||
{Tr('Info')}
|
||||
</Button>
|
||||
)}
|
||||
{handleRemove && (
|
||||
<Button size="small" onClick={handleRemove} disableElevation>
|
||||
{Tr('Remove')}
|
||||
</Button>
|
||||
)}
|
||||
</CardActions>
|
||||
</SelectCard>
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
@@ -1,51 +1,19 @@
|
||||
import React, { memo } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
|
||||
import {
|
||||
makeStyles, Fade, Card, CardHeader, CardActionArea
|
||||
} from '@material-ui/core'
|
||||
import FileIcon from '@material-ui/icons/Description'
|
||||
|
||||
const useStyles = makeStyles(() => ({
|
||||
root: {
|
||||
height: '100%',
|
||||
minHeight: 140,
|
||||
display: 'flex',
|
||||
flexDirection: 'column'
|
||||
},
|
||||
actionArea: {
|
||||
height: '100%'
|
||||
},
|
||||
headerContent: {
|
||||
overflowX: 'hidden'
|
||||
}
|
||||
}))
|
||||
import SelectCard from './SelectCard'
|
||||
|
||||
const ProviderTemplateCard = memo(
|
||||
({ value, handleClick }) => {
|
||||
const classes = useStyles()
|
||||
const { name } = value
|
||||
|
||||
return (
|
||||
<Fade in unmountOnExit={false}>
|
||||
<Card className={classes.root}>
|
||||
<CardActionArea
|
||||
className={classes.actionArea}
|
||||
onClick={handleClick}
|
||||
>
|
||||
<CardHeader
|
||||
avatar={<FileIcon />}
|
||||
classes={{ content: classes.headerContent }}
|
||||
title={name}
|
||||
titleTypographyProps={{
|
||||
variant: 'body2',
|
||||
noWrap: true,
|
||||
title: name
|
||||
}}
|
||||
/>
|
||||
</CardActionArea>
|
||||
</Card>
|
||||
</Fade>
|
||||
<SelectCard
|
||||
title={name}
|
||||
handleClick={handleClick}
|
||||
icon={<FileIcon />}
|
||||
/>
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
@@ -2,10 +2,11 @@ import React, { memo } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
|
||||
import clsx from 'clsx'
|
||||
import { Card, CardActionArea, CardContent, CardHeader, Fade, makeStyles } from '@material-ui/core'
|
||||
import { Card, CardActionArea, CardHeader, Fade, makeStyles } from '@material-ui/core'
|
||||
import { Skeleton } from '@material-ui/lab'
|
||||
|
||||
import useNearScreen from 'client/hooks/useNearScreen'
|
||||
import ConditionalWrap from 'client/components/HOC/ConditionalWrap'
|
||||
|
||||
const useStyles = makeStyles(theme => ({
|
||||
root: {
|
||||
@@ -17,6 +18,9 @@ const useStyles = makeStyles(theme => ({
|
||||
'& .badge': {
|
||||
color: theme.palette.primary.main,
|
||||
backgroundColor: theme.palette.common.white
|
||||
},
|
||||
'& $subheader': {
|
||||
color: 'inherit'
|
||||
}
|
||||
},
|
||||
actionArea: {
|
||||
@@ -26,53 +30,100 @@ const useStyles = makeStyles(theme => ({
|
||||
},
|
||||
headerContent: {
|
||||
overflowX: 'hidden'
|
||||
},
|
||||
subheader: {
|
||||
overflow: 'hidden',
|
||||
textOverflow: 'ellipsis',
|
||||
whiteSpace: 'initial',
|
||||
display: '-webkit-box',
|
||||
lineClamp: 2,
|
||||
boxOrient: 'vertical'
|
||||
}
|
||||
}))
|
||||
|
||||
const SelectCard = memo(
|
||||
({ title, icon, isSelected, handleClick, children }) => {
|
||||
const classes = useStyles()
|
||||
const { isNearScreen, fromRef } = useNearScreen({
|
||||
distance: '100px'
|
||||
})
|
||||
const SelectCard = memo(({
|
||||
title,
|
||||
subheader,
|
||||
icon,
|
||||
isSelected,
|
||||
handleClick,
|
||||
cardProps,
|
||||
observerOff,
|
||||
children
|
||||
}) => {
|
||||
const classes = useStyles()
|
||||
const { isNearScreen, fromRef } = useNearScreen({
|
||||
distance: '100px'
|
||||
})
|
||||
|
||||
return (
|
||||
<div ref={fromRef}>
|
||||
{isNearScreen ? (
|
||||
<Fade in={isNearScreen}>
|
||||
<Card className={clsx(classes.root, { [classes.selected]: isSelected })}>
|
||||
<CardActionArea className={classes.actionArea} onClick={handleClick}>
|
||||
<CardHeader
|
||||
avatar={icon}
|
||||
classes={{ content: classes.headerContent }}
|
||||
title={title}
|
||||
titleTypographyProps={{
|
||||
variant: 'body2',
|
||||
noWrap: true,
|
||||
title: title
|
||||
}}
|
||||
/>
|
||||
{children && <CardContent>{children}</CardContent>}
|
||||
</CardActionArea>
|
||||
</Card>
|
||||
</Fade>
|
||||
) : (
|
||||
<Skeleton variant="rect" width="100%" height={140} />
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
},
|
||||
(prev, next) => prev.isSelected === next.isSelected
|
||||
)
|
||||
return (
|
||||
<ConditionalWrap
|
||||
condition={!observerOff}
|
||||
wrap={children => <div ref={fromRef}>{children}</div>}>
|
||||
{observerOff || isNearScreen ? (
|
||||
<Fade in={observerOff || isNearScreen}>
|
||||
<Card
|
||||
className={clsx(classes.root, {
|
||||
[classes.actionArea]: !handleClick,
|
||||
[classes.selected]: isSelected
|
||||
})}
|
||||
{...cardProps}
|
||||
>
|
||||
<ConditionalWrap
|
||||
condition={handleClick}
|
||||
wrap={children =>
|
||||
<CardActionArea
|
||||
className={classes.actionArea}
|
||||
onClick={handleClick}>
|
||||
{children}
|
||||
</CardActionArea>
|
||||
}
|
||||
>
|
||||
<CardHeader
|
||||
avatar={icon}
|
||||
classes={{ content: classes.headerContent }}
|
||||
title={title}
|
||||
titleTypographyProps={{
|
||||
variant: 'body2',
|
||||
noWrap: true,
|
||||
title: title
|
||||
}}
|
||||
subheader={subheader}
|
||||
subheaderTypographyProps={{
|
||||
variant: 'body2',
|
||||
noWrap: true,
|
||||
className: classes.subheader,
|
||||
title: subheader
|
||||
}}
|
||||
/>
|
||||
{children}
|
||||
</ConditionalWrap>
|
||||
</Card>
|
||||
</Fade>
|
||||
) : (
|
||||
<Skeleton variant="rect" width="100%" height={140} />
|
||||
)}
|
||||
</ConditionalWrap>
|
||||
)
|
||||
})
|
||||
|
||||
SelectCard.propTypes = {
|
||||
title: PropTypes.oneOfType([
|
||||
PropTypes.string,
|
||||
PropTypes.object
|
||||
]),
|
||||
icon: PropTypes.object,
|
||||
subheader: PropTypes.oneOfType([
|
||||
PropTypes.string,
|
||||
PropTypes.object
|
||||
]),
|
||||
icon: PropTypes.oneOfType([
|
||||
PropTypes.string,
|
||||
PropTypes.object
|
||||
]),
|
||||
isSelected: PropTypes.bool,
|
||||
handleClick: PropTypes.func,
|
||||
cardProps: PropTypes.object,
|
||||
observerOff: PropTypes.bool,
|
||||
children: PropTypes.oneOfType([
|
||||
PropTypes.arrayOf(PropTypes.node),
|
||||
PropTypes.node,
|
||||
@@ -82,9 +133,12 @@ SelectCard.propTypes = {
|
||||
|
||||
SelectCard.defaultProps = {
|
||||
title: undefined,
|
||||
subheader: undefined,
|
||||
icon: undefined,
|
||||
isSelected: false,
|
||||
handleClick: () => undefined,
|
||||
handleClick: undefined,
|
||||
cardProps: undefined,
|
||||
observerOff: false,
|
||||
children: undefined
|
||||
}
|
||||
|
||||
|
||||
@@ -1,88 +1,47 @@
|
||||
import React, { memo } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
|
||||
import {
|
||||
makeStyles,
|
||||
Card,
|
||||
Button,
|
||||
CardHeader,
|
||||
CardActions,
|
||||
Badge
|
||||
} from '@material-ui/core'
|
||||
import { Button, CardActions, Badge } from '@material-ui/core'
|
||||
import DesktopWindowsIcon from '@material-ui/icons/DesktopWindows'
|
||||
|
||||
import { Tr } from 'client/components/HOC'
|
||||
|
||||
const useStyles = makeStyles(() => ({
|
||||
root: {
|
||||
height: '100%',
|
||||
minHeight: 140,
|
||||
display: 'flex',
|
||||
flexDirection: 'column'
|
||||
},
|
||||
header: {
|
||||
overflowX: 'hidden',
|
||||
flexGrow: 1
|
||||
},
|
||||
headerContent: {},
|
||||
title: {
|
||||
overflow: 'hidden',
|
||||
textOverflow: 'ellipsis',
|
||||
whiteSpace: 'initial',
|
||||
display: '-webkit-box',
|
||||
lineClamp: 2,
|
||||
boxOrient: 'vertical'
|
||||
}
|
||||
}))
|
||||
import SelectCard from './SelectCard'
|
||||
|
||||
const TierCard = memo(
|
||||
({ value, handleEdit, handleClone, handleRemove, cardProps }) => {
|
||||
const classes = useStyles()
|
||||
({ value, handleEdit, handleRemove, cardProps }) => {
|
||||
const { name, cardinality } = value
|
||||
|
||||
return (
|
||||
<Card className={classes.root} {...cardProps}>
|
||||
<CardHeader
|
||||
avatar={
|
||||
<Badge
|
||||
badgeContent={cardinality}
|
||||
color="primary"
|
||||
anchorOrigin={{
|
||||
vertical: 'top',
|
||||
horizontal: 'left'
|
||||
}}
|
||||
>
|
||||
<DesktopWindowsIcon />
|
||||
</Badge>
|
||||
}
|
||||
className={classes.header}
|
||||
classes={{ content: classes.headerContent }}
|
||||
title={name}
|
||||
titleTypographyProps={{
|
||||
variant: 'body2',
|
||||
noWrap: true,
|
||||
className: classes.title,
|
||||
title: name
|
||||
}}
|
||||
/>
|
||||
<SelectCard
|
||||
observerOff
|
||||
icon={
|
||||
<Badge
|
||||
badgeContent={cardinality}
|
||||
color="primary"
|
||||
anchorOrigin={{
|
||||
vertical: 'top',
|
||||
horizontal: 'left'
|
||||
}}
|
||||
>
|
||||
<DesktopWindowsIcon />
|
||||
</Badge>
|
||||
}
|
||||
title={name}
|
||||
cardProps={cardProps}
|
||||
>
|
||||
<CardActions>
|
||||
{handleEdit && (
|
||||
<Button variant="contained" size="small" onClick={handleEdit} disableElevation>
|
||||
{Tr('Edit')}
|
||||
</Button>
|
||||
)}
|
||||
{handleClone && (
|
||||
<Button variant="contained" size="small" onClick={handleClone} disableElevation>
|
||||
{Tr('Clone')}
|
||||
</Button>
|
||||
)}
|
||||
{handleRemove && (
|
||||
<Button size="small" onClick={handleRemove} disableElevation>
|
||||
{Tr('Remove')}
|
||||
</Button>
|
||||
)}
|
||||
</CardActions>
|
||||
</Card>
|
||||
</SelectCard>
|
||||
)
|
||||
}
|
||||
)
|
||||
@@ -96,7 +55,6 @@ TierCard.propTypes = {
|
||||
])
|
||||
}),
|
||||
handleEdit: PropTypes.func,
|
||||
handleClone: PropTypes.func,
|
||||
handleRemove: PropTypes.func,
|
||||
cardProps: PropTypes.object
|
||||
}
|
||||
@@ -104,7 +62,6 @@ TierCard.propTypes = {
|
||||
TierCard.defaultProps = {
|
||||
value: {},
|
||||
handleEdit: undefined,
|
||||
handleClone: undefined,
|
||||
handleRemove: undefined,
|
||||
cardProps: undefined
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ const useStyles = makeStyles(theme => ({
|
||||
root: {
|
||||
position: 'sticky',
|
||||
top: -15,
|
||||
backdropFilter: 'blur(5px)',
|
||||
background: fade(theme.palette.primary.main, 0.65),
|
||||
zIndex: theme.zIndex.mobileStepper,
|
||||
margin: theme.spacing(2, 0)
|
||||
|
||||
@@ -2,7 +2,6 @@ import React from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
|
||||
import {
|
||||
styled,
|
||||
Button,
|
||||
Stepper,
|
||||
Step,
|
||||
@@ -10,19 +9,21 @@ import {
|
||||
Box,
|
||||
Typography
|
||||
} from '@material-ui/core'
|
||||
import { makeStyles, fade } from '@material-ui/core/styles'
|
||||
|
||||
import ButtonSubmit from 'client/components/FormControl/SubmitButton'
|
||||
import { Finish, Back, Next } from 'client/constants/translates'
|
||||
import { Tr } from 'client/components/HOC'
|
||||
|
||||
const StickyStepper = styled(Stepper)({
|
||||
position: 'sticky',
|
||||
top: -15,
|
||||
minHeight: 100,
|
||||
backdropFilter: 'blur(5px)',
|
||||
background: '#fafafa9c',
|
||||
zIndex: 1
|
||||
})
|
||||
const useStyles = makeStyles(theme => ({
|
||||
root: {
|
||||
position: 'sticky',
|
||||
top: -15,
|
||||
minHeight: 100,
|
||||
background: fade(theme.palette.background.default, 0.65),
|
||||
zIndex: theme.zIndex.mobileStepper
|
||||
}
|
||||
}))
|
||||
|
||||
const CustomStepper = ({
|
||||
steps,
|
||||
@@ -33,35 +34,39 @@ const CustomStepper = ({
|
||||
handleBack,
|
||||
errors,
|
||||
isSubmitting
|
||||
}) => (
|
||||
<>
|
||||
<StickyStepper activeStep={activeStep}>
|
||||
{steps?.map(({ id, label }) => (
|
||||
<Step key={id}>
|
||||
<StepLabel
|
||||
{...(Boolean(errors[id]) && { error: true })}
|
||||
optional={
|
||||
<Typography variant="caption" color="error">
|
||||
{errors[id]?.message}
|
||||
</Typography>
|
||||
}
|
||||
>{label}</StepLabel>
|
||||
</Step>
|
||||
))}
|
||||
</StickyStepper>
|
||||
<Box marginY={2}>
|
||||
<Button onClick={handleBack} disabled={disabledBack}>
|
||||
{Tr(Back)}
|
||||
</Button>
|
||||
<ButtonSubmit
|
||||
data-cy="stepper-next-button"
|
||||
onClick={handleNext}
|
||||
isSubmitting={isSubmitting}
|
||||
label={activeStep === lastStep ? Tr(Finish) : Tr(Next)}
|
||||
/>
|
||||
</Box>
|
||||
</>
|
||||
)
|
||||
}) => {
|
||||
const classes = useStyles()
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stepper activeStep={activeStep} className={classes.root}>
|
||||
{steps?.map(({ id, label }) => (
|
||||
<Step key={id}>
|
||||
<StepLabel
|
||||
{...(Boolean(errors[id]) && { error: true })}
|
||||
optional={
|
||||
<Typography variant="caption" color="error">
|
||||
{errors[id]?.message}
|
||||
</Typography>
|
||||
}
|
||||
>{label}</StepLabel>
|
||||
</Step>
|
||||
))}
|
||||
</Stepper>
|
||||
<Box marginY={2}>
|
||||
<Button onClick={handleBack} disabled={disabledBack}>
|
||||
{Tr(Back)}
|
||||
</Button>
|
||||
<ButtonSubmit
|
||||
data-cy="stepper-next-button"
|
||||
onClick={handleNext}
|
||||
isSubmitting={isSubmitting}
|
||||
label={activeStep === lastStep ? Tr(Finish) : Tr(Next)}
|
||||
/>
|
||||
</Box>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
CustomStepper.propTypes = {
|
||||
steps: PropTypes.arrayOf(
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
import React from 'react'
|
||||
|
||||
export default ({ condition, children, wrap }) =>
|
||||
condition ? React.cloneElement(wrap(children)) : children
|
||||
@@ -126,6 +126,7 @@ const SelectTranslate = () => {
|
||||
<Select
|
||||
native
|
||||
type="select"
|
||||
fullWidth
|
||||
onChange={e => handleChange(e, context.changeLang)}
|
||||
defaultValue={context.lang}
|
||||
>
|
||||
|
||||
@@ -18,6 +18,7 @@ import PropTypes from 'prop-types'
|
||||
|
||||
import {
|
||||
AppBar,
|
||||
Box,
|
||||
Toolbar,
|
||||
Typography,
|
||||
IconButton,
|
||||
@@ -37,6 +38,7 @@ const Header = ({ title }) => {
|
||||
const { isFixMenu, fixMenu } = useGeneral()
|
||||
const classes = headerStyles()
|
||||
const isUpLg = useMediaQuery(theme => theme.breakpoints.up('lg'))
|
||||
const isMobile = useMediaQuery(theme => theme.breakpoints.only('xs'))
|
||||
|
||||
const handleFixMenu = () => fixMenu(true)
|
||||
|
||||
@@ -49,20 +51,24 @@ const Header = ({ title }) => {
|
||||
<MenuIcon />
|
||||
</IconButton>
|
||||
)}
|
||||
<Typography
|
||||
variant="h6"
|
||||
className={classes.title}
|
||||
data-cy="header-title"
|
||||
>
|
||||
{title}
|
||||
</Typography>
|
||||
<User />
|
||||
{!isOneAdmin && <Group />}
|
||||
<Zone />
|
||||
{!isMobile && (
|
||||
<Typography
|
||||
variant="h6"
|
||||
className={classes.title}
|
||||
data-cy="header-title"
|
||||
>
|
||||
{title}
|
||||
</Typography>
|
||||
)}
|
||||
<Box flexGrow={isMobile ? 1 : 0} textAlign="end">
|
||||
<User />
|
||||
{!isOneAdmin && <Group />}
|
||||
<Zone />
|
||||
</Box>
|
||||
</Toolbar>
|
||||
</AppBar>
|
||||
),
|
||||
[isFixMenu, fixMenu, isUpLg, isOneAdmin]
|
||||
[isFixMenu, fixMenu, isUpLg, isMobile, isOneAdmin]
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -26,9 +26,7 @@ const ListInfiniteScroll = ({ list, renderResult }) => {
|
||||
}, [list])
|
||||
|
||||
const debounceHandleNextPage = useCallback(
|
||||
debounce(() => {
|
||||
setLength(prevLength => prevLength + 20)
|
||||
}, 200),
|
||||
debounce(() => setLength(prevLength => prevLength + 20), 200),
|
||||
[setLength]
|
||||
)
|
||||
|
||||
|
||||
@@ -28,6 +28,8 @@ module.exports = {
|
||||
/* sections */
|
||||
Dashboard: 'Dashboard',
|
||||
Settings: 'Settings',
|
||||
ApplicationsTemplates: 'Applications templates',
|
||||
ApplicationsInstances: 'Applications instances',
|
||||
Providers: 'Providers',
|
||||
Provisions: 'Provisions',
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from 'react'
|
||||
import React, { memo } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
|
||||
import { List, ListItem, Typography, Chip, Grid, Paper, Divider } from '@material-ui/core'
|
||||
@@ -9,7 +9,7 @@ import useStyles from 'client/containers/ApplicationsInstances/DialogInfo/styles
|
||||
import { APPLICATION_STATES } from 'client/constants/states'
|
||||
import { Tr } from 'client/components/HOC'
|
||||
|
||||
const InfoTab = React.memo(({ info }) => {
|
||||
const InfoTab = memo(({ info }) => {
|
||||
const classes = useStyles()
|
||||
const { ID, TEMPLATE, UNAME, GNAME, PERMISSIONS } = info
|
||||
const {
|
||||
@@ -26,7 +26,7 @@ const InfoTab = React.memo(({ info }) => {
|
||||
checked === '1' ? <CheckBox /> : <CheckBoxOutlineBlank />
|
||||
|
||||
return (
|
||||
<Grid container spacing={2}>
|
||||
<Grid container spacing={1}>
|
||||
<Grid item xs={12} md={6}>
|
||||
<Paper variant="outlined">
|
||||
<List className={clsx(classes.list, 'w-50')}>
|
||||
|
||||
@@ -1,35 +1,30 @@
|
||||
import React, { useEffect, useMemo, useState } from 'react'
|
||||
|
||||
import { Container, Box } from '@material-ui/core'
|
||||
import { Alert } from '@material-ui/lab'
|
||||
import { Container, Box, Typography, Divider } from '@material-ui/core'
|
||||
import RefreshIcon from '@material-ui/icons/Autorenew'
|
||||
|
||||
import useApplication from 'client/hooks/useApplication'
|
||||
import useFetch from 'client/hooks/useFetch'
|
||||
|
||||
import ListCards from 'client/components/List/ListCards'
|
||||
import DialogInfo from 'client/containers/ApplicationsInstances/DialogInfo'
|
||||
import SubmitButton from 'client/components/FormControl/SubmitButton'
|
||||
import ListCards from 'client/components/List/ListCards'
|
||||
import AlertError from 'client/components/Alerts/Error'
|
||||
import { ApplicationCard, EmptyCard } from 'client/components/Cards'
|
||||
|
||||
import { DONE, APPLICATION_STATES } from 'client/constants/states'
|
||||
import { CannotConnectOneFlow } from 'client/constants/translates'
|
||||
import { Tr } from 'client/components/HOC'
|
||||
|
||||
const Error = () => (
|
||||
<Box pt={3} display="flex" justifyContent="center">
|
||||
<Alert severity="error" icon={false} variant="filled">
|
||||
{Tr(CannotConnectOneFlow)}
|
||||
</Alert>
|
||||
</Box>
|
||||
)
|
||||
import {
|
||||
ApplicationsInstances as ApplicationsInstancesLabel,
|
||||
CannotConnectOneFlow
|
||||
} from 'client/constants/translates'
|
||||
|
||||
function ApplicationsInstances () {
|
||||
const { applications, getApplications } = useApplication()
|
||||
const [showDialog, setShowDialog] = useState(false)
|
||||
const { fetchRequest, loading, error } = useFetch(getApplications)
|
||||
const { error, fetchRequest, loading, reloading } = useFetch(getApplications)
|
||||
|
||||
useEffect(() => {
|
||||
fetchRequest()
|
||||
}, [])
|
||||
useEffect(() => { fetchRequest() }, [])
|
||||
|
||||
const list = useMemo(() => (
|
||||
applications.length > 0
|
||||
@@ -39,24 +34,44 @@ function ApplicationsInstances () {
|
||||
: applications
|
||||
), [applications])
|
||||
|
||||
if (error) {
|
||||
return <Error />
|
||||
}
|
||||
|
||||
return (
|
||||
<Container disableGutters>
|
||||
<Box p={3}>
|
||||
<ListCards
|
||||
list={list}
|
||||
isLoading={list.length === 0 && loading}
|
||||
EmptyComponent={<EmptyCard title={'Your applications instances list is empty'} />}
|
||||
CardComponent={ApplicationCard}
|
||||
cardsProps={({ value }) => ({
|
||||
handleShow: () => setShowDialog(value)
|
||||
})}
|
||||
<Box p={3} display="flex" alignItems="center">
|
||||
<SubmitButton
|
||||
fab
|
||||
onClick={() => fetchRequest(undefined, { reload: true, delay: 500 })}
|
||||
isSubmitting={loading || reloading}
|
||||
label={<RefreshIcon />}
|
||||
/>
|
||||
<Typography variant="h5" style={{ marginLeft: 8 }}>
|
||||
{Tr(ApplicationsInstancesLabel)}
|
||||
</Typography>
|
||||
</Box>
|
||||
<Divider />
|
||||
<Box p={3}>
|
||||
{error ? (
|
||||
<AlertError>
|
||||
{Tr(CannotConnectOneFlow)}
|
||||
</AlertError>
|
||||
) : (
|
||||
<ListCards
|
||||
list={list}
|
||||
isLoading={list.length === 0 && loading}
|
||||
EmptyComponent={
|
||||
<EmptyCard title={'Your applications instances list is empty'} />
|
||||
}
|
||||
CardComponent={ApplicationCard}
|
||||
cardsProps={({ value }) => ({
|
||||
handleShow: () => setShowDialog(value)
|
||||
})}
|
||||
breakpoints={{ xs: 12, sm: 6, md: 4 }}
|
||||
/>
|
||||
)}
|
||||
{showDialog !== false && (
|
||||
<DialogInfo info={showDialog} handleClose={() => setShowDialog(false)} />
|
||||
<DialogInfo
|
||||
info={showDialog}
|
||||
handleClose={() => setShowDialog(false)}
|
||||
/>
|
||||
)}
|
||||
</Box>
|
||||
</Container>
|
||||
|
||||
+1
-1
@@ -75,7 +75,7 @@ const CustomNode = memo(({ data, selected, ...nodeProps }) => {
|
||||
handleEdit={handleEdit}
|
||||
cardProps={{
|
||||
elevation: selected ? 6 : 1,
|
||||
style: { minWidth: 200 }
|
||||
style: { width: 300 }
|
||||
}}
|
||||
/>
|
||||
<Handle
|
||||
|
||||
+5
@@ -17,7 +17,12 @@ const NOT_KEY_CODE = -1
|
||||
const useStyles = makeStyles(() => ({
|
||||
root: {
|
||||
'& .react-flow__handle': {
|
||||
width: 10,
|
||||
height: 10,
|
||||
backgroundColor: 'rgba(0,0,0,0.2)',
|
||||
'&-bottom': {
|
||||
bottom: -6
|
||||
},
|
||||
'&-connecting': {
|
||||
backgroundColor: '#ff6060'
|
||||
},
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ const NAME = {
|
||||
validation: yup
|
||||
.string()
|
||||
.trim()
|
||||
.matches(/^[\w+\s*]*$/g, { message: 'Invalid characters' })
|
||||
.matches(/^\w+$/g, { message: 'Invalid characters' })
|
||||
.required('Name field is required')
|
||||
.default('')
|
||||
}
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@ import React, { useCallback, useContext } from 'react'
|
||||
|
||||
import useListForm from 'client/hooks/useListForm'
|
||||
import ListCards from 'client/components/List/ListCards'
|
||||
import { SelectCard } from 'client/components/Cards'
|
||||
import { NetworkCard } from 'client/components/Cards'
|
||||
|
||||
import { STEP_ID as NETWORKING } from 'client/containers/ApplicationsTemplates/Form/Create/Steps/Networking'
|
||||
import { Context } from 'client/containers/ApplicationsTemplates/Form/Create/Steps/Tiers'
|
||||
@@ -25,7 +25,7 @@ const Networks = () => ({
|
||||
return (
|
||||
<ListCards
|
||||
list={list[NETWORKING]}
|
||||
CardComponent={SelectCard}
|
||||
CardComponent={NetworkCard}
|
||||
cardsProps={({ value: { id, name } }) => {
|
||||
const isSelected = data?.some(selected => selected === id)
|
||||
|
||||
|
||||
@@ -1,57 +1,73 @@
|
||||
import React, { useEffect, useState } from 'react'
|
||||
|
||||
import { useHistory } from 'react-router-dom'
|
||||
import { Container, Box } from '@material-ui/core'
|
||||
import { Alert } from '@material-ui/lab'
|
||||
import { Container, Box, Typography, Divider } from '@material-ui/core'
|
||||
import RefreshIcon from '@material-ui/icons/Autorenew'
|
||||
|
||||
import { PATH } from 'client/router/fireedge'
|
||||
import useApplication from 'client/hooks/useApplication'
|
||||
import useFetch from 'client/hooks/useFetch'
|
||||
|
||||
import DeployForm from 'client/containers/ApplicationsTemplates/Form/Deploy'
|
||||
import SubmitButton from 'client/components/FormControl/SubmitButton'
|
||||
import ListCards from 'client/components/List/ListCards'
|
||||
import AlertError from 'client/components/Alerts/Error'
|
||||
import { ApplicationTemplateCard } from 'client/components/Cards'
|
||||
|
||||
import { Tr } from 'client/components/HOC'
|
||||
import { CannotConnectOneFlow } from 'client/constants/translates'
|
||||
|
||||
const Error = () => (
|
||||
<Box pt={3} display="flex" justifyContent="center">
|
||||
<Alert severity="error" icon={false} variant="filled">
|
||||
{Tr(CannotConnectOneFlow)}
|
||||
</Alert>
|
||||
</Box>
|
||||
)
|
||||
import {
|
||||
ApplicationsTemplates as ApplicationsTemplatesLabel,
|
||||
CannotConnectOneFlow
|
||||
} from 'client/constants/translates'
|
||||
|
||||
function ApplicationsTemplates () {
|
||||
const history = useHistory()
|
||||
const [showDialog, setShowDialog] = useState(false)
|
||||
const { applicationsTemplates, getApplicationsTemplates } = useApplication()
|
||||
const { fetchRequest, loading, error } = useFetch(getApplicationsTemplates)
|
||||
const {
|
||||
error,
|
||||
fetchRequest,
|
||||
loading,
|
||||
reloading
|
||||
} = useFetch(getApplicationsTemplates)
|
||||
|
||||
useEffect(() => {
|
||||
fetchRequest()
|
||||
}, [])
|
||||
|
||||
if (error) {
|
||||
return <Error />
|
||||
}
|
||||
useEffect(() => { fetchRequest() }, [])
|
||||
|
||||
return (
|
||||
<Container disableGutters>
|
||||
<Box p={3}>
|
||||
<ListCards
|
||||
list={applicationsTemplates}
|
||||
isLoading={applicationsTemplates?.length === 0 && loading}
|
||||
handleCreate={() => history.push(PATH.APPLICATIONS_TEMPLATES.CREATE)}
|
||||
CardComponent={ApplicationTemplateCard}
|
||||
cardsProps={({ value }) => ({
|
||||
handleEdit: () =>
|
||||
history.push(PATH.APPLICATIONS_TEMPLATES.EDIT.replace(':id', value?.ID)),
|
||||
handleDeploy: () => setShowDialog(value),
|
||||
handleRemove: undefined
|
||||
})}
|
||||
<Box p={3} display="flex" alignItems="center">
|
||||
<SubmitButton
|
||||
fab
|
||||
onClick={() => fetchRequest(undefined, { reload: true, delay: 500 })}
|
||||
isSubmitting={loading || reloading}
|
||||
label={<RefreshIcon />}
|
||||
/>
|
||||
<Typography variant="h5" style={{ marginLeft: 8 }}>
|
||||
{Tr(ApplicationsTemplatesLabel)}
|
||||
</Typography>
|
||||
</Box>
|
||||
<Divider />
|
||||
<Box p={3}>
|
||||
{error ? (
|
||||
<AlertError>
|
||||
{Tr(CannotConnectOneFlow)}
|
||||
</AlertError>
|
||||
) : (
|
||||
<ListCards
|
||||
list={applicationsTemplates}
|
||||
isLoading={applicationsTemplates?.length === 0 && loading}
|
||||
handleCreate={() => history.push(PATH.APPLICATIONS_TEMPLATES.CREATE)}
|
||||
CardComponent={ApplicationTemplateCard}
|
||||
cardsProps={({ value }) => ({
|
||||
handleEdit: () => history.push(
|
||||
PATH.APPLICATIONS_TEMPLATES.EDIT.replace(':id', value?.ID)
|
||||
),
|
||||
handleDeploy: () => setShowDialog(value),
|
||||
handleRemove: undefined
|
||||
})}
|
||||
breakpoints={{ xs: 12, sm: 6, md: 4 }}
|
||||
/>
|
||||
)}
|
||||
{showDialog !== false && (
|
||||
<DeployForm
|
||||
applicationTemplate={showDialog}
|
||||
|
||||
@@ -22,25 +22,18 @@ function Providers () {
|
||||
const {
|
||||
error,
|
||||
fetchRequest,
|
||||
cancelRequest,
|
||||
loading,
|
||||
reloading
|
||||
} = useFetch(getProviders)
|
||||
|
||||
useEffect(() => {
|
||||
fetchRequest()
|
||||
|
||||
return () => {
|
||||
cancelRequest()
|
||||
}
|
||||
}, [])
|
||||
useEffect(() => { fetchRequest() }, [])
|
||||
|
||||
return (
|
||||
<Container disableGutters>
|
||||
<Box p={3} display="flex" alignItems="center">
|
||||
<SubmitButton
|
||||
fab
|
||||
onClick={() => fetchRequest(undefined, true)}
|
||||
onClick={() => fetchRequest(undefined, { reload: true })}
|
||||
isSubmitting={loading || reloading}
|
||||
label={<RefreshIcon />}
|
||||
/>
|
||||
|
||||
@@ -22,25 +22,18 @@ function Provisions () {
|
||||
const {
|
||||
error,
|
||||
fetchRequest,
|
||||
cancelRequest,
|
||||
loading,
|
||||
reloading
|
||||
} = useFetch(getProvisions)
|
||||
|
||||
useEffect(() => {
|
||||
fetchRequest()
|
||||
|
||||
return () => {
|
||||
cancelRequest()
|
||||
}
|
||||
}, [])
|
||||
useEffect(() => { fetchRequest() }, [])
|
||||
|
||||
return (
|
||||
<Container disableGutters>
|
||||
<Box p={3} display="flex" alignItems="center">
|
||||
<SubmitButton
|
||||
fab
|
||||
onClick={() => fetchRequest(undefined, true)}
|
||||
onClick={() => fetchRequest(undefined, { reload: true })}
|
||||
isSubmitting={loading || reloading}
|
||||
label={<RefreshIcon />}
|
||||
/>
|
||||
|
||||
@@ -73,8 +73,8 @@ export default function useOpennebula () {
|
||||
filterBy([doc].concat(applicationsTemplates), 'ID')
|
||||
)
|
||||
)
|
||||
|
||||
return dispatch(enqueueSuccess(`Template created - ID: ${doc.ID}`))
|
||||
dispatch(enqueueSuccess(`Template created - ID: ${doc.ID}`))
|
||||
return doc
|
||||
})
|
||||
.catch(err => {
|
||||
dispatch(
|
||||
@@ -94,8 +94,9 @@ export default function useOpennebula () {
|
||||
filterBy([doc].concat(applicationsTemplates), 'ID')
|
||||
)
|
||||
)
|
||||
dispatch(enqueueSuccess(`Template updated - ID: ${doc.ID}`))
|
||||
|
||||
return dispatch(enqueueSuccess(`Template updated - ID: ${doc.ID}`))
|
||||
return doc
|
||||
})
|
||||
.catch(err => {
|
||||
dispatch(
|
||||
|
||||
@@ -1,36 +1,50 @@
|
||||
import { useState, useCallback } from 'react'
|
||||
import { useState, useCallback, useEffect, useRef } from 'react'
|
||||
import axios from 'axios'
|
||||
import { debounce } from '@material-ui/core'
|
||||
import { fakeDelay } from 'client/utils'
|
||||
|
||||
const useRequest = request => {
|
||||
const [data, setData] = useState(undefined)
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [reloading, setReloading] = useState(false)
|
||||
const [error, setError] = useState(false)
|
||||
const source = axios.CancelToken.source()
|
||||
const isMounted = useRef(true)
|
||||
|
||||
const fetchRequest = useCallback((payload, reload = false) => {
|
||||
reload ? setReloading(true) : setLoading(true)
|
||||
useEffect(() => () => { isMounted.current = false }, [])
|
||||
|
||||
request({
|
||||
...payload,
|
||||
config: { cancelToken: source.token }
|
||||
}).then(response => {
|
||||
if (!axios.isCancel(response)) {
|
||||
if (response !== undefined) {
|
||||
setData(response)
|
||||
setError(false)
|
||||
} else setError(true)
|
||||
const doFetch = useCallback(
|
||||
debounce(payload =>
|
||||
request({ ...payload }).then(response => {
|
||||
if (isMounted.current && !axios.isCancel(response)) {
|
||||
if (response !== undefined) {
|
||||
setData(response)
|
||||
setError(false)
|
||||
} else setError(true)
|
||||
|
||||
setLoading(false)
|
||||
setReloading(false)
|
||||
}
|
||||
})
|
||||
}, [source])
|
||||
setLoading(false)
|
||||
setReloading(false)
|
||||
}
|
||||
})
|
||||
), [isMounted])
|
||||
|
||||
const fetchRequest = useCallback((payload, options = {}) => {
|
||||
const { reload = false, delay = 0 } = options
|
||||
if (!(Number.isInteger(delay) && delay >= 0)) {
|
||||
console.error(`
|
||||
Delay must be a number >= 0!
|
||||
If you're using it as a function, it must also return a number >= 0.`)
|
||||
}
|
||||
|
||||
if (isMounted.current) {
|
||||
reload ? setReloading(true) : setLoading(true)
|
||||
}
|
||||
|
||||
fakeDelay(delay).then(() => doFetch(payload))
|
||||
}, [isMounted])
|
||||
|
||||
return {
|
||||
data,
|
||||
fetchRequest,
|
||||
cancelRequest: source.cancel,
|
||||
loading,
|
||||
reloading,
|
||||
error
|
||||
|
||||
@@ -10,7 +10,7 @@ const useNearScreen = ({ externalRef, distance, once = true }) => {
|
||||
const element = externalRef ? externalRef.current : fromRef.current
|
||||
|
||||
const onChange = entries => {
|
||||
entries.forEach(({ isIntersecting }) => {
|
||||
element && entries.forEach(({ isIntersecting }) => {
|
||||
if (isIntersecting) {
|
||||
setShow(true)
|
||||
once && observer.disconnect()
|
||||
|
||||
@@ -121,9 +121,9 @@ export default function useOpennebula () {
|
||||
)
|
||||
|
||||
const getProvisions = useCallback(
|
||||
({ end, start, config } = { end: -1, start: -1, config: {} }) =>
|
||||
({ end, start } = { end: -1, start: -1 }) =>
|
||||
serviceProvision
|
||||
.getProvisions({ filter, end, start, config })
|
||||
.getProvisions({ filter, end, start })
|
||||
.then(doc => {
|
||||
dispatch(setProvisions(doc))
|
||||
return doc
|
||||
|
||||
@@ -42,7 +42,7 @@ export const getProviders = ({ filter }) =>
|
||||
method: GET,
|
||||
error: err => err?.message
|
||||
}).then(res => {
|
||||
if (axios.isCancel(res) || !res?.id || res?.id !== httpCodes.ok.id) throw res
|
||||
if (!res?.id || res?.id !== httpCodes.ok.id) throw res
|
||||
|
||||
return [res?.data?.DOCUMENT_POOL?.DOCUMENT ?? []].flat()
|
||||
})
|
||||
@@ -99,13 +99,12 @@ export const getProvision = ({ id }) =>
|
||||
return res?.data?.DOCUMENT ?? {}
|
||||
})
|
||||
|
||||
export const getProvisions = ({ filter, config }) =>
|
||||
export const getProvisions = ({ filter }) =>
|
||||
requestData(`/api/${PROVISION}/list`, {
|
||||
config,
|
||||
data: { filter },
|
||||
method: GET
|
||||
}).then(res => {
|
||||
if (axios.isCancel(res) || !res?.id || res?.id !== httpCodes.ok.id) throw res
|
||||
if (!res?.id || res?.id !== httpCodes.ok.id) throw res
|
||||
|
||||
return [res?.data?.DOCUMENT_POOL?.DOCUMENT ?? []].flat()
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user