From: Jordan Augé Date: Wed, 6 Aug 2014 10:01:30 +0000 (+0200) Subject: fixes testbed filter when no testbed is selected (closes ticket #50). X-Git-Tag: myslice-1.0~28 X-Git-Url: http://git.onelab.eu/?p=myslice.git;a=commitdiff_plain;h=7e2459e0dc1cef399e9b010d99381e38da5c5556 fixes testbed filter when no testbed is selected (closes ticket #50). --- diff --git a/manifoldapi/static/js/manifold.js b/manifoldapi/static/js/manifold.js index 17677b95..59cb4bb9 100644 --- a/manifoldapi/static/js/manifold.js +++ b/manifoldapi/static/js/manifold.js @@ -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 == '!=') { diff --git a/plugins/testbeds/static/js/testbeds.js b/plugins/testbeds/static/js/testbeds.js index 623bc91c..e21446cf 100644 --- a/plugins/testbeds/static/js/testbeds.js +++ b/plugins/testbeds/static/js/testbeds.js @@ -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); } @@ -133,25 +133,6 @@ 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() @@ -168,6 +149,7 @@ return angular.element('[ng-controller=TestbedsCtrl]').scope() }, +/* _addFilter: function(key, op, value) { values = Array(); @@ -187,6 +169,7 @@ // 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); @@ -213,7 +196,7 @@ manifold.raise_event(this.options.query_uuid, FILTER_ADDED, [key, op, values]); } } - +*/ }); /* Plugin registration */