Page MenuHomec4science

content-view-tab-component.component.ts
No OneTemporary

File Metadata

Created
Sat, Apr 27, 22:46

content-view-tab-component.component.ts

import {Component, OnInit} from '@angular/core';
import {ActivatedRoute, Params, Router} from '@angular/router';
import {Subscription} from "rxjs/index";
import {NavigationEntity} from "../models/models";
import {NavigationServiceService} from "../services/navigation-service.service";
@Component({
selector: 'app-content-view-tab-component',
templateUrl: './content-view-tab-component.component.html',
styleUrls: ['./content-view-tab-component.component.scss']
})
export class ContentViewTabComponentComponent implements OnInit {
// navigation tab (manuscript, page, rhizome)
navTabLinks: any[];
// navbar on th left for navigating
navBarOpenState: boolean;
navBarOpenMode = 'push'; // side || over || push
navTreeData: Array<NavigationEntity>;
// listening to whats going on
queryParamSubscription: Subscription;
activeViewSubscription: Subscription;
navTreeSubscription: Subscription;
// only for accessing params in the template TODO: maybe not needed.
manQueryParam: string;
pageQueryParam: string;
wordQueryParam: string;
constructor(private router: Router,
private activatedRoute: ActivatedRoute,
private naviService: NavigationServiceService) {
this.navTabLinks = [
{
label: 'Manuskripte',
link: 'manuscript',
index: 0
}, {
label: 'Seitenansicht',
link: 'page',
index: 1
}, {
label: 'Rhizome-Ansicht',
link: 'rhizome',
index: 2
},
];
}
ngOnInit(): void {
// TODO: This must trigger into 1) queries, 2) infobox
this.naviService.createManuscriptNavTree();
// TODO: trigger here changes into service like selectManuscript(man)
// resetting the chosen things according to the query params of the url
this.queryParamSubscription = this.activatedRoute.queryParams.subscribe( (queryparams: Params ) => {
this.manQueryParam = queryparams['man'];
this.pageQueryParam = queryparams['page'];
this.wordQueryParam = queryparams['word'];
}
);
// subscribe to activated route/chosen tab and set the navTreeData accordingly
this.activeViewSubscription = this.activatedRoute.firstChild.url.subscribe(actualView =>
this.naviService.setActiveNavigationTree(actualView[0].path));
// always subscribe to new navigation tree. Might change due to change of activeViewSubscription
this.navTreeSubscription = this.naviService.navTreeDataChange.subscribe(tree => {
this.navTreeData = tree;
});
}
toggleDrawer() {
this.navBarOpenState = !this.navBarOpenState;
}
}

Event Timeline