forked from DSpace/dspace-angular
-
Notifications
You must be signed in to change notification settings - Fork 0
/
navbar.component.ts
89 lines (83 loc) · 2.65 KB
/
navbar.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import { Component, Inject, Injector, OnInit } from '@angular/core';
import { slideMobileNav } from '../shared/animations/slide';
import { MenuComponent } from '../shared/menu/menu.component';
import { MenuService } from '../shared/menu/menu.service';
import { MenuID, MenuItemType } from '../shared/menu/initial-menus-state';
import { TextMenuItemModel } from '../shared/menu/menu-item/models/text.model';
import { LinkMenuItemModel } from '../shared/menu/menu-item/models/link.model';
import { HostWindowService } from '../shared/host-window.service';
import { environment } from '../../environments/environment';
/**
* Component representing the public navbar
*/
@Component({
selector: 'ds-navbar',
styleUrls: ['./navbar.component.scss'],
templateUrl: './navbar.component.html',
animations: [slideMobileNav]
})
export class NavbarComponent extends MenuComponent {
/**
* The menu ID of the Navbar is PUBLIC
* @type {MenuID.PUBLIC}
*/
menuID = MenuID.PUBLIC;
constructor(protected menuService: MenuService,
protected injector: Injector,
public windowService: HostWindowService
) {
super(menuService, injector);
}
ngOnInit(): void {
this.createMenu();
super.ngOnInit();
}
/**
* Initialize all menu sections and items for this menu
*/
createMenu() {
const menuList: any[] = [
/* News */
{
id: 'browse_global',
active: false,
visible: true,
model: {
type: MenuItemType.TEXT,
text: 'menu.section.browse_global'
} as TextMenuItemModel,
index: 0
},
/* Communities & Collections tree */
{
id: `browse_global_communities_and_collections`,
parentID: 'browse_global',
active: false,
visible: true,
model: {
type: MenuItemType.LINK,
text: `menu.section.browse_global_communities_and_collections`,
link: `/community-list`
} as LinkMenuItemModel
},
];
// Read the different Browse-By types from config and add them to the browse menu
const types = environment.browseBy.types;
types.forEach((typeConfig) => {
menuList.push({
id: `browse_global_by_${typeConfig.id}`,
parentID: 'browse_global',
active: false,
visible: true,
model: {
type: MenuItemType.LINK,
text: `menu.section.browse_global_by_${typeConfig.id}`,
link: `/browse/${typeConfig.id}`
} as LinkMenuItemModel
});
});
menuList.forEach((menuSection) => this.menuService.addSection(this.menuID, Object.assign(menuSection, {
shouldPersistOnRouteChange: true
})));
}
}