mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-24 08:01:07 +02:00
* remvoe request tolicense in dashboard client count card * cleanup jsdoc * add changelog * use helper to set start time * update component tests * update overview test * update util tests * throw error instead, add comment to util file * fix accidentally removed type from import * remove typo arg from test component * rename token stat getter to avoid future typos
52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import ActivityComponent from '../activity';
|
|
|
|
import type {
|
|
ByMonthNewClients,
|
|
MountNewClients,
|
|
NamespaceByKey,
|
|
NamespaceNewClients,
|
|
} from 'core/utils/client-count-utils';
|
|
|
|
export default class ClientsTokenPageComponent extends ActivityComponent {
|
|
legend = [
|
|
{ key: 'entity_clients', label: 'entity clients' },
|
|
{ key: 'non_entity_clients', label: 'non-entity clients' },
|
|
];
|
|
|
|
calculateClientAverages(
|
|
dataset:
|
|
| (NamespaceByKey | undefined)[]
|
|
| (ByMonthNewClients | NamespaceNewClients | MountNewClients | undefined)[]
|
|
) {
|
|
return ['entity_clients', 'non_entity_clients'].reduce((count, key) => {
|
|
const average = this.average(dataset, key);
|
|
return (count += average || 0);
|
|
}, 0);
|
|
}
|
|
|
|
get averageTotalClients() {
|
|
return this.calculateClientAverages(this.byMonthActivityData);
|
|
}
|
|
|
|
get averageNewClients() {
|
|
return this.calculateClientAverages(this.byMonthNewClients);
|
|
}
|
|
|
|
get tokenStats() {
|
|
if (this.totalUsageCounts) {
|
|
const { entity_clients, non_entity_clients } = this.totalUsageCounts;
|
|
return {
|
|
total: entity_clients + non_entity_clients,
|
|
entity_clients,
|
|
non_entity_clients,
|
|
};
|
|
}
|
|
return null;
|
|
}
|
|
}
|