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

[UI] Switch between allocated and used capacity on dashboard #10215

Merged
merged 4 commits into from
Jan 23, 2025
Merged
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
29 changes: 26 additions & 3 deletions ui/src/views/dashboard/CapacityDashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,12 @@
<template #title>
<div class="center">
<h3><cloud-outlined /> {{ $t('label.compute') }}</h3>
<a-switch
:checked-children="$t('label.allocated') + ' ' + $t('label.capacity')"
:un-checked-children="$t('label.used') + ' ' + $t('label.capacity')"
v-model:checked="this.displayAllocatedCompute"
@change="val => { this.displayAllocatedCompute = val }"
/>
</div>
</template>
<div>
Expand All @@ -184,15 +190,19 @@
</div>
<a-progress
status="active"
:percent="statsMap[ctype]?.capacitytotal > 0 ? parseFloat(100.0 * statsMap[ctype]?.capacityused / statsMap[ctype]?.capacitytotal) : 0"
:format="p => statsMap[ctype]?.capacitytotal > 0 ? parseFloat(100.0 * statsMap[ctype]?.capacityused / statsMap[ctype]?.capacitytotal).toFixed(2) + '%' : '0%'"
:percent="statsMap[ctype]?.capacitytotal > 0 ?
displayPercentUsedOrAllocated(statsMap[ctype]?.capacityused, statsMap[ctype]?.capacityallocated, statsMap[ctype]?.capacitytotal)
: 0"
:format="p => statsMap[ctype]?.capacitytotal > 0 ?
displayPercentFormatUsedOrAllocated(statsMap[ctype]?.capacityused, statsMap[ctype]?.capacityallocated, statsMap[ctype]?.capacitytotal)
: '0%'"
stroke-color="#52c41a"
size="small"
style="width:95%; float: left"
/>
<br/>
<div style="text-align: center">
{{ displayData(ctype, statsMap[ctype]?.capacityused) }} {{ $t('label.allocated') }} | {{ displayData(ctype, statsMap[ctype]?.capacitytotal) }} {{ $t('label.total') }}
{{ displayDataUsedOrAllocated(ctype, statsMap[ctype]?.capacityused, statsMap[ctype]?.capacityallocated) }} {{ this.displayAllocatedCompute ? $t('label.allocated') : $t('label.used') }} | {{ displayData(ctype, statsMap[ctype]?.capacitytotal) }} {{ $t('label.total') }}
</div>
</div>
</div>
Expand Down Expand Up @@ -346,6 +356,7 @@ export default {
zones: [],
zoneSelected: {},
statsMap: {},
displayAllocatedCompute: false,
data: {
pods: 0,
clusters: 0,
Expand Down Expand Up @@ -402,6 +413,18 @@ export default {
}
return 'normal'
},
displayPercentUsedOrAllocated (used, allocated, total) {
var value = this.displayAllocatedCompute ? allocated : used
return parseFloat(100.0 * value / total)
},
displayPercentFormatUsedOrAllocated (used, allocated, total) {
var value = this.displayAllocatedCompute ? allocated : used
return parseFloat(100.0 * value / total).toFixed(2) + '%'
},
displayDataUsedOrAllocated (dataType, used, allocated) {
var value = this.displayAllocatedCompute ? allocated : used
return this.displayData(dataType, value)
},
displayData (dataType, value) {
if (!value) {
value = 0
Expand Down
Loading