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
co-authored by GitHub
parent e6423852ef
commit 9b4406ec9e
11 changed files with 196 additions and 52 deletions
+4 -1
View File
@@ -98,7 +98,10 @@ class DynamicConfig
{
/** @var Collection $grouped */
$grouped = $this->definitions->filter->isValid()->sortBy('group')->groupBy('group')->map(function ($group) {
return $group->sortBy('section')->groupBy('section')->map->sortBy('order');
return $group->sortBy('section')->groupBy('section')->map(function ($section) {
/** @var Collection $section */
return $section->sortBy('order')->pluck('name');
});
});
$grouped->prepend($grouped->pull(''), 'global'); // rename '' to global
return $grouped;
+3 -1
View File
@@ -12,15 +12,17 @@ class SettingsController extends Controller
/**
* Display a listing of the resource.
*
* @param DynamicConfig $dynamicConfig
* @param string $tab
* @param string $section
* @return \Illuminate\Http\Response
*/
public function index($tab = 'global', $section = '')
public function index(DynamicConfig $dynamicConfig, $tab = 'global', $section = '')
{
$data = [
'active_tab' => $tab,
'active_section' => $section,
'groups' => $dynamicConfig->getGrouped()->forget('global'),
];
return view('settings.index', $data);
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -1,6 +1,6 @@
{
"/js/app.js": "/js/app.js?id=f39833017290f21b8e19",
"/js/app.js": "/js/app.js?id=5c0876339a6786677dfe",
"/css/app.css": "/css/app.css?id=17e56994706c74ee9663",
"/js/manifest.js": "/js/manifest.js?id=3c768977c2574a34506e",
"/js/vendor.js": "/js/vendor.js?id=930ffdff63156343dd1f"
"/js/vendor.js": "/js/vendor.js?id=dc98201378abb0b1bb08"
}
+107 -4
View File
@@ -145,7 +145,10 @@
},
"allow_duplicate_sysName": {
"default": false,
"type": "boolean"
"type": "boolean",
"group": "discovery",
"section": "general",
"order": 0
},
"allow_entity_sensor.amperes": {
"default": true,
@@ -485,7 +488,7 @@
"units": "days",
"group": "auth",
"section": "general",
"order": 1,
"order": 3,
"type": "integer"
},
"authlog_purge": {
@@ -2834,6 +2837,91 @@
},
"type": "array"
},
"graylog.base_uri": {
"type": "text",
"group": "external",
"section": "graylog",
"order": 3,
"when": {
"setting": "graylog.version",
"operator": "equals",
"value": "other"
}
},
"graylog.device-page.loglevel": {
"default": 7,
"type": "select",
"group": "external",
"section": "graylog",
"order": 8,
"options": {
"0": "0",
"1": "1",
"2": "2",
"3": "3",
"4": "4",
"5": "5",
"6": "6",
"7": "7"
}
},
"graylog.device-page.rowCount": {
"default": 10,
"type": "integer",
"group": "external",
"section": "graylog",
"order": 9
},
"graylog.password": {
"type": "password",
"group": "external",
"section": "graylog",
"order": 5
},
"graylog.port": {
"type": "integer",
"group": "external",
"section": "graylog",
"order": 1,
"validate": {
"value": "int|nullable|between:1,65535"
}
},
"graylog.server": {
"type": "text",
"group": "external",
"section": "graylog",
"order": 0,
"validate": {
"value": "nullable|url"
}
},
"graylog.timezone": {
"type": "text",
"group": "external",
"section": "graylog",
"order": 6,
"validate": {
"value": "nullable|timezone"
}
},
"graylog.username": {
"type": "text",
"group": "external",
"section": "graylog",
"order": 4
},
"graylog.version": {
"type": "select",
"group": "external",
"section": "graylog",
"order": 2,
"options": {
"2.0": "Less than 2.1",
"2.1": "2.1 or newer",
"other": "Other"
}
},
"gui.network-map.style": {
"default": "new",
"type": "select",
@@ -3084,7 +3172,7 @@
"default": "Unauthorised access or use shall render the user liable to criminal and/or civil prosecution.",
"group": "auth",
"section": "general",
"order": 3,
"order": 4,
"type": "text"
},
"map.engine": {
@@ -3113,6 +3201,15 @@
"order": 4,
"type": "text"
},
"mydomain": {
"type": "text",
"group": "discovery",
"section": "general",
"order": 3,
"validate": {
"value": "regex:/^(((?!-))(xn--|_{1,1})?[a-z0-9-]{0,61}[a-z0-9]{1,1}\\.)*(xn--)?([a-z0-9][a-z0-9\\-]{0,60}|[a-z0-9-]{1,30}\\.[a-z]{2,})$/"
}
},
"nagios_plugins": {
"default": "/usr/lib/nagios/plugins",
"type": "text"
@@ -3726,7 +3823,7 @@
"default": false,
"group": "auth",
"section": "general",
"order": 4,
"order": 5,
"type": "boolean"
},
"rancid_ignorecomments": {
@@ -4121,6 +4218,12 @@
"default": ["transit"],
"type": "array"
},
"twofactor": {
"type": "boolean",
"group": "auth",
"section": "general",
"order": 1
},
"unix-agent-connection-time-out": {
"default": 10,
"type": "integer"
+15 -8
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() {
+2 -33
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>
+3 -1
View File
@@ -48,5 +48,7 @@
</script>
<style scoped>
.form-control {
padding-right: 12px;
}
</style>
+57
View File
@@ -8,6 +8,7 @@ return [
'external' => 'External',
'global' => 'Global',
'os' => 'OS',
'discovery' => 'Discovery',
'poller' => 'Poller',
'system' => 'System',
'webui' => 'Web UI',
@@ -22,9 +23,13 @@ return [
'ad' => 'Active Directory Settings',
'ldap' => 'LDAP Settings'
],
'discovery' => [
'general' => 'General Discovery Settings'
],
'external' => [
'binaries' => 'Binary Locations',
'location' => 'Location Settings',
'graylog' => 'Graylog Integration',
'oxidized' => 'Oxidized Integration',
'peeringdb' => 'PeeringDB Integration',
'nfsen' => 'NfSen Integration',
@@ -121,6 +126,10 @@ return [
'description' => 'Alert log entries older than',
'help' => 'Cleanup done by daily.sh',
],
'allow_duplicate_sysName' => [
'description' => 'Allow Duplicate sysName',
'help' => 'By default duplicate sysNames are disabled from being added to prevent a device with multiple interfaces from being added multiple times'
],
'allow_unauth_graphs' => [
'description' => 'Allow unauthenticated graph access',
'help' => 'Allows any one to access graphs without login'
@@ -422,6 +431,46 @@ return [
]
]
],
'graylog' => [
'base_uri' => [
'description' => 'Base URI',
'help' => 'Override the base uri in the case you have modified the Graylog default.'
],
'device-page' => [
'loglevel' => [
'description' => 'Device Overview Log Level',
'help' => 'Sets the maximum log level shown on the device overview page.'
],
'rowCount' => [
'description' => 'Device Overview Row Count',
'help' => 'Sets the number of rows show on the device overview page.'
]
],
'password' => [
'description' => 'Password',
'help' => 'Password for accessing Graylog API.'
],
'port' => [
'description' => 'Port',
'help' => 'The port used to access the Graylog API. If none give, it will be 80 for http and 443 for https.'
],
'server' => [
'description' => 'Server',
'help' => 'The ip or hostname of the Graylog server API endpoint.'
],
'timezone' => [
'description' => 'Display Timezone',
'help' => 'Graylog times are stored in GMT, this setting will change the displayed timezone. The value must be a valid PHP timezone.'
],
'username' => [
'description' => 'Username',
'help' => 'Username for accessing the Graylog API.'
],
'version' => [
'description' => 'Version',
'help' => 'This is used to automatically create the base_uri for the Graylog API. If you have modified the API uri from the default, set this to other and specify your base_uri.'
]
],
'http_proxy' => [
'description' => 'HTTP(S) Proxy',
'help' => 'Set this as a fallback if http_proxy or https_proxy environment variable is not available.'
@@ -439,6 +488,10 @@ return [
'mtr' => [
'description' => 'Path to mtr'
],
'mydomain' => [
'description' => 'Primary Domain',
'help' => 'This domain is used for network auto-discovery and other processes. LibreNMS will attempt to append it to unqualified hostnames.'
],
'nfsen_enable' => [
'description' => 'Enable NfSen',
'help' => 'Enable Integration with NfSen',
@@ -719,6 +772,10 @@ return [
'description' => 'Path to whois'
]
],
'twofactor' => [
'description' => 'Enable Two-Factor Auth',
'help' => "Enables the built in Two-Factor authentication. You must set up each account to make it active."
],
'units' => [
'days' => 'days',
'ms' => 'ms',
+1
View File
@@ -9,6 +9,7 @@
prefix="{{ url('settings') }}"
initial-tab="{{ $active_tab }}"
initial-section="{{ $active_section }}"
:groups="{{ $groups }}"
></librenms-settings>
</div>
</div>