Skip to content

Commit d63e268

Browse files
MukeshMukesh
authored andcommitted
overview pages with tab style and individual vm overview
1 parent 9ad7118 commit d63e268

File tree

11 files changed

+212
-99
lines changed

11 files changed

+212
-99
lines changed

src/components/observability/ObservabilityRouter.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,23 @@ import { Redirect, Route, Switch, useRouteMatch } from 'react-router-dom'
33
import { URLS } from '@devtron-labs/devtron-fe-common-lib'
44

55
import Customers from './Customer/Customers'
6+
import { Overview } from './Overview'
67
import Project from './ProjectObservability/Project'
78
import { ProjectOverview } from './ProjectObservability/ProjectOverview'
9+
import SingleVMOverview from './SingleVMOverview'
810
import VM from './VMObservability/VM'
911
import VMList from './VMObservability/VMList'
1012
import { VMOverview } from './VMObservability/VMOverview'
11-
import { Overview } from './Overview'
1213

1314
const ObservabilityRouter: React.FC = () => {
1415
const { path } = useRouteMatch()
1516
return (
1617
<Switch>
18+
19+
<Route path={`${URLS.OBSERVABILITY_CUSTOMER_LIST}/:customerId/projects/:projectId/vms/:vmId`}>
20+
<SingleVMOverview />
21+
</Route>
22+
1723
<Route exact path={URLS.OBSERVABILITY_OVERVIEW}>
1824
<Overview />
1925
</Route>

src/components/observability/ProjectObservability/Project.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ const Project = () => {
5454
{
5555
id: 'project_overview',
5656
label: 'Overview',
57-
tabType: 'link',
57+
tabType: 'navLink',
5858
props: {
5959
to: `${match.url}/overview`,
6060
},
6161
},
6262
{
6363
id: 'project_list',
6464
label: 'Projects',
65-
tabType: 'link',
65+
tabType: 'navLink',
6666
props: {
6767
to: `${match.url}/projects`,
6868
},
@@ -131,7 +131,7 @@ const Project = () => {
131131
})
132132
const renderBreadcrumbs = () => <BreadCrumb breadcrumbs={breadcrumbs} />
133133
const searchKey = ''
134-
const handleSearch = () => {}
134+
const handleSearch = () => { }
135135
return (
136136
<div className="observability-overview flex-grow-1 dc__overflow-auto">
137137
<PageHeader isBreadcrumbs breadCrumbs={renderBreadcrumbs} />

src/components/observability/ProjectObservability/ProjectOverview.tsx

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,10 @@ export const ProjectOverview = () => {
3030
}
3131
// alert(JSON.stringify(data))
3232
return (
33-
<div className="dc__grid glance-cards-wrapper">
34-
<MetricsInfoCard
35-
tooltipContent="paliwal"
36-
dataTestId="id"
37-
metricValue="value"
38-
metricTitle="title"
39-
metricUnit="unit"
40-
valueOutOf="valueof"
41-
iconName="ic-bg-cpu"
42-
/>
33+
<div className="dc__grid workflow-overview-cards-wrapper">
34+
{data.map((value) => {
35+
return <MetricsInfoCard key={value.metricTitle} {...value} />
36+
})}
4337
</div>
4438
)
4539
}
@@ -51,7 +45,9 @@ export const ProjectOverview = () => {
5145
<h3 className="m-0 cn-9 fs-20 fw-4 lh-1-5">At a Glance</h3>
5246
</div>
5347
</div>
54-
{renderBody()}
48+
<div className="flexbox-col dc__gap-12">
49+
{renderBody()}
50+
</div>
5551
</div>
5652
)
5753
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
2+
3+
4+
import { GenericSectionErrorState } from '.yalc/@devtron-labs/devtron-fe-common-lib/dist'
5+
import { MetricsInfoCard } from './MetricsInfoCard'
6+
import './styles.scss'
7+
import { GlanceMetricsKeys } from './types'
8+
import { MetricsInfoLoadingCard, useGetGlanceConfig } from './utils'
9+
10+
let interval
11+
const SingleVMOverview = () => {
12+
const { isFetching, data, isError, refetch } = useGetGlanceConfig()
13+
console.log(data)
14+
15+
const renderBody = () => {
16+
if (isFetching) {
17+
return (
18+
<div className="dc__grid glance-cards-wrapper">
19+
{Object.keys(GlanceMetricsKeys).map((key) => (
20+
<MetricsInfoLoadingCard key={key} />
21+
))}
22+
</div>
23+
)
24+
}
25+
26+
if (isError) {
27+
return (
28+
<GenericSectionErrorState
29+
subTitle=""
30+
reload={refetch}
31+
rootClassName="bg__primary br-8 border__secondary"
32+
/>
33+
)
34+
}
35+
// alert(JSON.stringify(data))
36+
return (
37+
<div className="dc__grid workflow-overview-cards-wrapper">
38+
{data.map((value) => {
39+
return <MetricsInfoCard key={value.metricTitle} {...value} />
40+
})}
41+
</div>
42+
)
43+
}
44+
45+
return (
46+
<div className="flexbox-col dc__gap-32 dc__overflow-auto p-20 flex-grow-1">
47+
<div className="flexbox-col dc__gap-16">
48+
<div className="flexbox dc__content-space dc__gap-16">
49+
<h3 className="m-0 cn-9 fs-20 fw-4 lh-1-5">At a Glance</h3>
50+
</div>
51+
</div>
52+
<div className="flexbox-col dc__gap-12">
53+
{renderBody()}
54+
</div>
55+
</div>
56+
)
57+
}
58+
59+
export default SingleVMOverview;

src/components/observability/VMObservability/VM.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ const VM = () => {
5454
{
5555
id: 'vm_overview',
5656
label: 'Overview',
57-
tabType: 'link',
57+
tabType: 'navLink',
5858
props: {
5959
to: `${match.url}/overview`,
6060
},
6161
},
6262
{
6363
id: 'vm_list',
6464
label: 'VMs',
65-
tabType: 'link',
65+
tabType: 'navLink',
6666
props: {
6767
to: `${match.url}/vms`,
6868
},
@@ -135,7 +135,7 @@ const VM = () => {
135135
})
136136
const renderBreadcrumbs = () => <BreadCrumb breadcrumbs={breadcrumbs} />
137137
const searchKey = ''
138-
const handleSearch = () => {}
138+
const handleSearch = () => { }
139139
return (
140140
<div className="observability-overview flex-grow-1 dc__overflow-auto">
141141
<PageHeader isBreadcrumbs breadCrumbs={renderBreadcrumbs} />

src/components/observability/VMObservability/VMListCellComponent.tsx

Lines changed: 49 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -20,58 +20,59 @@ export const VMListCellComponent: FunctionComponent<
2020
isRowActive,
2121
signals,
2222
}: TableCellComponentProps<ObservabilityVM, FiltersTypeEnum.STATE, {}>) => {
23-
const linkRef = useRef<HTMLAnchorElement>(null)
23+
const linkRef = useRef<HTMLAnchorElement>(null)
2424

25-
const match = useRouteMatch()
25+
const match = useRouteMatch()
2626

27-
useEffect(() => {
28-
const handleEnter = ({ detail: { activeRowData } }) => {
29-
if (activeRowData.data.id === id) {
30-
linkRef.current?.click()
27+
useEffect(() => {
28+
const handleEnter = ({ detail: { activeRowData } }) => {
29+
if (activeRowData.data.id === id) {
30+
linkRef.current?.click()
31+
}
3132
}
32-
}
3333

34-
if (isRowActive) {
35-
signals.addEventListener(TableSignalEnum.ENTER_PRESSED, handleEnter)
36-
}
34+
if (isRowActive) {
35+
signals.addEventListener(TableSignalEnum.ENTER_PRESSED, handleEnter)
36+
}
3737

38-
return () => {
39-
signals.removeEventListener(TableSignalEnum.ENTER_PRESSED, handleEnter)
40-
}
41-
}, [isRowActive])
38+
return () => {
39+
signals.removeEventListener(TableSignalEnum.ENTER_PRESSED, handleEnter)
40+
}
41+
}, [isRowActive])
4242

43-
switch (field) {
44-
case VMListFields.VM_NAME:
45-
return (
46-
<Link ref={linkRef} to={`${match.path}/${name}`} className="flex left py-10">
47-
<Tooltip content={name}>
48-
<span className="dc__truncate">{name}</span>
49-
</Tooltip>
50-
</Link>
51-
)
52-
case VMListFields.VM_IPADDRESS:
53-
return <span className="flex left py-10">{ipAddress}</span>
54-
case VMListFields.VM_STATUS:
55-
return <span className="flex left py-10">{status}</span>
56-
case VMListFields.VM_CPU:
57-
return <span className="flex left py-10">{cpu}</span>
58-
case VMListFields.VM_MEMORY:
59-
return (
60-
<div className="flex left py-10">
61-
<Tooltip content={memory}>
62-
<span className="dc__truncate">{memory}</span>
63-
</Tooltip>
64-
</div>
65-
)
66-
case VMListFields.VM_DISK:
67-
return (
68-
<div className="flex left py-10">
69-
<Tooltip content={disk}>
70-
<span className="dc__truncate">{disk}</span>
71-
</Tooltip>
72-
</div>
73-
)
74-
default:
75-
return null
43+
switch (field) {
44+
case VMListFields.VM_NAME:
45+
debugger;
46+
return (
47+
<Link ref={linkRef} to={`${match.path}/${name}`} className="flex left py-10">
48+
<Tooltip content={name}>
49+
<span className="dc__truncate">{name}</span>
50+
</Tooltip>
51+
</Link>
52+
)
53+
case VMListFields.VM_IPADDRESS:
54+
return <span className="flex left py-10">{ipAddress}</span>
55+
case VMListFields.VM_STATUS:
56+
return <span className="flex left py-10">{status}</span>
57+
case VMListFields.VM_CPU:
58+
return <span className="flex left py-10">{cpu}</span>
59+
case VMListFields.VM_MEMORY:
60+
return (
61+
<div className="flex left py-10">
62+
<Tooltip content={memory}>
63+
<span className="dc__truncate">{memory}</span>
64+
</Tooltip>
65+
</div>
66+
)
67+
case VMListFields.VM_DISK:
68+
return (
69+
<div className="flex left py-10">
70+
<Tooltip content={disk}>
71+
<span className="dc__truncate">{disk}</span>
72+
</Tooltip>
73+
</div>
74+
)
75+
default:
76+
return null
77+
}
7678
}
77-
}

src/components/observability/VMObservability/VMOverview.tsx

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import { MetricsInfoLoadingCard, useGetGlanceConfig } from '../utils'
88
import '../styles.scss'
99

1010
export const VMOverview = () => {
11-
const { isFetching, isError, refetch } = useGetGlanceConfig()
11+
const { isFetching, data, isError, refetch } = useGetGlanceConfig()
12+
console.log(data)
1213

1314
const renderBody = () => {
1415
if (isFetching) {
@@ -32,16 +33,10 @@ export const VMOverview = () => {
3233
}
3334
// alert(JSON.stringify(data))
3435
return (
35-
<div className="dc__grid glance-cards-wrapper">
36-
<MetricsInfoCard
37-
tooltipContent="paliwal"
38-
dataTestId="id"
39-
metricValue="value"
40-
metricTitle="title"
41-
metricUnit="unit"
42-
valueOutOf="valueof"
43-
iconName="ic-bg-cpu"
44-
/>
36+
<div className="dc__grid workflow-overview-cards-wrapper">
37+
{data.map((value) => {
38+
return <MetricsInfoCard key={value.metricTitle} {...value} />
39+
})}
4540
</div>
4641
)
4742
}
@@ -53,7 +48,9 @@ export const VMOverview = () => {
5348
<h3 className="m-0 cn-9 fs-20 fw-4 lh-1-5">At a Glance</h3>
5449
</div>
5550
</div>
56-
{renderBody()}
51+
<div className="flexbox-col dc__gap-12">
52+
{renderBody()}
53+
</div>
5754
</div>
5855
)
5956
}

src/components/observability/service.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,35 @@ export const getCustomerListData: () => Promise<CustomerObservabilityDTO[]> = ()
101101
activeVms: 1,
102102
},
103103
])
104+
105+
export const getProjectOverViewCards: () => Promise<any> = () =>
106+
Promise.resolve([
107+
{
108+
tooltipContent: "",
109+
dataTestId: "cpu_id",
110+
metricValue: "16",
111+
metricTitle: "CPU",
112+
iconName: "ic-bg-cpu"
113+
},
114+
{
115+
tooltipContent: "",
116+
dataTestId: "disk_id",
117+
metricValue: "400",
118+
metricTitle: "DISK",
119+
iconName: "ic-bg-cpu"
120+
},
121+
{
122+
tooltipContent: "",
123+
dataTestId: "memory_id",
124+
metricValue: "1000",
125+
metricTitle: "MEMORY",
126+
iconName: "ic-bg-cpu"
127+
},
128+
{
129+
tooltipContent: "",
130+
dataTestId: "running_id",
131+
metricValue: "10",
132+
metricTitle: "RUNNING VMs",
133+
iconName: "ic-bg-cpu"
134+
}
135+
])

0 commit comments

Comments
 (0)