Skip to content

Commit e57a82a

Browse files
UI: Fixes in the Usage UI (#10000)
* fixes on usage ui * dont call API when caller does not have access to it * handle when lastheartbeat is undefined * hide last collection datetime when lastheartbeat is undefined * apply Pearl's suggestions Co-authored-by: Pearl Dsilva <[email protected]> * apply Pearl's suggestions Co-authored-by: Pearl Dsilva <[email protected]> * apply Pearl's suggestions Co-authored-by: Pearl Dsilva <[email protected]> * apply Pearl's suggestions Co-authored-by: Pearl Dsilva <[email protected]> * apply Pearl's suggestions Co-authored-by: Pearl Dsilva <[email protected]> --------- Co-authored-by: Pearl Dsilva <[email protected]>
1 parent 9231c1c commit e57a82a

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

ui/public/locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,6 +1528,7 @@
15281528
"label.networkspeed": "Network speed",
15291529
"label.networktype": "Network type",
15301530
"label.networkwrite": "Network write",
1531+
"label.never": "Never",
15311532
"label.new": "New",
15321533
"label.new.autoscale.vmgroup": "New AutoScaling Group",
15331534
"label.new.instance.group": "New Instance group",

ui/src/components/view/ListView.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
:rowSelection="explicitlyAllowRowSelection || enableGroupAction() || $route.name === 'event' ? {selectedRowKeys: selectedRowKeys, onChange: onSelectChange, columnWidth: 30} : null"
2727
:rowClassName="getRowClassName"
2828
@resizeColumn="handleResizeColumn"
29-
style="overflow-y: auto"
29+
:style="{ 'overflow-y': this.$route.name === 'usage' ? 'hidden' : 'auto' }"
3030
>
3131
<template #customFilterDropdown>
3232
<div style="padding: 8px" class="filter-dropdown">

ui/src/views/infra/UsageRecords.vue

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
<a-row justify="end">
5151
<a-col>
5252
<tooltip-button
53+
v-if="'generateUsageRecords' in $store.getters.apis"
5354
type="primary"
5455
icon="hdd-outlined"
5556
:tooltip="$t('label.usage.records.generate')"
@@ -58,6 +59,7 @@
5859
</a-col>&nbsp;&nbsp;
5960
<a-col>
6061
<tooltip-button
62+
v-if="'removeRawUsageRecords' in $store.getters.apis"
6163
type="danger"
6264
icon="delete-outlined"
6365
:tooltip="$t('label.usage.records.purge')"
@@ -70,7 +72,7 @@
7072
</a-card>
7173
</a-affix>
7274
<a-col>
73-
<a-card size="small" :loading="serverMetricsLoading">
75+
<a-card size="small" :loading="serverMetricsLoading" v-if="'listUsageServerMetrics' in $store.getters.apis">
7476
<a-row justify="space-around">
7577
<a-card-grid style="width: 30%; text-align: center; font-size: small;">
7678
<a-statistic
@@ -86,10 +88,10 @@
8688
<a-card-grid style="width: 35%; text-align: center; font-size: small;">
8789
<a-statistic
8890
:title="$t('label.lastheartbeat')"
89-
:value="$toLocaleDate(serverStats.lastheartbeat)"
91+
:value="serverStats.lastheartbeat ? $toLocaleDate(serverStats.lastheartbeat) : $t('label.never')"
9092
valueStyle="font-size: medium"
9193
/>
92-
<a-card-meta :description="getTimeSince(serverStats.collectiontime)" />
94+
<a-card-meta v-if="!!serverStats.lastheartbeat" :description="getTimeSince(serverStats.collectiontime)" />
9395
</a-card-grid>
9496
<a-card-grid style="width: 35%; text-align: center; font-size: small;">
9597
<a-statistic
@@ -159,7 +161,7 @@
159161
/>
160162
</a-form-item>
161163
</a-col>
162-
<a-col :span="3">
164+
<a-col :span="3" v-if="'listUsageTypes' in $store.getters.apis">
163165
<a-form-item
164166
ref="type"
165167
name="type"
@@ -173,7 +175,7 @@
173175
/>
174176
</a-form-item>
175177
</a-col>
176-
<a-col :span="3">
178+
<a-col :span="3" v-if="'listUsageTypes' in $store.getters.apis">
177179
<a-form-item
178180
ref="id"
179181
name="id"
@@ -501,6 +503,11 @@ export default {
501503
}
502504
},
503505
listUsageServerMetrics () {
506+
if (!('listUsageServerMetrics' in this.$store.getters.apis)) {
507+
this.serverMetricsLoading = false
508+
return
509+
}
510+
504511
this.serverMetricsLoading = true
505512
api('listUsageServerMetrics').then(json => {
506513
this.stats = []
@@ -637,6 +644,10 @@ export default {
637644
})
638645
},
639646
getUsageTypes () {
647+
if (!('listUsageTypes' in this.$store.getters.apis)) {
648+
return
649+
}
650+
640651
api('listUsageTypes').then(json => {
641652
if (json && json.listusagetypesresponse && json.listusagetypesresponse.usagetype) {
642653
this.usageTypes = [{ id: null, value: '' }, ...json.listusagetypesresponse.usagetype.map(x => {

0 commit comments

Comments
 (0)