mirror of
https://github.com/OpenNebula/one.git
synced 2026-12-06 07:04:45 +09:00
1 parent
4ac5a418ee
commit
ed7a35444b
20 files changed
+376
-279
No files matched your search
@@ -0,0 +1,86 @@
|
||||
import React, { memo } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
|
||||
import { Button, CardActions } from '@material-ui/core'
|
||||
|
||||
import { Tr } from 'client/components/HOC'
|
||||
import SelectCard from 'client/components/Cards/SelectCard'
|
||||
|
||||
const ApplicationNetworkCard = memo(({
|
||||
value,
|
||||
isSelected,
|
||||
handleClick,
|
||||
handleEdit,
|
||||
handleClone,
|
||||
handleRemove
|
||||
}) => {
|
||||
const { mandatory, name, description } = value
|
||||
|
||||
return (
|
||||
<SelectCard
|
||||
icon={mandatory ? 'M' : undefined}
|
||||
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>
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
ApplicationNetworkCard.propTypes = {
|
||||
value: PropTypes.shape({
|
||||
mandatory: PropTypes.bool,
|
||||
name: PropTypes.string.isRequired,
|
||||
description: PropTypes.string,
|
||||
type: PropTypes.string,
|
||||
id: PropTypes.string,
|
||||
extra: PropTypes.string
|
||||
}),
|
||||
isSelected: PropTypes.bool,
|
||||
handleClick: PropTypes.func,
|
||||
handleEdit: PropTypes.func,
|
||||
handleClone: PropTypes.func,
|
||||
handleRemove: PropTypes.func
|
||||
}
|
||||
|
||||
ApplicationNetworkCard.defaultProps = {
|
||||
value: {},
|
||||
isSelected: false,
|
||||
handleClick: undefined,
|
||||
handleEdit: undefined,
|
||||
handleClone: undefined,
|
||||
handleRemove: undefined
|
||||
}
|
||||
|
||||
ApplicationNetworkCard.displayName = 'ApplicationNetworkCard'
|
||||
|
||||
export default ApplicationNetworkCard
|
||||
@@ -13,7 +13,7 @@ const useStyles = makeStyles(() => ({
|
||||
}))
|
||||
|
||||
const DatastoreCard = memo(
|
||||
({ value, isSelected, handleClick }) => {
|
||||
({ value, isSelected, handleClick, actions }) => {
|
||||
const { ID, NAME, TYPE, STATE } = value
|
||||
const type = Datastore.TYPES[TYPE]
|
||||
const state = Datastore.STATES[STATE]
|
||||
@@ -25,7 +25,7 @@ const DatastoreCard = memo(
|
||||
|
||||
return (
|
||||
<SelectCard
|
||||
stylesProps={{ minHeight: 75 }}
|
||||
stylesProps={{ minHeight: 160 }}
|
||||
icon={<DatastoreIcon />}
|
||||
title={(
|
||||
<Box component="span" className={classes.title}>
|
||||
@@ -37,6 +37,7 @@ const DatastoreCard = memo(
|
||||
cardHeaderProps={{ disableTypography: true }}
|
||||
isSelected={isSelected}
|
||||
handleClick={handleClick}
|
||||
actions={actions}
|
||||
/>
|
||||
)
|
||||
},
|
||||
@@ -51,13 +52,24 @@ DatastoreCard.propTypes = {
|
||||
STATE: PropTypes.string
|
||||
}),
|
||||
isSelected: PropTypes.bool,
|
||||
handleClick: PropTypes.func
|
||||
handleClick: PropTypes.func,
|
||||
actions: PropTypes.arrayOf(
|
||||
PropTypes.shape({
|
||||
handleClick: PropTypes.func.isRequired,
|
||||
icon: PropTypes.object.isRequired,
|
||||
iconColor: PropTypes.oneOf([
|
||||
'inherit', 'primary', 'secondary', 'action', 'error', 'disabled'
|
||||
]),
|
||||
cy: PropTypes.string
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
DatastoreCard.defaultProps = {
|
||||
value: {},
|
||||
isSelected: false,
|
||||
handleClick: undefined
|
||||
handleClick: undefined,
|
||||
actions: undefined
|
||||
}
|
||||
|
||||
DatastoreCard.displayName = 'DatastoreCard'
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React, { memo } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
|
||||
import { makeStyles, Chip } from '@material-ui/core'
|
||||
import { makeStyles, Chip, Box, Typography } from '@material-ui/core'
|
||||
import { VideogameAsset as HostIcon } from '@material-ui/icons'
|
||||
|
||||
import SelectCard from 'client/components/Cards/SelectCard'
|
||||
@@ -13,9 +13,10 @@ const useStyles = makeStyles(() => ({
|
||||
}))
|
||||
|
||||
const HostCard = memo(
|
||||
({ value, isSelected, handleClick }) => {
|
||||
const { ID, NAME, STATE } = value
|
||||
({ value, isSelected, handleClick, actions }) => {
|
||||
const { ID, NAME, STATE, IM_MAD: imMad, VM_MAD: vmMad } = value
|
||||
const state = Host.STATES[STATE]
|
||||
const mad = imMad === vmMad ? imMad : `${imMad}/${vmMad}`
|
||||
|
||||
const classes = useStyles({ stateColor: state.color })
|
||||
|
||||
@@ -24,12 +25,20 @@ const HostCard = memo(
|
||||
|
||||
return (
|
||||
<SelectCard
|
||||
stylesProps={{ minHeight: 75 }}
|
||||
stylesProps={{ minHeight: 160 }}
|
||||
icon={<HostIcon />}
|
||||
title={`${ID} - ${NAME}`}
|
||||
subheader={renderChip({ label: state.name, className: classes.state })}
|
||||
title={(
|
||||
<Box component="span" className={classes.title}>
|
||||
<Typography noWrap>{`${ID} - ${NAME}`}</Typography>
|
||||
{renderChip({ label: mad })}
|
||||
</Box>
|
||||
)}
|
||||
subheader={
|
||||
renderChip({ label: state.name, className: classes.state })
|
||||
}
|
||||
isSelected={isSelected}
|
||||
handleClick={handleClick}
|
||||
actions={actions}
|
||||
/>
|
||||
)
|
||||
},
|
||||
@@ -41,16 +50,29 @@ HostCard.propTypes = {
|
||||
ID: PropTypes.string.isRequired,
|
||||
NAME: PropTypes.string.isRequired,
|
||||
TYPE: PropTypes.string,
|
||||
STATE: PropTypes.string
|
||||
STATE: PropTypes.string,
|
||||
IM_MAD: PropTypes.string,
|
||||
VM_MAD: PropTypes.string
|
||||
}),
|
||||
isSelected: PropTypes.bool,
|
||||
handleClick: PropTypes.func
|
||||
handleClick: PropTypes.func,
|
||||
actions: PropTypes.arrayOf(
|
||||
PropTypes.shape({
|
||||
handleClick: PropTypes.func.isRequired,
|
||||
icon: PropTypes.object.isRequired,
|
||||
iconColor: PropTypes.oneOf([
|
||||
'inherit', 'primary', 'secondary', 'action', 'error', 'disabled'
|
||||
]),
|
||||
cy: PropTypes.string
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
HostCard.defaultProps = {
|
||||
value: {},
|
||||
isSelected: false,
|
||||
handleClick: undefined
|
||||
handleClick: undefined,
|
||||
actions: undefined
|
||||
}
|
||||
|
||||
HostCard.displayName = 'HostCard'
|
||||
|
||||
@@ -1,84 +1,53 @@
|
||||
import React, { memo } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
|
||||
import { Button, CardActions } from '@material-ui/core'
|
||||
|
||||
import { Tr } from 'client/components/HOC'
|
||||
import { AccountTree as NetworkIcon } from '@material-ui/icons'
|
||||
import SelectCard from 'client/components/Cards/SelectCard'
|
||||
|
||||
const NetworkCard = memo(({
|
||||
value,
|
||||
isSelected,
|
||||
handleClick,
|
||||
handleEdit,
|
||||
handleClone,
|
||||
handleRemove
|
||||
}) => {
|
||||
const { mandatory, name, description } = value
|
||||
const NetworkCard = memo(
|
||||
({ value, isSelected, handleClick, actions }) => {
|
||||
const { ID, NAME } = value
|
||||
|
||||
return (
|
||||
<SelectCard
|
||||
icon={mandatory ? 'M' : undefined}
|
||||
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>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<SelectCard
|
||||
stylesProps={{ minHeight: 120 }}
|
||||
icon={<NetworkIcon />}
|
||||
title={`${ID} - ${NAME}`}
|
||||
isSelected={isSelected}
|
||||
handleClick={handleClick}
|
||||
actions={actions}
|
||||
/>
|
||||
)
|
||||
},
|
||||
(prev, next) => prev.isSelected === next.isSelected
|
||||
)
|
||||
|
||||
NetworkCard.propTypes = {
|
||||
value: PropTypes.shape({
|
||||
mandatory: PropTypes.bool,
|
||||
name: PropTypes.string.isRequired,
|
||||
description: PropTypes.string,
|
||||
type: PropTypes.string,
|
||||
id: PropTypes.string,
|
||||
extra: PropTypes.string
|
||||
ID: PropTypes.string.isRequired,
|
||||
NAME: PropTypes.string.isRequired,
|
||||
TYPE: PropTypes.string,
|
||||
STATE: PropTypes.string
|
||||
}),
|
||||
isSelected: PropTypes.bool,
|
||||
handleClick: PropTypes.func,
|
||||
handleEdit: PropTypes.func,
|
||||
handleClone: PropTypes.func,
|
||||
handleRemove: PropTypes.func
|
||||
actions: PropTypes.arrayOf(
|
||||
PropTypes.shape({
|
||||
handleClick: PropTypes.func.isRequired,
|
||||
icon: PropTypes.object.isRequired,
|
||||
iconColor: PropTypes.oneOf([
|
||||
'inherit', 'primary', 'secondary', 'action', 'error', 'disabled'
|
||||
]),
|
||||
cy: PropTypes.string
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
NetworkCard.defaultProps = {
|
||||
value: {},
|
||||
isSelected: false,
|
||||
handleClick: undefined,
|
||||
handleEdit: undefined,
|
||||
handleClone: undefined,
|
||||
handleRemove: undefined
|
||||
actions: undefined
|
||||
}
|
||||
|
||||
NetworkCard.displayName = 'NetworkCard'
|
||||
|
||||
@@ -1,56 +1,41 @@
|
||||
import React, { memo } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
|
||||
import { CardActions, IconButton } from '@material-ui/core'
|
||||
import TemplateIcon from '@material-ui/icons/Description'
|
||||
import InfoIcon from '@material-ui/icons/Info'
|
||||
import EditIcon from '@material-ui/icons/Build'
|
||||
import DeleteIcon from '@material-ui/icons/Delete'
|
||||
|
||||
import SelectCard from 'client/components/Cards/SelectCard'
|
||||
|
||||
const ProviderCard = memo(
|
||||
({ value, handleShow, handleEdit, handleDelete }) => {
|
||||
const { ID, NAME } = value
|
||||
const ProviderCard = memo(({ value, actions }) => {
|
||||
const { ID, NAME } = value
|
||||
|
||||
const renderAction = ({ handleClick, icon: Icon, iconColor }) =>
|
||||
handleClick && (
|
||||
<IconButton onClick={handleClick} size="small">
|
||||
<Icon color={iconColor} style={{ margin: 8 }} />
|
||||
</IconButton>
|
||||
)
|
||||
|
||||
return (
|
||||
<SelectCard title={`${ID} - ${NAME}`} icon={<TemplateIcon />}>
|
||||
<CardActions>
|
||||
{renderAction({
|
||||
handleClick: handleShow,
|
||||
icon: InfoIcon,
|
||||
iconColor: 'primary'
|
||||
})}
|
||||
{renderAction({ handleClick: handleEdit, icon: EditIcon })}
|
||||
{renderAction({ handleClick: handleDelete, icon: DeleteIcon })}
|
||||
</CardActions>
|
||||
</SelectCard>
|
||||
)
|
||||
}
|
||||
)
|
||||
return (
|
||||
<SelectCard
|
||||
title={`${ID} - ${NAME}`}
|
||||
icon={<TemplateIcon />}
|
||||
actions={actions}
|
||||
/>
|
||||
)
|
||||
})
|
||||
|
||||
ProviderCard.propTypes = {
|
||||
value: PropTypes.shape({
|
||||
ID: PropTypes.string.isRequired,
|
||||
NAME: PropTypes.string.isRequired
|
||||
}),
|
||||
handleShow: PropTypes.func,
|
||||
handleEdit: PropTypes.func,
|
||||
handleDelete: PropTypes.func
|
||||
actions: PropTypes.arrayOf(
|
||||
PropTypes.shape({
|
||||
handleClick: PropTypes.func.isRequired,
|
||||
icon: PropTypes.object.isRequired,
|
||||
iconColor: PropTypes.oneOf([
|
||||
'inherit', 'primary', 'secondary', 'action', 'error', 'disabled'
|
||||
]),
|
||||
cy: PropTypes.string
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
ProviderCard.defaultProps = {
|
||||
value: {},
|
||||
handleShow: undefined,
|
||||
handleEdit: undefined,
|
||||
handleDelete: undefined
|
||||
actions: undefined
|
||||
}
|
||||
|
||||
ProviderCard.displayName = 'ProviderCard'
|
||||
|
||||
@@ -1,56 +1,41 @@
|
||||
import React, { memo } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
|
||||
import { CardActions, IconButton } from '@material-ui/core'
|
||||
import ProvisionIcon from '@material-ui/icons/Cloud'
|
||||
import InfoIcon from '@material-ui/icons/Info'
|
||||
import EditIcon from '@material-ui/icons/Build'
|
||||
import DeleteIcon from '@material-ui/icons/Delete'
|
||||
|
||||
import SelectCard from 'client/components/Cards/SelectCard'
|
||||
|
||||
const ProvisionCard = memo(
|
||||
({ value, handleShow, handleEdit, handleDelete }) => {
|
||||
const { ID, NAME } = value
|
||||
const ProvisionCard = memo(({ value, actions }) => {
|
||||
const { ID, NAME } = value
|
||||
|
||||
const renderAction = ({ handleClick, icon: Icon, iconColor }) =>
|
||||
handleClick && (
|
||||
<IconButton onClick={handleClick} size="small">
|
||||
<Icon color={iconColor} style={{ margin: 8 }} />
|
||||
</IconButton>
|
||||
)
|
||||
|
||||
return (
|
||||
<SelectCard title={`${ID} - ${NAME}`} icon={<ProvisionIcon />}>
|
||||
<CardActions>
|
||||
{renderAction({
|
||||
handleClick: handleShow,
|
||||
icon: InfoIcon,
|
||||
iconColor: 'primary'
|
||||
})}
|
||||
{renderAction({ handleClick: handleEdit, icon: EditIcon })}
|
||||
{renderAction({ handleClick: handleDelete, icon: DeleteIcon })}
|
||||
</CardActions>
|
||||
</SelectCard>
|
||||
)
|
||||
}
|
||||
)
|
||||
return (
|
||||
<SelectCard
|
||||
title={`${ID} - ${NAME}`}
|
||||
icon={<ProvisionIcon />}
|
||||
actions={actions}
|
||||
/>
|
||||
)
|
||||
})
|
||||
|
||||
ProvisionCard.propTypes = {
|
||||
value: PropTypes.shape({
|
||||
ID: PropTypes.string.isRequired,
|
||||
NAME: PropTypes.string.isRequired
|
||||
}),
|
||||
handleShow: PropTypes.func,
|
||||
handleEdit: PropTypes.func,
|
||||
handleDelete: PropTypes.func
|
||||
actions: PropTypes.arrayOf(
|
||||
PropTypes.shape({
|
||||
handleClick: PropTypes.func.isRequired,
|
||||
icon: PropTypes.object.isRequired,
|
||||
iconColor: PropTypes.oneOf([
|
||||
'inherit', 'primary', 'secondary', 'action', 'error', 'disabled'
|
||||
]),
|
||||
cy: PropTypes.string
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
ProvisionCard.defaultProps = {
|
||||
value: {},
|
||||
handleShow: undefined,
|
||||
handleEdit: undefined,
|
||||
handleDelete: undefined
|
||||
actions: undefined
|
||||
}
|
||||
|
||||
ProvisionCard.displayName = 'ProvisionCard'
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import React, { memo } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
|
||||
import clsx from 'clsx'
|
||||
import { Card, CardActionArea, CardHeader, Fade, makeStyles } from '@material-ui/core'
|
||||
|
||||
import {
|
||||
makeStyles, Card, CardActionArea, CardHeader, CardActions, IconButton
|
||||
} 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: {
|
||||
height: '100%'
|
||||
},
|
||||
root: { height: '100%' },
|
||||
selected: {
|
||||
color: theme.palette.primary.contrastText,
|
||||
backgroundColor: theme.palette.primary.main,
|
||||
@@ -37,11 +37,14 @@ const useStyles = makeStyles(theme => ({
|
||||
display: '-webkit-box',
|
||||
lineClamp: 2,
|
||||
boxOrient: 'vertical'
|
||||
}
|
||||
},
|
||||
actionsIcon: { margin: theme.spacing(1) }
|
||||
}))
|
||||
|
||||
const SelectCard = memo(({
|
||||
stylesProps,
|
||||
action,
|
||||
actions,
|
||||
icon,
|
||||
title,
|
||||
subheader,
|
||||
@@ -57,6 +60,12 @@ const SelectCard = memo(({
|
||||
distance: '100px'
|
||||
})
|
||||
|
||||
const renderAction = ({ handleClick, icon: Icon, iconColor, cy }) => (
|
||||
<IconButton key={cy} data-cy={cy} onClick={handleClick} size="small">
|
||||
<Icon color={iconColor} className={classes.actionsIcon} />
|
||||
</IconButton>
|
||||
)
|
||||
|
||||
return (
|
||||
<ConditionalWrap
|
||||
condition={!observerOff}
|
||||
@@ -81,6 +90,7 @@ const SelectCard = memo(({
|
||||
}
|
||||
>
|
||||
<CardHeader
|
||||
action={action}
|
||||
avatar={icon}
|
||||
classes={{
|
||||
content: classes.headerContent,
|
||||
@@ -102,6 +112,11 @@ const SelectCard = memo(({
|
||||
{...cardHeaderProps}
|
||||
/>
|
||||
{children}
|
||||
{actions?.length > 0 && (
|
||||
<CardActions>
|
||||
{actions?.map(action => renderAction(action))}
|
||||
</CardActions>
|
||||
)}
|
||||
</ConditionalWrap>
|
||||
</Card>
|
||||
) : (
|
||||
@@ -113,6 +128,21 @@ const SelectCard = memo(({
|
||||
|
||||
SelectCard.propTypes = {
|
||||
stylesProps: PropTypes.object,
|
||||
action: PropTypes.node,
|
||||
actions: PropTypes.arrayOf(
|
||||
PropTypes.shape({
|
||||
handleClick: PropTypes.func.isRequired,
|
||||
icon: PropTypes.object.isRequired,
|
||||
iconColor: PropTypes.oneOf([
|
||||
'inherit', 'primary', 'secondary', 'action', 'error', 'disabled'
|
||||
]),
|
||||
cy: PropTypes.string
|
||||
})
|
||||
),
|
||||
icon: PropTypes.oneOfType([
|
||||
PropTypes.string,
|
||||
PropTypes.object
|
||||
]),
|
||||
title: PropTypes.oneOfType([
|
||||
PropTypes.string,
|
||||
PropTypes.object
|
||||
@@ -121,10 +151,6 @@ SelectCard.propTypes = {
|
||||
PropTypes.string,
|
||||
PropTypes.object
|
||||
]),
|
||||
icon: PropTypes.oneOfType([
|
||||
PropTypes.string,
|
||||
PropTypes.object
|
||||
]),
|
||||
cardHeaderProps: PropTypes.shape({
|
||||
titleTypographyProps: PropTypes.object,
|
||||
subheaderTypographyProps: PropTypes.object
|
||||
@@ -142,9 +168,11 @@ SelectCard.propTypes = {
|
||||
|
||||
SelectCard.defaultProps = {
|
||||
stylesProps: undefined,
|
||||
action: undefined,
|
||||
actions: undefined,
|
||||
icon: undefined,
|
||||
title: undefined,
|
||||
subheader: undefined,
|
||||
icon: undefined,
|
||||
cardHeaderProps: undefined,
|
||||
isSelected: false,
|
||||
handleClick: undefined,
|
||||
|
||||
@@ -7,6 +7,7 @@ import EmptyCard from 'client/components/Cards/EmptyCard'
|
||||
import SelectCard from 'client/components/Cards/SelectCard'
|
||||
import ApplicationTemplateCard from 'client/components/Cards/ApplicationTemplateCard'
|
||||
import ApplicationCard from 'client/components/Cards/ApplicationCard'
|
||||
import ApplicationNetworkCard from 'client/components/Cards/ApplicationNetworkCard'
|
||||
import PolicyCard from 'client/components/Cards/PolicyCard'
|
||||
import ProviderTemplateCard from 'client/components/Cards/ProviderTemplateCard'
|
||||
import ProviderCard from 'client/components/Cards/ProviderCard'
|
||||
@@ -23,6 +24,7 @@ export {
|
||||
SelectCard,
|
||||
ApplicationTemplateCard,
|
||||
ApplicationCard,
|
||||
ApplicationNetworkCard,
|
||||
PolicyCard,
|
||||
ProviderTemplateCard,
|
||||
ProviderCard,
|
||||
|
||||
@@ -56,3 +56,8 @@ export {
|
||||
INPUT_TYPES,
|
||||
REQUEST_ACTIONS
|
||||
}
|
||||
|
||||
export * as T from 'client/constants/translates'
|
||||
export * from 'client/constants/flow'
|
||||
export * from 'client/constants/states'
|
||||
export * from 'client/constants/provision'
|
||||
@@ -40,6 +40,7 @@ module.exports = {
|
||||
ProvidersLabel: 'Providers',
|
||||
ProvisionLabel: 'Provision',
|
||||
ProvisionsLabel: 'Provisions',
|
||||
ClustersLabel: 'Clusters',
|
||||
|
||||
/* tabs */
|
||||
Information: 'Information',
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@ import useListForm from 'client/hooks/useListForm'
|
||||
import FormWithSchema from 'client/components/Forms/FormWithSchema'
|
||||
import ListCards from 'client/components/List/ListCards'
|
||||
import { DialogForm } from 'client/components/Dialogs'
|
||||
import { NetworkCard } from 'client/components/Cards'
|
||||
import { ApplicationNetworkCard } from 'client/components/Cards'
|
||||
|
||||
import { STEP_ID as TIERS_ID } from 'client/containers/ApplicationsTemplates/Form/Create/Steps/Tiers'
|
||||
import { FORM_FIELDS, NETWORK_FORM_SCHEMA, STEP_FORM_SCHEMA } from './schema'
|
||||
@@ -44,7 +44,7 @@ const Networks = () => ({
|
||||
<>
|
||||
<ListCards
|
||||
list={data}
|
||||
CardComponent={NetworkCard}
|
||||
CardComponent={ApplicationNetworkCard}
|
||||
handleCreate={() => {
|
||||
handleEdit()
|
||||
setShowDialog(true)
|
||||
|
||||
+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 { NetworkCard } from 'client/components/Cards'
|
||||
import { ApplicationNetworkCard } 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={NetworkCard}
|
||||
CardComponent={ApplicationNetworkCard}
|
||||
cardsProps={({ value: { id, name } }) => {
|
||||
const isSelected = data?.some(selected => selected === id)
|
||||
|
||||
|
||||
@@ -3,6 +3,9 @@ import React, { useState, useEffect } from 'react'
|
||||
import { useHistory } from 'react-router-dom'
|
||||
import { Container, Box, Typography, Divider } from '@material-ui/core'
|
||||
import RefreshIcon from '@material-ui/icons/Autorenew'
|
||||
import InfoIcon from '@material-ui/icons/Info'
|
||||
import EditIcon from '@material-ui/icons/Build'
|
||||
import DeleteIcon from '@material-ui/icons/Delete'
|
||||
|
||||
import { PATH } from 'client/router/provision'
|
||||
import useProvision from 'client/hooks/useProvision'
|
||||
@@ -55,21 +58,36 @@ function Providers () {
|
||||
isLoading={providers.length === 0 && loading}
|
||||
handleCreate={() => history.push(PATH.PROVIDERS.CREATE)}
|
||||
CardComponent={ProviderCard}
|
||||
cardsProps={({ value }) => ({
|
||||
handleEdit: () =>
|
||||
history.push(PATH.PROVIDERS.EDIT.replace(':id', value.ID)),
|
||||
handleShow: () => setShowDialog({
|
||||
id: value.ID,
|
||||
title: `(ID: ${value.ID}) ${value.NAME}`
|
||||
}),
|
||||
handleDelete: () => setShowDialog({
|
||||
id: value.ID,
|
||||
title: `DELETE provider - (ID: ${value.ID}) ${value.NAME}`,
|
||||
handleAccept: () => {
|
||||
deleteProvider({ id: value.ID })
|
||||
setShowDialog(false)
|
||||
cardsProps={({ value: { ID, NAME } }) => ({
|
||||
actions: [
|
||||
{
|
||||
handleClick: () => setShowDialog({
|
||||
id: ID,
|
||||
title: `(ID: ${ID}) ${NAME}`
|
||||
}),
|
||||
icon: InfoIcon,
|
||||
iconColor: 'primary',
|
||||
cy: `provider-info-${ID}`
|
||||
},
|
||||
{
|
||||
handleClick: () =>
|
||||
history.push(PATH.PROVIDERS.EDIT.replace(':id', ID)),
|
||||
icon: EditIcon,
|
||||
cy: `provider-edit-${ID}`
|
||||
},
|
||||
{
|
||||
handleClick: () => setShowDialog({
|
||||
id: ID,
|
||||
title: `DELETE provider - (ID: ${ID}) ${NAME}`,
|
||||
handleAccept: () => {
|
||||
deleteProvider({ id: ID })
|
||||
setShowDialog(false)
|
||||
}
|
||||
}),
|
||||
icon: DeleteIcon,
|
||||
cy: `provider-delete-${ID}`
|
||||
}
|
||||
})
|
||||
]
|
||||
})}
|
||||
breakpoints={{ xs: 12, sm: 6, md: 4 }}
|
||||
/>
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
import React, { memo, useEffect } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
|
||||
import useFetchAll from 'client/hooks/useFetchAll'
|
||||
import useOpennebula from 'client/hooks/useOpennebula'
|
||||
import ListCards from 'client/components/List/ListCards'
|
||||
import { ClusterCard } from 'client/components/Cards'
|
||||
|
||||
const Clusters = memo(({ hidden, data }) => {
|
||||
const {
|
||||
clusters
|
||||
} = data?.TEMPLATE?.PROVISION_BODY?.provision?.infrastructure
|
||||
|
||||
const { getCluster } = useOpennebula()
|
||||
const { data: list, fetchRequestAll, loading } = useFetchAll()
|
||||
|
||||
useEffect(() => {
|
||||
if (!list && !hidden) {
|
||||
const reqs = clusters?.map(({ id }) => getCluster({ id }))
|
||||
fetchRequestAll(reqs)
|
||||
}
|
||||
}, [hidden])
|
||||
|
||||
return (
|
||||
<ListCards
|
||||
list={list}
|
||||
isLoading={loading}
|
||||
CardComponent={ClusterCard}
|
||||
displayEmpty
|
||||
breakpoints={{ xs: 12, sm: 6, md: 4 }}
|
||||
/>
|
||||
)
|
||||
}, (prev, next) => prev.hidden === next.hiddfen)
|
||||
|
||||
Clusters.propTypes = {
|
||||
data: PropTypes.object.isRequired,
|
||||
hidden: PropTypes.bool
|
||||
}
|
||||
|
||||
Clusters.defaultProps = {
|
||||
data: {},
|
||||
hidden: true
|
||||
}
|
||||
|
||||
Clusters.displayName = 'Clusters'
|
||||
|
||||
export default Clusters
|
||||
@@ -1,6 +1,8 @@
|
||||
import React, { memo, useEffect } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
|
||||
import DeleteIcon from '@material-ui/icons/Delete'
|
||||
|
||||
import useFetchAll from 'client/hooks/useFetchAll'
|
||||
import useOpennebula from 'client/hooks/useOpennebula'
|
||||
import ListCards from 'client/components/List/ListCards'
|
||||
@@ -26,6 +28,13 @@ const Datastores = memo(({ hidden, data }) => {
|
||||
list={list}
|
||||
isLoading={loading}
|
||||
CardComponent={DatastoreCard}
|
||||
cardsProps={({ value: { ID } }) => ({
|
||||
actions: [{
|
||||
handleClick: () => undefined,
|
||||
icon: DeleteIcon,
|
||||
cy: `provision-datastore-delete-${ID}`
|
||||
}]
|
||||
})}
|
||||
displayEmpty
|
||||
breakpoints={{ xs: 12, md: 6 }}
|
||||
/>
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import React, { memo, useEffect } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
|
||||
import DeleteIcon from '@material-ui/icons/Delete'
|
||||
import ConfigureIcon from '@material-ui/icons/Build'
|
||||
|
||||
import useFetchAll from 'client/hooks/useFetchAll'
|
||||
import useOpennebula from 'client/hooks/useOpennebula'
|
||||
import ListCards from 'client/components/List/ListCards'
|
||||
@@ -26,6 +29,20 @@ const Hosts = memo(({ hidden, data }) => {
|
||||
list={list}
|
||||
isLoading={loading}
|
||||
CardComponent={HostCard}
|
||||
cardsProps={({ value: { ID } }) => ({
|
||||
actions: [
|
||||
{
|
||||
handleClick: () => undefined,
|
||||
icon: ConfigureIcon,
|
||||
cy: `provision-host-configure-${ID}`
|
||||
},
|
||||
{
|
||||
handleClick: () => undefined,
|
||||
icon: DeleteIcon,
|
||||
cy: `provision-host-delete-${ID}`
|
||||
}
|
||||
]
|
||||
})}
|
||||
displayEmpty
|
||||
breakpoints={{ xs: 12, md: 6 }}
|
||||
/>
|
||||
|
||||
@@ -3,20 +3,17 @@ import PropTypes from 'prop-types'
|
||||
|
||||
import { AppBar, Tabs, Tab, Box } from '@material-ui/core'
|
||||
import InfoIcon from '@material-ui/icons/Info'
|
||||
import ClusterIcon from '@material-ui/icons/Storage'
|
||||
import DatastoreIcon from '@material-ui/icons/FolderOpen'
|
||||
import NetworkIcon from '@material-ui/icons/AccountTree'
|
||||
import HostIcon from '@material-ui/icons/VideogameAsset'
|
||||
|
||||
import InfoTab from 'client/containers/Provisions/DialogInfo/info'
|
||||
import ClustersTab from 'client/containers/Provisions/DialogInfo/clusters'
|
||||
import DatastoresTab from 'client/containers/Provisions/DialogInfo/datastores'
|
||||
import NetworksTab from 'client/containers/Provisions/DialogInfo/networks'
|
||||
import HostsTab from 'client/containers/Provisions/DialogInfo/hosts'
|
||||
|
||||
const TABS = [
|
||||
{ name: 'info', icon: InfoIcon, content: InfoTab },
|
||||
{ name: 'clusters', icon: ClusterIcon, content: ClustersTab },
|
||||
{ name: 'datastores', icon: DatastoreIcon, content: DatastoresTab },
|
||||
{ name: 'networks', icon: NetworkIcon, content: NetworksTab },
|
||||
{ name: 'hosts', icon: HostIcon, content: HostsTab }
|
||||
|
||||
@@ -6,24 +6,8 @@ import { CheckBox, CheckBoxOutlineBlank } from '@material-ui/icons'
|
||||
import clsx from 'clsx'
|
||||
|
||||
import useStyles from 'client/containers/Provisions/DialogInfo/styles'
|
||||
import { PROVISIONS_STATES } from 'client/constants/provision'
|
||||
import { Tr } from 'client/components/HOC'
|
||||
import {
|
||||
Information,
|
||||
Name,
|
||||
Description,
|
||||
ProviderLabel,
|
||||
StartTime,
|
||||
Permissions,
|
||||
Use,
|
||||
Manage,
|
||||
Admin,
|
||||
Ownership,
|
||||
Owner,
|
||||
Group,
|
||||
Other,
|
||||
State
|
||||
} from 'client/constants/translates'
|
||||
import { T, PROVISIONS_STATES } from 'client/constants'
|
||||
|
||||
const Info = memo(({ data }) => {
|
||||
const classes = useStyles()
|
||||
@@ -33,9 +17,11 @@ const Info = memo(({ data }) => {
|
||||
description,
|
||||
name,
|
||||
provider: providerName,
|
||||
start_time: time
|
||||
start_time: time,
|
||||
provision: { infrastructure = {} }
|
||||
} = TEMPLATE?.PROVISION_BODY
|
||||
|
||||
const { id: clusterId, name: clusterName } = infrastructure?.clusters?.[0]
|
||||
const stateInfo = PROVISIONS_STATES[state]
|
||||
|
||||
const isChecked = checked =>
|
||||
@@ -47,7 +33,7 @@ const Info = memo(({ data }) => {
|
||||
<Paper variant="outlined">
|
||||
<List className={clsx(classes.list, 'w-50')}>
|
||||
<ListItem className={classes.title}>
|
||||
<Typography>{Tr(Information)}</Typography>
|
||||
<Typography>{Tr(T.Information)}</Typography>
|
||||
</ListItem>
|
||||
<Divider />
|
||||
<ListItem>
|
||||
@@ -55,25 +41,29 @@ const Info = memo(({ data }) => {
|
||||
<Typography>{ID}</Typography>
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<Typography>{Tr(Name)}</Typography>
|
||||
<Typography>{Tr(T.Name)}</Typography>
|
||||
<Typography>{name}</Typography>
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<Typography>{Tr(Description)}</Typography>
|
||||
<Typography>{Tr(T.Description)}</Typography>
|
||||
<Typography>{description}</Typography>
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<Typography>{Tr(ProviderLabel)}</Typography>
|
||||
<Typography>{Tr(T.ProviderLabel)}</Typography>
|
||||
<Typography>{providerName}</Typography>
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<Typography>{Tr(StartTime)}</Typography>
|
||||
<Typography>{Tr(T.ClustersLabel)}</Typography>
|
||||
<Typography>{`${clusterId} - ${clusterName}`}</Typography>
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<Typography>{Tr(T.StartTime)}</Typography>
|
||||
<Typography>
|
||||
{new Date(time * 1000).toLocaleString()}
|
||||
</Typography>
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<Typography>{Tr(State)}</Typography>
|
||||
<Typography>{Tr(T.State)}</Typography>
|
||||
<Chip
|
||||
size="small"
|
||||
label={stateInfo?.name}
|
||||
@@ -87,26 +77,26 @@ const Info = memo(({ data }) => {
|
||||
<Paper variant="outlined" className={classes.permissions}>
|
||||
<List className={clsx(classes.list, 'w-25')}>
|
||||
<ListItem className={classes.title}>
|
||||
<Typography>{Tr(Permissions)}</Typography>
|
||||
<Typography>{Tr(Use)}</Typography>
|
||||
<Typography>{Tr(Manage)}</Typography>
|
||||
<Typography>{Tr(Admin)}</Typography>
|
||||
<Typography>{Tr(T.Permissions)}</Typography>
|
||||
<Typography>{Tr(T.Use)}</Typography>
|
||||
<Typography>{Tr(T.Manage)}</Typography>
|
||||
<Typography>{Tr(T.Admin)}</Typography>
|
||||
</ListItem>
|
||||
<Divider />
|
||||
<ListItem>
|
||||
<Typography>{Tr(Owner)}</Typography>
|
||||
<Typography>{Tr(T.Owner)}</Typography>
|
||||
<Typography>{isChecked(PERMISSIONS.OWNER_U)}</Typography>
|
||||
<Typography>{isChecked(PERMISSIONS.OWNER_M)}</Typography>
|
||||
<Typography>{isChecked(PERMISSIONS.OWNER_A)}</Typography>
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<Typography>{Tr(Group)}</Typography>
|
||||
<Typography>{Tr(T.Group)}</Typography>
|
||||
<Typography>{isChecked(PERMISSIONS.GROUP_U)}</Typography>
|
||||
<Typography>{isChecked(PERMISSIONS.GROUP_M)}</Typography>
|
||||
<Typography>{isChecked(PERMISSIONS.GROUP_A)}</Typography>
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<Typography>{Tr(Other)}</Typography>
|
||||
<Typography>{Tr(T.Other)}</Typography>
|
||||
<Typography>{isChecked(PERMISSIONS.OTHER_U)}</Typography>
|
||||
<Typography>{isChecked(PERMISSIONS.OTHER_M)}</Typography>
|
||||
<Typography>{isChecked(PERMISSIONS.OTHER_A)}</Typography>
|
||||
@@ -116,15 +106,15 @@ const Info = memo(({ data }) => {
|
||||
<Paper variant="outlined">
|
||||
<List className={clsx(classes.list, 'w-50')}>
|
||||
<ListItem className={classes.title}>
|
||||
<Typography>{Tr(Ownership)}</Typography>
|
||||
<Typography>{Tr(T.Ownership)}</Typography>
|
||||
</ListItem>
|
||||
<Divider />
|
||||
<ListItem>
|
||||
<Typography>{Tr(Owner)}</Typography>
|
||||
<Typography>{Tr(T.Owner)}</Typography>
|
||||
<Typography>{UNAME}</Typography>
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<Typography>{Tr(Group)}</Typography>
|
||||
<Typography>{Tr(T.Group)}</Typography>
|
||||
<Typography>{GNAME}</Typography>
|
||||
</ListItem>
|
||||
</List>
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import React, { memo, useEffect } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
|
||||
import DeleteIcon from '@material-ui/icons/Delete'
|
||||
|
||||
import useFetchAll from 'client/hooks/useFetchAll'
|
||||
import useOpennebula from 'client/hooks/useOpennebula'
|
||||
import ListCards from 'client/components/List/ListCards'
|
||||
import { SelectCard } from 'client/components/Cards'
|
||||
import { NetworkCard } from 'client/components/Cards'
|
||||
|
||||
const Networks = memo(({ hidden, data }) => {
|
||||
const {
|
||||
@@ -25,10 +27,13 @@ const Networks = memo(({ hidden, data }) => {
|
||||
<ListCards
|
||||
list={list}
|
||||
isLoading={loading}
|
||||
CardComponent={SelectCard}
|
||||
cardsProps={({ value: { ID, NAME } }) => ({
|
||||
title: `${ID} - ${NAME}`,
|
||||
stylesProps: { minHeight: 75 }
|
||||
CardComponent={NetworkCard}
|
||||
cardsProps={({ value: { ID } }) => ({
|
||||
actions: [{
|
||||
handleClick: () => undefined,
|
||||
icon: DeleteIcon,
|
||||
cy: `provision-vnet-delete-${ID}`
|
||||
}]
|
||||
})}
|
||||
displayEmpty
|
||||
breakpoints={{ xs: 12, md: 6 }}
|
||||
|
||||
@@ -3,6 +3,8 @@ import React, { useState, useEffect, createElement } from 'react'
|
||||
import { useHistory } from 'react-router-dom'
|
||||
import { Container, Box, Typography, Divider } from '@material-ui/core'
|
||||
import RefreshIcon from '@material-ui/icons/Autorenew'
|
||||
import InfoIcon from '@material-ui/icons/Info'
|
||||
import DeleteIcon from '@material-ui/icons/Delete'
|
||||
|
||||
import { PATH } from 'client/router/provision'
|
||||
import useProvision from 'client/hooks/useProvision'
|
||||
@@ -57,21 +59,32 @@ function Provisions () {
|
||||
isLoading={provisions.length === 0 && loading}
|
||||
handleCreate={() => history.push(PATH.PROVISIONS.CREATE)}
|
||||
CardComponent={ProvisionCard}
|
||||
cardsProps={({ value }) => ({
|
||||
handleShow: () => setShowDialog({
|
||||
id: value.ID,
|
||||
title: `(ID: ${value.ID}) ${value.NAME}`,
|
||||
content: DialogInfo
|
||||
}),
|
||||
handleDelete: () => setShowDialog({
|
||||
id: value.ID,
|
||||
title: `DELETE provider - (ID: ${value.ID}) ${value.NAME}`,
|
||||
handleAccept: () => {
|
||||
deleteProvision({ id: value.ID })
|
||||
setShowDialog(false)
|
||||
cardsProps={({ value: { ID, NAME } }) => ({
|
||||
actions: [
|
||||
{
|
||||
handleClick: () => setShowDialog({
|
||||
id: ID,
|
||||
title: `(ID: ${ID}) ${NAME}`,
|
||||
content: DialogInfo
|
||||
}),
|
||||
icon: InfoIcon,
|
||||
iconColor: 'primary',
|
||||
cy: `provision-info-${ID}`
|
||||
},
|
||||
content: DialogInfo
|
||||
})
|
||||
{
|
||||
handleClick: () => setShowDialog({
|
||||
id: ID,
|
||||
title: `DELETE provision - (ID: ${ID}) ${NAME}`,
|
||||
handleAccept: () => {
|
||||
deleteProvision({ id: ID })
|
||||
setShowDialog(false)
|
||||
},
|
||||
content: DialogInfo
|
||||
}),
|
||||
icon: DeleteIcon,
|
||||
cy: `provision-delete-${ID}`
|
||||
}
|
||||
]
|
||||
})}
|
||||
breakpoints={{ xs: 12, sm: 6, md: 4 }}
|
||||
/>
|
||||
|
||||
Reference in new issue
Block a user