-
Notifications
You must be signed in to change notification settings - Fork 498
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: Frederick Borges <[email protected]>
- Loading branch information
1 parent
201d388
commit b06bd9a
Showing
79 changed files
with
4,483 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--- | ||
# This file describes the information and actions available in the VIRTUAL DATA CENTER tab | ||
|
||
# Resource | ||
|
||
resource_name: "VIRTUAL-DATA-CENTER" | ||
|
||
# Actions - Which buttons are visible to operate over the resources | ||
|
||
actions: | ||
create_dialog: true | ||
update_dialog: true | ||
delete: true | ||
edit_labels: true | ||
|
||
# Filters - List of criteria to filter the resources | ||
|
||
filters: | ||
label: true | ||
|
||
# Info Tabs - Which info tabs are used to show extended information | ||
|
||
info-tabs: | ||
info: | ||
enabled: true | ||
information_panel: | ||
enabled: true | ||
actions: | ||
rename: true | ||
attributes_panel: | ||
enabled: true | ||
actions: | ||
copy: true | ||
add: true | ||
edit: true | ||
delete: true | ||
|
||
groups: | ||
enabled: true | ||
clusters: | ||
enabled: true | ||
datastores: | ||
enabled: true | ||
hosts: | ||
enabled: true | ||
vnets: | ||
enabled: true | ||
|
||
|
||
# Dialogs | ||
dialogs: | ||
create_dialog: | ||
clusters: true | ||
datastores: true | ||
hosts: true | ||
vnets: true |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
173 changes: 173 additions & 0 deletions
173
src/fireedge/src/client/components/Cards/VirtualDataCenterCard.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
/* ------------------------------------------------------------------------- * | ||
* Copyright 2002-2023, OpenNebula Project, OpenNebula Systems * | ||
* * | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may * | ||
* not use this file except in compliance with the License. You may obtain * | ||
* a copy of the License at * | ||
* * | ||
* http://www.apache.org/licenses/LICENSE-2.0 * | ||
* * | ||
* Unless required by applicable law or agreed to in writing, software * | ||
* distributed under the License is distributed on an "AS IS" BASIS, * | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * | ||
* See the License for the specific language governing permissions and * | ||
* limitations under the License. * | ||
* ------------------------------------------------------------------------- */ | ||
import PropTypes from 'prop-types' | ||
import { ReactElement, memo, useMemo } from 'react' | ||
|
||
import { Typography } from '@mui/material' | ||
import { | ||
Server as ClusterIcon, | ||
Db as DatastoreIcon, | ||
Group as GroupIcon, | ||
HardDrive as HostIcon, | ||
Network as VNetIcon, | ||
} from 'iconoir-react' | ||
|
||
import MultipleTags from 'client/components/MultipleTags' | ||
import { useViews } from 'client/features/Auth' | ||
|
||
import { Tr } from 'client/components/HOC' | ||
import { StatusCircle } from 'client/components/Status' | ||
import { rowStyles } from 'client/components/Tables/styles' | ||
|
||
import { ACTIONS, ALL_SELECTED, RESOURCE_NAMES, T, VDC } from 'client/constants' | ||
import COLOR from 'client/constants/color' | ||
import { getColorFromString, getUniqueLabels } from 'client/models/Helper' | ||
|
||
const isAllSelected = (resourceArray) => | ||
resourceArray.length === 1 && resourceArray[0] === ALL_SELECTED | ||
|
||
const VirtualDataCenterCard = memo( | ||
/** | ||
* @param {object} props - Props | ||
* @param {VDC} props.template - Virtual Data Center resource | ||
* @param {object} props.rootProps - Props to root component | ||
* @param {function(string):Promise} [props.onClickLabel] - Callback to click label | ||
* @param {function(string):Promise} [props.onDeleteLabel] - Callback to delete label | ||
* @returns {ReactElement} - Card | ||
*/ | ||
({ template, rootProps, onClickLabel, onDeleteLabel }) => { | ||
const classes = rowStyles() | ||
const { [RESOURCE_NAMES.VDC]: vdcView } = useViews() | ||
|
||
const enableEditLabels = | ||
vdcView?.actions?.[ACTIONS.EDIT_LABELS] === true && !!onDeleteLabel | ||
|
||
const { | ||
ID, | ||
NAME, | ||
GROUPS, | ||
CLUSTERS, | ||
HOSTS, | ||
DATASTORES, | ||
VNETS, | ||
TEMPLATE: { LABELS }, | ||
} = template | ||
|
||
const groupsCount = useMemo(() => { | ||
const { ID: groupsIds = [] } = GROUPS | ||
const groupsArray = Array.isArray(groupsIds) ? groupsIds : [groupsIds] | ||
|
||
return groupsArray.length | ||
}, [GROUPS.ID]) | ||
|
||
const clustersCount = useMemo(() => { | ||
const { CLUSTER: clustersInfo = [] } = CLUSTERS | ||
const clustersArray = ( | ||
Array.isArray(clustersInfo) ? clustersInfo : [clustersInfo] | ||
).map((cluster) => cluster.CLUSTER_ID) | ||
|
||
return isAllSelected(clustersArray) ? T.All : clustersArray.length | ||
}, [CLUSTERS.CLUSTER]) | ||
|
||
const hostsCount = useMemo(() => { | ||
const { HOST: hostsInfo = [] } = HOSTS | ||
const hostsArray = ( | ||
Array.isArray(hostsInfo) ? hostsInfo : [hostsInfo] | ||
).map((host) => host.HOST_ID) | ||
|
||
return isAllSelected(hostsArray) ? T.All : hostsArray.length | ||
}, [HOSTS.HOST]) | ||
|
||
const datastoresCount = useMemo(() => { | ||
const { DATASTORE: datastoresInfo = [] } = DATASTORES | ||
const datastoresArray = ( | ||
Array.isArray(datastoresInfo) ? datastoresInfo : [datastoresInfo] | ||
).map((ds) => ds.DATASTORE_ID) | ||
|
||
return isAllSelected(datastoresArray) ? T.All : datastoresArray.length | ||
}, [DATASTORES.DATASTORE]) | ||
|
||
const vnetsCount = useMemo(() => { | ||
const { VNET: vnetsInfo = [] } = VNETS | ||
const vnetsArray = ( | ||
Array.isArray(vnetsInfo) ? vnetsInfo : [vnetsInfo] | ||
).map((vnet) => vnet.VNET_ID) | ||
|
||
return isAllSelected(vnetsArray) ? T.All : vnetsArray.length | ||
}, [VNETS.VNET]) | ||
|
||
const labels = useMemo( | ||
() => | ||
getUniqueLabels(LABELS).map((label) => ({ | ||
text: label, | ||
stateColor: getColorFromString(label), | ||
onClick: onClickLabel, | ||
onDelete: enableEditLabels && onDeleteLabel, | ||
})), | ||
[LABELS, enableEditLabels, onClickLabel, onDeleteLabel] | ||
) | ||
|
||
return ( | ||
<div {...rootProps} data-cy={`vdc-${ID}`}> | ||
<div className={classes.main}> | ||
<div className={classes.title}> | ||
<StatusCircle color={COLOR.success.main} /> | ||
<Typography component="span">{NAME}</Typography> | ||
<span className={classes.labels}> | ||
<MultipleTags tags={labels} /> | ||
</span> | ||
</div> | ||
<div className={classes.caption}> | ||
<span>{`#${ID}`}</span> | ||
<span title={`${Tr(T.Groups)}: ${groupsCount}`}> | ||
<GroupIcon /> | ||
<span>{` ${groupsCount}`}</span> | ||
</span> | ||
<span title={`${Tr(T.Clusters)}: ${clustersCount}`}> | ||
<ClusterIcon /> | ||
<span>{` ${clustersCount}`}</span> | ||
</span> | ||
<span title={`${Tr(T.Hosts)}: ${hostsCount}`}> | ||
<HostIcon /> | ||
<span>{` ${hostsCount}`}</span> | ||
</span> | ||
<span title={`${Tr(T.Datastores)}: ${datastoresCount}`}> | ||
<DatastoreIcon /> | ||
<span>{` ${datastoresCount}`}</span> | ||
</span> | ||
<span title={`${Tr(T.VirtualNetworks)}: ${vnetsCount}`}> | ||
<VNetIcon /> | ||
<span>{` ${vnetsCount}`}</span> | ||
</span> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} | ||
) | ||
|
||
VirtualDataCenterCard.propTypes = { | ||
template: PropTypes.object, | ||
rootProps: PropTypes.shape({ | ||
className: PropTypes.string, | ||
}), | ||
onClickLabel: PropTypes.func, | ||
onDeleteLabel: PropTypes.func, | ||
} | ||
|
||
VirtualDataCenterCard.displayName = 'VirtualDataCenterCard' | ||
|
||
export default VirtualDataCenterCard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.