}
+// NOTE: In rel_4.3 we are going to affect syslog sink category by default
+
+Config.setDefaultSyslogSeverity = function(req) {
+ // TODO: verify there is one key at root of data: 'default-severity'
+ // OR just filter on the request body
+ return handlePutRequest(req, APIVersion + '/api/config/logging/sink/syslog');
+}
+
+Config.deleteDefaultSyslogSeverity = function(req) {
+ // TODO: verify there is one key at root of data: 'default-severity'
+ // OR just filter on the request body
+ var Categories = req.body;
+ return new Promise(function(resolve, reject) {
+ var promises = Categories.map(function(categoryName) {
+ return handleDeleteRequest(req, APIVersion + '/api/config/logging/sink/syslog/filter/category/' + categoryName);
+ });
+ return Promise.all(promises).then(
+ function(data) {
+ resolve(data[0]);
+ },
+ function(data) {
+ reject(data);
+ }
+ )
+ })
+
+}
+
/*
get body of forms
endpoint: '/api/config/default-severity',
apiHandler: loggingAPI['config'].deleteDefaultSeverity
},
+ {
+ method: 'PUT',
+ endpoint: '/api/config/default-syslog-severity',
+ apiHandler: loggingAPI['config'].setDefaultSyslogSeverity
+ },
+ {
+ method: 'DELETE',
+ endpoint: '/api/config/default-syslog-severity',
+ apiHandler: loggingAPI['config'].deleteDefaultSyslogSeverity
+ },
{
method: 'PUT',
endpoint: '/api/config/allow-duplicate-events',
generateRows(defaultSeverities, severityOptions) {
let self = this;
return defaultSeverities.map(function(catsev) {
+ // let dropList = (<DropList options={severityOptions}
+ // selectedOption={catsev.severity}
+ // onChange={self.onChangeSeverity(catsev.category)} />);
let dropList = (<DropList options={severityOptions}
selectedOption={catsev.severity}
- onChange={self.onChangeSeverity(catsev.category)} />);
- return [catsev.category, dropList];
+ onChange={self.onChangeSyslogSeverity(catsev.name)} />);
+ return [catsev.name, dropList];
});
}
- onChangeSeverity (category) {
+ // onChangeSeverity (category) {
+ // return function(e) {
+ // LoggingStore.updateCategoryDefaultSeverity({
+ // category: category,
+ // severity: e
+ // });
+ // }
+ // }
+
+ onChangeSyslogSeverity (name) {
return function(e) {
- LoggingStore.updateCategoryDefaultSeverity({
- category: category,
+ LoggingStore.updateCategoryDefaultSyslogSeverity({
+ name: name,
severity: e
});
}
CategorySeverityGrid.defaultProps = {
cellLabels: [
- 'Category', 'Severity'
+ 'Name', 'Severity'
],
columnClasses: [
'category', 'severity'
return (
<DashboardCard className="defaultCategorySeverityPanel"
showHeader={true}
- title="Default Category Severity">
+ title="Syslog Category Severity">
<CategorySeverityGrid defaultSeverities={defaultSeverities}
severityOptions={severities}/>
</DashboardCard>
isLoading: true
});
LoggingStore.updateLoggingConfig(
- this.collectNulledCategories(
+ /* this.collectNulledCategories(
this.state.initialLoggingConfig,
this.state.loggingConfig),
- this.removeCategoryNulls(
- this.state.loggingConfig
- )
- );
+ this.removeCategoryNulls(
+ this.state.loggingConfig */
+ this.state.nulledCategories,
+ this.cleanupConfig(
+ this.state.loggingConfig
+ )
+ )
} else {
console.log("LoggingGeneral.handleSave failed validation");
}
this.context.router.push({pathname: ''});
}
- removeCategoryNulls(config) {
+ // removeCategoryNulls(config) {
+ // let cleanConfig = _.cloneDeep(config);
+ // let cleanSeverities = [];
+ // config.defaultSeverities.map(function(d) {
+ // if (d.severity) {
+ // cleanSeverities.push(d);
+ // }
+ // });
+ // cleanConfig.defaultSeverities = cleanSeverities;
+ // return cleanConfig;
+ // }
+ cleanupConfig(config) {
let cleanConfig = _.cloneDeep(config);
let cleanSeverities = [];
- config.defaultSeverities.map(function(d) {
- if (d.severity) {
- cleanSeverities.push(d);
+ cleanConfig.defaultSeverities && cleanConfig.defaultSeverities.map((defSev) => {
+ if (defSev.severity) {
+ cleanSeverities.push(defSev);
}
});
cleanConfig.defaultSeverities = cleanSeverities;
+
return cleanConfig;
}
- collectNulledCategories(oldCat, newCat) {
- let nulledCategories = [];
- let newSeverities = newCat.defaultSeverities;
- let oldSeverities = oldCat.defaultSeverities;
- newSeverities.map(function(c, i) {
- if(!c.severity) {
- if(oldSeverities[i].severity) {
- //verify that categories are the same
- if(oldSeverities[i].category == c.category) {
- nulledCategories.push({category: c.category})
- }
- }
- }
- });
- return nulledCategories;
- }
+ // collectNulledCategories(oldCat, newCat) {
+ // let nulledCategories = [];
+ // let newSeverities = newCat.defaultSeverities;
+ // let oldSeverities = oldCat.defaultSeverities;
+ // newSeverities.map(function(c, i) {
+ // if(!c.severity) {
+ // if(oldSeverities[i].severity) {
+ // //verify that categories are the same
+ // if(oldSeverities[i].category == c.category) {
+ // nulledCategories.push({category: c.category})
+ // }
+ // }
+ // }
+ // });
+ // return nulledCategories;
+ // }
validateData() {
function isEventIdValid(eventID) {
let syslogViewerURL = this.state.loggingConfig.syslogviewer;
let defaultSeverities = this.state.loggingConfig.defaultSeverities;
+ // NOTE: There are modifications to original code here
+ // for RIFT-14856 so that default severities map to syslog sink
+
+ // Find first syslog sink with (WTF - no type on sinks!) name syslog.
+ let syslogSink = this.state.loggingConfig.sinks && _.find(this.state.loggingConfig.sinks, {
+ name: 'syslog'
+ });
+ let defaultSyslogSeverities = [];
+
+ this.state.loggingConfig && this.state.loggingConfig.defaultSeverities && this.state.loggingConfig.defaultSeverities.map((defaultSeverity) => {
+ // Mapping between default categories and names inside a sink
+ let syslogFilterCategory = (syslogSink.filter && syslogSink.filter.category && _.find(syslogSink.filter.category, {
+ name: defaultSeverity.category
+ })) || {
+ name: defaultSeverity.category,
+ severity: null
+ };
+ defaultSyslogSeverities.push(syslogFilterCategory);
+ });
let severities = this.state.loggingConfig.severities;
let allowDuplicateEvents = this.state.loggingConfig.allowDuplicateEvents;
let denyEventIDs = this.state.loggingConfig.denyEventIDs;
{errorMessage}
<ScreenLoader show={this.state.isLoading}/>
<div className="panelContainer">
- <DefaultCategorySeverityPanel defaultSeverities={defaultSeverities}
+ {/*<DefaultCategorySeverityPanel defaultSeverities={defaultSeverities}
+ severities={severities}
+ />*/}
+ <DefaultCategorySeverityPanel defaultSeverities={defaultSyslogSeverities}
severities={severities}
/>
<LoggingEventsPanel allowDuplicateEvents={allowDuplicateEvents}
}
});
promises.push(change);
+ /* Backend bug disallows deleting: RIFT-14910
+
if(nulledCategories.length > 0) {
remove = $.ajax({
- url: apiUrl('api/config/default-severity'),
+ // url: apiUrl('api/config/default-severity'),
+ url: apiUrl('api/config/default-syslog-severity'),
type: 'DELETE',
beforeSend: Utils.addAuthorizationStub,
- data: {
- 'default-severity' : nulledCategories
- },
+ data: nulledCategories,
success: function(data) {
resolve(data);
},
});
promises.push(remove);
}
+ */
Promise.all(promises).then(function(data){
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,
}
}
+ 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;