diff --git a/frontend/public/locales/en-GB/routes.json b/frontend/public/locales/en-GB/routes.json index f3df8f6c9d..625638d85f 100644 --- a/frontend/public/locales/en-GB/routes.json +++ b/frontend/public/locales/en-GB/routes.json @@ -2,5 +2,8 @@ "general": "General", "alert_channels": "Alert Channels", "organization_settings": "Organization Settings", - "my_settings": "My Settings" + "my_settings": "My Settings", + "overview_metrics": "Overview Metrics", + "dbcall_metrics": "Database Calls", + "external_metrics": "External Calls" } diff --git a/frontend/public/locales/en/routes.json b/frontend/public/locales/en/routes.json index f3df8f6c9d..625638d85f 100644 --- a/frontend/public/locales/en/routes.json +++ b/frontend/public/locales/en/routes.json @@ -2,5 +2,8 @@ "general": "General", "alert_channels": "Alert Channels", "organization_settings": "Organization Settings", - "my_settings": "My Settings" + "my_settings": "My Settings", + "overview_metrics": "Overview Metrics", + "dbcall_metrics": "Database Calls", + "external_metrics": "External Calls" } diff --git a/frontend/src/components/RouteTab/index.tsx b/frontend/src/components/RouteTab/index.tsx index 4a565d84b9..1192f2f8e2 100644 --- a/frontend/src/components/RouteTab/index.tsx +++ b/frontend/src/components/RouteTab/index.tsx @@ -27,12 +27,19 @@ function RouteTab({ onChange={onChange} destroyInactiveTabPane activeKey={activeKey} + animated // eslint-disable-next-line react/jsx-props-no-spreading {...rest} > {routes.map( - ({ Component, name }): JSX.Element => ( - + ({ Component, name, route }): JSX.Element => ( + ), diff --git a/frontend/src/container/MetricsApplication/Tabs/Application.tsx b/frontend/src/container/MetricsApplication/Tabs/Overview.tsx similarity index 100% rename from frontend/src/container/MetricsApplication/Tabs/Application.tsx rename to frontend/src/container/MetricsApplication/Tabs/Overview.tsx diff --git a/frontend/src/container/MetricsApplication/index.tsx b/frontend/src/container/MetricsApplication/index.tsx index 51725ab80a..f72fa1c04b 100644 --- a/frontend/src/container/MetricsApplication/index.tsx +++ b/frontend/src/container/MetricsApplication/index.tsx @@ -1,54 +1,108 @@ -import { Tabs } from 'antd'; +import RouteTab from 'components/RouteTab'; +import ROUTES from 'constants/routes'; import React from 'react'; +import { generatePath, useParams } from 'react-router-dom'; +import { useLocation } from 'react-use'; import { Widgets } from 'types/api/dashboard/getAll'; import ResourceAttributesFilter from './ResourceAttributesFilter'; -import Application from './Tabs/Application'; import DBCall from './Tabs/DBCall'; import External from './Tabs/External'; +import Overview from './Tabs/Overview'; -const { TabPane } = Tabs; +const getWidget = (query: Widgets['query']): Widgets => { + return { + description: '', + id: '', + isStacked: false, + nullZeroValues: '', + opacity: '0', + panelTypes: 'TIME_SERIES', + query, + queryData: { + data: [], + error: false, + errorMessage: '', + loading: false, + }, + timePreferance: 'GLOBAL_TIME', + title: '', + stepSize: 60, + }; +}; + +function OverViewTab(): JSX.Element { + return ; +} + +function DbCallTab(): JSX.Element { + return ; +} + +function ExternalTab(): JSX.Element { + return ; +} function ServiceMetrics(): JSX.Element { - const getWidget = (query: Widgets['query']): Widgets => { - return { - description: '', - id: '', - isStacked: false, - nullZeroValues: '', - opacity: '0', - panelTypes: 'TIME_SERIES', - query, - queryData: { - data: [], - error: false, - errorMessage: '', - loading: false, - }, - timePreferance: 'GLOBAL_TIME', - title: '', - stepSize: 60, - }; + const { search } = useLocation(); + const { servicename } = useParams<{ servicename: string }>(); + + const searchParams = new URLSearchParams(search); + const tab = searchParams.get('tab'); + + const overMetrics = 'Overview Metrics'; + const dbCallMetrics = 'Database Calls'; + const externalMetrics = 'External Calls'; + + const getActiveKey = (): string => { + if (tab === null) { + return overMetrics; + } + + if (tab === dbCallMetrics) { + return dbCallMetrics; + } + + if (tab === externalMetrics) { + return externalMetrics; + } + + return overMetrics; }; + const activeKey = getActiveKey(); + return ( <> - - - - - - - - - - - - - + ); } -export default ServiceMetrics; +export default React.memo(ServiceMetrics);