-
Notifications
You must be signed in to change notification settings - Fork 488
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added Graphs tab * Added PCI tab * MultiChart is used for PCI subtab - this also enables exporting in CSV & PDF format Signed-off-by: Victor Hansson <[email protected]>
- Loading branch information
1 parent
e6e8202
commit 5ba0cd9
Showing
7 changed files
with
286 additions
and
19 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
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
79 changes: 79 additions & 0 deletions
79
src/fireedge/src/client/components/Tabs/Host/Graphs/index.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,79 @@ | ||
/* ------------------------------------------------------------------------- * | ||
* 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 { Grid } from '@mui/material' | ||
import { prettyBytes } from 'client/utils' | ||
import PropTypes from 'prop-types' | ||
import { ReactElement } from 'react' | ||
import { Chartist } from 'client/components/Charts' | ||
import { T } from 'client/constants' | ||
import { useGetHostMonitoringQuery } from 'client/features/OneApi/host' | ||
|
||
/** | ||
* Renders the host Graph tab. | ||
* | ||
* @param {object} props - Props | ||
* @param {string} props.id - Host id | ||
* @returns {ReactElement} Graphs tab | ||
*/ | ||
const HostGraphTab = ({ id }) => { | ||
const { | ||
data: { MONITORING_DATA: { MONITORING: monitoring = [] } = {} } = {}, | ||
} = useGetHostMonitoringQuery(id) || {} | ||
|
||
const cpuMemoryData = monitoring?.map(({ TIMESTAMP, CAPACITY }) => ({ | ||
TIMESTAMP, | ||
...CAPACITY, | ||
})) | ||
|
||
return ( | ||
<Grid container spacing={1}> | ||
<Grid item xs={12} sm={12}> | ||
<Chartist | ||
name={'CPU'} | ||
filter={['FREE_CPU', 'USED_CPU']} | ||
data={cpuMemoryData} | ||
y={['FREE_CPU', 'USED_CPU']} | ||
x="TIMESTAMP" | ||
enableLegend={true} | ||
legendNames={[T.FreeCPU, T.UsedCPU]} | ||
lineColors={['#039be5', '#757575']} | ||
/> | ||
</Grid> | ||
<Grid item xs={12} sm={12}> | ||
<Chartist | ||
name={T.Memory} | ||
filter={['FREE_MEMORY', 'USED_MEMORY']} | ||
data={cpuMemoryData} | ||
y={['FREE_MEMORY', 'USED_MEMORY']} | ||
x="TIMESTAMP" | ||
enableLegend={true} | ||
lineColors={['#039be5', '#757575']} | ||
legendNames={[T.FreeMemory, T.UsedMemory]} | ||
interpolationY={(value) => prettyBytes(value)} | ||
/> | ||
</Grid> | ||
</Grid> | ||
) | ||
} | ||
|
||
HostGraphTab.propTypes = { | ||
tabProps: PropTypes.object, | ||
id: PropTypes.string, | ||
} | ||
|
||
HostGraphTab.displayName = 'HostGraphTab' | ||
|
||
export default HostGraphTab |
136 changes: 136 additions & 0 deletions
136
src/fireedge/src/client/components/Tabs/Host/PCI/index.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,136 @@ | ||
/* ------------------------------------------------------------------------- * | ||
* 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, useState, useCallback } from 'react' | ||
import { MultiChart } from 'client/components/Charts' | ||
import { useGetHostQuery } from 'client/features/OneApi/host' | ||
import { transformApiResponseToDataset } from 'client/components/Charts/MultiChart/helpers/scripts' | ||
import { Select, MenuItem, InputLabel, FormControl, Box } from '@mui/material' | ||
import _ from 'lodash' | ||
|
||
const keyMap = { | ||
ADDRESS: 'fullAddress', | ||
SHORT_ADDRESS: 'shortAddress', | ||
TYPE: 'type', | ||
DEVICE_NAME: 'deviceName', | ||
VENDOR_NAME: 'vendor', | ||
VMID: 'vmId', | ||
} | ||
|
||
const DataGridColumns = [ | ||
{ field: 'vmId', headerName: 'VM', flex: 1, type: 'number' }, | ||
{ field: 'shortAddress', headerName: 'Address', flex: 1 }, | ||
{ field: 'type', headerName: 'Type', flex: 1 }, | ||
{ field: 'deviceName', headerName: 'Name', flex: 1 }, | ||
{ field: 'vendor', headerName: 'Vendor', flex: 1, type: 'number' }, | ||
] | ||
|
||
const metricKeys = ['vmId'] | ||
|
||
const metricNames = { | ||
shortAddress: 'PCI Address', | ||
type: 'Type', | ||
deviceName: 'Name', | ||
vmId: 'VMs', | ||
} | ||
|
||
const labelingFunc = () => `PCI` | ||
|
||
/** | ||
* Renders mainly information tab. | ||
* | ||
* @param {object} props - Props | ||
* @param {string} props.id - Host id | ||
* @returns {ReactElement} Information tab | ||
*/ | ||
const HostPciTab = ({ id }) => { | ||
const [chartType, setChartType] = useState('table') | ||
const { data } = useGetHostQuery({ id }) | ||
|
||
const pciDevicesPath = 'HOST_SHARE.PCI_DEVICES.PCI' | ||
|
||
const transformedDataset = transformApiResponseToDataset( | ||
data, | ||
keyMap, | ||
metricKeys, | ||
labelingFunc, | ||
0, | ||
pciDevicesPath | ||
) | ||
|
||
const handleChartTypeChange = useCallback((event) => { | ||
const newChartType = event.target.value | ||
setChartType(newChartType) | ||
}, []) | ||
|
||
transformedDataset.dataset.data.forEach((dev, idx) => { | ||
if (+dev.vmId < 0) { | ||
_.set(transformedDataset.dataset.data, [idx, 'vmId'], '0') | ||
} | ||
}) | ||
|
||
return ( | ||
<> | ||
<Box | ||
display="flex" | ||
alignItems="center" | ||
justifyContent="flex-start" | ||
gap={2} | ||
> | ||
<FormControl | ||
variant="outlined" | ||
size="small" | ||
style={{ marginRight: 2, minWidth: 120 }} | ||
> | ||
<InputLabel>Chart Type</InputLabel> | ||
<Select | ||
value={chartType} | ||
onChange={handleChartTypeChange} | ||
label="Chart Type" | ||
> | ||
<MenuItem value="line">Line Chart</MenuItem> | ||
<MenuItem value="bar">Bar Chart</MenuItem> | ||
<MenuItem value="area">Area Chart</MenuItem> | ||
<MenuItem value="table">Table Chart</MenuItem> | ||
</Select> | ||
</FormControl> | ||
</Box> | ||
<MultiChart | ||
datasets={[ | ||
{ | ||
...transformedDataset.dataset, | ||
...transformedDataset.error, | ||
...transformedDataset.isEmpty, | ||
}, | ||
]} | ||
metricNames={metricNames} | ||
chartType={chartType} | ||
ItemsPerPage={10} | ||
tableColumns={DataGridColumns} | ||
groupBy={'deviceName'} | ||
/> | ||
</> | ||
) | ||
} | ||
|
||
HostPciTab.propTypes = { | ||
tabProps: PropTypes.object, | ||
id: PropTypes.string, | ||
} | ||
|
||
HostPciTab.displayName = 'HostPciTab' | ||
|
||
export default HostPciTab |
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.