Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 3x 1x 2x 2x 1x 2x 1x 2x 2x 1x | /* * Copyright 2022 Harness Inc. All rights reserved. * Use of this source code is governed by the PolyForm Shield 1.0.0 license * that can be found in the licenses directory at the root of this repository, also available at * https://polyformproject.org/wp-content/uploads/2020/06/PolyForm-Shield-1.0.0.txt. */ import React, { useMemo } from 'react' import { Container, Layout, Text, Card } from '@wings-software/uicore' import { Color, FontVariation } from '@harness/design-system' import { useStrings } from 'framework/strings' import { HorizontalLayout, LEGEND_LIMIT, ListType, Stats, TableList } from '@ce/components/OverviewPage/OverviewPageLayout' import { CE_COLOR_CONST } from '@ce/components/CEChart/CEChartOptions' import formatCost from '@ce/utils/formatCost' import css from '../../pages/anomalies-overview/AnomaliesOverviewPage.module.scss' interface AnomaliesOverviewProps { costData: Record<string, any> perspectiveAnomaliesData: Record<string, any>[] cloudProvidersWiseData: Record<string, any>[] statusWiseData: Record<string, any>[] allDefaultProviders: Record<string, any> } const map: Record<string, string> = { AZURE: 'defaultAzurePerspectiveId', AWS: 'defaultAwsPerspectiveId', GCP: 'defaultGcpPerspectiveId' } const transformCloudCost = (data: Record<string, any>[], providers: Record<string, any>): Stats[] => { return data.map((d, idx) => { return { label: d.name as string, value: d.anomalousCost, count: d.count, trend: 0, legendColor: CE_COLOR_CONST[idx % CE_COLOR_CONST.length], linkId: providers[map[d.name as string]] } }) } const AnomaliesSummary: React.FC<AnomaliesOverviewProps> = ({ costData, perspectiveAnomaliesData, cloudProvidersWiseData, statusWiseData, allDefaultProviders }) => { const { getString } = useStrings() const cloudProviderChartData = useMemo( () => transformCloudCost(cloudProvidersWiseData, allDefaultProviders), [cloudProvidersWiseData] ) const perspectiveWiseChartData = useMemo( () => transformCloudCost(perspectiveAnomaliesData, allDefaultProviders), [perspectiveAnomaliesData] ) const statusWiseChartData = useMemo(() => transformCloudCost(statusWiseData, allDefaultProviders), [statusWiseData]) return ( <Layout.Horizontal spacing="medium"> <Layout.Vertical spacing="small"> <Card className={css.countCard}> <Text color={Color.GREY_600} font={{ variation: FontVariation.SMALL_SEMI }}> {getString('ce.anomalyDetection.summary.totalCountText')} </Text> <Text color={Color.RED_600} font={{ variation: FontVariation.H4 }}> {costData?.count} </Text> </Card> <Card className={css.costCard}> <Text color={Color.GREY_600} font={{ variation: FontVariation.SMALL_SEMI }}> {getString('ce.anomalyDetection.summary.costImpacted')} </Text> <Text color={Color.RED_500} font={{ variation: FontVariation.H4 }}> {formatCost(costData?.anomalousCost || 0)} </Text> </Card> </Layout.Vertical> <Container className={css.summaryCharts}> <HorizontalLayout title={getString('ce.anomalyDetection.summary.perspectiveWise')} chartData={perspectiveWiseChartData} showTrendInChart={false} totalCost={{ label: '', value: 0, trend: 0, legendColor: '' }} chartSize={120} headingSize={'small'} showGist={false} sideBar={ <TableList data={perspectiveWiseChartData.slice(0, LEGEND_LIMIT)} type={ListType.KEY_VALUE} classNames={css.rowGap8} /> } /> </Container> <Container className={css.summaryCharts}> <HorizontalLayout title={getString('ce.anomalyDetection.summary.cloudProvidersWise')} chartData={cloudProviderChartData} showTrendInChart={false} totalCost={{ label: '', value: 0, trend: 0, legendColor: '' }} chartSize={120} headingSize={'small'} showGist={false} sideBar={ <TableList data={cloudProviderChartData.slice(0, LEGEND_LIMIT)} type={ListType.KEY_VALUE} classNames={css.rowGap8} /> } /> </Container> <Container className={css.summaryCharts}> <HorizontalLayout title={getString('ce.anomalyDetection.summary.statusWise')} chartData={statusWiseChartData} showTrendInChart={false} totalCost={{ label: '', value: 0, trend: 0, legendColor: '' }} chartSize={120} headingSize={'small'} showGist={false} sideBar={ <TableList data={statusWiseChartData.slice(0, LEGEND_LIMIT)} type={ListType.KEY_VALUE} classNames={css.rowGap8} showCost={false} /> } /> </Container> </Layout.Horizontal> ) } export default AnomaliesSummary |