Skip to content

Commit

Permalink
feat(springboot-plugin): Create empty plugin with Health,Loggers,Info…
Browse files Browse the repository at this point in the history
…,Trace pages
  • Loading branch information
mmelko committed Nov 15, 2023
1 parent 44f4d34 commit 1898cb0
Show file tree
Hide file tree
Showing 11 changed files with 157 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/hawtio/src/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { logs } from './logs'
import { quartz } from './quartz'
import { rbac } from './rbac'
import { runtime } from './runtime'
import { springboot } from './springboot'

/**
* Registers the builtin plugins for Hawtio React.
Expand All @@ -24,6 +25,7 @@ export const registerPlugins: HawtioPlugin = () => {
runtime()
logs()
quartz()
springboot()
}

export * from './connect'
Expand Down
27 changes: 27 additions & 0 deletions packages/hawtio/src/plugins/springboot/Health.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from 'react'
import { Card, CardBody, CardHeader, Grid, GridItem, PageSection, Title } from '@patternfly/react-core'
import { loadHealth } from '@hawtiosrc/plugins/springboot/springboot-service'

export const Health: React.FunctionComponent = () => {
loadHealth()
return (
<PageSection variant='light'>
<Grid hasGutter span={12}>
<GridItem>
<Card>
<CardHeader>
<Title headingLevel='h2'>System</Title>
</CardHeader>
<CardBody></CardBody>
</Card>
<Card>
<CardHeader>
<Title headingLevel='h2'>System</Title>
</CardHeader>
<CardBody></CardBody>
</Card>
</GridItem>
</Grid>
</PageSection>
)
}
8 changes: 8 additions & 0 deletions packages/hawtio/src/plugins/springboot/Info.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from "react"
import {PageSection} from "@patternfly/react-core"

export const Info:React.FunctionComponent = () => (
<PageSection variant='light'>
Info - TO BE DONE
</PageSection>
)
4 changes: 4 additions & 0 deletions packages/hawtio/src/plugins/springboot/Loggers.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import React from 'react'
import { PageSection } from '@patternfly/react-core'

export const Loggers: React.FunctionComponent = () => <PageSection variant='light'>Loggers - TO BE DONE</PageSection>
54 changes: 54 additions & 0 deletions packages/hawtio/src/plugins/springboot/Springboot.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { Nav, NavItem, NavList, PageGroup, PageNavigation, PageSection, Title } from '@patternfly/react-core'
import React from 'react'

import { Navigate, NavLink, Route, Routes, useLocation } from 'react-router-dom'
import {Health} from "@hawtiosrc/plugins/springboot/Health"
import {Info} from "@hawtiosrc/plugins/springboot/Info"
import {Loggers} from "@hawtiosrc/plugins/springboot/Loggers"
import {Trace} from "@hawtiosrc/plugins/springboot/Trace"


type NavItem = {
id: string
title: string
component: JSX.Element
}
export const Springboot: React.FunctionComponent = () => {
const location = useLocation()

const navItems: NavItem[] = [
{ id: 'health', title: 'Health', component: <Health /> },
{ id: 'info', title: 'Info', component: <Info /> },
{ id: 'loggers', title: 'Loggers', component: <Loggers /> },
{ id: 'trace', title: 'Trace', component: <Trace /> },
]

return (
<React.Fragment>
<PageSection variant='light'>
<Title headingLevel='h1'>Springboot</Title>
</PageSection>
<PageGroup>
<PageNavigation>
<Nav aria-label='Spring-boot Nav' variant='tertiary'>
<NavList>
{navItems.map(navItem => (
<NavItem key={navItem.id} isActive={location.pathname === `/springboot/${navItem.id}`}>
<NavLink to={navItem.id}>{navItem.title}</NavLink>
</NavItem>
))}
</NavList>
</Nav>
</PageNavigation>
</PageGroup>
<PageSection>
<Routes>
{navItems.map(navItem => (
<Route key={navItem.id} path={navItem.id} element={navItem.component} />
))}
<Route path='/' element={<Navigate to='health' />} />
</Routes>
</PageSection>
</React.Fragment>
)
}
8 changes: 8 additions & 0 deletions packages/hawtio/src/plugins/springboot/Trace.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from "react"
import {PageSection} from "@patternfly/react-core"

export const Trace:React.FunctionComponent = () => (
<PageSection variant='light'>
Trace - TO BE DONE
</PageSection>
)
6 changes: 6 additions & 0 deletions packages/hawtio/src/plugins/springboot/globals.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { Logger } from '@hawtiosrc/core/logging'

export const pluginId = 'springboot'
export const pluginName = 'hawtio-springboot'
export const pluginPath = '/springboot'
export const log = Logger.get(pluginName)
19 changes: 19 additions & 0 deletions packages/hawtio/src/plugins/springboot/help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## Spring Boot

The Spring Boot plugin provides the capability interact with [actuator](https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html) endpoints exposed by an application.

### Health

Displays the current health status of the application together with details returned from any Spring Boot health checks.

### Info

Displays relevant information regarding the Spring boot application. It is the output of the Info actuator endpoint.

### Loggers

Lists all the available loggers in the application. You can modify the level of a logger and the changes will take effect immediately.

### Trace

Lists any HTTP traces for your application and lets you view information about the request / response such as headers, time taken etc.
18 changes: 18 additions & 0 deletions packages/hawtio/src/plugins/springboot/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { hawtio, HawtioPlugin } from '@hawtiosrc/core'

import { pluginId, pluginPath } from './globals'
import { workspace } from '@hawtiosrc/plugins'
import { helpRegistry } from '@hawtiosrc/help'
import help from './help.md'
import {Springboot} from "@hawtiosrc/plugins/springboot/Springboot"

export const springboot: HawtioPlugin = () => {
hawtio.addPlugin({
id: pluginId,
title: 'Springboot',
path: pluginPath,
component: Springboot,
isActive: async () => workspace.hasMBeans(),
})
helpRegistry.add(pluginId, 'Runtime', help, 16)
}
11 changes: 11 additions & 0 deletions packages/hawtio/src/plugins/springboot/springboot-service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { SystemProperty } from '@hawtiosrc/plugins/runtime/types'
import { jolokiaService } from '@hawtiosrc/plugins'

export async function loadHealth() {
const attr = await jolokiaService.execute('org.springframework.boot:type=Endpoint,name=Health', 'health')
console.log(attr)
// for (const [k, v] of Object.entries(attr as object)) {
// systemProperties.push({ key: k, value: v })
// }
//return systemProperties
}
Empty file.

0 comments on commit 1898cb0

Please sign in to comment.