2020-10-08 15:23:59 +00:00
|
|
|
|
/**
|
2021-09-16 22:28:03 +00:00
|
|
|
|
* @module ClientsConfig
|
|
|
|
|
* ClientsConfig components are used to show and edit the client count config information.
|
2020-10-08 15:23:59 +00:00
|
|
|
|
*
|
|
|
|
|
* @example
|
|
|
|
|
* ```js
|
2021-09-16 22:28:03 +00:00
|
|
|
|
* <Clients::Config @model={{model}} @mode="edit" />
|
2020-10-08 15:23:59 +00:00
|
|
|
|
* ```
|
2021-09-16 22:28:03 +00:00
|
|
|
|
* @param {object} model - model is the DS clients/config model which should be passed in
|
2020-10-08 15:23:59 +00:00
|
|
|
|
* @param {string} [mode=show] - mode is either show or edit. Show results in a table with the config, show has a form.
|
|
|
|
|
*/
|
|
|
|
|
|
2021-08-25 21:22:15 +00:00
|
|
|
|
import Component from '@glimmer/component';
|
|
|
|
|
import { action } from '@ember/object';
|
2020-10-08 15:23:59 +00:00
|
|
|
|
import { inject as service } from '@ember/service';
|
2021-08-25 21:22:15 +00:00
|
|
|
|
import { tracked } from '@glimmer/tracking';
|
2020-10-08 15:23:59 +00:00
|
|
|
|
import { task } from 'ember-concurrency';
|
|
|
|
|
|
2021-09-16 22:28:03 +00:00
|
|
|
|
export default class ConfigComponent extends Component {
|
2021-08-25 21:22:15 +00:00
|
|
|
|
@service router;
|
|
|
|
|
@tracked mode = 'show';
|
|
|
|
|
@tracked modalOpen = false;
|
|
|
|
|
error = null;
|
2020-10-08 15:23:59 +00:00
|
|
|
|
|
2021-08-25 21:22:15 +00:00
|
|
|
|
get infoRows() {
|
2020-10-08 15:23:59 +00:00
|
|
|
|
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',
|
|
|
|
|
},
|
|
|
|
|
];
|
2021-08-25 21:22:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get modalTitle() {
|
2020-10-08 15:23:59 +00:00
|
|
|
|
let content = 'Turn usage tracking off?';
|
2021-08-25 21:22:15 +00:00
|
|
|
|
if (this.args.model && this.args.model.enabled === 'On') {
|
2020-10-08 15:23:59 +00:00
|
|
|
|
content = 'Turn usage tracking on?';
|
|
|
|
|
}
|
|
|
|
|
return content;
|
2021-08-25 21:22:15 +00:00
|
|
|
|
}
|
2020-10-08 15:23:59 +00:00
|
|
|
|
|
2021-12-17 03:44:29 +00:00
|
|
|
|
@(task(function* () {
|
2020-10-08 15:23:59 +00:00
|
|
|
|
try {
|
2021-08-25 21:22:15 +00:00
|
|
|
|
yield this.args.model.save();
|
2020-10-08 15:23:59 +00:00
|
|
|
|
} catch (err) {
|
2021-08-25 21:22:15 +00:00
|
|
|
|
this.error = err.message;
|
2020-10-08 15:23:59 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2021-09-16 22:28:03 +00:00
|
|
|
|
this.router.transitionTo('vault.cluster.clients.index');
|
2021-08-25 21:22:15 +00:00
|
|
|
|
}).drop())
|
|
|
|
|
save;
|
|
|
|
|
|
|
|
|
|
@action
|
|
|
|
|
updateBooleanValue(attr, value) {
|
|
|
|
|
let valueToSet = value === true ? attr.options.trueValue : attr.options.falseValue;
|
|
|
|
|
this.args.model[attr.name] = valueToSet;
|
|
|
|
|
}
|
2020-10-08 15:23:59 +00:00
|
|
|
|
|
2021-08-25 21:22:15 +00:00
|
|
|
|
@action
|
|
|
|
|
onSaveChanges(evt) {
|
|
|
|
|
evt.preventDefault();
|
|
|
|
|
const changed = this.args.model.changedAttributes();
|
|
|
|
|
if (!changed.enabled) {
|
|
|
|
|
this.save.perform();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.modalOpen = true;
|
|
|
|
|
}
|
|
|
|
|
}
|