fixes testbed filter when no testbed is selected (closes ticket #50).
authorJordan Augé <jordan.auge@lip6.fr>
Wed, 6 Aug 2014 10:01:30 +0000 (12:01 +0200)
committerJordan Augé <jordan.auge@lip6.fr>
Wed, 6 Aug 2014 10:01:59 +0000 (12:01 +0200)
manifoldapi/static/js/manifold.js
plugins/testbeds/static/js/testbeds.js

index 17677b9..59cb4bb 100644 (file)
@@ -560,6 +560,8 @@ function QueryStore() {
 
         this.iter_records(query_uuid, function(record_key, record) {
             var is_reserved, is_pending, in_set,  is_unconfigured;
+
+            /* By default, a record is visible unless a filter says the opposite */
             var visible = true;
 
             var record_state = manifold.query_store.get_record_state(query_uuid, record_key, STATE_SET);
@@ -629,13 +631,16 @@ function QueryStore() {
                 if (op == '=' || op == '==') {
                     if ( col_value != value || col_value==null || col_value=="" || col_value=="n/a")
                         visible = false;
+
                 }else if (op == 'included') {
+                    /* By default, the filter returns false unless the record
+                     * field match at least one value of the included statement
+                     */
+                    visible = false;
                     $.each(value, function(i,x) {
                       if(x == col_value){
                           visible = true;
                           return false; // ~ break
-                      }else{
-                          visible = false;
                       }
                     });
                 }else if (op == '!=') {
index 623bc91..e21446c 100644 (file)
@@ -49,7 +49,7 @@
                 manifold.raise_event($scope.instance.options.query_uuid, FILTER_REMOVED, filter);
             }
 
-            if ((num_selected != 0) && (num_selected != num)) {
+            if (num_selected != num) {
                 filter = ['network_hrn', 'included', selected];
                 manifold.raise_event($scope.instance.options.query_uuid, FILTER_ADDED, filter);
             }
              this.set_networks();
         },
 
-/*
-            var self = this;
-            console.log('query network DONE');
-            $("[id^='testbeds-filter_']").on('click',function(e) {
-                $(this).toggleClass("active");
-
-                // avoid multiple calls when an event is raised to manifold.js
-                e.stopPropagation();
-
-                value = this.dataset['platform'];
-                // handle the hrn that include . in their name (has to be in sync with the data from SFA)
-                //value = value.replace(/\./g,"\\.");
-                key = "network_hrn";
-                op = "included";
-                return $(this).hasClass('active') ? self._addFilter(key, op, value) : self._removeFilter(key, op, value);
-            });
-           
-        },*/
-
         /* INTERNAL FUNCTIONS */
 
         set_networks: function()
             return angular.element('[ng-controller=TestbedsCtrl]').scope()
         },
 
+/*
         _addFilter: function(key, op, value)
         {
             values = Array();
             // Update the filter with the new list of values, ex: [ple,nitos,wilab]
             manifold.raise_event(this.options.query_uuid, FILTER_ADDED, [key, op, values]);
         },
+
         _removeFilter: function(key, op, value)
         {
             console.log("remove "+value);
                 manifold.raise_event(this.options.query_uuid, FILTER_ADDED, [key, op, values]);
             }
         }
-
+*/
     });
 
     /* Plugin registration */