forked from hazza/dspace-angular
101 lines
2.9 KiB
TypeScript
101 lines
2.9 KiB
TypeScript
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 { GLOBAL_CONFIG, GlobalConfig } from '../../config';
|
|
|
|
/**
|
|
* Component representing the public navbar
|
|
*/
|
|
@Component({
|
|
selector: 'ds-navbar',
|
|
styleUrls: ['navbar.component.scss'],
|
|
templateUrl: 'navbar.component.html',
|
|
animations: [slideMobileNav]
|
|
})
|
|
export class NavbarComponent extends MenuComponent implements OnInit {
|
|
/**
|
|
* The menu ID of the Navbar is PUBLIC
|
|
* @type {MenuID.PUBLIC}
|
|
*/
|
|
menuID = MenuID.PUBLIC;
|
|
|
|
constructor(@Inject(GLOBAL_CONFIG) public config: GlobalConfig,
|
|
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
|
|
},
|
|
// {
|
|
// 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: '#'
|
|
// } as LinkMenuItemModel,
|
|
// },
|
|
|
|
/* Statistics */
|
|
{
|
|
id: 'statistics',
|
|
active: false,
|
|
visible: true,
|
|
model: {
|
|
type: MenuItemType.LINK,
|
|
text: 'menu.section.statistics',
|
|
link: '#'
|
|
} as LinkMenuItemModel,
|
|
index: 2
|
|
},
|
|
];
|
|
// Read the different Browse-By types from config and add them to the browse menu
|
|
const types = this.config.browseBy.types;
|
|
types.forEach((typeConfig) => {
|
|
menuList.push({
|
|
id: `browse_global_by_${typeConfig.metadata}`,
|
|
parentID: 'browse_global',
|
|
active: false,
|
|
visible: true,
|
|
model: {
|
|
type: MenuItemType.LINK,
|
|
text: `menu.section.browse_global_by_${typeConfig.metadata}`,
|
|
link: `/browse/${typeConfig.metadata}`
|
|
} as LinkMenuItemModel
|
|
});
|
|
});
|
|
menuList.forEach((menuSection) => this.menuService.addSection(this.menuID, menuSection));
|
|
|
|
}
|
|
|
|
}
|