77 */
88
99import { Injectable } from '@angular/core' ;
10+ import { ActivatedRoute } from '@angular/router' ;
1011import {
1112 combineLatest ,
1213 map ,
1314 Observable ,
1415} from 'rxjs' ;
16+ import {
17+ switchMap ,
18+ take ,
19+ } from 'rxjs/operators' ;
1520
16- import { getDSORoute } from '../../../app-routing-paths' ;
1721import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service' ;
1822import { FeatureID } from '../../../core/data/feature-authorization/feature-id' ;
1923import { DSpaceObject } from '../../../core/shared/dspace-object.model' ;
20- import { hasValue } from '../../empty.util' ;
2124import { MenuItemType } from '../menu-item-type.model' ;
2225import { PartialMenuSection } from '../menu-provider.model' ;
2326import { DSpaceObjectPageMenuProvider } from './helper-providers/dso.menu' ;
24- import { switchMap , take } from 'rxjs/operators' ;
25- import { ActivatedRoute } from '@angular/router' ;
2627
2728/**
2829 * Menu provider to create the "Statistics" menu section in the public navbar. The menu depends on the page it is on.
@@ -35,7 +36,7 @@ export class StatisticsMenuProvider extends DSpaceObjectPageMenuProvider {
3536
3637 constructor (
3738 protected authorizationService : AuthorizationDataService ,
38- protected route : ActivatedRoute
39+ protected route : ActivatedRoute ,
3940 ) {
4041 super ( ) ;
4142 }
@@ -109,67 +110,67 @@ export class StatisticsMenuProvider extends DSpaceObjectPageMenuProvider {
109110 canViewWorkflow : this . getAuthorizedWorkflowStatistics ( ) ,
110111 } ) . pipe (
111112 take ( 1 ) ,
112- map ( ( { canViewUsage, canViewLogin, canViewWorkflow} ) => {
113- const menuList = [ ] ;
114- if ( canViewUsage || canViewLogin || canViewWorkflow ) {
115- if ( canViewUsage ) {
116- menuList . push ( {
117- id : 'statistics_site' ,
118- parentID : 'statistics' ,
119- active : false ,
120- visible : true ,
121- model : {
122- type : MenuItemType . LINK ,
123- text : 'menu.section.statistics.site' ,
124- link : '/statistics' ,
125- } ,
126- } ) ;
127- }
113+ map ( ( { canViewUsage, canViewLogin, canViewWorkflow } ) => {
114+ const menuList = [ ] ;
115+ if ( canViewUsage || canViewLogin || canViewWorkflow ) {
116+ if ( canViewUsage ) {
117+ menuList . push ( {
118+ id : 'statistics_site' ,
119+ parentID : 'statistics' ,
120+ active : false ,
121+ visible : true ,
122+ model : {
123+ type : MenuItemType . LINK ,
124+ text : 'menu.section.statistics.site' ,
125+ link : '/statistics' ,
126+ } ,
127+ } ) ;
128+ }
128129
129- if ( canViewLogin ) {
130- menuList . push ( {
131- id : 'statistics_login' ,
132- parentID : 'statistics' ,
133- active : false ,
134- visible : true ,
135- model : {
136- type : MenuItemType . LINK ,
137- text : 'menu.section.statistics.login' ,
138- link : '/statistics/login' ,
139- } ,
140- } ) ;
141- }
130+ if ( canViewLogin ) {
131+ menuList . push ( {
132+ id : 'statistics_login' ,
133+ parentID : 'statistics' ,
134+ active : false ,
135+ visible : true ,
136+ model : {
137+ type : MenuItemType . LINK ,
138+ text : 'menu.section.statistics.login' ,
139+ link : '/statistics/login' ,
140+ } ,
141+ } ) ;
142+ }
142143
143- if ( canViewWorkflow ) {
144- menuList . push ( {
145- id : 'statistics_workflow' ,
146- parentID : 'statistics' ,
147- active : false ,
148- visible : true ,
149- model : {
150- type : MenuItemType . LINK ,
151- text : 'menu.section.statistics.workflow' ,
152- link : '/statistics/workflow' ,
153- } ,
154- } ) ;
155- }
144+ if ( canViewWorkflow ) {
145+ menuList . push ( {
146+ id : 'statistics_workflow' ,
147+ parentID : 'statistics' ,
148+ active : false ,
149+ visible : true ,
150+ model : {
151+ type : MenuItemType . LINK ,
152+ text : 'menu.section.statistics.workflow' ,
153+ link : '/statistics/workflow' ,
154+ } ,
155+ } ) ;
156+ }
156157
157- // the parent menu should be added after the children
158- menuList . push (
159- {
160- id : 'statistics' ,
161- active : false ,
162- visible : true ,
163- index : 1 ,
164- model : {
165- type : MenuItemType . TEXT ,
166- text : 'menu.section.statistics' ,
158+ // the parent menu should be added after the children
159+ menuList . push (
160+ {
161+ id : 'statistics' ,
162+ active : false ,
163+ visible : true ,
164+ index : 1 ,
165+ model : {
166+ type : MenuItemType . TEXT ,
167+ text : 'menu.section.statistics' ,
168+ } ,
167169 } ,
168- } ,
169- ) ;
170- }
171- return menuList ;
172- } ) ) ;
170+ ) ;
171+ }
172+ return menuList ;
173+ } ) ) ;
173174 }
174175
175176 protected isApplicable ( dso : DSpaceObject ) : boolean {
0 commit comments