forked from opensearch-project/dashboards-observability
-
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.
Signed-off-by: SuZhou-Joe <[email protected]>
- Loading branch information
1 parent
c8fb54e
commit eaba163
Showing
7 changed files
with
168 additions
and
175 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React, { useState, useEffect, useCallback } from 'react'; | ||
import { useSelector } from 'react-redux'; | ||
import { EuiDataGridColumn } from '@elastic/eui'; | ||
import { | ||
DataGrid, | ||
DataGridProps, | ||
} from '../../components/event_analytics/explorer/events_views/data_grid'; | ||
import { getOSDHttp, getPPLService } from '../../../common/utils'; | ||
import { selectFields } from '../../components/event_analytics/redux/slices/field_slice'; | ||
import { initialTabId } from '../../framework/redux/store/shared_state'; | ||
import { useFetchEvents } from '../../components/event_analytics/hooks'; | ||
import { redoQuery } from '../../components/event_analytics/utils/utils'; | ||
import { DEFAULT_TIMESTAMP_COLUMN } from '../../../common/constants/explorer'; | ||
import { RenderProps } from '../../types'; | ||
|
||
export const DataGridContainer = ( | ||
props: Pick<DataGridProps, 'rawQuery'> & { renderProps: RenderProps } | ||
) => { | ||
const { renderProps, ...others } = props; | ||
const pplService = getPPLService(); | ||
const http = getOSDHttp(); | ||
const tabId = initialTabId; | ||
const explorerFields = useSelector(selectFields)[tabId]; | ||
const { fetchEvents } = useFetchEvents({ | ||
pplService, | ||
requestParams: { | ||
tabId, | ||
}, | ||
}); | ||
const [data, setData] = useState<any[]>([]); | ||
const isFullScreen = renderProps.chatContext.flyoutFullScreen; | ||
useEffect(() => { | ||
if (props.rawQuery) { | ||
redoQuery( | ||
'', | ||
'', | ||
props.rawQuery || '', | ||
'', | ||
{ current: [] }, | ||
{ current: [0, 5] }, | ||
fetchEvents, | ||
setData | ||
); | ||
} | ||
}, [props.rawQuery]); | ||
const formatGridColumn = useCallback( | ||
(columns: EuiDataGridColumn[]) => | ||
columns.map((item) => { | ||
if (item.id === DEFAULT_TIMESTAMP_COLUMN.id) { | ||
const { initialWidth, ...otherConfig } = item; | ||
return { | ||
...otherConfig, | ||
initialWidth: renderProps.chatContext.flyoutFullScreen ? initialWidth : 50, | ||
}; | ||
} | ||
|
||
return item; | ||
}), | ||
[renderProps.chatContext.flyoutFullScreen] | ||
); | ||
if (!data.length || !props.rawQuery) { | ||
return null; | ||
} | ||
return ( | ||
<div style={{ overflowX: 'hidden' }}> | ||
<DataGrid | ||
http={http} | ||
pplService={pplService} | ||
rows={data} | ||
explorerFields={explorerFields} | ||
timeStampField="timestamp" | ||
totalHits={data.length} | ||
requestParams={{ | ||
tabId, | ||
}} | ||
startTime={''} | ||
endTime="now" | ||
storedSelectedColumns={[]} | ||
formatGridColumn={formatGridColumn} | ||
OUIDataGridProps={{ | ||
gridStyle: isFullScreen | ||
? {} | ||
: { | ||
fontSize: 's', | ||
cellPadding: 's', | ||
}, | ||
/** | ||
* Chatbot's default width is smaller than 478 | ||
*/ | ||
minSizeForControls: 300, | ||
/** | ||
* In non-fullscreen mode, it requires at least 80px to avoid truncate. | ||
*/ | ||
rowHeightsOptions: { | ||
defaultHeight: isFullScreen ? undefined : 80, | ||
}, | ||
}} | ||
{...others} | ||
/> | ||
</div> | ||
); | ||
}; |
78 changes: 0 additions & 78 deletions
78
public/dependencies/components/ppl_visualization_model.tsx
This file was deleted.
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
Oops, something went wrong.