forked from opensearch-project/query-insights-dashboards
-
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.
Merge pull request #6 from opensearch-project/main
Top n queries overview page (#7)
- Loading branch information
Showing
9 changed files
with
373 additions
and
218 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,5 @@ yarn-error.log | |
.DS_Store | ||
/cypress/screenshots/ | ||
/cypress/videos/ | ||
target | ||
target | ||
.eslintcache |
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,119 +1,8 @@ | ||
import React, { useState } from 'react'; | ||
import { i18n } from '@osd/i18n'; | ||
import { FormattedMessage, I18nProvider } from '@osd/i18n/react'; | ||
import { BrowserRouter as Router } from 'react-router-dom'; | ||
|
||
import { | ||
EuiButton, | ||
EuiHorizontalRule, | ||
EuiPage, | ||
EuiPageBody, | ||
EuiPageContent, | ||
EuiPageContentBody, | ||
EuiPageContentHeader, | ||
EuiPageHeader, | ||
EuiTitle, | ||
EuiText, | ||
} from '@elastic/eui'; | ||
|
||
import React from 'react'; | ||
import { Route } from 'react-router-dom'; | ||
import TopNQueries from '../pages/TopNQueries/TopNQueries'; | ||
import { CoreStart } from '../../../../src/core/public'; | ||
import { NavigationPublicPluginStart } from '../../../../src/plugins/navigation/public'; | ||
|
||
import { PLUGIN_ID, PLUGIN_NAME } from '../../common'; | ||
|
||
interface QueryInsightsDashboardsAppDeps { | ||
basename: string; | ||
notifications: CoreStart['notifications']; | ||
http: CoreStart['http']; | ||
navigation: NavigationPublicPluginStart; | ||
} | ||
|
||
export const QueryInsightsDashboardsApp = ({ | ||
basename, | ||
notifications, | ||
http, | ||
navigation, | ||
}: QueryInsightsDashboardsAppDeps) => { | ||
// Use React hooks to manage state. | ||
const [timestamp, setTimestamp] = useState<string | undefined>(); | ||
|
||
const onClickHandler = () => { | ||
// Use the core http service to make a response to the server API. | ||
http.get('/api/query_insights_dashboards/example').then((res) => { | ||
setTimestamp(res.time); | ||
// Use the core notifications service to display a success message. | ||
notifications.toasts.addSuccess( | ||
i18n.translate('queryInsightsDashboards.dataUpdated', { | ||
defaultMessage: 'Data updated', | ||
}) | ||
); | ||
}); | ||
}; | ||
|
||
// Render the application DOM. | ||
// Note that `navigation.ui.TopNavMenu` is a stateful component exported on the `navigation` plugin's start contract. | ||
return ( | ||
<Router basename={basename}> | ||
<I18nProvider> | ||
<> | ||
<navigation.ui.TopNavMenu | ||
appName={PLUGIN_ID} | ||
showSearchBar={true} | ||
useDefaultBehaviors={true} | ||
/> | ||
<EuiPage restrictWidth="1000px"> | ||
<EuiPageBody component="main"> | ||
<EuiPageHeader> | ||
<EuiTitle size="l"> | ||
<h1> | ||
<FormattedMessage | ||
id="queryInsightsDashboards.helloWorldText" | ||
defaultMessage="{name}" | ||
values={{ name: PLUGIN_NAME }} | ||
/> | ||
</h1> | ||
</EuiTitle> | ||
</EuiPageHeader> | ||
<EuiPageContent> | ||
<EuiPageContentHeader> | ||
<EuiTitle> | ||
<h2> | ||
<FormattedMessage | ||
id="queryInsightsDashboards.congratulationsTitle" | ||
defaultMessage="Congratulations, you have successfully created a new OpenSearch Dashboards Plugin!" | ||
/> | ||
</h2> | ||
</EuiTitle> | ||
</EuiPageContentHeader> | ||
<EuiPageContentBody> | ||
<EuiText> | ||
<p> | ||
<FormattedMessage | ||
id="queryInsightsDashboards.content" | ||
defaultMessage="Look through the generated code and check out the plugin development documentation." | ||
/> | ||
</p> | ||
<EuiHorizontalRule /> | ||
<p> | ||
<FormattedMessage | ||
id="queryInsightsDashboards.timestampText" | ||
defaultMessage="Last timestamp: {time}" | ||
values={{ time: timestamp ? timestamp : 'Unknown' }} | ||
/> | ||
</p> | ||
<EuiButton type="primary" size="s" onClick={onClickHandler}> | ||
<FormattedMessage | ||
id="queryInsightsDashboards.buttonText" | ||
defaultMessage="Get data" | ||
/> | ||
</EuiButton> | ||
</EuiText> | ||
</EuiPageContentBody> | ||
</EuiPageContent> | ||
</EuiPageBody> | ||
</EuiPage> | ||
</> | ||
</I18nProvider> | ||
</Router> | ||
); | ||
export const QueryInsightsDashboardsApp = ({ core }: { core: CoreStart }) => { | ||
return <Route render={() => <TopNQueries core={core} />} />; | ||
}; |
Oops, something went wrong.