Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,17 @@ export const ArtemisHeader: React.FunctionComponent = () => {
const [ brokerHeader, setBrokerHeader] = useState('')

useEffect(() => {

artemisService.getBrokerInfo()
.then((brokerInfo) => {
setBrokerHeader(brokerInfo ? brokerInfo.name : '');
artemisService.getBrokerName()
.then((brokerName) => {
setBrokerHeader(brokerName ? brokerName : '');
})
.catch((error: string) => {
eventService.notify({
type: 'warning',
message: error,
})
});
})
},[])

return (
<><Text>{'Broker ('}</Text><Text style={{ color: 'var(--pf-v5-global--active-color--200)' }} >{brokerHeader}</Text><Text>{')'}</Text></>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,15 @@ class ArtemisService {
return search && search[0] ? search[0] : "";
}

async getBrokerName(): Promise<string | null> {
const brokerObjectName = await this.brokerObjectName;
const response = await jolokiaService.readAttribute(brokerObjectName, "Name");
if (response) {
return response as string;
}
return null;
}

async getBrokerInfo(): Promise<BrokerInfo | null> {
return new Promise<BrokerInfo | null>(async (resolve, reject) => {
const brokerObjectName = await this.brokerObjectName;
Expand Down Expand Up @@ -218,7 +227,6 @@ class ArtemisService {
});
}


async createBrokerTopology(maxAddresses: number, addressFilter: string): Promise<BrokerTopology> {
return new Promise<BrokerTopology>(async (resolve, reject) => {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,57 +55,62 @@ export const Status: React.FunctionComponent = () => {

const [showAttributesDialog, setShowAttributesDialog] = useState(false);
const [showOperationsDialog, setShowOperationsDialog] = useState(false);
useEffect(() => {
const getBrokerInfo = async () => {
artemisService.getBrokerInfo()
.then((brokerInfo) => {
setBrokerInfo(brokerInfo ?? undefined)
})
.catch((error: string) => {
eventService.notify({
type: 'warning',
message: error,
})
});
}

const getAcceptors = async () => {
artemisService.createAcceptors()
.then((acceptors) => {
setAcceptors(acceptors)
const getBrokerInfo = async () => {
artemisService.getBrokerInfo()
.then((brokerInfo) => {
setBrokerInfo(brokerInfo ?? undefined)
})
.catch((error: string) => {
eventService.notify({
type: 'warning',
message: error,
})
.catch((error: string) => {
eventService.notify({
type: 'warning',
message: error,
})
});
}
if (!brokerInfo) {
getBrokerInfo();
}
});
}

if (!acceptors) {
getAcceptors();
}
const getAcceptors = async () => {
artemisService.createAcceptors()
.then((acceptors) => {
setAcceptors(acceptors)
})
.catch((error: string) => {
eventService.notify({
type: 'warning',
message: error,
})
});
}

if (!clusterConnections) {
artemisService.createClusterConnections()
.then((clusterConnections) => {
setClusterConnections(clusterConnections)
const getClusterConnections = async () => {
artemisService.createClusterConnections()
.then((clusterConnections) => {
setClusterConnections(clusterConnections)
})
.catch((error: string) => {
eventService.notify({
type: 'warning',
message: error,
})
.catch((error: string) => {
eventService.notify({
type: 'warning',
message: error,
})
});
}
});
}

useEffect(() => {
// run only once at the beginning
getBrokerInfo();

getAcceptors();

getClusterConnections();

const timer = setInterval(getBrokerInfo, 5000)
return () => clearInterval(timer)

}, [brokerInfo, acceptors, clusterConnections])
}, [])

useEffect(() => {
// update frontend when brokerInfo, acceptors, or clusterConnections change
}, [brokerInfo, acceptors, clusterConnections]);

const [isBrokerInfoOpen, setIsBrokerInfoOpen] = useState<boolean>(false);

Expand Down