|
17 | 17 |
|
18 | 18 | <template> |
19 | 19 | <div> |
20 | | - <a-input-search |
21 | | - style="width: 25vw;float: right;margin-bottom: 10px; z-index: 8;" |
22 | | - :placeholder="$t('label.search')" |
23 | | - v-model:value="filter" |
24 | | - @search="handleSearch" /> |
25 | | - |
26 | | - <a-list size="large" class="list" :loading="loading || tabLoading"> |
27 | | - <a-list-item :key="index" v-for="(item, index) in items" class="item"> |
28 | | - <a-list-item-meta> |
29 | | - <template #title style="word-break: break-all">{{ item.name }}</template> |
30 | | - <template #description style="word-break: break-all">{{ item.description }}</template> |
31 | | - </a-list-item-meta> |
32 | | - |
33 | | - <div class="item__content"> |
34 | | - <a-input |
35 | | - v-focus="editableValueKey === index" |
36 | | - v-if="editableValueKey === index" |
37 | | - class="editable-value value" |
38 | | - :defaultValue="item.value" |
39 | | - v-model:value="editableValue" |
40 | | - @keydown.esc="editableValueKey = null" |
41 | | - @pressEnter="updateData(item)"> |
42 | | - </a-input> |
43 | | - <span v-else class="value"> |
44 | | - {{ item.value }} |
45 | | - </span> |
46 | | - </div> |
47 | | - |
48 | | - <template #actions class="action"> |
49 | | - <tooltip-button |
50 | | - :tooltip="$t('label.edit')" |
51 | | - :disabled="!('updateConfiguration' in $store.getters.apis)" |
52 | | - v-if="editableValueKey !== index" |
53 | | - icon="edit-outlined" |
54 | | - @onClick="setEditableSetting(item, index)" /> |
55 | | - <tooltip-button |
56 | | - :tooltip="$t('label.cancel')" |
57 | | - @onClick="editableValueKey = null" |
58 | | - v-if="editableValueKey === index" |
59 | | - iconType="CloseCircleTwoTone" |
60 | | - iconTwoToneColor="#f5222d" /> |
61 | | - <tooltip-button |
62 | | - :tooltip="$t('label.ok')" |
63 | | - @onClick="updateData(item)" |
64 | | - v-if="editableValueKey === index" |
65 | | - iconType="CheckCircleTwoTone" |
66 | | - iconTwoToneColor="#52c41a" /> |
67 | | - <tooltip-button |
68 | | - :tooltip="$t('label.reset.config.value')" |
69 | | - @onClick="resetConfig(item)" |
70 | | - v-if="editableValueKey !== index" |
71 | | - icon="reload-outlined" |
72 | | - :disabled="!('updateConfiguration' in $store.getters.apis)" /> |
73 | | - </template> |
74 | | - </a-list-item> |
75 | | - </a-list> |
| 20 | + <a-col :span="24"> |
| 21 | + <a-input-search |
| 22 | + style="width: 25vw;float: right;margin-bottom: 10px; z-index: 8;" |
| 23 | + :placeholder="$t('label.search')" |
| 24 | + v-model:value="filter" |
| 25 | + @search="handleSearch" /> |
| 26 | + <ConfigurationTable |
| 27 | + :columns="columns" |
| 28 | + :config="items" /> |
| 29 | + </a-col> |
76 | 30 | </div> |
77 | 31 | </template> |
78 | 32 |
|
79 | 33 | <script> |
80 | 34 | import { api } from '@/api' |
81 | 35 | import TooltipButton from '@/components/widgets/TooltipButton' |
| 36 | +import ConfigurationTable from '@/views/setting/ConfigurationTable.vue' |
82 | 37 |
|
83 | 38 | export default { |
84 | 39 | components: { |
| 40 | + ConfigurationTable, |
85 | 41 | TooltipButton |
86 | 42 | }, |
87 | 43 | name: 'SettingsTab', |
@@ -112,7 +68,20 @@ export default { |
112 | 68 | scope: 'zone', |
113 | 69 | warning: this.$t('message.warn.zone.mtu.update') |
114 | 70 | } |
115 | | - } |
| 71 | + }, |
| 72 | + columns: [ |
| 73 | + { |
| 74 | + title: 'name', |
| 75 | + dataIndex: 'name', |
| 76 | + key: 'name' |
| 77 | + }, |
| 78 | + { |
| 79 | + title: 'value', |
| 80 | + dataIndex: 'value', |
| 81 | + key: 'value', |
| 82 | + width: '29%' |
| 83 | + } |
| 84 | + ] |
116 | 85 | } |
117 | 86 | }, |
118 | 87 | created () { |
@@ -167,70 +136,9 @@ export default { |
167 | 136 | callback() |
168 | 137 | }) |
169 | 138 | }, |
170 | | - updateData (item) { |
171 | | - this.tabLoading = true |
172 | | - api('updateConfiguration', { |
173 | | - [this.scopeKey]: this.resource.id, |
174 | | - name: item.name, |
175 | | - value: this.editableValue |
176 | | - }).then(() => { |
177 | | - var message = `${this.$t('label.setting')} ${item.name} ${this.$t('label.update.to')} ${this.editableValue}` |
178 | | - this.handleSuccessMessage(item, this.$route.meta.name, message) |
179 | | - }).catch(error => { |
180 | | - console.error(error) |
181 | | - this.$message.error(this.$t('message.error.save.setting')) |
182 | | - this.$notification.error({ |
183 | | - message: this.$t('label.error'), |
184 | | - description: this.$t('message.error.try.save.setting') |
185 | | - }) |
186 | | - }).finally(() => { |
187 | | - this.tabLoading = false |
188 | | - this.fetchData(() => { |
189 | | - this.editableValueKey = null |
190 | | - }) |
191 | | - }) |
192 | | - }, |
193 | | - setEditableSetting (item, index) { |
194 | | - this.editableValueKey = index |
195 | | - this.editableValue = item.value |
196 | | - }, |
197 | 139 | handleSearch (value) { |
198 | 140 | this.filter = value |
199 | 141 | this.fetchData() |
200 | | - }, |
201 | | - resetConfig (item) { |
202 | | - this.tabLoading = true |
203 | | - api('resetConfiguration', { |
204 | | - [this.scopeKey]: this.resource.id, |
205 | | - name: item.name |
206 | | - }).then(() => { |
207 | | - var message = `${this.$t('label.setting')} ${item.name} ${this.$t('label.reset.config.value')}` |
208 | | - this.handleSuccessMessage(item, this.$route.meta.name, message) |
209 | | - }).catch(error => { |
210 | | - console.error(error) |
211 | | - this.$message.error(this.$t('message.error.reset.config')) |
212 | | - this.$notification.error({ |
213 | | - message: this.$t('label.error'), |
214 | | - description: this.$t('message.error.reset.config') |
215 | | - }) |
216 | | - }).finally(() => { |
217 | | - this.tabLoading = false |
218 | | - this.fetchData(() => { |
219 | | - this.editableValueKey = null |
220 | | - }) |
221 | | - }) |
222 | | - }, |
223 | | - handleSuccessMessage (config, scope, message) { |
224 | | - var obj = this.warningMessages[config.name] |
225 | | - if (obj && obj.scope === scope) { |
226 | | - var content = obj.warning |
227 | | - if (config.isdynamic) { |
228 | | - content = `this.$t('message.setting.update.delay').\n ${content}` |
229 | | - } |
230 | | - this.$warning({ title: message, content: content }) |
231 | | - } else { |
232 | | - this.$messageConfigSuccess(message, config) |
233 | | - } |
234 | 142 | } |
235 | 143 | } |
236 | 144 | } |
|
0 commit comments