generated from amazon-archives/__template_Custom
-
Notifications
You must be signed in to change notification settings - Fork 106
Home table #169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Home table #169
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
9bd5b7e
Create history_table.tsx
kavithacm 97b09cb
Update history_table.tsx
kavithacm 78513c4
Update home.tsx
kavithacm 276a590
Update history_table.tsx
kavithacm 693b261
Update history_table.tsx
kavithacm ba84e8d
Update home.tsx
kavithacm f6cd878
Update home.tsx
kavithacm e7783f8
Delete home.tsx
kavithacm e4d33d3
merge (#3)
kavithacm 6487a5a
Merge branch 'opensearch-project:main' into main
kavithacm e1437d3
Merge branch 'opensearch-project:main' into main
kavithacm 679c225
Create history_table.tsx
kavithacm 2952b29
Update home.tsx
kavithacm 8c5bcd7
Update home.tsx
kavithacm 2192249
Delete history_table.tsx
kavithacm e6b4597
Update history_table.tsx
kavithacm f45d9f7
Update history_table.tsx
kavithacm 6c103f1
Update home.tsx
kavithacm 514546b
Update history_table.tsx
kavithacm 37ce69e
Update history_table.tsx
kavithacm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
101 changes: 101 additions & 0 deletions
101
dashboards-observability/public/components/explorer/home_table/history_table.tsx
This file contains hidden or 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,101 @@ | ||
| /* | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| * | ||
| * The OpenSearch Contributors require contributions made to | ||
| * this file be licensed under the Apache-2.0 license or a | ||
| * compatible open source license. | ||
| * | ||
| * Modifications Copyright OpenSearch Contributors. See | ||
| * GitHub history for details. | ||
| */ | ||
|
|
||
| import React, { useState, useRef, useEffect } from 'react'; | ||
|
|
||
| import { | ||
| EuiBasicTable, | ||
| EuiSpacer, | ||
| EuiLink, | ||
| } from '@elastic/eui'; | ||
|
|
||
|
|
||
| interface TableData { | ||
| savedHistory: []; | ||
| savedQuerySearch: (searchQuery: string, selectedDateRange: [], selectedTimeStamp, selectedFields: []) => void; | ||
| } | ||
|
|
||
| export function Table(options: TableData) { | ||
| const [pageIndex, setPageIndex] = useState(0); | ||
| const [pageSize, setPageSize] = useState(10); | ||
| const pageIndexRef = useRef(); | ||
| pageIndexRef.current = pageIndex; | ||
| const pageSizeRef = useRef(); | ||
| pageSizeRef.current = pageSize; | ||
|
|
||
|
|
||
| const onTableChange = ({ page = {} }) => { | ||
| const { index: pageIndex, size: pageSize } = page; | ||
|
|
||
| setPageIndex(pageIndex); | ||
| setPageSize(pageSize); | ||
| }; | ||
|
|
||
| const columns = [ | ||
| { | ||
| field: 'data', | ||
| name: 'Name', | ||
| render: (item)=>{return <EuiLink onClick={() => | ||
| {options.savedQuerySearch(item.query, [item.date_start, item.date_end], item.timestamp, item.fields)}}> | ||
| {item.name} | ||
| </EuiLink>}, | ||
| }, | ||
| { | ||
| field: 'description', | ||
| name: 'Description', | ||
| }, | ||
| ]; | ||
|
|
||
|
|
||
|
|
||
| const queries = options.savedHistory.map((h) => { | ||
| const savedObject = h.hasOwnProperty('savedVisualization') | ||
| ? h.savedVisualization | ||
| : h.savedQuery; | ||
| return { | ||
| data: { | ||
| name: savedObject.name, | ||
| query: savedObject.query, | ||
| date_start: savedObject.selected_date_range.start, | ||
| date_end : savedObject.selected_date_range.end, | ||
| timestamp: savedObject.selected_timestamp?.name || '', | ||
| fields: savedObject.selected_fields?.tokens || [] | ||
| }, | ||
| name: savedObject.name || '', | ||
| description: savedObject.description || '', | ||
|
|
||
| }; | ||
| }); | ||
|
|
||
|
|
||
| const totalItemCount = queries.length; | ||
|
|
||
| const pagination = { | ||
| pageIndex, | ||
| pageSize, | ||
| totalItemCount, | ||
| pageSizeOptions: [5, 10, 20, 50], | ||
| }; | ||
|
|
||
| return ( | ||
| <div> | ||
| <EuiSpacer size="xl" /> | ||
| <EuiBasicTable | ||
| items={queries.slice(pageIndex * pageSize, pageIndex * pageSize + pageSize)} | ||
| columns={columns} | ||
| pagination={pagination} | ||
| onChange={onTableChange} | ||
| /> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: Are we just showing the name in table? Or Are we adding Date Created and Date Modified to the table, like we have for notebooks and panels.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No we're just displaying the name of the query. All other details are just passed internally for dispatch