Commit 52ed7b34 authored by Jaden's avatar Jaden Committed by Samuel GAIST

[reports][js] fix exp table name/URL construction & use accessMap

Fixes two issues with the experiments table after merging the
several reports MR changes.
The experiments table now also uses the new accessMap scheme.
It also properly generates URLs for report experiments.

Fixes #531 and #532
parent 9f85138c
......@@ -46,8 +46,17 @@ angular.module('reportApp')
scope.getExperimentListPath = UrlService.getExperimentListPath;
scope.isViewmode = UrlService.isViewmode;
//expNames are either the full experiment names, or just the last segment
scope.expNames = ExperimentsService.experimentNames;
scope.exps = ExperimentsService.experiments;
scope.getFullExpName = (expName) => {
if(ReportService.experiments.includes(expName)){
return expName;
} else {
return ReportService.experiments.find(n => n.split('/').pop() === expName);
}
};
scope.getAccessMap = (expName) => ReportService.accessMap[scope.getFullExpName(expName)];
scope.groups = GroupsService.groups;
......@@ -62,15 +71,15 @@ angular.module('reportApp')
ExperimentsService.deleteExperiment(expName);
};
const getUnusedExperiments = (expNames, groups) => {
const usedExps = Array.from(new Set([].concat.apply([], groups.map(g => g.experiments))));
const unusedExps = expNames.filter(n => !usedExps.includes(n));
scope.unusedExps = unusedExps;
};
const getUnusedExperiments = (expNames, groups) => {
const usedExps = Array.from(new Set([].concat.apply([], groups.map(g => g.experiments))));
const unusedExps = expNames.filter(n => !usedExps.includes(n));
scope.unusedExps = unusedExps;
};
scope.$watchCollection('expNames', (names) => {getUnusedExperiments(names, scope.groups);});
scope.$watch('groups', (gs) => {getUnusedExperiments(scope.expNames, gs);}, true);
getUnusedExperiments(scope.expNames, scope.groups);
scope.$watchCollection('expNames', (names) => {getUnusedExperiments(names, scope.groups);});
scope.$watch('groups', (gs) => {getUnusedExperiments(scope.expNames, gs);}, true);
getUnusedExperiments(scope.expNames, scope.groups);
},
template: `
<div id='{{ domId }}' class='panel panel-default'>
......@@ -120,7 +129,7 @@ angular.module('reportApp')
</td>
<td ng-if='!isViewmode()'>
<span
ng-if='unusedExps.includes(expName)'
ng-if='unusedExps.includes(expName)'
style='cursor: help;'
title="Experiment needs to be added to a group">
<i class="fa fa-flag fa-lg text-warning"></i>
......@@ -131,7 +140,10 @@ angular.module('reportApp')
{{ groups[0].aliases[expName] }}
</span>
</td>
<td><a href='{{ getExpUrl(expName) }}'>{{ expName }}</a></td>
<td>
<a ng-if='getAccessMap(expName)' href='{{ getExpUrl(getFullExpName(expName)) }}'>{{ expName }}</a>
<span ng-if='!getAccessMap(expName)'>{{ expName }}</span>
</td>
<td>
<span ng-repeat='db in getExpDatabases(expName) track by db'>
<a href='{{ getDatabaseUrl(db.split("@")[0]) }}'>{{ db }}</a>
......
......@@ -35,6 +35,8 @@ angular.module('reportApp').factory('ReportService', ['GroupsService', 'plotterF
rs.number = undefined;
rs.author = undefined;
rs.name = undefined;
rs.experiments = undefined;
rs.accessMap = undefined;
rs.plotters = [];
rs.defaultPlotters = [];
......@@ -50,8 +52,8 @@ angular.module('reportApp').factory('ReportService', ['GroupsService', 'plotterF
rs.number = report.number;
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.accessMap = report.experiments.reduce((o, expName, i) => ({...o, [expName]: report.experiment_access_map[i]}), {});
rs.experiments = report.experiments;
// start up our GroupsService
GroupsService.loadGroups(report.content.groups);
......
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