Skip to content

Commit

Permalink
feat(desktop): display mqtt properties on tree node info
Browse files Browse the repository at this point in the history
  • Loading branch information
ysfscream committed Nov 22, 2024
1 parent 54534e9 commit 7d8b29d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/components/MqttProperties.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@
/>
</template>
<template v-else>
<span>{{ $t(`connections.${field.key}`) }}: {{ properties[field.key] }}</span>
<span class="property-item">
<span class="label"
>{{ $t(`connections.${field.key}`) }}<span v-if="showColon" class="colon">: </span></span
>
<span class="value">{{ properties[field.key] }}</span>
</span>
</template>
</p>
</template>
Expand All @@ -38,6 +43,7 @@ interface PropertyField {
export default class MqttProperties extends Vue {
@Prop({ required: true }) public properties!: PushPropertiesModel
@Prop({ default: '' }) public direction!: string
@Prop({ default: true }) public showColon!: boolean
private propertyFields: PropertyField[] = [
{ key: 'subscriptionIdentifier' },
Expand Down
37 changes: 36 additions & 1 deletion src/widgets/TreeNodeInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@
<pre
class="payload-container mt-2 mb-2"
><code :class="`language-${payloadFormat}`" v-html="latestMessage"></code></pre>
<MqttProperties
class="tree-node-info-mqtt-properties"
:show-colon="false"
:properties="node.message.properties"
/>
</div>
</div>
</template>
Expand All @@ -64,8 +69,13 @@ import { Getter } from 'vuex-class'
import { findSubTopics, findFullTopicPath, isPayloadEmpty } from '@/utils/topicTree'
import Prism from 'prismjs'
import { jsonStringify, jsonParse } from '@/utils/jsonUtils'
import MqttProperties from '@/components/MqttProperties.vue'
@Component
@Component({
components: {
MqttProperties,
},
})
export default class TreeNodeInfo extends Vue {
@Prop() private node!: TopicTreeNode
@Prop() private treeData!: TopicTreeNode[]
Expand Down Expand Up @@ -182,5 +192,30 @@ body.night {
word-wrap: break-word;
}
}
.mqtt-properties.tree-node-info-mqtt-properties {
margin-top: 12px;
.properties {
.property-item {
display: flex;
flex-direction: column;
margin: 6px 0 12px 0;
.value {
background-color: var(--color-bg-select_lang);
padding: 6px 12px;
border-radius: 8px;
margin-top: 6px;
}
}
&.user-properties {
.editor-header {
margin-bottom: 6px;
}
.el-textarea.is-disabled .el-textarea__inner {
color: var(--color-text-default);
border: 1px solid var(--color-border-default);
}
}
}
}
}
</style>

0 comments on commit 7d8b29d

Please sign in to comment.