diff --git a/beat/web/reports/static/reports/app/controllers/groupsController.js b/beat/web/reports/static/reports/app/controllers/groupsController.js index ba4fa7ffd8da665ffbd1558ee34428cee58135d9..47eaa42f2b948846da26a3206528a63f147ba1d3 100644 --- a/beat/web/reports/static/reports/app/controllers/groupsController.js +++ b/beat/web/reports/static/reports/app/controllers/groupsController.js @@ -27,10 +27,22 @@ angular.module('reportApp').controller('GroupsController', ['$scope', 'ReportSer vm.test = 'test'; vm.report = $scope.report; + const getAnalyzerFromExpName = (expName) => { + let analyzer_block = vm.report.all_experiments[expName].declaration.analyzers.analysis + || vm.report.all_experiments[expName].declaration.analyzers.analyzer_private; + + return analyzer_block.algorithm; + }; + // ReportService stuff to be used directly in ui vm.groups = ReportService.groups; vm.removeExperimentFromGroup = ReportService.removeExperimentFromGroup; - vm.addExperimentToGroup = ReportService.addExperimentToGroup; + vm.addExperimentToGroup = (expName, groupName) => { + let analyzer = getAnalyzerFromExpName(expName); + ReportService.addExperimentToGroup(expName, groupName); + ReportService.groups.find(g => g.name === groupName).analyzer = analyzer; + }; + vm.createGroup = function(name) { ReportService.createGroup(name); vm.newGroupName = ''; @@ -41,6 +53,16 @@ angular.module('reportApp').controller('GroupsController', ['$scope', 'ReportSer vm.newGroupName = ''; // report's experiments vm.experiments = $scope.report_experiments; + // same analyzer + vm.compatibleExperiments = (analyzer) => { + if(!vm.report.all_experiments){ + return {}; + } + + return Object.entries(vm.report.all_experiments) + .filter(([eName, e]) => analyzer === '' || getAnalyzerFromExpName(eName) === analyzer) + .reduce((o, [eName, e]) => Object.assign(o, { [eName]: e }), {}); + }; // a group panel's classes // one panel is the active group ('panel-success') diff --git a/beat/web/reports/static/reports/app/services/reportService.js b/beat/web/reports/static/reports/app/services/reportService.js index a1ea27a55d8924820216e6ddd267c4f102b66d9a..668c2a4d20bdce70868b80ba9bba111e318b77d4 100644 --- a/beat/web/reports/static/reports/app/services/reportService.js +++ b/beat/web/reports/static/reports/app/services/reportService.js @@ -37,6 +37,7 @@ angular.module('reportApp').factory('ReportService', ['$http', function($http){ class Group { constructor (name) { this._name = name; + this._analyzer = ''; this._experimentNames = new Set(); this._reportItemIds = new Set(); } @@ -56,6 +57,16 @@ angular.module('reportApp').factory('ReportService', ['$http', function($http){ return this._name; } + // get the analyzer of the experiments in this group + get analyzer () { + return this._analyzer; + } + + set analyzer (analyzer) { + console.log(`setting anayzler = ${analyzer}`); + this._analyzer = analyzer; + } + // add an exp to this group addExperiment (expName) { return this._experimentNames.add(expName); @@ -84,7 +95,7 @@ angular.module('reportApp').factory('ReportService', ['$http', function($http){ // serializes groups as an object with form: // { - // <group name 1>: <array of exp names for group 1>, + // <group name 1>: { experiments: [], reportItemIds: [], analyzer: '' }, // ... // } reportServiceInstance.serializeGroups = () => { @@ -92,7 +103,8 @@ angular.module('reportApp').factory('ReportService', ['$http', function($http){ .map(g => { return { [g.name]: { experiments: g.experiments, - reportItemIds: g.reportItemIds + reportItemIds: g.reportItemIds, + analyzer: g.analyzer } }; }) @@ -129,20 +141,27 @@ angular.module('reportApp').factory('ReportService', ['$http', function($http){ // load group info from the serialized format: // { - // <group name 1>: <array of exp names for group 1>, + // <group name 1>: { experiments: [], reportItemIds: [], analyzer: '' }, // ... // } reportServiceInstance.loadGroups = (data) => { - if(!data){ - return; - } // wipe data and load groups groupData.splice(0, groupData.length); + + // if there's no group data, create a default one + if(!data || Object.keys(data).length === 0){ + reportServiceInstance.createGroup('default'); + return; + } + Object.entries(data) - .forEach(([groupName, groupData]) => { + // sometimes we get an empty string for name for some reason + .filter(([groupName, gData]) => groupName.length > 0) + .forEach(([groupName, gData]) => { let g = reportServiceInstance.createGroup(groupName); - groupData.experiments.forEach(n => g.addExperiment(n)); - groupData.reportItemIds.forEach(id => g.addReportItem(id)); + g.analyzer = gData.analyzer; + gData.experiments.forEach(n => g.addExperiment(n)); + gData.reportItemIds.forEach(id => g.addReportItem(id)); }); }; @@ -152,11 +171,11 @@ angular.module('reportApp').factory('ReportService', ['$http', function($http){ }; // add experiment to group - reportServiceInstance.addExperimentToGroup = (expName, groupName) => { + reportServiceInstance.addExperimentToGroup = (expName, groupName, analyzer) => { checkForGroup(groupName); let group = groupData.find(g => g.name === groupName); - return group.addExperiment(expName); + return group.addExperiment(expName, analyzer); }; // rm experiment from group diff --git a/beat/web/reports/templates/reports/panels/viewer.html b/beat/web/reports/templates/reports/panels/viewer.html index a3a4326fd6528d38039c4d193a9bfbc204fbe34f..f5725d2cdd6371246ec65a523d284ad344d989d8 100644 --- a/beat/web/reports/templates/reports/panels/viewer.html +++ b/beat/web/reports/templates/reports/panels/viewer.html @@ -102,11 +102,12 @@ <span class="caret"></span> </button> <ul class="dropdown-menu" aria-labelledby="dropdownMenu1"> - <li ng-click='groups.addExperimentToGroup(expName, group.name)' ng-repeat='(expName, exp) in groups.experiments'> + <li ng-click='groups.addExperimentToGroup(expName, group.name)' ng-repeat='(expName, exp) in groups.compatibleExperiments(group.analyzer)'> <a href='#'>{$ expName $}</a> </li> </ul> </div> + <p>Group Analyzer: {$ group.analyzer $}</p> <p>Saved Report Items Associated to Group</p> <ul class='list-group' style='margin-top: 1em'> <li class='list-group-item' ng-repeat='id in group.reportItemIds'>