Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(desktop): add mqtt properties component #1819

Merged
merged 1 commit into from
Nov 25, 2024
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
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>
Loading