diff --git a/beat/web/reports/serializers.py b/beat/web/reports/serializers.py index 158db1c814a3dd26cbf96c0a891588660c9a6704..583667fcfdd6f0b476744aa615bc11fd42b197e9 100644 --- a/beat/web/reports/serializers.py +++ b/beat/web/reports/serializers.py @@ -51,6 +51,7 @@ class BasicReportSerializer(serializers.ModelSerializer): author = serializers.SerializerMethodField() experiments = serializers.SerializerMethodField() experiment_access_map = serializers.SerializerMethodField() + analyzers_access_map = serializers.SerializerMethodField() analyzer = serializers.SerializerMethodField() html_description = serializers.SerializerMethodField() add_url = serializers.SerializerMethodField() @@ -93,6 +94,16 @@ class BasicReportSerializer(serializers.ModelSerializer): obj.experiments.iterator())) return access_map + def get_analyzers_access_map(self, obj): + user = self.context['request'].user + access_map = list() + for exp in obj.experiments.iterator(): + # find analyzer + analyzers = exp.blocks.filter(analyzer=True) + if len(analyzers) > 0: + access_map.append(analyzers[0].algorithm.accessibility_for(user)[0]) + return access_map + def get_analyzer(self, obj): if obj.analyzer is not None: return obj.analyzer.fullname() @@ -125,7 +136,7 @@ class FullReportSerializer(BasicReportSerializer): class Meta(BasicReportSerializer.Meta): - fields = ['name', 'number', 'short_description', 'description', 'is_owner', 'author','status', 'creation_date', 'publication_date', 'experiments', 'analyzer', 'content', 'html_description', 'experiment_access_map'] + fields = ['name', 'number', 'short_description', 'description', 'is_owner', 'author','status', 'creation_date', 'publication_date', 'experiments', 'analyzer', 'content', 'html_description', 'experiment_access_map', 'analyzers_access_map'] #---------------------------------------------------------- diff --git a/beat/web/reports/static/reports/app/directives/experimentsTable.js b/beat/web/reports/static/reports/app/directives/experimentsTable.js index f9b14bdf468888c32849f2e04d797246ddfb21cb..ac13f826f3856c8c2dbfb01fced9b71dd594fceb 100644 --- a/beat/web/reports/static/reports/app/directives/experimentsTable.js +++ b/beat/web/reports/static/reports/app/directives/experimentsTable.js @@ -40,6 +40,10 @@ angular.module('reportApp') scope.ReportService = ReportService; scope.domId = `experiments-table`; scope.getAnalyzerFromExpName = ExperimentsService.getAnalyzerFromExpName; + scope.getAnalyzerShortName = (expName) => { + const name = scope.getAnalyzerFromExpName(expName); + return name.split('/').slice(1).join('/'); + }; scope.getExpUrl = UrlService.getExperimentUrl; scope.getBlockUrl = UrlService.getBlockUrl; scope.getDatabaseUrl = UrlService.getDatabaseUrl; @@ -57,6 +61,7 @@ angular.module('reportApp') } }; scope.getAccessMap = (expName) => ReportService.accessMap[scope.getFullExpName(expName)]; + scope.getAnalyzerAccessMap = (expName) => ReportService.analyzerAccessMap[scope.getFullExpName(expName)]; scope.groups = GroupsService.groups; @@ -150,7 +155,10 @@ angular.module('reportApp') </span> </td> - <td>{{ getAnalyzerFromExpName(expName) }}</td> + <td> + <a ng-if='getAnalyzerAccessMap(expName)' href='{{ getBlockUrl(getAnalyzerFromExpName(expName)) }}'>{{ getAnalyzerFromExpName(expName) }}</a> + <span ng-if='!getAnalyzerAccessMap(expName)'>{{ getAnalyzerShortName(expName) }}</a> + </td> </tr> </tbody> </table> diff --git a/beat/web/reports/static/reports/app/directives/panelExperiments.js b/beat/web/reports/static/reports/app/directives/panelExperiments.js index 882c2d236fad589b92edc8ce791a0f77d106e52e..a7dbc91596b3ad56d28fed20b10291d07bdf1a96 100644 --- a/beat/web/reports/static/reports/app/directives/panelExperiments.js +++ b/beat/web/reports/static/reports/app/directives/panelExperiments.js @@ -36,6 +36,10 @@ angular.module('reportApp').directive("groupPanelExperiments", ['GroupsService', scope.experiments = ExperimentsService.experiments; scope.dropdownId = `${scope.group.name}_exp_add_dropdown`; scope.accessMap = ReportService.accessMap; + scope.getAnalyzerShortName = () => { + return scope.group.analyzer.split('/').slice(1).join('/'); + }; + scope.analyzerIsAccessible = () => ReportService.analyzerAccessMap[scope.group.experiments[0]]; scope.getExpName = (expName) => scope.experiments[expName] ? expName : expName.split('/').pop(); const getExp = (expName) => scope.experiments[expName] || scope.experiments[expName.split('/').pop()]; @@ -105,7 +109,9 @@ angular.module('reportApp').directive("groupPanelExperiments", ['GroupsService', </div> </div> <i style='margin-left: 5px;' ng-if='group.analyzer.length > 0'> - Analyzer: <a href='{{ getBlockUrl(group.analyzer) }}'>{{ group.analyzer }}</a> + Analyzer: + <a ng-if='analyzerIsAccessible()' href='{{ getBlockUrl(group.analyzer) }}'>{{ group.analyzer }}</a> + <span ng-if='!analyzerIsAccessible()'>{{ getAnalyzerShortName() }}</a> </i> </h4> </div> diff --git a/beat/web/reports/static/reports/app/services/reportService.js b/beat/web/reports/static/reports/app/services/reportService.js index 54f721665431ffaff02c66d433f944835d489ad5..043498b362ad7256ad1b2e9cd4d799b4aaa4bb58 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', ['GroupsService', 'plotterF rs.name = undefined; rs.experiments = undefined; rs.accessMap = undefined; + rs.analyzerAccessMap = undefined; rs.plotters = []; rs.defaultPlotters = []; @@ -53,6 +54,7 @@ angular.module('reportApp').factory('ReportService', ['GroupsService', 'plotterF rs.author = report.author; rs.name = report.name.split('/').length > 1 ? report.name.split('/')[1] : null; rs.accessMap = report.experiments.reduce((o, expName, i) => ({...o, [expName]: report.experiment_access_map[i]}), {}); + rs.analyzerAccessMap = report.experiments.reduce((o, expName, i) => ({...o, [expName]: report.analyzers_access_map[i]}), {}); rs.experiments = report.experiments; // start up our GroupsService