From: Laurence Maultsby Date: Thu, 20 Oct 2016 15:23:09 +0000 (-0400) Subject: RIFT-14916: Code added but commented out for removing cat severity filter X-Git-Tag: v1.0.1~10^2~6 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F53%2F553%2F1;p=osm%2FUI.git RIFT-14916: Code added but commented out for removing cat severity filter Signed-off-by: Laurence Maultsby --- diff --git a/skyquake/plugins/logging/api/logging.js b/skyquake/plugins/logging/api/logging.js index a3bc18221..499a81421 100644 --- a/skyquake/plugins/logging/api/logging.js +++ b/skyquake/plugins/logging/api/logging.js @@ -333,21 +333,21 @@ Config.setDefaultSyslogSeverity = function(req) { 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; + var Categories = req.params.nulledCategories.split(','); + var promises = []; return new Promise(function(resolve, reject) { - var promises = Categories.map(function(categoryName) { - return handleDeleteRequest(req, APIVersion + '/api/config/logging/sink/syslog/filter/category/' + categoryName); + promises.concat(Categories.map(function(categoryName) { + return handleDeleteRequest(req, APIVersion + '/api/config/logging/sink/syslog/filter/category/' + categoryName); + })); + return Promise.all(promises).then( + function(data) { + resolve({statusCode: 200, data: data[0]}); + }, + function(data) { + reject(data); + } + ) }); - return Promise.all(promises).then( - function(data) { - resolve(data[0]); - }, - function(data) { - reject(data); - } - ) - }) - } /* diff --git a/skyquake/plugins/logging/routes.js b/skyquake/plugins/logging/routes.js index 6c6df7860..02b4514cf 100644 --- a/skyquake/plugins/logging/routes.js +++ b/skyquake/plugins/logging/routes.js @@ -1,5 +1,5 @@ /* - * + * * Copyright 2016 RIFT.IO Inc * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -71,7 +71,7 @@ var loggingRoutes = [ }, { method: 'DELETE', - endpoint: '/api/config/default-syslog-severity', + endpoint: '/api/config/default-syslog-severity/:nulledCategories', apiHandler: loggingAPI['config'].deleteDefaultSyslogSeverity }, { diff --git a/skyquake/plugins/logging/src/loggingSource.js b/skyquake/plugins/logging/src/loggingSource.js index 47e6e48ae..690d32326 100644 --- a/skyquake/plugins/logging/src/loggingSource.js +++ b/skyquake/plugins/logging/src/loggingSource.js @@ -1,5 +1,5 @@ /* - * + * * Copyright 2016 RIFT.IO Inc * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -66,30 +66,12 @@ export default { return new Promise(function(resolve, reject) { let promises = []; let remove = null; - let change = $.ajax({ - url: apiUrl('api/aggregate'), - type: 'PUT', - beforeSend: Utils.addAuthorizationStub, - data: loggingConfig, - success: function(data) { - resolve(data); - }, - error: function(error) { - console.log("There was an error updating the logging config data", - error); - reject(error); - } - }); - 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-syslog-severity'), + url: apiUrl('api/config/default-syslog-severity/' + nulledCategories.join(',')), type: 'DELETE', beforeSend: Utils.addAuthorizationStub, - data: nulledCategories, success: function(data) { resolve(data); }, @@ -101,10 +83,22 @@ export default { }); promises.push(remove); } - */ - - - Promise.all(promises).then(function(data){ + Promise.all(promises).then(function(data) { + return $.ajax({ + url: apiUrl('api/aggregate'), + type: 'PUT', + beforeSend: Utils.addAuthorizationStub, + data: loggingConfig, + success: function(data) { + resolve(data); + }, + error: function(error) { + console.log("There was an error updating the logging config data", + error); + reject(error); + } + }); + }).then(function(data){ resolve(data) }, function(){ reject(arguments) diff --git a/skyquake/plugins/logging/src/loggingStore.js b/skyquake/plugins/logging/src/loggingStore.js index d8f0d70a6..53575ebbc 100644 --- a/skyquake/plugins/logging/src/loggingStore.js +++ b/skyquake/plugins/logging/src/loggingStore.js @@ -1,5 +1,5 @@ /* - * + * * Copyright 2016 RIFT.IO Inc * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -126,7 +126,7 @@ class LoggingStore { // 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. + // // Delete first followed by save/put. // _.remove(loggingConfig.sinks[sinkIndex].filter.category, { // name: catsev.name // }); @@ -134,6 +134,10 @@ class LoggingStore { sink.filter.category[catIndex] = catsev; } } else { + _.remove(nulledCategories, (v) => v == catsev.name); + this.setState({ + nulledCategories: nulledCategories + }); sink.filter.category.push(catsev); } } else {