Files
doneit-web/src/app/services/active-tab.service.ts
T

70 lines
1.5 KiB
TypeScript
Raw Normal View History

2023-02-08 09:53:21 +01:00
import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
2024-03-04 09:11:06 +01:00
import { HeaderSettingsService } from './header-settings.service';
2023-02-08 09:53:21 +01:00
@Injectable({
providedIn: 'root'
})
export class ActiveTabService {
pages = {
chat: false,
agenda: false,
publication: false,
home: false,
2024-03-04 09:11:06 +01:00
gabinete: false,
gabineteDetails: false
2023-02-08 09:53:21 +01:00
}
updatePublications = () => {}
2024-03-04 09:11:06 +01:00
constructor(
private router: Router,
public HeaderSettingsService: HeaderSettingsService) {
2023-02-08 09:53:21 +01:00
this.detectActiveTab()
2024-03-04 09:11:06 +01:00
2023-02-08 09:53:21 +01:00
this.router.events.subscribe((val) => {
this.detectActiveTab()
});
}
detectActiveTab() {
this.setFalseToAllPage();
const pathName = window.location.pathname
2024-03-04 09:11:06 +01:00
this.HeaderSettingsService.hideHeader = false
2023-02-08 09:53:21 +01:00
if(pathName.startsWith('/home/agenda')) {
this.pages.agenda = true
} else if (pathName.startsWith('/home/events')) {
this.pages.home = true
} else if (pathName.startsWith('/home/gabinete-digital')) {
this.pages.gabinete = true
2024-03-04 09:11:06 +01:00
if (pathName.endsWith('gabinete-digital')) {
this.pages.gabineteDetails = true
}
2023-02-08 09:53:21 +01:00
} else if (pathName.startsWith('/home/publications')) {
this.pages.publication = true
if(pathName.includes("/publications/")) {
if(this.updatePublications) {
this.updatePublications()
}
}
2023-02-08 09:53:21 +01:00
} else if (pathName.startsWith('/home/chat')) {
this.pages.chat = true
}
}
setFalseToAllPage() {
for( const page in this.pages) {
this.pages[page] = false
2024-03-04 09:11:06 +01:00
}
2023-02-08 09:53:21 +01:00
}
}