Skip to content

Commit df11882

Browse files
bernardodemarcoPearl1594
authored andcommitted
UI: Fixes in the Usage UI (apache#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 0eb311e commit df11882

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
@@ -1579,6 +1579,7 @@
15791579
"label.networkspeed": "Network speed",
15801580
"label.networktype": "Network type",
15811581
"label.networkwrite": "Network write",
1582+
"label.never": "Never",
15821583
"label.new": "New",
15831584
"label.new.autoscale.vmgroup": "New AutoScaling Group",
15841585
"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"
@@ -506,6 +508,11 @@ export default {
506508
}
507509
},
508510
listUsageServerMetrics () {
511+
if (!('listUsageServerMetrics' in this.$store.getters.apis)) {
512+
this.serverMetricsLoading = false
513+
return
514+
}
515+
509516
this.serverMetricsLoading = true
510517
api('listUsageServerMetrics').then(json => {
511518
this.stats = []
@@ -642,6 +649,10 @@ export default {
642649
})
643650
},
644651
getUsageTypes () {
652+
if (!('listUsageTypes' in this.$store.getters.apis)) {
653+
return
654+
}
655+
645656
api('listUsageTypes').then(json => {
646657
if (json && json.listusagetypesresponse && json.listusagetypesresponse.usagetype) {
647658
this.usageTypes = [{ id: null, value: '' }, ...json.listusagetypesresponse.usagetype.map(x => {

0 commit comments

Comments
 (0)