LWM2MDescription.vue
5.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
<script lang="ts" setup>
import { Input, Tabs } from 'ant-design-vue';
import { computed, h, unref } from 'vue';
import {
BindingNameEnum,
FirmwareUpdateStrategyNameEnum,
PowerModeNameEnum,
SecurityModeNameEnum,
} from './const';
import { Bootstrap, ClientSettings, DeviceRecord } from '/@/api/device/model/deviceModel';
import { CollapseContainer } from '/@/components/Container';
import { useDescription, Description, DescItem } from '/@/components/Description';
type TransportConfiguration = DeviceRecord['profileData']['transportConfiguration'];
const props = defineProps<{
record: TransportConfiguration;
}>();
enum TabKeyEnum {
LWM2M_MODEL = 'LWM2M Model',
BOOTSTRAP = 'Bootstrap',
OTHER_SETTINGS = 'Other settings',
JSON_CONFIG_PROFILE_DEVICE = 'JSON Config Profile Device',
}
const getBootstrapSetting = computed(() => {
const { record } = props;
return record.bootstrap;
});
const getOtherSetting = computed(() => {
const { record } = props;
return record.clientLwM2mSettings;
});
const [registerLWM2MModel] = useDescription({
layout: 'vertical',
column: 2,
data: {},
schema: [
{
field: 'objectList',
label: '对象列表',
render: () => h('div', { class: 'min-h-6' }),
},
],
});
const getCollapseTitle = (item: Bootstrap) => {
return `LwM2M Server Short server ID: ${item.shortServerId} Security config mode: ${item.securityMode}`;
};
const bootstrapDescriptionSchema: DescItem[] = [
{
label: '安全配置',
field: 'securityMode',
render: (_, data: Bootstrap) => SecurityModeNameEnum[data.securityMode],
},
{
label: '短服务器ID',
field: 'shortServerId',
},
{
label: '主机',
field: 'host',
},
{
label: '端口',
field: 'port',
},
{
label: '延迟时间',
field: 'clientHoldOffTime',
},
{
label: '超时后的账户',
field: 'bootstrapServerAccountTimeout',
},
{
label: '注册生存期',
field: 'lifetime',
},
{
label: '两次通知之间的最小周期',
field: 'defaultMinPeriod',
},
{
label: 'Binding',
field: 'binding',
span: 2,
render: (_, data: Bootstrap) => BindingNameEnum[data.binding],
},
{
label: '禁用或脱机时的通知存储',
field: 'notifIfDisabled',
render: (_, data: Bootstrap) => (data.notifIfDisabled ? '启用' : '禁用'),
},
];
const [registerOtherSettings] = useDescription({
layout: 'vertical',
column: 2,
data: unref(getOtherSetting),
schema: [
{
label: '固件更新策略',
field: 'fwUpdateStrategy',
span: 2,
render: (_, data: ClientSettings) => FirmwareUpdateStrategyNameEnum[data.fwUpdateStrategy],
},
{
label: '固件更新COAP资源',
field: 'fwUpdateResource',
span: 2,
},
{
label: '软件更新策略',
field: 'swUpdateStrategy',
span: 2,
render: (_, data: ClientSettings) => FirmwareUpdateStrategyNameEnum[data.swUpdateStrategy],
},
{
label: '软件更新COAP资源',
field: 'swUpdateResource',
span: 2,
},
{
label: '节能模式',
field: 'powerMode',
render: (_, data: ClientSettings) => PowerModeNameEnum[data.powerMode],
},
{
label: 'PSM活动计时器',
field: 'edrxCycle',
},
{
label: 'PSM活动计时器单位',
field: 'edrxCycleTimeUnit',
render: () => '秒',
},
{
label: '支持复合读/写观察操作',
field: '',
render: () => '禁用',
},
],
});
const [registerJSONConfig] = useDescription({
layout: 'vertical',
column: 2,
data: props.record,
schema: [
{
field: 'json',
label: 'LWM2M',
render: (_, data: TransportConfiguration) => {
return h(Input.TextArea, { value: JSON.stringify(data, null, 2), autoSize: true });
},
},
],
});
</script>
<template>
<Tabs>
<Tabs.TabPane :tab="TabKeyEnum.LWM2M_MODEL" :key="TabKeyEnum.LWM2M_MODEL">
<Description @register="registerLWM2MModel" />
</Tabs.TabPane>
<Tabs.TabPane :tab="TabKeyEnum.BOOTSTRAP" :key="TabKeyEnum.BOOTSTRAP">
<CollapseContainer
v-for="(item, index) in getBootstrapSetting"
:key="index"
:title="getCollapseTitle(item)"
class="mt-4"
>
<Description
layout="vertical"
:column="2"
:schema="bootstrapDescriptionSchema"
:data="item"
/>
</CollapseContainer>
</Tabs.TabPane>
<Tabs.TabPane :tab="TabKeyEnum.OTHER_SETTINGS" :key="TabKeyEnum.OTHER_SETTINGS">
<Description @register="registerOtherSettings" />
</Tabs.TabPane>
<Tabs.TabPane
:tab="TabKeyEnum.JSON_CONFIG_PROFILE_DEVICE"
:key="TabKeyEnum.JSON_CONFIG_PROFILE_DEVICE"
>
<Description @register="registerJSONConfig" />
</Tabs.TabPane>
</Tabs>
</template>