+ num = $scope.facility_names.length;
+ prev_num_selected = prev_selected.length;
+ num_selected = selected.length;
+
+ if ((prev_num_selected != 0) && (prev_num_selected != num)) {
+ // Remove previous filter
+ filter = ['facility_name', 'included', prev_selected];
+ manifold.raise_event($scope.instance.options.query_uuid, FILTER_REMOVED, filter);
+ }
+
+ if (num_selected != num) {
+ filter = ['facility_name', 'included', selected];
+ manifold.raise_event($scope.instance.options.query_uuid, FILTER_ADDED, filter);
+ }
+ };
+
+ $scope.select_testbed = function(facility, testbed)
+ {
+ var selected, prev_selected, num, num_selected, num_prev_selected, filter;
+
+ prev_selected = Array();
+ $.each($scope.facility_names, function(i, facility_name) {
+ $.each($scope.testbed_names[facility_name], function(j, testbed_name) {
+ if ($scope.is_testbed_active(facility_name, testbed_name)) {
+ // XXX We should have a joint facility/testbed filter
+ prev_selected.push(testbed_name);
+ }
+ });
+
+ });
+
+ $scope.set_testbed_active(facility, testbed, ! $scope.is_testbed_active(facility, testbed));
+
+ selected = Array();
+ $.each($scope.facility_names, function(i, facility_name) {
+ $.each($scope.testbed_names[facility_name], function(j, testbed_name) {
+ if ($scope.is_testbed_active(facility_name, testbed_name)) {
+ // XXX We should have a joint facility/testbed filter
+ selected.push(testbed_name);
+ }
+ });
+
+ });
+
+ num = 0;
+ $.each($scope.facility_names, function(i, facility_name) {
+ num += $scope.testbed_names[facility_name].length;
+ });