Skip to content

Commit 06a0210

Browse files
committed
[DSC-648] Fix wrong import path and start to fix menu entries creation
1 parent f861287 commit 06a0210

16 files changed

Lines changed: 189 additions & 39 deletions

File tree

src/app/app.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { APP_BASE_HREF, CommonModule, DOCUMENT } from '@angular/common';
2-
import { HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';
2+
import { HTTP_INTERCEPTORS, HttpClientJsonpModule, HttpClientModule } from '@angular/common/http';
33
import { APP_INITIALIZER, NgModule } from '@angular/core';
44
import { AbstractControl } from '@angular/forms';
55
import { BrowserModule } from '@angular/platform-browser';
@@ -37,8 +37,8 @@ import { APP_CONFIG, AppConfig } from '../config/app-config.interface';
3737
import { NgxMaskModule } from 'ngx-mask';
3838
import { StoreDevModules } from '../config/store/devtools';
3939
import { RootModule } from './root.module';
40-
import { SocialComponent } from './social/social.component';
4140
import { NuMarkdownModule } from '@ng-util/markdown';
41+
import { FooterModule } from './footer/footer.module';
4242

4343
export function getConfig() {
4444
return environment;

src/app/core/audit/audit-data.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ import { dataService } from '../cache/builders/build-decorators';
1212
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
1313
import { RequestParam } from '../cache/models/request-param.model';
1414
import { ObjectCacheService } from '../cache/object-cache.service';
15-
import { CoreState } from '../core.reducers';
15+
import { CoreState } from '../core-state.model';
1616
import { EPerson } from '../eperson/models/eperson.model';
1717
import { HALEndpointService } from '../shared/hal-endpoint.service';
1818
import { DataService } from '../data/data.service';
1919
import { DefaultChangeAnalyzer } from '../data/default-change-analyzer.service';
2020
import { PaginatedList } from '../data/paginated-list.model';
2121
import { RemoteData } from '../data/remote-data';
22-
import { FindListOptions } from '../data/request.models';
22+
import { FindListOptions } from '../data/find-list-options.model';
2323
import { RequestService } from '../data/request.service';
2424
import {
2525
getFirstSucceededRemoteDataPayload,

src/app/core/audit/model/audit.model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CacheableObject } from '../../cache/object-cache.reducer';
1+
import { CacheableObject } from '../../cache/cacheable-object.model';
22
import { HALLink } from '../../shared/hal-link.model';
33
import { autoserialize, deserialize } from 'cerialize';
44
import { AUDIT } from './audit.resource-type';

src/app/core/config/config.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model';
1515
import { getFirstCompletedRemoteData } from '../shared/operators';
1616
import { map } from 'rxjs/operators';
1717
import { CoreState } from '../core-state.model';
18-
import { FindListOptions } from '../data/request.models';
18+
import { FindListOptions } from '../data/find-list-options.model';
1919
import { PaginatedList } from '../data/paginated-list.model';
2020

2121
class DataServiceImpl extends DataService<ConfigObject> {

src/app/cris-layout/cris-layout-matrix/cris-layout-box-container/boxes/metadata/rendering-types/attachment/attachment.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { BitstreamDataService } from '../../../../../../../core/data/bitstream-d
99
import { RemoteData } from '../../../../../../../core/data/remote-data';
1010
import { Bitstream } from '../../../../../../../core/shared/bitstream.model';
1111
import { createSuccessfulRemoteDataObject$ } from '../../../../../../../shared/remote-data.utils';
12-
import { FindListOptions } from '../../../../../../../core/data/request.models';
12+
import { FindListOptions } from '../../../../../../../core/data/find-list-options.model';
1313
import { FollowLinkConfig } from '../../../../../../../shared/utils/follow-link-config.model';
1414
import { PaginatedList } from '../../../../../../../core/data/paginated-list.model';
1515
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';

src/app/menu.resolver.ts

Lines changed: 160 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Injectable } from '@angular/core';
2-
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router';
3-
import { combineLatest as observableCombineLatest, combineLatest, Observable } from 'rxjs';
2+
import { ActivatedRoute, ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router';
3+
import { combineLatest as observableCombineLatest, Observable } from 'rxjs';
44
import { MenuID } from './shared/menu/menu-id.model';
55
import { MenuState } from './shared/menu/menu-state.model';
66
import { MenuItemType } from './shared/menu/menu-item-type.model';
@@ -12,7 +12,7 @@ import { RemoteData } from './core/data/remote-data';
1212
import { TextMenuItemModel } from './shared/menu/menu-item/models/text.model';
1313
import { BrowseService } from './core/browse/browse.service';
1414
import { MenuService } from './shared/menu/menu.service';
15-
import { filter, find, map, take } from 'rxjs/operators';
15+
import { filter, find, map, switchMap, take } from 'rxjs/operators';
1616
import { hasValue } from './shared/empty.util';
1717
import { FeatureID } from './core/data/feature-authorization/feature-id';
1818
import {
@@ -44,6 +44,7 @@ import {
4444
METADATA_IMPORT_SCRIPT_NAME,
4545
ScriptDataService
4646
} from './core/data/processes/script-data.service';
47+
import { environment } from '../environments/environment';
4748

4849
/**
4950
* Creates all of the app's menus
@@ -52,7 +53,11 @@ import {
5253
providedIn: 'root'
5354
})
5455
export class MenuResolver implements Resolve<boolean> {
56+
57+
private activatedRouteLastChild: ActivatedRoute;
58+
5559
constructor(
60+
protected route: ActivatedRoute,
5661
protected menuService: MenuService,
5762
protected browseService: BrowseService,
5863
protected authorizationService: AuthorizationDataService,
@@ -65,7 +70,7 @@ export class MenuResolver implements Resolve<boolean> {
6570
* Initialize all menus
6671
*/
6772
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> {
68-
return combineLatest([
73+
return observableCombineLatest([
6974
this.createPublicMenu$(),
7075
this.createAdminMenu$(),
7176
]).pipe(
@@ -89,20 +94,25 @@ export class MenuResolver implements Resolve<boolean> {
8994
* Initialize all menu sections and items for {@link MenuID.PUBLIC}
9095
*/
9196
createPublicMenu$(): Observable<boolean> {
92-
const menuList: any[] = [
93-
/* Communities & Collections tree */
94-
{
95-
id: `browse_global_communities_and_collections`,
96-
active: false,
97-
visible: true,
98-
index: 0,
99-
model: {
100-
type: MenuItemType.LINK,
101-
text: `menu.section.browse_global_communities_and_collections`,
102-
link: `/community-list`
103-
} as LinkMenuItemModel
104-
}
105-
];
97+
const menuList: any[] = [];
98+
99+
/* Communities & Collections tree */
100+
const CommunityCollectionMenuItem = {
101+
id: `browse_global_communities_and_collections`,
102+
active: false,
103+
visible: environment.layout.navbar.showCommunityCollection,
104+
index: 0,
105+
model: {
106+
type: MenuItemType.LINK,
107+
text: `menu.section.communities_and_collections`,
108+
link: `/community-list`
109+
} as LinkMenuItemModel
110+
};
111+
112+
if (environment.layout.navbar.showCommunityCollection) {
113+
menuList.push(CommunityCollectionMenuItem);
114+
}
115+
106116
// Read the different Browse-By types from config and add them to the browse menu
107117
this.browseService.getBrowseDefinitions()
108118
.pipe(getFirstCompletedRemoteData<PaginatedList<BrowseDefinition>>())
@@ -140,9 +150,79 @@ export class MenuResolver implements Resolve<boolean> {
140150
})));
141151
});
142152

153+
this.createStatisticsMenu();
143154
return this.waitForMenu$(MenuID.PUBLIC);
144155
}
145156

157+
createStatisticsMenu() {
158+
this.activatedRouteLastChild = this.getActivatedRoute(this.route);
159+
observableCombineLatest([
160+
this.getAuthorizedUsageStatistics(),
161+
this.getAuthorizedLoginStatistics(),
162+
this.getAuthorizedWorkflowStatistics()
163+
]).pipe(take(1)).subscribe(([canViewUsage, canViewLogin, canViewWorkflow]) => {
164+
const menuList = [];
165+
if (canViewUsage || canViewLogin || canViewWorkflow) {
166+
menuList.push(
167+
{
168+
id: 'statistics',
169+
active: false,
170+
visible: true,
171+
index: 1,
172+
model: {
173+
type: MenuItemType.TEXT,
174+
text: 'menu.section.statistics'
175+
} as TextMenuItemModel,
176+
}
177+
);
178+
179+
if (canViewUsage) {
180+
menuList.push({
181+
id: 'statistics_site',
182+
parentID: 'statistics',
183+
active: false,
184+
visible: true,
185+
model: {
186+
type: MenuItemType.LINK,
187+
text: 'menu.section.statistics.site',
188+
link: '/statistics'
189+
} as LinkMenuItemModel
190+
});
191+
}
192+
193+
if (canViewLogin) {
194+
menuList.push({
195+
id: 'statistics_login',
196+
parentID: 'statistics',
197+
active: false,
198+
visible: true,
199+
model: {
200+
type: MenuItemType.LINK,
201+
text: 'menu.section.statistics.login',
202+
link: '/statistics/login'
203+
} as LinkMenuItemModel
204+
});
205+
}
206+
207+
if (canViewWorkflow) {
208+
menuList.push({
209+
id: 'statistics_workflow',
210+
parentID: 'statistics',
211+
active: false,
212+
visible: true,
213+
model: {
214+
type: MenuItemType.LINK,
215+
text: 'menu.section.statistics.workflow',
216+
link: '/statistics/workflow'
217+
} as LinkMenuItemModel
218+
});
219+
}
220+
}
221+
menuList.forEach((menuSection) => this.menuService.addSection(MenuID.ADMIN, Object.assign(menuSection, {
222+
shouldPersistOnRouteChange: true
223+
})));
224+
});
225+
}
146226
/**
147227
* Initialize all menu sections and items for {@link MenuID.ADMIN}
148228
*/
@@ -161,7 +241,7 @@ export class MenuResolver implements Resolve<boolean> {
161241
* edit_community / edit_collection is only included if the current user is a Community or Collection admin
162242
*/
163243
createMainMenuSections() {
164-
combineLatest([
244+
observableCombineLatest([
165245
this.authorizationService.isAuthorized(FeatureID.IsCollectionAdmin),
166246
this.authorizationService.isAuthorized(FeatureID.IsCommunityAdmin),
167247
this.authorizationService.isAuthorized(FeatureID.AdministratorOf)
@@ -652,4 +732,65 @@ export class MenuResolver implements Resolve<boolean> {
652732
})));
653733
});
654734
}
735+
736+
/**
737+
* Get activated route of the deepest activated route
738+
*/
739+
getActivatedRoute(route) {
740+
if (route.children.length > 0) {
741+
return this.getActivatedRoute(route.firstChild);
742+
} else {
743+
return route;
744+
}
745+
}
746+
747+
/**
748+
* Checking authorization for Usage
749+
*/
750+
getAuthorizedUsageStatistics() {
751+
return this.activatedRouteLastChild.data.pipe(
752+
switchMap((data) => {
753+
return this.authorizationService.isAuthorized(FeatureID.CanViewUsageStatistics, this.getObjectUrl(data)).pipe(
754+
map((canViewUsageStatistics: boolean) => {
755+
return canViewUsageStatistics;
756+
}));
757+
})
758+
);
759+
}
760+
761+
/**
762+
* Checking authorization for Login
763+
*/
764+
getAuthorizedLoginStatistics() {
765+
return this.activatedRouteLastChild.data.pipe(
766+
switchMap((data) => {
767+
return this.authorizationService.isAuthorized(FeatureID.CanViewLoginStatistics, this.getObjectUrl(data)).pipe(
768+
map((canViewLoginStatistics: boolean) => {
769+
return canViewLoginStatistics;
770+
}));
771+
})
772+
);
773+
}
774+
775+
/**
776+
* Checking authorization for Workflow
777+
*/
778+
getAuthorizedWorkflowStatistics() {
779+
return this.activatedRouteLastChild.data.pipe(
780+
switchMap((data) => {
781+
return this.authorizationService.isAuthorized(FeatureID.CanViewWorkflowStatistics, this.getObjectUrl(data)).pipe(
782+
map((canViewWorkflowStatistics: boolean) => {
783+
return canViewWorkflowStatistics;
784+
}));
785+
})
786+
);
787+
}
788+
789+
/**
790+
* Get statistics route dso data
791+
*/
792+
getObjectUrl(data) {
793+
const object = data.site ? data.site : data.dso?.payload;
794+
return object?._links?.self?.href;
795+
}
655796
}

src/app/root.module.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ import {
4242
} from './page-internal-server-error/page-internal-server-error.component';
4343
import { ThemedPageErrorComponent } from './page-error/themed-page-error.component';
4444
import { PageErrorComponent } from './page-error/page-error.component';
45+
import {
46+
ProcessNotificationComponent
47+
} from './shared/notifications/process-notification/process-notification.component';
4548

4649
const IMPORTS = [
4750
CommonModule,
@@ -70,6 +73,7 @@ const DECLARATIONS = [
7073
ThemedPageNotFoundComponent,
7174
NotificationComponent,
7275
NotificationsBoardComponent,
76+
ProcessNotificationComponent,
7377
BreadcrumbsComponent,
7478
ThemedBreadcrumbsComponent,
7579
ForbiddenComponent,

src/app/shared/dso-selector/dso-selector/administered-collection-selector/administered-collection-selector.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { createPaginatedList } from '../../../testing/utils.test';
1111
import { VarDirective } from '../../../utils/var.directive';
1212
import { AdministeredCollectionSelectorComponent } from './administered-collection-selector.component';
1313
import { NotificationsService } from '../../../notifications/notifications.service';
14-
import { FindListOptions } from '../../../../core/data/request.models';
14+
import { FindListOptions } from '../../../../core/data/find-list-options.model';
1515

1616
describe('AdministeredCollectionSelectorComponent', () => {
1717
let component: AdministeredCollectionSelectorComponent;

src/app/shared/dso-selector/dso-selector/administered-collection-selector/administered-collection-selector.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { TranslateService } from '@ngx-translate/core';
66

77
import { CollectionDataService } from '../../../../core/data/collection-data.service';
88
import { buildPaginatedList, PaginatedList } from '../../../../core/data/paginated-list.model';
9-
import { FindListOptions } from '../../../../core/data/request.models';
9+
import { FindListOptions } from '../../../../core/data/find-list-options.model';
1010
import { DSpaceObject } from '../../../../core/shared/dspace-object.model';
1111
import { getFirstCompletedRemoteData } from '../../../../core/shared/operators';
1212
import { SearchService } from '../../../../core/shared/search/search.service';

src/app/shared/dso-selector/modal-wrappers/claim-item-selector/claim-item-selector.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe('ClaimItemSelectorComponent', () => {
1313
let fixture: ComponentFixture<ClaimItemSelectorComponent>;
1414

1515
const profileClaimService = jasmine.createSpyObj('profileClaimService', {
16-
search: of({ payload: {page: []}})
16+
searchForSuggestions: of({ payload: {page: []}})
1717
});
1818

1919
beforeEach(waitForAsync(() => {

0 commit comments

Comments
 (0)