diff --git a/beat/web/reports/static/reports/app/directives/tableItem.js b/beat/web/reports/static/reports/app/directives/tableItem.js index 3105eb9e0ac3ab06ae4373a482b63b3fa66f3718..20ccdc16ae71fe075b8d2c0010881e35c7b6dfd6 100644 --- a/beat/web/reports/static/reports/app/directives/tableItem.js +++ b/beat/web/reports/static/reports/app/directives/tableItem.js @@ -26,7 +26,7 @@ * displays a table report item */ angular.module('reportApp') -.directive("tableItem", ['GroupsService', 'ExperimentsService', function(GroupsService, ExperimentsService){ +.directive("tableItem", ['GroupsService', 'ExperimentsService', 'UrlService', function(GroupsService, ExperimentsService, UrlService){ return { scope: { group: '=', @@ -139,6 +139,22 @@ angular.module('reportApp') return str; }; + + // get experiment url for linking to exps + // returns the url if successful else false + scope.getExperimentUrl = (expName) => { + // if theres more than 2 '/' in the expName, + // its the absolute URL, and the user has access + // to view the experiment. + if(expName.split('/').length > 3){ + return UrlService.getExperimentUrl(expName); + } + + // else, its the short name + // (just the exp name, not including author/toolchain) + // and the user cant see the exp + return false; + }; }, template: ` <div ng-if='isViewingCsv.val'> @@ -167,7 +183,12 @@ angular.module('reportApp') <tbody> <tr ng-repeat="exp in group.experiments | orderBy:sortFunc:sortField.isReversed"> <td ng-repeat='field in fields'> - {{ getFieldVal(exp, field) }} + <a ng-if='$index == 0 && getExperimentUrl(exp)' href='{{ getExperimentUrl(exp) }}'> + {{ getFieldVal(exp, field) }} + </a> + <span ng-if='!$index == 0 || !getExperimentUrl(exp)'> + {{ getFieldVal(exp, field) }} + </span> </td> </tr> </tbody>