Merge branch 'master' of github.com:veops/cmdb

This commit is contained in:
pycook 2024-11-28 19:22:55 +08:00
commit 9ffa9c943d
4 changed files with 57 additions and 6 deletions

View File

@ -84,3 +84,10 @@ export function getDCIMHistoryOperate(params) {
params params
}) })
} }
export function calcUnitFreeCount() {
return axios({
url: `/v0.1/dcim/rack/calc_u_free_count`,
method: 'POST'
})
}

View File

@ -894,7 +894,11 @@ if __name__ == "__main__":
deviceName: 'Device Name', deviceName: 'Device Name',
removeDevice: 'Remove Device', removeDevice: 'Remove Device',
moveDevice: 'Move Device', moveDevice: 'Move Device',
rackDetail: 'Rack Detail' rackDetail: 'Rack Detail',
calcUnitFreeCount: 'Calculate Rack Free Unit Count',
calcUnitFreeCountTip: 'Calculating in the background, refresh the page later to see the result',
calcUnitFreeCountTip1: 'Calculate Trigger Success, refresh the page later to see the result',
calcUnitFreeCountTip2: `Confirm that you want to calculate the number of free Units for all rack?`
} }
} }
export default cmdb_en export default cmdb_en

View File

@ -893,7 +893,11 @@ if __name__ == "__main__":
deviceName: '设备名', deviceName: '设备名',
removeDevice: '删除设备', removeDevice: '删除设备',
moveDevice: '移动设备', moveDevice: '移动设备',
rackDetail: '机柜详情' rackDetail: '机柜详情',
calcUnitFreeCount: '计算机柜空闲U数',
calcUnitFreeCountTip: '后台计算中,稍后刷新页面查看结果',
calcUnitFreeCountTip1: '计算触发成功,稍后刷新页面查看结果',
calcUnitFreeCountTip2: '确认要计算所有机柜的空闲U数'
} }
} }
export default cmdb_zh export default cmdb_zh

View File

@ -21,11 +21,24 @@
<a> <a>
<a-icon <a-icon
type="plus-circle" type="plus-circle"
class="dcim-tree-header-add-icon" class="dcim-tree-header-menu-icon"
/> />
{{ $t(addActionTitle[type]) }} {{ $t(addActionTitle[type]) }}
</a> </a>
</a-menu-item> </a-menu-item>
<a-menu-item
class="dcim-tree-header-calc"
@click="calcUnitFreeCount"
>
<a>
<ops-icon
type="veops-refresh"
class="dcim-tree-header-menu-icon"
/>
{{ $t('cmdb.dcim.calcUnitFreeCount') }}
</a>
</a-menu-item>
</a-menu> </a-menu>
</a-dropdown> </a-dropdown>
</div> </div>
@ -121,7 +134,7 @@
<script> <script>
import _ from 'lodash' import _ from 'lodash'
import { DCIM_TYPE, DCIM_TYPE_NAME_MAP } from '../constants.js' import { DCIM_TYPE, DCIM_TYPE_NAME_MAP } from '../constants.js'
import { deleteDCIM } from '@/modules/cmdb/api/dcim.js' import { deleteDCIM, calcUnitFreeCount } from '@/modules/cmdb/api/dcim.js'
import CIDetailDrawer from '@/modules/cmdb/views/ci/modules/ciDetailDrawer.vue' import CIDetailDrawer from '@/modules/cmdb/views/ci/modules/ciDetailDrawer.vue'
export default { export default {
@ -153,7 +166,9 @@ export default {
], ],
viewDetailCITypeId: 0, viewDetailCITypeId: 0,
viewDetailAttrObj: {} viewDetailAttrObj: {},
calculatedFreeUnitCount: false,
} }
}, },
computed: { computed: {
@ -259,6 +274,23 @@ export default {
this.$refs.CIdetailRef.create(node._id) this.$refs.CIdetailRef.create(node._id)
}) })
}) })
},
calcUnitFreeCount() {
if (this.calculatedFreeUnitCount) {
this.$message.info(this.$t('cmdb.dcim.calcUnitFreeCountTip'))
} else {
this.$confirm({
title: this.$t('tip'),
content: this.$t('cmdb.dcim.calcUnitFreeCountTip2'),
onOk: () => {
calcUnitFreeCount().then(() => {
this.calculatedFreeUnitCount = true
this.$message.success(this.$t('cmdb.dcim.calcUnitFreeCountTip1'))
})
}
})
}
} }
} }
} }
@ -281,7 +313,11 @@ export default {
padding: 0px; padding: 0px;
} }
&-add-icon { &-calc {
border-top: dashed 1px #e8e8e8;
}
&-menu-icon {
margin-right: 6px; margin-right: 6px;
} }
} }