meilisearch-admin/app/components/index-setting.js

38 lines
769 B
JavaScript
Raw Normal View History

2022-09-02 08:53:33 +00:00
import Component from '@glimmer/component';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
export default class FormIndexSettingComponent extends Component {
@tracked value;
@tracked error;
2022-09-02 08:53:33 +00:00
constructor() {
super(...arguments);
this.setInitialValue();
}
@action
save(newValue) {
this.error = null;
try {
this.args.index.updateSetting(this.args.name, JSON.parse(newValue));
} catch (error) {
this.error = error.error || error;
}
2022-09-02 08:53:33 +00:00
}
@action
async setInitialValue() {
this.value = await this.args.index.getSetting(this.args.name);
this.error = null;
2022-09-02 08:53:33 +00:00
}
@action
async reset() {
await this.args.index.resetSetting(this.args.name);
this.error = null;
2022-09-02 08:53:33 +00:00
}
}