RIFT-14874: Allow deny of duplicate events in loggin
[osm/UI.git] / skyquake / plugins / logging / src / loggingSource.js
index e073809..c83b322 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 
+ *
  *   Copyright 2016 RIFT.IO Inc
  *
  *   Licensed under the Apache License, Version 2.0 (the "License");
@@ -66,7 +66,49 @@ export default {
         return new Promise(function(resolve, reject) {
           let promises = [];
           let remove = null;
-          let change = $.ajax({
+          // $.ajax({
+          //   url: 'https://10.66.202.130:8008/api/config/logging/allow/duplicate',
+          //   type: 'DELETE',
+          //   beforeSend: Utils.addAuthorizationStub
+          // })
+          if(loggingConfig.hasOwnProperty('allowDuplicateEvents')) {
+            promises.push($.ajax({
+              // url: apiUrl('api/config/default-severity'),
+              url: apiUrl('api/config/allow-duplicate-events'),
+              type: 'PUT',
+              beforeSend: Utils.addAuthorizationStub,
+              data: {
+                allowDuplicateEvents: loggingConfig.allowDuplicateEvents
+              },
+              success: function(data) {
+                resolve(data);
+              },
+              error: function(error) {
+                console.log("There was an error updating the logging config data",
+                  error);
+                reject(error);
+              }
+            }))
+          }
+          // if(nulledCategories.length > 0) {
+          //   remove = $.ajax({
+          //     // url: apiUrl('api/config/default-severity'),
+          //     url: apiUrl('api/config/default-syslog-severity/' + nulledCategories.join(',')),
+          //     type: 'DELETE',
+          //     beforeSend: Utils.addAuthorizationStub,
+          //     success: function(data) {
+          //       resolve(data);
+          //     },
+          //     error: function(error) {
+          //       console.log("There was an error updating the logging config data",
+          //         error);
+          //       reject(error);
+          //     }
+          //   });
+          //   promises.push(remove);
+          // }
+          Promise.all(promises).then(function(data) {
+            return $.ajax({
                 url: apiUrl('api/aggregate'),
                 type: 'PUT',
                 beforeSend: Utils.addAuthorizationStub,
@@ -80,29 +122,7 @@ export default {
                   reject(error);
                 }
           });
-          promises.push(change);
-          if(nulledCategories.length > 0) {
-            remove = $.ajax({
-              url: apiUrl('api/config/default-severity'),
-              type: 'DELETE',
-              beforeSend: Utils.addAuthorizationStub,
-              data: {
-                'default-severity' : nulledCategories
-              },
-              success: function(data) {
-                resolve(data);
-              },
-              error: function(error) {
-                console.log("There was an error updating the logging config data",
-                  error);
-                reject(error);
-              }
-            });
-            promises.push(remove);
-          }
-
-
-          Promise.all(promises).then(function(data){
+          }).then(function(data){
             resolve(data)
           }, function(){
             reject(arguments)