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

feat(ui): dcim - add calc free unit count btn #646

Merged
merged 1 commit into from
Nov 28, 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
7 changes: 7 additions & 0 deletions cmdb-ui/src/modules/cmdb/api/dcim.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,10 @@ export function getDCIMHistoryOperate(params) {
params
})
}

export function calcUnitFreeCount() {
return axios({
url: `/v0.1/dcim/rack/calc_u_free_count`,
method: 'POST'
})
}
6 changes: 5 additions & 1 deletion cmdb-ui/src/modules/cmdb/lang/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,11 @@ if __name__ == "__main__":
deviceName: 'Device Name',
removeDevice: 'Remove 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
6 changes: 5 additions & 1 deletion cmdb-ui/src/modules/cmdb/lang/zh.js
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,11 @@ if __name__ == "__main__":
deviceName: '设备名',
removeDevice: '删除设备',
moveDevice: '移动设备',
rackDetail: '机柜详情'
rackDetail: '机柜详情',
calcUnitFreeCount: '计算机柜空闲U数',
calcUnitFreeCountTip: '后台计算中,稍后刷新页面查看结果',
calcUnitFreeCountTip1: '计算触发成功,稍后刷新页面查看结果',
calcUnitFreeCountTip2: '确认要计算所有机柜的空闲U数?'
}
}
export default cmdb_zh
44 changes: 40 additions & 4 deletions cmdb-ui/src/modules/cmdb/views/dcim/components/dcimTree.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,24 @@
<a>
<a-icon
type="plus-circle"
class="dcim-tree-header-add-icon"
class="dcim-tree-header-menu-icon"
/>
{{ $t(addActionTitle[type]) }}
</a>
</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-dropdown>
</div>
Expand Down Expand Up @@ -121,7 +134,7 @@
<script>
import _ from 'lodash'
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'

export default {
Expand Down Expand Up @@ -153,7 +166,9 @@ export default {
],

viewDetailCITypeId: 0,
viewDetailAttrObj: {}
viewDetailAttrObj: {},

calculatedFreeUnitCount: false,
}
},
computed: {
Expand Down Expand Up @@ -259,6 +274,23 @@ export default {
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'))
})
}
})
}
}
}
}
Expand All @@ -281,7 +313,11 @@ export default {
padding: 0px;
}

&-add-icon {
&-calc {
border-top: dashed 1px #e8e8e8;
}

&-menu-icon {
margin-right: 6px;
}
}
Expand Down
Loading