35c188fba7
* 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
81 lines
2.2 KiB
JavaScript
81 lines
2.2 KiB
JavaScript
/**
|
||
* @module ClientsConfig
|
||
* ClientsConfig components are used to show and edit the client count config information.
|
||
*
|
||
* @example
|
||
* ```js
|
||
* <Clients::Config @model={{model}} @mode="edit" />
|
||
* ```
|
||
* @param {object} model - model is the DS clients/config model which should be passed in
|
||
* @param {string} [mode=show] - mode is either show or edit. Show results in a table with the config, show has a form.
|
||
*/
|
||
|
||
import Component from '@glimmer/component';
|
||
import { action } from '@ember/object';
|
||
import { inject as service } from '@ember/service';
|
||
import { tracked } from '@glimmer/tracking';
|
||
import { task } from 'ember-concurrency';
|
||
|
||
export default class ConfigComponent extends Component {
|
||
@service router;
|
||
@tracked mode = 'show';
|
||
@tracked modalOpen = false;
|
||
error = null;
|
||
|
||
get infoRows() {
|
||
return [
|
||
{
|
||
label: 'Usage data collection',
|
||
helperText: 'Enable or disable collecting data to track clients.',
|
||
valueKey: 'enabled',
|
||
},
|
||
{
|
||
label: 'Retention period',
|
||
helperText: 'The number of months of activity logs to maintain for client tracking.',
|
||
valueKey: 'retentionMonths',
|
||
},
|
||
{
|
||
label: 'Default display',
|
||
helperText: 'The number of months we’ll display in the Vault usage dashboard by default.',
|
||
valueKey: 'defaultReportMonths',
|
||
},
|
||
];
|
||
}
|
||
|
||
get modalTitle() {
|
||
let content = 'Turn usage tracking off?';
|
||
if (this.args.model && this.args.model.enabled === 'On') {
|
||
content = 'Turn usage tracking on?';
|
||
}
|
||
return content;
|
||
}
|
||
|
||
@(task(function*() {
|
||
try {
|
||
yield this.args.model.save();
|
||
} catch (err) {
|
||
this.error = err.message;
|
||
return;
|
||
}
|
||
this.router.transitionTo('vault.cluster.clients.index');
|
||
}).drop())
|
||
save;
|
||
|
||
@action
|
||
updateBooleanValue(attr, value) {
|
||
let valueToSet = value === true ? attr.options.trueValue : attr.options.falseValue;
|
||
this.args.model[attr.name] = valueToSet;
|
||
}
|
||
|
||
@action
|
||
onSaveChanges(evt) {
|
||
evt.preventDefault();
|
||
const changed = this.args.model.changedAttributes();
|
||
if (!changed.enabled) {
|
||
this.save.perform();
|
||
return;
|
||
}
|
||
this.modalOpen = true;
|
||
}
|
||
}
|