Error in JS logs when click in the background
[clamp.git] / src / main / resources / META-INF / resources / designer / scripts / CldsModelService.js
index c2b4f67..8bc6e32 100644 (file)
 app.service('cldsModelService', ['alertService','$http', '$q', function (alertService,$http, $q) {
   
   function checkIfElementType(name){
+      //This will open the methods located in the app.js
+      if (undefined == name) {
+          return
+      }
+      
+      mapping = {
+          'stringmatch': StringMatchWindow,
+          'tca': TCAWindow,
+          'policy': PolicyWindow,
+          'collector': CollectorsWindow,
+          'vescollector': VesCollectorWindow,
+          'holmes': HolmesWindow,
+      };
 
-    //This will open the methods located in the app.js
-       if (name.toLowerCase().indexOf("stringmatch")>=0)
-           StringMatchWindow();
-       else if (name.toLowerCase().indexOf("tca")>=0)
-               TCAWindow();
-    else if(name.toLowerCase().indexOf("policy")>=0)
-       PolicyWindow();
-    else if(name.toLowerCase().indexOf("collector")>=0)
-        CollectorsWindow();
-    
+      key = name.split('_')[0].toLowerCase()
+      if (key in mapping) {
+          mapping[key]();
+      }
   }
 
   this.toggleDeploy = function  (uiAction, modelName, controlNamePrefixIn,