mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 13:02:56 +00:00
activation improve
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ActiveTabService } from './active-tab.service';
|
||||
|
||||
describe('ActiveTabService', () => {
|
||||
let service: ActiveTabService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(ActiveTabService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,49 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ActiveTabService {
|
||||
|
||||
pages = {
|
||||
chat: false,
|
||||
agenda: false,
|
||||
publication: false,
|
||||
home: false,
|
||||
gabinete: false
|
||||
}
|
||||
|
||||
constructor(private router: Router) {
|
||||
|
||||
this.detectActiveTab()
|
||||
|
||||
this.router.events.subscribe((val) => {
|
||||
this.detectActiveTab()
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
detectActiveTab() {
|
||||
this.setFalseToAllPage();
|
||||
const pathName = window.location.pathname
|
||||
|
||||
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
|
||||
} else if (pathName.startsWith('/home/publications')) {
|
||||
this.pages.publication = true
|
||||
} else if (pathName.startsWith('/home/chat')) {
|
||||
this.pages.chat = true
|
||||
}
|
||||
}
|
||||
|
||||
setFalseToAllPage() {
|
||||
for( const page in this.pages) {
|
||||
this.pages[page] = false
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user