vault/ui/app/serializers/clients/config.js
Arnav Palnitkar 681a931df4
Client count updates (#12554)
* Client count updates

- Added Current month tab which leverages partial monthly activity api
- Refactored Vault usage to Monthly history
- New client count history component based on StatText and BarChart component
- Restrict bar chart to showcase only top 10 namespaces
- Removed config route, as config and history component will be rendered based on query param
- Updated all metrics reference to clients
- Removed old tests and added integration test for current month

* Fixed navbar permission

- Added changelog

* Updated the model for current month data

* Fixed current month tests

* Fixed indentation and chart label
2021-09-16 15:28:03 -07:00

34 lines
1.1 KiB
JavaScript

import ApplicationSerializer from '../application';
export default ApplicationSerializer.extend({
normalizeResponse(store, primaryModelClass, payload, id, requestType) {
if (!payload.data) {
// CBS TODO: Remove this if block once API is published
return this._super(store, primaryModelClass, payload, id, requestType);
}
const normalizedPayload = {
id: payload.id,
data: {
...payload.data,
enabled: payload.data.enabled.includes('enable') ? 'On' : 'Off',
},
};
return this._super(store, primaryModelClass, normalizedPayload, id, requestType);
},
serialize() {
let json = this._super(...arguments);
if (json.enabled === 'On' || json.enabled === 'Off') {
const oldEnabled = json.enabled;
json.enabled = oldEnabled === 'On' ? 'enable' : 'disable';
}
json.default_report_months = parseInt(json.default_report_months, 10);
json.retention_months = parseInt(json.retention_months, 10);
if (isNaN(json.default_report_months) || isNaN(json.retention_months)) {
throw new Error('Invalid number value');
}
delete json.queries_available;
return json;
},
});