Skip to content

Commit

Permalink
add new pages for different modules
Browse files Browse the repository at this point in the history
Signed-off-by: Eric <[email protected]>
  • Loading branch information
mengweieric committed Nov 10, 2024
1 parent 9d7ac64 commit b17b31a
Show file tree
Hide file tree
Showing 12 changed files with 688 additions and 38 deletions.
12 changes: 11 additions & 1 deletion public/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ import { Home as TraceAnalyticsHome } from './trace_analytics/home';
import { Home as GettingStartedHome } from './getting_started/home';
import { Home as OverviewHome } from './overview/home';
import { Home as KubernetesHome } from './kubernetes/home';
import { ClusterOverview } from './kubernetes/cluster/overview';
import { clusterOverviewHome } from './kubernetes/cluster';
import { NodeOverview } from './kubernetes/node/overview';
import { NamespacesOverviewHome } from './kubernetes/namespaces';
import { KubernetesOverview } from './kubernetes/overview';

interface ObservabilityAppDeps {
CoreStartProp: CoreStart;
Expand Down Expand Up @@ -57,7 +62,10 @@ const pages = {
dataconnections: DataConnectionsHome,
gettingStarted: GettingStartedHome,
overview: OverviewHome,
kubernetes: KubernetesHome,
kubernetesOverview: KubernetesOverview,
kubernetesCluster: clusterOverviewHome,
kubernetesNode: NodeOverview,
kubernetesNamespaces: NamespacesOverviewHome,
};

export const App = ({
Expand All @@ -75,6 +83,7 @@ export const App = ({
dataSourceEnabled,
savedObjectsMDSClient,
defaultRoute,
AppMountParametersProp,
}: ObservabilityAppDeps) => {
const { chrome, http, notifications, savedObjects: _coreSavedObjects } = CoreStartProp;
const parentBreadcrumb = {
Expand Down Expand Up @@ -111,6 +120,7 @@ export const App = ({
setActionMenu={setActionMenu}
savedObjectsMDSClient={savedObjectsMDSClient}
defaultRoute={defaultRoute}
AppMountParametersProp={AppMountParametersProp}
/>
</MetricsListener>
</I18nProvider>
Expand Down
2 changes: 2 additions & 0 deletions public/components/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const Observability = (
) => {
const { setHeaderActionMenu } = AppMountParametersProp;
const { dataSource } = DepsStart;
console.log('activated?');
ReactDOM.render(
<App
CoreStartProp={CoreStartProp}
Expand All @@ -44,6 +45,7 @@ export const Observability = (
dataSourceEnabled={!!dataSource}
savedObjectsMDSClient={savedObjectsMDSClient}
defaultRoute={defaultRoute}
AppMountParametersProp={AppMountParametersProp}
/>,
AppMountParametersProp.element
);
Expand Down
23 changes: 23 additions & 0 deletions public/components/kubernetes/cluster/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import React from 'react';
import { Router, Route, Switch } from 'react-router-dom';
import { ClusterOverview } from './overview';
import { Home as ClusterDetails } from '../home';

export const clusterOverviewHome = (props) => {
console.log('clusterOverviewHome props: ', props);
return (
<Router
history={props.AppMountParametersProp.history}
>
<Switch>
<Route path="/:clusterName" component={ClusterDetails} />
<Route path="/" component={ClusterOverview} />
</Switch>
</Router>
);
};
131 changes: 131 additions & 0 deletions public/components/kubernetes/cluster/overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,134 @@
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import React from 'react';
// import { useNavigate } from 'react-router-dom';
import {
EuiPage,
EuiPageBody,
EuiPageHeader,
EuiPageHeaderSection,
EuiTitle,
EuiFlexGroup,
EuiFlexItem,
EuiCard,
EuiPanel,
EuiTable,
EuiTableHeader,
EuiTableHeaderCell,
EuiTableBody,
EuiTableRow,
EuiTableRowCell,
EuiSpacer,
EuiBadge,
EuiLink,
} from '@elastic/eui';

export const ClusterOverview = (props) => {
console.log('clusterOverviewHome props: ', props);
// const navigate = useNavigate();
const fakeData = [
{
clusterName: 'eks-cluster-with-vpc',
provider: 'digitalocean',
nodes: 2,
cpuUsage: { avg: '0.607 cores', max: '1.45 cores' },
memoryUsage: { avg: '4.66 GiB', max: '5.01 GiB' },
alerts: 2,
resourceUsage: 'low',
},
];

// const handleClusterClick = (clusterName: string) => {
// navigate(`/${clusterName}`);
// };

return (
<EuiPage>
<EuiPageBody>
<EuiPageHeader>
<EuiPageHeaderSection>
<EuiTitle size="l">
<h1>Clusters</h1>
</EuiTitle>
</EuiPageHeaderSection>
</EuiPageHeader>

<EuiSpacer size="l" />

<EuiPanel>
{/* <EuiFlexGroup gutterSize="m">
<EuiFlexItem>
<EuiCard
title="Usage"
description=""
/>
</EuiFlexItem>
<EuiFlexItem>
<EuiCard
title="Cost"
description=""
/>
</EuiFlexItem>
<EuiFlexItem>
<EuiCard
title="Explore Clusters"
description=""
/>
</EuiFlexItem>
</EuiFlexGroup>
<EuiSpacer size="m" /> */}

<EuiTable>
<EuiTableHeader>
<EuiTableHeaderCell>Cluster</EuiTableHeaderCell>
<EuiTableHeaderCell>Provider</EuiTableHeaderCell>
<EuiTableHeaderCell>Nodes</EuiTableHeaderCell>
<EuiTableHeaderCell>CPU Usage (Average)</EuiTableHeaderCell>
<EuiTableHeaderCell>CPU Usage (Max)</EuiTableHeaderCell>
<EuiTableHeaderCell>Memory Usage (Average)</EuiTableHeaderCell>
<EuiTableHeaderCell>Memory Usage (Max)</EuiTableHeaderCell>
<EuiTableHeaderCell>Alerts</EuiTableHeaderCell>
<EuiTableHeaderCell>Resource Usage</EuiTableHeaderCell>
</EuiTableHeader>

<EuiTableBody>
{fakeData.map((cluster, index) => (
<EuiTableRow key={index}>
<EuiTableRowCell>
{/* <Link
to={`/${cluster.clusterName}`}
style={{ textDecoration: 'none', color: 'blue' }}
>
{cluster.clusterName}
</Link> */}
<EuiLink href={`kubernetes-cluster/${cluster.clusterName}`}>
{/* <EuiLink onClick={() => handleClusterClick(cluster.clusterName)}> */}
{cluster.clusterName}
</EuiLink>
</EuiTableRowCell>
<EuiTableRowCell>{cluster.provider}</EuiTableRowCell>
<EuiTableRowCell>{cluster.nodes}</EuiTableRowCell>
<EuiTableRowCell>{cluster.cpuUsage.avg}</EuiTableRowCell>
<EuiTableRowCell>{cluster.cpuUsage.max}</EuiTableRowCell>
<EuiTableRowCell>{cluster.memoryUsage.avg}</EuiTableRowCell>
<EuiTableRowCell>{cluster.memoryUsage.max}</EuiTableRowCell>
<EuiTableRowCell>
<EuiBadge color="warning">{cluster.alerts}</EuiBadge>
</EuiTableRowCell>
<EuiTableRowCell>
<EuiBadge color={cluster.resourceUsage === 'low' ? 'success' : 'danger'}>
{cluster.resourceUsage}
</EuiBadge>
</EuiTableRowCell>
</EuiTableRow>
))}
</EuiTableBody>
</EuiTable>
</EuiPanel>
</EuiPageBody>
</EuiPage>
);
};
8 changes: 8 additions & 0 deletions public/components/kubernetes/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react';
import { Home } from './home';

export const kubernetes = (props) => {
console.log('top props: ', props);
return <Home />

};
20 changes: 20 additions & 0 deletions public/components/kubernetes/namespaces/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import React from 'react';
import { Router, Route, Switch } from 'react-router-dom';
import { NamespaceOverview } from './overview';
import { Home as ClusterDetails } from '../home';

export const NamespacesOverviewHome = (props) => {
return (
<Router history={props.AppMountParametersProp.history}>
<Switch>
{/* <Route path="/:nodeName" component={ClusterDetails} /> */}
<Route path="/" component={ NamespaceOverview } />
</Switch>
</Router>
);
};
141 changes: 141 additions & 0 deletions public/components/kubernetes/namespaces/overview.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import React from 'react';
import {
EuiPage,
EuiPageBody,
EuiPageHeader,
EuiPageHeaderSection,
EuiTitle,
EuiFlexGroup,
EuiFlexItem,
EuiCard,
EuiPanel,
EuiTable,
EuiTableHeader,
EuiTableHeaderCell,
EuiTableBody,
EuiTableRow,
EuiTableRowCell,
EuiBadge,
EuiButton,
EuiSelect,
EuiFieldSearch,
EuiIcon,
} from '@elastic/eui';

export const NamespaceOverview = () => {
const fakeData = [
{
namespace: 'argocd',
cluster: 'do-nyc1-demo-infra',
workloads: 7,
cpuUsage: { avg: '0.0521 cores', max: '0.128 cores' },
memoryUsage: { avg: '866.37 MiB', max: '1009.99 MiB' },
alerts: 0,
},
{
namespace: 'cert-manager',
cluster: 'do-nyc1-demo-infra',
workloads: 3,
cpuUsage: { avg: '0.00199 cores', max: '0.00302 cores' },
memoryUsage: { avg: '101.07 MiB', max: '101.17 MiB' },
alerts: 0,
},
{
namespace: 'ingress-nginx',
cluster: 'do-nyc1-demo-infra',
workloads: 1,
cpuUsage: { avg: '0.176 cores', max: '0.215 cores' },
memoryUsage: { avg: '92.9 MiB', max: '95.17 MiB' },
alerts: 1,
},
// Additional rows with similar structure
];

return (
<EuiPage paddingSize="l">
<EuiPageBody>
<EuiPageHeader>
<EuiPageHeaderSection>
<EuiTitle size="l">
<h1>Namespaces</h1>
</EuiTitle>
</EuiPageHeaderSection>
</EuiPageHeader>

{/* <EuiFlexGroup gutterSize="m" style={{ marginTop: '20px' }}>
<EuiFlexItem>
<EuiCard title="Usage" description="" />
</EuiFlexItem>
<EuiFlexItem>
<EuiCard title="Cost" description="" />
</EuiFlexItem>
<EuiFlexItem>
<EuiCard title="Explore namespaces" description="" />
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiFieldSearch
placeholder="Filter Namespace"
onChange={() => {}}
isClearable={true}
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiSelect
options={[
{ value: 'Filter Clusters', text: 'Filter Clusters' },
{ value: 'Cluster 1', text: 'Cluster 1' },
{ value: 'Cluster 2', text: 'Cluster 2' },
]}
aria-label="Select cluster filter"
/>
</EuiFlexItem>
</EuiFlexGroup> */}

<EuiPanel paddingSize="none" style={{ marginTop: '20px' }}>
<EuiTable>
<EuiTableHeader>
<EuiTableHeaderCell>NAMESPACE</EuiTableHeaderCell>
<EuiTableHeaderCell>CLUSTER</EuiTableHeaderCell>
<EuiTableHeaderCell>WORKLOADS</EuiTableHeaderCell>
<EuiTableHeaderCell>CPU USAGE (Average)</EuiTableHeaderCell>
<EuiTableHeaderCell>CPU USAGE (Max)</EuiTableHeaderCell>
<EuiTableHeaderCell>MEMORY USAGE (Average)</EuiTableHeaderCell>
<EuiTableHeaderCell>MEMORY USAGE (Max)</EuiTableHeaderCell>
<EuiTableHeaderCell>ALERTS</EuiTableHeaderCell>
</EuiTableHeader>

<EuiTableBody>
{fakeData.map((namespace, index) => (
<EuiTableRow key={index}>
<EuiTableRowCell>
<EuiIcon type="arrowRight" /> {namespace.namespace}
</EuiTableRowCell>
<EuiTableRowCell>
<EuiBadge color="hollow">{namespace.cluster}</EuiBadge>
</EuiTableRowCell>
<EuiTableRowCell>{namespace.workloads}</EuiTableRowCell>
<EuiTableRowCell>{namespace.cpuUsage.avg || 'No data'}</EuiTableRowCell>
<EuiTableRowCell>{namespace.cpuUsage.max || 'No data'}</EuiTableRowCell>
<EuiTableRowCell>{namespace.memoryUsage.avg || 'No data'}</EuiTableRowCell>
<EuiTableRowCell>{namespace.memoryUsage.max || 'No data'}</EuiTableRowCell>
<EuiTableRowCell>
{namespace.alerts > 0 ? (
<EuiBadge color="warning">{namespace.alerts}</EuiBadge>
) : (
<span>None</span>
)}
</EuiTableRowCell>
</EuiTableRow>
))}
</EuiTableBody>
</EuiTable>
</EuiPanel>
</EuiPageBody>
</EuiPage>
);
};
6 changes: 6 additions & 0 deletions public/components/kubernetes/node/details.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import React from 'react';
Loading

0 comments on commit b17b31a

Please sign in to comment.