Add Graylog settings (#10740)

* Add Graylog settings
Fix order of settings
Don't clobber text input when validation fails
fixed spacing for setting reset/undo buttons and help

* fix style
This commit is contained in:
Tony Murray
2019-10-26 00:29:47 +00:00
committed by GitHub
parent e6423852ef
commit 9b4406ec9e
11 changed files with 196 additions and 52 deletions

View File

@@ -42,9 +42,8 @@
<span class="form-control-feedback"></span>
</div>
<div class="col-sm-2">
<button v-show="showUndo()" @click="resetToInitial" class="btn btn-primary" type="button" v-tooltip="$t('Undo')"><i class="fa fa-undo"></i></button>
<button v-show="showResetToDefault()" @click="resetToDefault" class="btn btn-default" type="button" v-tooltip="$t('Reset to default')"><i class="fa fa-refresh"></i>
</button>
<button :style="{'opacity': showResetToDefault()?1:0}" @click="resetToDefault" class="btn btn-default" type="button" v-tooltip="$t('Reset to default')"><i class="fa fa-refresh"></i></button>
<button :style="{'opacity': showUndo()?1:0}" @click="resetToInitial" class="btn btn-primary" type="button" v-tooltip="$t('Undo')"><i class="fa fa-undo"></i></button>
<div v-if="hasHelp()" v-tooltip="{content: getHelp(), trigger: 'hover click'}" class="fa fa-fw fa-lg fa-question-circle"></div>
</div>
</div>
@@ -72,11 +71,20 @@
setTimeout(() => this.feedback = '', 3000);
})
.catch((error) => {
this.value = error.response.data.value;
this.$emit('setting-updated', {name: this.setting.name, value: this.value});
this.feedback = 'has-error';
setTimeout(() => this.feedback = '', 3000);
toastr.error(error.response.data.message);
// don't reset certain types back to actual value on error
const ignore = [
'text',
'email',
'password'
];
if (!ignore.includes(this.setting.type)) {
this.value = error.response.data.value;
this.$emit('setting-updated', {name: this.setting.name, value: this.value});
setTimeout(() => this.feedback = '', 3000);
}
})
},
debouncePersistValue: _.debounce(function (value) {
@@ -124,8 +132,7 @@
this.changeValue(this.setting.value)
},
showResetToDefault() {
return this.setting.default !== null
&& !this.setting.overridden
return !this.setting.overridden
&& !_.isEqual(this.value, this.setting.default)
},
showUndo() {

View File

@@ -60,7 +60,8 @@
props: {
prefix: String,
initialTab: {type: String, default: 'alerting'},
initialSection: String
initialSection: String,
groups: {type: Object}
},
data() {
return {
@@ -125,38 +126,6 @@
mounted() {
window.onpopstate = this.handleBack; // handle back button
axios.get(route('settings.list')).then((response) => this.settings = response.data)
},
computed: {
groups() {
// populate layout data
let groups = {};
for (const key of Object.keys(this.settings)) {
let setting = this.settings[key];
// filter
if (!setting.name.includes(this.search_phrase)) {
continue
}
if (setting.group) {
if (!(setting.group in groups)) {
groups[setting.group] = {};
}
if (setting.section) {
if (!(setting.section in groups[setting.group])) {
groups[setting.group][setting.section] = [];
}
// insert based on order
groups[setting.group][setting.section].splice(setting.order, 0, setting.name);
}
}
}
// sort groups
return Object.keys(groups).sort().reduce((a, c) => (a[c] = groups[c], a), {});
}
}
}
</script>

View File

@@ -48,5 +48,7 @@
</script>
<style scoped>
.form-control {
padding-right: 12px;
}
</style>