mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 03:27:54 +00:00
UI/cleanup client charts for 1.11 (#15408)
* remove manipulations of data ranges; * fix bar aligntment * consume empty months existing on response * revert grey bar transformation * up one more line.. * remove attr
This commit is contained in:
@@ -2,6 +2,7 @@ import { parseAPITimestamp } from 'core/utils/date-formatters';
|
||||
import { compareAsc } from 'date-fns';
|
||||
|
||||
export const formatByMonths = (monthsArray) => {
|
||||
// the months array will always include a timestamp of the month and either new/total client data or counts = null
|
||||
if (!Array.isArray(monthsArray)) return monthsArray;
|
||||
const sortedPayload = sortMonthsByTimestamp(monthsArray);
|
||||
return sortedPayload.map((m) => {
|
||||
@@ -14,7 +15,7 @@ export const formatByMonths = (monthsArray) => {
|
||||
return {
|
||||
month,
|
||||
...totalCounts,
|
||||
namespaces: formatByNamespace(m.namespaces),
|
||||
namespaces: formatByNamespace(m.namespaces) || [],
|
||||
namespaces_by_key: namespaceArrayToObject(totalClientsByNamespace, newClientsByNamespace, month),
|
||||
new_clients: {
|
||||
month,
|
||||
@@ -75,7 +76,6 @@ export const homogenizeClientNaming = (object) => {
|
||||
};
|
||||
|
||||
export const flattenDataset = (object) => {
|
||||
// TODO CMB revisit when backend has finished ticket VAULT-6035
|
||||
if (object?.counts) {
|
||||
let flattenedObject = {};
|
||||
Object.keys(object['counts']).forEach((key) => (flattenedObject[key] = object['counts'][key]));
|
||||
@@ -94,6 +94,7 @@ export const sortMonthsByTimestamp = (monthsArray) => {
|
||||
};
|
||||
|
||||
export const namespaceArrayToObject = (totalClientsByNamespace, newClientsByNamespace, month) => {
|
||||
if (!totalClientsByNamespace) return {}; // return if no data for that month
|
||||
// all 'new_client' data resides within a separate key of each month (see data structure below)
|
||||
// FIRST: iterate and nest respective 'new_clients' data within each namespace and mount object
|
||||
// note: this is happening within the month object
|
||||
|
||||
Reference in New Issue
Block a user