forked from apache/ozone
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HDDS-11160. Improve Insights page UI (apache#7327)
- Loading branch information
1 parent
782ad62
commit 32a8c09
Showing
28 changed files
with
2,587 additions
and
441 deletions.
There are no files selected for viewing
643 changes: 261 additions & 382 deletions
643
hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/api/db.json
Large diffs are not rendered by default.
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
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
55 changes: 55 additions & 0 deletions
55
...ain/resources/webapps/recon/ozone-recon-web/src/v2/components/breadcrumbs/breadcrumbs.tsx
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,55 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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 React from 'react'; | ||
import { Breadcrumb } from 'antd'; | ||
import { HomeOutlined } from '@ant-design/icons'; | ||
import { Link, useLocation } from 'react-router-dom'; | ||
|
||
import { breadcrumbNameMap } from '@/v2/constants/breadcrumbs.constants'; | ||
|
||
const Breadcrumbs: React.FC<{}> = () => { | ||
const location = useLocation(); | ||
//Split and filter to remove empty strings | ||
const pathSnippets = location.pathname.split('/').filter(i => i); | ||
|
||
const extraBreadcrumbItems = pathSnippets.map((_: string, index: number) => { | ||
const url = `/${pathSnippets.slice(0, index + 1).join('/')}`; | ||
return ( | ||
<Breadcrumb.Item key={url}> | ||
<Link to={url}> | ||
{breadcrumbNameMap[url]} | ||
</Link> | ||
</Breadcrumb.Item> | ||
) | ||
}); | ||
|
||
const breadcrumbItems = [( | ||
<Breadcrumb.Item key='home'> | ||
<Link to='/'><HomeOutlined /></Link> | ||
</Breadcrumb.Item> | ||
)].concat(extraBreadcrumbItems); | ||
|
||
return ( | ||
<Breadcrumb> | ||
{breadcrumbItems} | ||
</Breadcrumb> | ||
); | ||
} | ||
|
||
export default Breadcrumbs; |
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
File renamed without changes.
149 changes: 149 additions & 0 deletions
149
...resources/webapps/recon/ozone-recon-web/src/v2/components/plots/insightsContainerPlot.tsx
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,149 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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 React from 'react'; | ||
import filesize from 'filesize'; | ||
import { EChartsOption } from 'echarts'; | ||
|
||
import EChart from '@/v2/components/eChart/eChart'; | ||
import { ContainerCountResponse, ContainerPlotData } from '@/v2/types/insights.types'; | ||
|
||
type ContainerSizeDistributionProps = { | ||
containerCountResponse: ContainerCountResponse[]; | ||
containerSizeError: string | undefined; | ||
} | ||
|
||
const size = filesize.partial({ standard: 'iec', round: 0 }); | ||
|
||
const ContainerSizeDistribution: React.FC<ContainerSizeDistributionProps> = ({ | ||
containerCountResponse, | ||
containerSizeError | ||
}) => { | ||
|
||
const [containerPlotData, setContainerPlotData] = React.useState<ContainerPlotData>({ | ||
containerCountValues: [], | ||
containerCountMap: new Map<number, number>() | ||
}); | ||
|
||
function updatePlotData() { | ||
const containerCountMap: Map<number, number> = containerCountResponse.reduce( | ||
(map: Map<number, number>, current) => { | ||
const containerSize = current.containerSize; | ||
const oldCount = map.get(containerSize) ?? 0; | ||
map.set(containerSize, oldCount + current.count); | ||
return map; | ||
}, | ||
new Map<number, number>() | ||
); | ||
|
||
const containerCountValues = Array.from(containerCountMap.keys()).map(value => { | ||
const upperbound = size(value); | ||
const upperboundPwr = Math.log2(value); | ||
|
||
const lowerbound = upperboundPwr > 10 ? size(2 ** (upperboundPwr - 1)) : size(0); | ||
return `${lowerbound} - ${upperbound}`; | ||
}); | ||
|
||
setContainerPlotData({ | ||
containerCountValues: containerCountValues, | ||
containerCountMap: containerCountMap | ||
}); | ||
} | ||
|
||
React.useEffect(() => { | ||
updatePlotData(); | ||
}, []); | ||
|
||
const { containerCountMap, containerCountValues } = containerPlotData; | ||
|
||
const containerPlotOptions: EChartsOption = { | ||
tooltip: { | ||
trigger: 'item', | ||
formatter: ({ data }) => { | ||
return `Size Range: <strong>${data.name}</strong><br>Count: <strong>${data.value}</strong>` | ||
} | ||
}, | ||
legend: { | ||
orient: 'vertical', | ||
left: 'right' | ||
}, | ||
series: { | ||
type: 'pie', | ||
radius: '50%', | ||
data: Array.from(containerCountMap?.values() ?? []).map((value, idx) => { | ||
return { | ||
value: value, | ||
name: containerCountValues[idx] ?? '' | ||
} | ||
}), | ||
}, | ||
graphic: (containerSizeError) ? { | ||
type: 'group', | ||
left: 'center', | ||
top: 'middle', | ||
z: 100, | ||
children: [ | ||
{ | ||
type: 'rect', | ||
left: 'center', | ||
top: 'middle', | ||
z: 100, | ||
shape: { | ||
width: 500, | ||
height: 500 | ||
}, | ||
style: { | ||
fill: 'rgba(256, 256, 256, 0.5)' | ||
} | ||
}, | ||
{ | ||
type: 'rect', | ||
left: 'center', | ||
top: 'middle', | ||
z: 100, | ||
shape: { | ||
width: 500, | ||
height: 40 | ||
}, | ||
style: { | ||
fill: '#FC909B' | ||
} | ||
}, | ||
{ | ||
type: 'text', | ||
left: 'center', | ||
top: 'middle', | ||
z: 100, | ||
style: { | ||
text: `No data available. ${containerSizeError}`, | ||
font: '20px sans-serif' | ||
} | ||
} | ||
] | ||
} : undefined | ||
} | ||
|
||
return (<> | ||
<EChart option={containerPlotOptions} style={{ | ||
width: '30vw', | ||
height: '65vh' | ||
}} /> | ||
</>) | ||
} | ||
|
||
export default ContainerSizeDistribution; |
Oops, something went wrong.