Skip to content

Commit c9fea62

Browse files
authored
[UI] Switch between allocated and used capacity on dashboard (#10215)
* [UI] Switch between allocated and used capacity on dashboard * Fix text * Refactor * Internationalize capacity text
1 parent 4d9fd1b commit c9fea62

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

ui/src/views/dashboard/CapacityDashboard.vue

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,12 @@
174174
<template #title>
175175
<div class="center">
176176
<h3><cloud-outlined /> {{ $t('label.compute') }}</h3>
177+
<a-switch
178+
:checked-children="$t('label.allocated') + ' ' + $t('label.capacity')"
179+
:un-checked-children="$t('label.used') + ' ' + $t('label.capacity')"
180+
v-model:checked="this.displayAllocatedCompute"
181+
@change="val => { this.displayAllocatedCompute = val }"
182+
/>
177183
</div>
178184
</template>
179185
<div>
@@ -184,15 +190,19 @@
184190
</div>
185191
<a-progress
186192
status="active"
187-
:percent="statsMap[ctype]?.capacitytotal > 0 ? parseFloat(100.0 * statsMap[ctype]?.capacityused / statsMap[ctype]?.capacitytotal) : 0"
188-
:format="p => statsMap[ctype]?.capacitytotal > 0 ? parseFloat(100.0 * statsMap[ctype]?.capacityused / statsMap[ctype]?.capacitytotal).toFixed(2) + '%' : '0%'"
193+
:percent="statsMap[ctype]?.capacitytotal > 0 ?
194+
displayPercentUsedOrAllocated(statsMap[ctype]?.capacityused, statsMap[ctype]?.capacityallocated, statsMap[ctype]?.capacitytotal)
195+
: 0"
196+
:format="p => statsMap[ctype]?.capacitytotal > 0 ?
197+
displayPercentFormatUsedOrAllocated(statsMap[ctype]?.capacityused, statsMap[ctype]?.capacityallocated, statsMap[ctype]?.capacitytotal)
198+
: '0%'"
189199
stroke-color="#52c41a"
190200
size="small"
191201
style="width:95%; float: left"
192202
/>
193203
<br/>
194204
<div style="text-align: center">
195-
{{ displayData(ctype, statsMap[ctype]?.capacityused) }} {{ $t('label.allocated') }} | {{ displayData(ctype, statsMap[ctype]?.capacitytotal) }} {{ $t('label.total') }}
205+
{{ displayDataUsedOrAllocated(ctype, statsMap[ctype]?.capacityused, statsMap[ctype]?.capacityallocated) }} {{ this.displayAllocatedCompute ? $t('label.allocated') : $t('label.used') }} | {{ displayData(ctype, statsMap[ctype]?.capacitytotal) }} {{ $t('label.total') }}
196206
</div>
197207
</div>
198208
</div>
@@ -346,6 +356,7 @@ export default {
346356
zones: [],
347357
zoneSelected: {},
348358
statsMap: {},
359+
displayAllocatedCompute: false,
349360
data: {
350361
pods: 0,
351362
clusters: 0,
@@ -402,6 +413,18 @@ export default {
402413
}
403414
return 'normal'
404415
},
416+
displayPercentUsedOrAllocated (used, allocated, total) {
417+
var value = this.displayAllocatedCompute ? allocated : used
418+
return parseFloat(100.0 * value / total)
419+
},
420+
displayPercentFormatUsedOrAllocated (used, allocated, total) {
421+
var value = this.displayAllocatedCompute ? allocated : used
422+
return parseFloat(100.0 * value / total).toFixed(2) + '%'
423+
},
424+
displayDataUsedOrAllocated (dataType, used, allocated) {
425+
var value = this.displayAllocatedCompute ? allocated : used
426+
return this.displayData(dataType, value)
427+
},
405428
displayData (dataType, value) {
406429
if (!value) {
407430
value = 0

0 commit comments

Comments
 (0)