Commit 808b1a79 authored by Jaden's avatar Jaden Committed by Samuel GAIST

updated to fix to take into account analyzers

parent 52ed7b34
......@@ -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']
#----------------------------------------------------------
......
......@@ -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>
......
......@@ -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>
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment