+// XXX Inherit from an AngularPlugin class ?
+(function (ng, app) {
+
+ // Define our Controller constructor.
+ function Controller($scope) {
+ /* Contructor */
+
+ /* Plugin instance */
+ $scope.instance = null;
+
+ /* Models */
+ $scope.testbeds = Array();
+
+ /* Click event */
+ $scope.select = function(testbed)
+ {
+ var selected, prev_selected, num, num_selected, num_prev_selected, filter;
+
+ prev_selected = $.map($scope.testbeds, function(x, i) {
+ return x.active ? x.network_hrn : null;
+ });
+
+ testbed.active = !testbed.active;
+
+ selected = $.map($scope.testbeds, function(x, i) {
+ return x.active ? x.network_hrn : null;
+ });
+
+ num = $scope.testbeds.length;
+ prev_num_selected = prev_selected.length;
+ num_selected = selected.length;
+
+
+ if ((prev_num_selected != 0) && (prev_num_selected != num)) {
+ // Remove previous filter
+ filter = ['network_hrn', 'included', prev_selected];
+ manifold.raise_event($scope.instance.options.query_uuid, FILTER_REMOVED, filter);
+ }