RIFT-14916: Code added but commented out for removing cat severity filter 53/553/1
authorLaurence Maultsby <laurence.maultsby@riftio.com>
Thu, 20 Oct 2016 15:23:09 +0000 (11:23 -0400)
committerLaurence Maultsby <laurence.maultsby@riftio.com>
Thu, 20 Oct 2016 15:23:09 +0000 (11:23 -0400)
Signed-off-by: Laurence Maultsby <laurence.maultsby@riftio.com>
skyquake/plugins/logging/api/logging.js
skyquake/plugins/logging/routes.js
skyquake/plugins/logging/src/loggingSource.js
skyquake/plugins/logging/src/loggingStore.js

index a3bc182..499a814 100644 (file)
@@ -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
 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) {
   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);
-      }
-    )
-  })
-
 }
 
 /*
 }
 
 /*
index 6c6df78..02b4514 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * 
+ *
  *   Copyright 2016 RIFT.IO Inc
  *
  *   Licensed under the Apache License, Version 2.0 (the "License");
  *   Copyright 2016 RIFT.IO Inc
  *
  *   Licensed under the Apache License, Version 2.0 (the "License");
@@ -71,7 +71,7 @@ var loggingRoutes = [
     },
     {
         method: 'DELETE',
     },
     {
         method: 'DELETE',
-        endpoint: '/api/config/default-syslog-severity',
+        endpoint: '/api/config/default-syslog-severity/:nulledCategories',
         apiHandler: loggingAPI['config'].deleteDefaultSyslogSeverity
     },
     {
         apiHandler: loggingAPI['config'].deleteDefaultSyslogSeverity
     },
     {
index 47e6e48..690d323 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * 
+ *
  *   Copyright 2016 RIFT.IO Inc
  *
  *   Licensed under the Apache License, Version 2.0 (the "License");
  *   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;
         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'),
           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,
               type: 'DELETE',
               beforeSend: Utils.addAuthorizationStub,
-              data: nulledCategories,
               success: function(data) {
                 resolve(data);
               },
               success: function(data) {
                 resolve(data);
               },
@@ -101,10 +83,22 @@ export default {
             });
             promises.push(remove);
           }
             });
             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)
             resolve(data)
           }, function(){
             reject(arguments)
index d8f0d70..53575eb 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * 
+ *
  *   Copyright 2016 RIFT.IO Inc
  *
  *   Licensed under the Apache License, Version 2.0 (the "License");
  *   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
                 // 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
                 // });
                 // _.remove(loggingConfig.sinks[sinkIndex].filter.category, {
                 //   name: catsev.name
                 // });
@@ -134,6 +134,10 @@ class LoggingStore {
                 sink.filter.category[catIndex] = catsev;
               }
             } else {
                 sink.filter.category[catIndex] = catsev;
               }
             } else {
+              _.remove(nulledCategories, (v) => v == catsev.name);
+              this.setState({
+                nulledCategories: nulledCategories
+              });
               sink.filter.category.push(catsev);
             }
           } else {
               sink.filter.category.push(catsev);
             }
           } else {