|
15 | 15 | <v-card-title> |
16 | 16 | <v-text-field |
17 | 17 | v-model="topic_filter" |
18 | | - label="Search Topics" |
| 18 | + :label="`Search Topics (${filtered_topics.length})`" |
19 | 19 | clearable |
20 | 20 | prepend-inner-icon="mdi-magnify" |
21 | 21 | single-line |
|
41 | 41 | {{ item }} |
42 | 42 | <v-chip |
43 | 43 | x-small |
44 | | - :color="topic_liveliness[item] ? 'green' : 'red'" |
| 44 | + :color="topic_liveliness[item] === undefined ? 'grey' : (topic_liveliness[item] ? 'green' : 'red')" |
45 | 45 | class="ml-2" |
46 | 46 | > |
47 | | - {{ topic_liveliness[item] ? 'Alive' : 'Dead' }} |
| 47 | + {{ topic_liveliness[item] === undefined ? 'Unknown' : (topic_liveliness[item] ? 'Alive' : 'Dead') }} |
48 | 48 | </v-chip> |
49 | 49 | <v-chip |
50 | 50 | x-small |
|
90 | 90 | <v-card-title> |
91 | 91 | {{ selected_topic }} |
92 | 92 | <v-chip |
93 | | - :color="topic_liveliness[selected_topic] ? 'green' : 'red'" |
| 93 | + :color="topic_liveliness[selected_topic] === undefined ? 'grey' : (topic_liveliness[selected_topic] ? 'green' : 'red')" |
94 | 94 | class="ml-2" |
95 | 95 | > |
96 | | - {{ topic_liveliness[selected_topic] ? 'Alive' : 'Dead' }} |
| 96 | + {{ topic_liveliness[selected_topic] === undefined ? 'Unknown' : (topic_liveliness[selected_topic] ? 'Alive' : 'Dead') }} |
97 | 97 | </v-chip> |
98 | 98 | <v-chip |
99 | 99 | color="blue" |
@@ -171,27 +171,25 @@ export default Vue.extend({ |
171 | 171 | formatMessage(message: ZenohMessage | null): string { |
172 | 172 | if (!message) return 'No messages received yet' |
173 | 173 |
|
| 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 |
174 | 186 | 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 |
194 | 190 | } |
| 191 | +
|
| 192 | + return JSON.stringify(formattedMessage, null, 2) |
195 | 193 | }, |
196 | 194 | async setupZenoh() { |
197 | 195 | try { |
|
0 commit comments