/* Plugin instance */
$scope.instance = null;
+ $scope.facility_names = Array();
+ $scope.testbed_names = new Object();
+
/* Models */
- $scope.testbeds = Array();
+ //$scope.testbeds = Array();
+ $scope._facility_active = new Object();
+ $scope._testbed_active = new Object();
+
+ $scope.is_facility_active = function(facility)
+ {
+ return (($scope._facility_active[facility] === undefined) || $scope._facility_active[facility]);
+ };
+ $scope.is_testbed_active = function(facility, testbed)
+ {
+ return (($scope._testbed_active[facility] === undefined) ||
+ ($scope._testbed_active[facility][testbed] === undefined) ||
+ ($scope._testbed_active[facility][testbed]));
+ };
+
+ $scope.set_facility_active = function(facility, value)
+ {
+ $scope._facility_active[facility] = value;
+ };
+
+ $scope.set_testbed_active = function(facility, testbed, value)
+ {
+ if ($scope._testbed_active[facility] === undefined)
+ $scope._testbed_active[facility] = new Object();
+ $scope._testbed_active[facility][testbed] = value;
+ };
+
+ $scope.tolower = function(string) {
+ return string.toLowerCase(string);
+ };
+
/* Click event */
- $scope.select = function(testbed)
+
+ $scope.select_facility = function(facility)
{
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;
+ // prev_selected = $.map($scope.facility_names, function(x, i) {
+ // return $scope.is_facility_active(x) ? x : null;
+ // });
+
+ $scope.set_facility_active(facility, ! $scope.is_facility_active(facility));
+
+ $.each($scope.testbed_names[facility], function(j, testbed_name) {
+ $scope.select_testbed(facility, testbed_name);
});
+ console.log($scope);
+ // selected = $.map($scope.facility_names, function(x, i) {
+ // return $scope.is_facility_active(x) ? x : null;
+ // });
+
+ // 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);
+ // }
+ };
- testbed.active = !testbed.active;
+ $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);
+ }
+ });
- selected = $.map($scope.testbeds, function(x, i) {
- return x.active ? x.network_hrn : null;
});
- num = $scope.testbeds.length;
+ $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;
+ });
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];
+ // XXX We should have a joint facility/testbed filter
+ filter = ['testbed_name', 'included', prev_selected];
manifold.raise_event($scope.instance.options.query_uuid, FILTER_REMOVED, filter);
}
- if ((num_selected != 0) && (num_selected != num)) {
- filter = ['network_hrn', 'included', selected];
+ if (num_selected != num) {
+ // XXX We should have a joint facility/testbed filter
+ filter = ['testbed_name', 'included', selected];
manifold.raise_event($scope.instance.options.query_uuid, FILTER_ADDED, filter);
}
};
this._super(options, element);
/* Member variables */
- this.filters = Array();
this.testbeds = Array();
this._get_scope().instance = this;
/* HANDLERS */
/* When a filter is added/removed, update the list of filters local to the plugin */
+ /*
on_filter_added: function(filter)
{
this.filters.push(filter);
}
}
},
-
+ */
// ... be sure to list all events here
- on_networks_query_done: function()
+ on_query_done: function()
{
- 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);
+ var scope, query_ext, resources;
+ scope = this._get_scope();
+ query_ext = manifold.query_store.find_analyzed_query_ext(this.options.query_uuid);
+ resources = query_ext.records.values();
+
+ $.each(resources, function(i, resource) {
+ if ($.inArray(resource.facility_name, scope.facility_names) == -1)
+ scope.facility_names.push(resource.facility_name);
+ if (scope.testbed_names[resource.facility_name] === undefined)
+ scope.testbed_names[resource.facility_name] = Array();
+ if ($.inArray(resource.testbed_name, scope.testbed_names[resource.facility_name]) == -1)
+ scope.testbed_names[resource.facility_name].push(resource.testbed_name);
});
-
- },*/
- /* INTERNAL FUNCTIONS */
+ scope.$apply();
+ },
- set_networks: function()
+ /*
+ on_networks_query_done: function()
{
var scope = this._get_scope();
var query_ext = manifold.query_store.find_analyzed_query_ext(this.options.query_networks_uuid);
$.each(scope.testbeds, function(i, testbed) { testbed.active = true });
scope.$apply();
},
+*/
+
+ /* INTERNAL FUNCTIONS */
_get_scope : function()
{
- return angular.element('[ng-controller=TestbedsCtrl]').scope()
+ 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 */