X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FUI.git;a=blobdiff_plain;f=skyquake%2Fplugins%2Flogging%2Fsrc%2FloggingStore.js;h=d8f0d70a6daf5464df6285a43f86739c4f2a3002;hp=860ff9fc9da466201efd545e2eb89b2283f6ec4a;hb=27eea26c0b90dc1482aa785837b7c56da6090eaf;hpb=b771a7f18f2f2314798ba4b6baaaa807bbd2764e diff --git a/skyquake/plugins/logging/src/loggingStore.js b/skyquake/plugins/logging/src/loggingStore.js index 860ff9fc9..d8f0d70a6 100644 --- a/skyquake/plugins/logging/src/loggingStore.js +++ b/skyquake/plugins/logging/src/loggingStore.js @@ -26,10 +26,12 @@ class LoggingStore { this.loggingConfig = {}; // initialLoggingConfig is the saved state this.initialLoggingConfig = {}; + this.nulledCategories = []; this.bindActions(LoggingActions); this.registerAsync(LoggingSource); this.exportPublicMethods({ updateCategoryDefaultSeverity: this.updateCategoryDefaultSeverity, + updateCategoryDefaultSyslogSeverity: this.updateCategoryDefaultSyslogSeverity, updateAllowDuplicateEvents: this.updateAllowDuplicateEvents, addDenyEvent: this.addDenyEvent, updateDenyEvent: this.updateDenyEvent, @@ -97,6 +99,60 @@ class LoggingStore { } } + updateCategoryDefaultSyslogSeverity = (catsev) => { + console.log("LoggingStore.updateCategoryDefaultSyslogSeverity:", catsev); + // find the category (name) in the syslog sink + + let self = this; + let loggingConfig = _.cloneDeep(this.loggingConfig); + let syslogSinkIndex = -1; + let nulledCategories = this.nulledCategories; + + loggingConfig.sinks && loggingConfig.sinks.map((sink, sinkIndex) => { + if (sink.name == 'syslog') { + if (sink.filter) { + if (sink.filter.category) { + let catIndex = _.findIndex(sink.filter.category, { + name: catsev.name + }); + if (catIndex != -1) { + // found it + if (catsev.severity == "") { + // blank was selected + nulledCategories.push(catsev.name); + this.setState({ + nulledCategories: nulledCategories + }); + // TODO/NOTE: Can't delete from model as sending a top-level payload with + // missing elements is not allowed! + // When backend supports it, in loggingSource change the order of operations + // Delete first followed by save/put. + // _.remove(loggingConfig.sinks[sinkIndex].filter.category, { + // name: catsev.name + // }); + } else { + sink.filter.category[catIndex] = catsev; + } + } else { + sink.filter.category.push(catsev); + } + } else { + sink.filter.category = []; + sink.filter.category.push(catsev); + } + } else { + sink.filter = {}; + sink.filter.category = []; + sink.filter.category.push(catsev); + } + } + }); + + this.setState({ + loggingConfig: loggingConfig + }); + } + updateAllowDuplicateEvents = (allowFlag) => { console.log("LoggingStore.updateAllowDuplicateEvents called. allowFlag=", allowFlag); const loggingConfig = this.loggingConfig;