From 7652db7063d035465e8253a47c575d53efd3d144 Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Wed, 8 Feb 2023 09:53:21 +0100 Subject: [PATCH] activation improve --- src/app/home/home.page.html | 20 ++++----- src/app/home/home.page.ts | 6 +-- src/app/services/active-tab.service.spec.ts | 16 +++++++ src/app/services/active-tab.service.ts | 49 +++++++++++++++++++++ src/environments/environment.ts | 2 +- version/git-version.ts | 12 ++--- 6 files changed, 84 insertions(+), 21 deletions(-) create mode 100644 src/app/services/active-tab.service.spec.ts create mode 100644 src/app/services/active-tab.service.ts diff --git a/src/app/home/home.page.html b/src/app/home/home.page.html index f4287e966..8cb8dafb9 100644 --- a/src/app/home/home.page.html +++ b/src/app/home/home.page.html @@ -5,34 +5,34 @@ - - + + Início - - + + Agenda - - + + Gabinete - - + + Acções - - + + Chat diff --git a/src/app/home/home.page.ts b/src/app/home/home.page.ts index f87616714..7ab9447a9 100644 --- a/src/app/home/home.page.ts +++ b/src/app/home/home.page.ts @@ -14,6 +14,7 @@ import { EventsService } from 'src/app/services/events.service'; import { RochetChatConnectorService } from 'src/app/services/chat/rochet-chat-connector.service'; import { ProcessesService } from 'src/app/services/processes.service'; import { SqliteService } from 'src/app/services/sqlite.service'; +import { ActiveTabService } from 'src/app/services/active-tab.service'; import { Device } from '@capacitor/device'; import { RouteService } from 'src/app/services/route.service'; import { NetworkServiceService, ConnectionStatus } from 'src/app/services/network-service.service'; @@ -89,6 +90,7 @@ export class HomePage implements OnInit { private RochetChatConnectorService: RochetChatConnectorService, private NetworkServiceService: NetworkServiceService, public eventService: EventsService, + public ActiveTabService: ActiveTabService ) { if (SessionStore.exist) { this.user = SessionStore.user; @@ -223,10 +225,6 @@ export class HomePage implements OnInit { const info = await Device.getInfo(); } - get pathname() { - return window.location.pathname - } - updateList() { document.addEventListener('pause', function () { diff --git a/src/app/services/active-tab.service.spec.ts b/src/app/services/active-tab.service.spec.ts new file mode 100644 index 000000000..8815e356e --- /dev/null +++ b/src/app/services/active-tab.service.spec.ts @@ -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(); + }); +}); diff --git a/src/app/services/active-tab.service.ts b/src/app/services/active-tab.service.ts new file mode 100644 index 000000000..bba6b7c8e --- /dev/null +++ b/src/app/services/active-tab.service.ts @@ -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 + } + } +} diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 10909d23b..aaefbfe6d 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -3,4 +3,4 @@ import { oaprDev } from './suport/oapr' import { doneITDev } from './suport/doneIt' -export const environment: Environment = oaprDev; \ No newline at end of file +export const environment: Environment = doneITDev; \ No newline at end of file diff --git a/version/git-version.ts b/version/git-version.ts index b93aaf074..033d12aee 100644 --- a/version/git-version.ts +++ b/version/git-version.ts @@ -1,12 +1,12 @@ export let versionData = { - "shortSHA": "976f9cbf2", - "SHA": "976f9cbf2c3bd09c8ab08beb9f4d5044a3709a81", + "shortSHA": "468237128", + "SHA": "46823712867f8a5685047185c2104dd362a038cf", "branch": "no_bug_movemente", "lastCommitAuthor": "'Peter Maquiran'", - "lastCommitTime": "'Tue Feb 7 16:10:11 2023 +0100'", - "lastCommitMessage": "Fix", - "lastCommitNumber": "4749", + "lastCommitTime": "'Tue Feb 7 17:24:26 2023 +0100'", + "lastCommitMessage": "fix", + "lastCommitNumber": "4752", "change": "", - "changeStatus": "On branch no_bug_movemente\nAll conflicts fixed but you are still merging.\n (use \"git commit\" to conclude merge)\n\nChanges to be committed:\n\tmodified: src/environments/environment.ts\n\tmodified: version/git-version.ts", + "changeStatus": "On branch no_bug_movemente\nChanges to be committed:\n (use \"git restore --staged ...\" to unstage)\n\tmodified: src/app/home/home.page.html\n\tmodified: src/app/home/home.page.ts\n\tnew file: src/app/services/active-tab.service.spec.ts\n\tnew file: src/app/services/active-tab.service.ts\n\tmodified: src/environments/environment.ts", "changeAuthor": "peter.maquiran" } \ No newline at end of file