Skip to content

Commit d78cb0f

Browse files
committed
feat(ui): ad pool - add view raw data
1 parent c915b46 commit d78cb0f

5 files changed

Lines changed: 92 additions & 10 deletions

File tree

cmdb-ui/src/modules/cmdb/api/discovery.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,14 @@ export function getAdc(params) {
138138
})
139139
}
140140

141+
export function getAdcById(id, params) {
142+
return axios({
143+
url: `v0.1/adc/${id}`,
144+
method: 'GET',
145+
params
146+
})
147+
}
148+
141149
export function deleteAdc(adc_id) {
142150
return axios({
143151
url: `v0.1/adc/${adc_id}`,

cmdb-ui/src/modules/cmdb/lang/en.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,8 @@ if __name__ == "__main__":
686686
tabCustom: 'Custom',
687687
tabConfig: 'Configured',
688688
addConfig: 'Add Config',
689-
configErrTip: 'Please select config'
689+
configErrTip: 'Please select config',
690+
viewRawData: 'View Raw Data'
690691
},
691692
ci: {
692693
attributeDesc: 'Attribute Description',

cmdb-ui/src/modules/cmdb/lang/zh.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,8 @@ if __name__ == "__main__":
685685
tabCustom: '自定义',
686686
tabConfig: '已有配置',
687687
addConfig: '添加配置',
688-
configErrTip: '请选择配置'
688+
configErrTip: '请选择配置',
689+
viewRawData: '查看原始数据'
689690
},
690691
ci: {
691692
attributeDesc: '查看属性配置',
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<template>
2+
<a-modal
3+
:title="$t('cmdb.ad.viewRawData')"
4+
:visible="visible"
5+
wrapClassName="ci-json-editor"
6+
width="50%"
7+
:footer="null"
8+
@cancel="handleCancel"
9+
>
10+
<vue-json-editor
11+
v-model="jsonData"
12+
:style="{ '--custom-height': `${windowHeight - 300}px` }"
13+
:showBtns="false"
14+
:mode="'code'"
15+
lang="zh"
16+
/>
17+
</a-modal>
18+
</template>
19+
20+
<script>
21+
import vueJsonEditor from 'vue-json-editor'
22+
23+
export default {
24+
name: 'RawDataModal',
25+
components: { vueJsonEditor },
26+
data() {
27+
return {
28+
visible: false,
29+
jsonData: {},
30+
}
31+
},
32+
computed: {
33+
windowHeight() {
34+
return this.$store.state.windowHeight
35+
},
36+
},
37+
methods: {
38+
open(jsonData) {
39+
this.visible = true
40+
this.jsonData = jsonData
41+
},
42+
handleCancel() {
43+
this.visible = false
44+
this.jsonData = {}
45+
}
46+
},
47+
}
48+
</script>
49+
50+
<style lang="less">
51+
.ci-json-editor {
52+
.jsoneditor-outer {
53+
height: var(--custom-height) !important;
54+
border: 1px solid #2f54eb;
55+
}
56+
div.jsoneditor-menu {
57+
background-color: #2f54eb;
58+
}
59+
}
60+
</style>

cmdb-ui/src/modules/cmdb/views/discoveryCI/index.vue

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,13 @@
9292
:width="col.width"
9393
:sortable="col.sortable"
9494
>
95-
<template v-if="col.value_type === '6' || col.is_password" #default="{row}">
95+
<template #default="{row}">
9696
<PasswordField
9797
v-if="col.is_password"
9898
:password="row[col.field]"
9999
/>
100-
<span
101-
v-else-if="col.value_type === '6' && row[col.field]"
102-
>
103-
{{ row[col.field] }}
100+
<span>
101+
{{ typeof row[col.field] === 'object' ? JSON.stringify(row[col.field]) : row[col.field] }}
104102
</span>
105103
</template>
106104
</vxe-column>
@@ -137,7 +135,7 @@
137135
></vxe-column>
138136
<vxe-column
139137
:title="$t('operation')"
140-
v-bind="columns.length ? { width: '60px' } : { minWidth: '60px' }"
138+
v-bind="columns.length ? { width: '100px' } : { minWidth: '100px' }"
141139
align="center"
142140
fixed="right"
143141
>
@@ -146,6 +144,9 @@
146144
<a-tooltip :title="$t('cmdb.ad.accept')">
147145
<a v-if="!row.is_accept" @click="accept(row)"><ops-icon type="cmdb-manual_warehousing"/></a>
148146
</a-tooltip>
147+
<a-tooltip :title="$t('cmdb.ad.viewRawData')">
148+
<a @click="viewADC(row)"><a-icon type="eye"/></a>
149+
</a-tooltip>
149150
<a :style="{ color: 'red' }" @click="deleteADC(row)"><a-icon type="delete"/></a>
150151
</a-space>
151152
</template>
@@ -175,6 +176,8 @@
175176
</p>
176177
</a-modal>
177178
</div>
179+
180+
<RawDataModal ref="rawDataModalRef" />
178181
</template>
179182
</TwoColumnLayout>
180183
</template>
@@ -185,14 +188,16 @@ import XEUtils from 'xe-utils'
185188
import TwoColumnLayout from '@/components/TwoColumnLayout'
186189
import AdcCounter from './components/adcCounter.vue'
187190
import PasswordField from './components/passwordField.vue'
191+
import RawDataModal from './components/rawDataModal.vue'
188192
189193
import {
190194
getADCCiTypes,
191195
getAdc,
192196
updateADCAccept,
193197
getADCCiTypesAttrs,
194198
deleteAdc,
195-
getAdcExecHistories
199+
getAdcExecHistories,
200+
getAdcById
196201
} from '../../api/discovery'
197202
import { getCITableColumns } from '../../utils/helper'
198203
@@ -201,7 +206,8 @@ export default {
201206
components: {
202207
TwoColumnLayout,
203208
AdcCounter,
204-
PasswordField
209+
PasswordField,
210+
RawDataModal
205211
},
206212
data() {
207213
return {
@@ -352,6 +358,12 @@ export default {
352358
onCancel() {},
353359
})
354360
},
361+
362+
async viewADC(row) {
363+
const res = await getAdcById(row.id)
364+
this.$refs.rawDataModalRef.open(res || {})
365+
},
366+
355367
async batchAccept() {
356368
for (let i = 0; i < this.selectedRowKeys.length; i++) {
357369
await updateADCAccept(this.selectedRowKeys[i])

0 commit comments

Comments
 (0)