This is an automated email from the ASF dual-hosted git repository. jbertram pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/activemq-artemis-console.git
commit 01b60315b0092672fc373d84c3c8b472037d675b Author: Andy Taylor <[email protected]> AuthorDate: Mon Dec 9 08:21:22 2024 +0000 ARTEMIS-5197 - List broker name prominently in console --- .../src/artemis-extension/artemis/Artemis.tsx | 23 ++++++++++++++++++++-- .../src/artemis-extension/artemis/ArtemisJMX.tsx | 22 +++++++++++++++++++-- .../artemis-extension/artemis/artemis-service.ts | 10 ++++++++-- .../artemis-extension/artemis/status/Status.tsx | 2 +- 4 files changed, 50 insertions(+), 7 deletions(-) diff --git a/artemis-console-extension/artemis-extension/src/artemis-extension/artemis/Artemis.tsx b/artemis-console-extension/artemis-extension/src/artemis-extension/artemis/Artemis.tsx index 35fec0e..2ca5bb1 100644 --- a/artemis-console-extension/artemis-extension/src/artemis-extension/artemis/Artemis.tsx +++ b/artemis-console-extension/artemis-extension/src/artemis-extension/artemis/Artemis.tsx @@ -14,16 +14,35 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import React from 'react' +import React, { useEffect, useState } from 'react' import { ArtemisTabs } from './views/ArtemisTabView'; import { PageSection, TextContent, Text, PageSectionVariants, Page } from '@patternfly/react-core'; import { Grid } from '@patternfly/react-core'; import { GridItem } from '@patternfly/react-core'; +import { artemisService } from './artemis-service'; +import { eventService } from '@hawtio/react'; export const Artemis: React.FunctionComponent = () => { + const [brokerName, setBrokerName] = useState(""); + + useEffect(() => { + const getBrokerInfo = async () => { + artemisService.getBrokerInfo() + .then((brokerInfo) => { + setBrokerName(brokerInfo.name) + }) + .catch((error: string) => { + eventService.notify({ + type: 'warning', + message: error, + }) + }); + } + getBrokerInfo(); + }, [brokerName]) return ( <Page> @@ -31,7 +50,7 @@ export const Artemis: React.FunctionComponent = () => { <Grid > <GridItem span={2}> <TextContent> - <Text component="h1">Broker</Text> + <Text component="h1">Broker: {brokerName}</Text> </TextContent> </GridItem> </Grid> diff --git a/artemis-console-extension/artemis-extension/src/artemis-extension/artemis/ArtemisJMX.tsx b/artemis-console-extension/artemis-extension/src/artemis-extension/artemis/ArtemisJMX.tsx index 0fcaa01..deb59ba 100644 --- a/artemis-console-extension/artemis-extension/src/artemis-extension/artemis/ArtemisJMX.tsx +++ b/artemis-console-extension/artemis-extension/src/artemis-extension/artemis/ArtemisJMX.tsx @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import React from 'react' +import React, { useEffect, useState } from 'react' import { CubesIcon } from '@patternfly/react-icons' import Split from 'react-split' import { ArtemisContext, useArtemisTree } from './context'; @@ -24,13 +24,31 @@ import { Grid } from '@patternfly/react-core'; import { GridItem } from '@patternfly/react-core'; import { ArtemisJMXTabs } from './views/ArtemisJMXTabView'; import './artemisJMX.css' +import { eventService } from '@hawtio/react'; +import { artemisService } from './artemis-service'; export const ArtemisJMX: React.FunctionComponent = () => { const { tree, selectedNode, brokerNode, setSelectedNode, findAndSelectNode } = useArtemisTree(); + const [brokerName, setBrokerName] = useState(""); + useEffect(() => { + const getBrokerInfo = async () => { + artemisService.getBrokerInfo() + .then((brokerInfo) => { + setBrokerName(brokerInfo.name) + }) + .catch((error: string) => { + eventService.notify({ + type: 'warning', + message: error, + }) + }); + } + getBrokerInfo(); + }, [brokerName]) return ( <React.Fragment> @@ -38,7 +56,7 @@ export const ArtemisJMX: React.FunctionComponent = () => { <Grid > <GridItem span={2}> <TextContent> - <Text component="h1">Broker</Text> + <Text component="h1">Broker: {brokerName}</Text> </TextContent> </GridItem> diff --git a/artemis-console-extension/artemis-extension/src/artemis-extension/artemis/artemis-service.ts b/artemis-console-extension/artemis-extension/src/artemis-extension/artemis/artemis-service.ts index b97ce7f..52fd901 100644 --- a/artemis-console-extension/artemis-extension/src/artemis-extension/artemis/artemis-service.ts +++ b/artemis-console-extension/artemis-extension/src/artemis-extension/artemis/artemis-service.ts @@ -144,9 +144,11 @@ const typeLabels = ["DEFAULT", "1", "object", "text", "bytes", "map", "stream", class ArtemisService { private brokerObjectName: Promise<string> + private brokerInfo: Promise<BrokerInfo> constructor() { this.brokerObjectName = this.initBrokerObjectName(); + this.brokerInfo = this.initBrokerInfo(); } private async initBrokerObjectName(): Promise<string> { @@ -157,7 +159,7 @@ class ArtemisService { - async createBrokerInfo(): Promise<BrokerInfo> { + async initBrokerInfo(): Promise<BrokerInfo> { return new Promise<BrokerInfo>(async (resolve, reject) => { var brokerObjectName = await this.brokerObjectName; var response = await jolokiaService.readAttributes(brokerObjectName); @@ -196,10 +198,14 @@ class ArtemisService { }); } + async getBrokerInfo(): Promise<BrokerInfo> { + return await this.brokerInfo; + } + async createBrokerTopology(): Promise<BrokerTopology> { return new Promise<BrokerTopology>(async (resolve, reject) => { try { - var brokerInfo = await this.createBrokerInfo(); + var brokerInfo = await this.getBrokerInfo(); var brokerTopology: BrokerTopology = { broker: brokerInfo, addresses: [] diff --git a/artemis-console-extension/artemis-extension/src/artemis-extension/artemis/status/Status.tsx b/artemis-console-extension/artemis-extension/src/artemis-extension/artemis/status/Status.tsx index a7b99ec..acc9ba0 100644 --- a/artemis-console-extension/artemis-extension/src/artemis-extension/artemis/status/Status.tsx +++ b/artemis-console-extension/artemis-extension/src/artemis-extension/artemis/status/Status.tsx @@ -55,7 +55,7 @@ export const Status: React.FunctionComponent = () => { const [showOperationsDialog, setShowOperationsDialog] = useState(false); useEffect(() => { const getBrokerInfo = async () => { - artemisService.createBrokerInfo() + artemisService.getBrokerInfo() .then((brokerInfo) => { setBrokerInfo(brokerInfo) }) --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] For further information, visit: https://activemq.apache.org/contact
