Skip to content

Commit cc7e70e

Browse files
wip
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
1 parent dbf63e8 commit cc7e70e

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

core/frontend/src/components/zenoh-inspector/ZenohInspector.vue

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<v-card-title>
1616
<v-text-field
1717
v-model="topic_filter"
18-
label="Search Topics"
18+
:label="`Search Topics (${filtered_topics.length})`"
1919
clearable
2020
prepend-inner-icon="mdi-magnify"
2121
single-line
@@ -41,10 +41,10 @@
4141
{{ item }}
4242
<v-chip
4343
x-small
44-
:color="topic_liveliness[item] ? 'green' : 'red'"
44+
:color="topic_liveliness[item] === undefined ? 'grey' : (topic_liveliness[item] ? 'green' : 'red')"
4545
class="ml-2"
4646
>
47-
{{ topic_liveliness[item] ? 'Alive' : 'Dead' }}
47+
{{ topic_liveliness[item] === undefined ? 'Unknown' : (topic_liveliness[item] ? 'Alive' : 'Dead') }}
4848
</v-chip>
4949
<v-chip
5050
x-small
@@ -90,10 +90,10 @@
9090
<v-card-title>
9191
{{ selected_topic }}
9292
<v-chip
93-
:color="topic_liveliness[selected_topic] ? 'green' : 'red'"
93+
:color="topic_liveliness[selected_topic] === undefined ? 'grey' : (topic_liveliness[selected_topic] ? 'green' : 'red')"
9494
class="ml-2"
9595
>
96-
{{ topic_liveliness[selected_topic] ? 'Alive' : 'Dead' }}
96+
{{ topic_liveliness[selected_topic] === undefined ? 'Unknown' : (topic_liveliness[selected_topic] ? 'Alive' : 'Dead') }}
9797
</v-chip>
9898
<v-chip
9999
color="blue"
@@ -171,27 +171,25 @@ export default Vue.extend({
171171
formatMessage(message: ZenohMessage | null): string {
172172
if (!message) return 'No messages received yet'
173173
174+
// Create the base message object
175+
const formattedMessage = {
176+
topic: message.topic,
177+
timestamp: message.timestamp.toLocaleString(),
178+
liveliness: this.topic_liveliness[message.topic] === undefined ? 'Unknown' :
179+
(this.topic_liveliness[message.topic] ? 'Alive' : 'Dead'),
180+
topic_type: this.topic_types[message.topic] || 'Unknown',
181+
message_type: this.topic_typs[message.topic] || 'Unknown',
182+
payload: message.payload
183+
}
184+
185+
// Try to parse the payload as JSON if possible
174186
try {
175-
const parsedPayload = JSON.parse(message.payload)
176-
return JSON.stringify({
177-
topic: message.topic,
178-
timestamp: message.timestamp.toLocaleString(),
179-
liveliness: this.topic_liveliness[message.topic] ? 'Alive' : 'Dead',
180-
topic_type: this.topic_types[message.topic] || 'Unknown',
181-
message_type: this.topic_typs[message.topic] || 'Unknown',
182-
payload: parsedPayload
183-
}, null, 2)
184-
} catch (e) {
185-
// If payload is not valid JSON, return the raw message
186-
return JSON.stringify({
187-
topic: message.topic,
188-
timestamp: message.timestamp.toLocaleString(),
189-
liveliness: this.topic_liveliness[message.topic] ? 'Alive' : 'Dead',
190-
topic_type: this.topic_types[message.topic] || 'Unknown',
191-
message_type: this.topic_typs[message.topic] || 'Unknown',
192-
payload: message.payload
193-
}, null, 2)
187+
formattedMessage.payload = JSON.parse(message.payload)
188+
} catch (exception) {
189+
// Keep the raw payload if it's not valid JSON
194190
}
191+
192+
return JSON.stringify(formattedMessage, null, 2)
195193
},
196194
async setupZenoh() {
197195
try {

0 commit comments

Comments
 (0)