44 * you may not use this file except in compliance with the Elastic License.
55 */
66
7- import React from 'react' ;
7+ import React , { useCallback } from 'react' ;
88import { useInterval } from 'react-use' ;
99
10- import { euiPaletteColorBlind } from '@elastic/eui' ;
11- import { NodesOverview } from './nodes_overview ' ;
12- import { Toolbar } from './toolbars/toolbar ' ;
10+ import { euiPaletteColorBlind , EuiFlexGroup , EuiFlexItem } from '@elastic/eui' ;
11+ import { convertIntervalToString } from '../../../../utils/convert_interval_to_string ' ;
12+ import { NodesOverview , calculateBoundsFromNodes } from './nodes_overview ' ;
1313import { PageContent } from '../../../../components/page' ;
1414import { useSnapshot } from '../hooks/use_snaphot' ;
15- import { useInventoryMeta } from '../hooks/use_inventory_meta' ;
1615import { useWaffleTimeContext } from '../hooks/use_waffle_time' ;
1716import { useWaffleFiltersContext } from '../hooks/use_waffle_filters' ;
1817import { useWaffleOptionsContext } from '../hooks/use_waffle_options' ;
1918import { useSourceContext } from '../../../../containers/source' ;
2019import { InfraFormatterType , InfraWaffleMapGradientLegend } from '../../../../lib/lib' ;
20+ import { euiStyled } from '../../../../../../observability/public' ;
21+ import { Toolbar } from './toolbars/toolbar' ;
22+ import { ViewSwitcher } from './waffle/view_switcher' ;
23+ import { SavedViews } from './saved_views' ;
24+ import { IntervalLabel } from './waffle/interval_label' ;
25+ import { Legend } from './waffle/legend' ;
26+ import { createInventoryMetricFormatter } from '../lib/create_inventory_metric_formatter' ;
2127
2228const euiVisColorPalette = euiPaletteColorBlind ( ) ;
2329
@@ -34,7 +40,6 @@ export const Layout = () => {
3440 autoBounds,
3541 boundsOverride,
3642 } = useWaffleOptionsContext ( ) ;
37- const { accounts, regions } = useInventoryMeta ( sourceId , nodeType ) ;
3843 const { currentTime, jumpToTime, isAutoReloading } = useWaffleTimeContext ( ) ;
3944 const { filterQueryAsJson, applyFilterQuery } = useWaffleFiltersContext ( ) ;
4045 const { loading, nodes, reload, interval } = useSnapshot (
@@ -72,25 +77,75 @@ export const Layout = () => {
7277 isAutoReloading ? 5000 : null
7378 ) ;
7479
80+ const intervalAsString = convertIntervalToString ( interval ) ;
81+ const dataBounds = calculateBoundsFromNodes ( nodes ) ;
82+ const bounds = autoBounds ? dataBounds : boundsOverride ;
83+ const formatter = useCallback ( createInventoryMetricFormatter ( options . metric ) , [ options . metric ] ) ;
84+
7585 return (
7686 < >
77- < Toolbar accounts = { accounts } regions = { regions } nodeType = { nodeType } />
7887 < PageContent >
79- < NodesOverview
80- nodes = { nodes }
81- options = { options }
82- nodeType = { nodeType }
83- loading = { loading }
84- reload = { reload }
85- onDrilldown = { applyFilterQuery }
86- currentTime = { currentTime }
87- onViewChange = { changeView }
88- view = { view }
89- autoBounds = { autoBounds }
90- boundsOverride = { boundsOverride }
91- interval = { interval }
92- />
88+ < MainContainer >
89+ < TopActionContainer >
90+ < EuiFlexGroup justifyContent = "spaceBetween" gutterSize = "m" >
91+ < Toolbar nodeType = { nodeType } />
92+ < EuiFlexItem grow = { false } >
93+ < ViewSwitcher view = { view } onChange = { changeView } />
94+ </ EuiFlexItem >
95+ </ EuiFlexGroup >
96+ </ TopActionContainer >
97+ < NodesOverview
98+ nodes = { nodes }
99+ options = { options }
100+ nodeType = { nodeType }
101+ loading = { loading }
102+ reload = { reload }
103+ onDrilldown = { applyFilterQuery }
104+ currentTime = { currentTime }
105+ view = { view }
106+ autoBounds = { autoBounds }
107+ boundsOverride = { boundsOverride }
108+ formatter = { formatter }
109+ />
110+ < BottomActionContainer >
111+ < EuiFlexGroup justifyContent = "spaceBetween" >
112+ < EuiFlexItem grow = { false } >
113+ < SavedViews />
114+ </ EuiFlexItem >
115+ < EuiFlexItem grow = { false } style = { { position : 'relative' , minWidth : 400 } } >
116+ < Legend
117+ formatter = { formatter }
118+ bounds = { bounds }
119+ dataBounds = { dataBounds }
120+ legend = { options . legend }
121+ />
122+ </ EuiFlexItem >
123+ < EuiFlexItem grow = { false } >
124+ < IntervalLabel intervalAsString = { intervalAsString } />
125+ </ EuiFlexItem >
126+ </ EuiFlexGroup >
127+ </ BottomActionContainer >
128+ </ MainContainer >
93129 </ PageContent >
94130 </ >
95131 ) ;
96132} ;
133+
134+ const MainContainer = euiStyled . div `
135+ position: relative;
136+ flex: 1 1 auto;
137+ ` ;
138+
139+ const TopActionContainer = euiStyled . div `
140+ padding: ${ props => `12px ${ props . theme . eui . paddingSizes . m } ` } ;
141+ ` ;
142+
143+ const BottomActionContainer = euiStyled . div `
144+ background-color: ${ props => props . theme . eui . euiPageBackgroundColor } ;
145+ padding: ${ props => props . theme . eui . paddingSizes . m } ${ props =>
146+ props . theme . eui . paddingSizes . m } ${ props => props . theme . eui . paddingSizes . s } ;
147+ position: absolute;
148+ left: 0;
149+ bottom: 4px;
150+ right: 0;
151+ ` ;
0 commit comments