remove unnecessary code

This commit is contained in:
Peter Maquiran
2024-10-18 12:12:55 +01:00
parent 8484b1b600
commit 3f41e9e9c0
102 changed files with 102 additions and 196 deletions
@@ -0,0 +1,17 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { HeaderPrPage } from './header-pr.page';
const routes: Routes = [
{
path: '',
component: HeaderPrPage
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class HeaderPrPageRoutingModule {}
@@ -0,0 +1,20 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { IonicModule } from '@ionic/angular';
import { HeaderPrPageRoutingModule } from './header-pr-routing.module';
import { HeaderPrPage } from './header-pr.page';
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
HeaderPrPageRoutingModule
],
declarations: [HeaderPrPage]
})
export class HeaderPrPageModule {}
@@ -0,0 +1,17 @@
<ion-toolbar>
<div class="div-top-header">
<div class="div-search">
<ion-icon src='assets/images/icons-search.svg'></ion-icon>
</div>
<div class="div-logo">
<img src='assets/images/logo-no-bg.png' alt='logo'>
</div>
<div class="div-profile">
<ion-icon src='assets/images/icons-profile-pr.svg'></ion-icon>
<ion-icon class="font-45-rem" *ngIf="loggeduser.Profile == 'MDGPR'" src='assets/images/icons-profile.svg'></ion-icon>
<ion-icon class="font-45-rem" *ngIf="loggeduser.Profile == 'PR' " src='assets/images/icons-profile-pr-header.svg'></ion-icon>
</div>
</div>
</ion-toolbar>
@@ -0,0 +1,49 @@
@import '~src/function.scss';
.div-top-header{
margin: 0 em(20);
background-color: #0782c9;
padding-top: em(15);
border: 0!important;
}
.div-logo{
background: transparent;
width: em(140);
justify-content: center;
display: flex;
}
.div-logo img{
width: 100%;
margin: 0px auto;
}
.div-profile{
font-size: rem(45);
justify-content: flex-end;
display: flex;
}
.desktop{
display: none;
}
@media only screen and (min-width: 1366px) {
.mobile{
display: none !important;
}
.desktop{
display: block;
}
}
.tab{
height: 65px;
cursor: pointer;
user-select: none;
}
.active{
border-top: 7px solid white;
}
@@ -0,0 +1,24 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { IonicModule } from '@ionic/angular';
import { HeaderPrPage } from './header-pr.page';
describe('HeaderPrPage', () => {
let component: HeaderPrPage;
let fixture: ComponentFixture<HeaderPrPage>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ HeaderPrPage ],
imports: [IonicModule.forRoot()]
}).compileComponents();
fixture = TestBed.createComponent(HeaderPrPage);
component = fixture.componentInstance;
fixture.detectChanges();
}));
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,27 @@
import { Component, OnInit } from '@angular/core';
import { LoginUserRespose } from 'src/app/models/user.model';
import { AuthService } from 'src/app/services/auth.service';
import { SessionStore } from 'src/app/store/session.service';
@Component({
selector: 'app-header-pr',
templateUrl: './header-pr.page.html',
styleUrls: ['./header-pr.page.scss'],
})
export class HeaderPrPage implements OnInit {
loggeduser: LoginUserRespose;
constructor(authService: AuthService) {
this.loggeduser = SessionStore.user;
}
ngOnInit() {
}
locationPathname(): string {
return window.location.pathname
}
}
@@ -0,0 +1,17 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { HeaderPage } from './header.page';
const routes: Routes = [
{
path: '',
component: HeaderPage
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class HeaderPageRoutingModule {}
@@ -0,0 +1,21 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { IonicModule } from '@ionic/angular';
import { HeaderPageRoutingModule } from './header-routing.module';
import { HeaderPage } from './header.page';
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
HeaderPageRoutingModule
],
declarations: [HeaderPage],
exports: [HeaderPage]
})
export class HeaderPageModule {}
@@ -0,0 +1,260 @@
<div class="header-container header-fix" [ngClass]="{'d-none-header':HeaderSettingsService.hideHeader && ActiveTabService.pages.gabineteDetails}" >
<div class="main-tab pb-10 ion-toolbar header-color">
<div class="mobile pt-20 d-flex div-top-header justify-space-between">
<div title="Pesquisa" *ngIf="!hideSearchBtn" class="div-search viewport-font-size">
<div (click)="openSearch()" class="{{Cy.header.b.search}}">
<ion-icon *ngIf="ThemeService.currentTheme == 'doneIt' " class="font-45-em"
src="assets/images/theme/doneIt/icons-search.svg"></ion-icon>
<ion-icon *ngIf=" ThemeService.currentTheme == 'default' " class="font-45-em"
src='assets/images/icons-search.svg'></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="font-45-em"
src='assets/images/theme/gov/icons-search.svg'></ion-icon>
</div>
</div>
<div class="div-logo align-center justify-center">
<div class="logo-icon pr-10-rem">
<img *ngIf="ThemeService.currentTheme == 'default' " src='assets/images/logo-no-bg.png' alt='logo'>
<img *ngIf="ThemeService.currentTheme == 'gov' " src='assets/images/theme/gov/governoangola_A.png' alt='logo'>
<img *ngIf="ThemeService.currentTheme == 'doneIt'" src="assets/images/theme/doneIt/governoangola_A1.png"
alt='logo' />
</div>
<div *ngIf="ThemeService.currentTheme == 'gov'"
class="logo-description d-flex align-center justify-content-center">
<div class="logo-description-content">
<p class="logo-description-text tp-5">{{ environment.logoLabel }}</p>
<div class="add-line"></div>
<p class="logo-description-text tp-5">GABINETE DIGITAL</p>
</div>
</div>
<div *ngIf="ThemeService.currentTheme == 'default' "
class="logo-description d-flex align-center justify-content-center">
<div class="logo-description-content">
<p class="logo-description-text tp-5 color-white">{{ environment.logoLabel }}</p>
<div class="add-line-white"></div>
<p class="logo-description-text tp-5 color-white">GABINETE DIGITAL</p>
</div>
</div>
</div>
<div title="Perfil" class="div-profile cursor-pointer viewport-font-size " >
<div *ngIf="PublicationHolderService.count != 0" style="color: black" style="display: flex;
color: black;
justify-content: center;
align-items: center;
" >
<span *ngIf="!PublicationHolderService.PublicationFormMV?.[0]?.retry">{{ PublicationHolderService.count }}%</span>
<span style="padding-right: 12px" *ngIf="PublicationHolderService.PublicationFormMV?.[0]?.retry" (click)="PublicationHolderService.PublicationFormMV?.[0]?.retryFunction()" ><ion-icon src="assets/images/retry-svgrepo-com.svg" > </ion-icon></span>
<span style="padding-right: 7px" *ngIf="PublicationHolderService.PublicationFormMV?.[0]?.retry" (click)="PublicationHolderService.remove(PublicationHolderService.PublicationFormMV?.[0]?.id)">X</span>
</div>
<!-- <div *ngIf="this.NotificationHolderService.notificationList.length > 0" class="icon-badge">{{NotificationHolderService.notificationList.length}}</div> -->
<!-- <ion-icon *ngIf="ThemeService.currentTheme == 'doneIt' " class="icon font-45-em" src='assets/images/theme/doneIt/icons-profile.svg'></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="icon font-45-em" src='assets/images/icons-profile.svg'></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="icon font-45-em" src='assets/images/theme/gov/icons-profile.svg'></ion-icon> -->
<div (click)="openProfile()" *ngIf="profilePictureSubject == undefined " class="profile-image" >
<!-- <img *ngIf="loggeduser.RoleDescription == 'Presidente da República' " class="profile-image"
src='assets/images/presidente.png'>
<img *ngIf="loggeduser.RoleDescription == 'Ministro e Director do Gabinete do PR' " class="profile-image"
src='assets/images/ministro.png'>
<img *ngIf="loggeduser.RoleDescription == 'Secretário Geral' " class="profile-image"
src='assets/images/secretaria_geral.png'> -->
<ion-icon
class="icon font-45-em" src='assets/images/theme/gov/icons-profile.svg'></ion-icon>
</div>
<div (click)="openProfile()" *ngIf="(profilePictureSubject | async) as calendarData" class="profile-image">
<img class="profile-image image-prety" src={{calendarData.base64}}>
</div>
<div class="profile-text" *ngIf="(notificationCount$ | async) as notificationCount ">
<div *ngIf="notificationCount > 0" class="icon-badge" style="right: -6px;top: 38px;top: -6px;">
{{notificationCount}} </div>
</div>
</div>
</div>
<div class="desktop mx-20">
<div class="d-flex justify-space-between align-center">
<div tab="events" class="div-logo height-fit-content">
<div class="logo-icon pr-10-rem">
<img *ngIf="ThemeService.currentTheme == 'default'" src='assets/images/logo-no-bg.png' alt='logo'>
<img *ngIf="ThemeService.currentTheme == 'gov' " src='assets/images/theme/gov/governoangola_A.png'
alt='logo'>
<img *ngIf="ThemeService.currentTheme == 'doneIt' "
src='assets/images/theme/{{ThemeService.currentTheme}}/governoangola_A1.png' alt='logo'>
</div>
<div class="logo-description d-flex align-center justify-content-center">
<div class="logo-description-content">
<div *ngIf="ThemeService.currentTheme == 'gov' " class="logo-description-content">
<p class="logo-description-text">{{ environment.logoLabel }}</p>
<div class="add-line"></div>
<p class="logo-description-text">GABINETE DIGITAL</p>
</div>
<div *ngIf="ThemeService.currentTheme == 'default' " class="logo-description-content">
<p class="logo-description-text" style="color: white;">GABINETE DIGITAL</p>
<div class="add-line" style="border-bottom: 1px solid white;"></div>
</div>
</div>
</div>
</div>
<div class="d-flex flex-1 pr-20 pl-50"
*ngIf="p.userPermissionCount([permissionList.Agenda.access, permissionList.Gabinete.access, permissionList.Actions.access, permissionList.Chat.access]) >= 2 || (p.userPermission([permissionList.Agenda.access]) && loggeduser.OwnerCalendars.length != 0) || p.userPermission([permissionList.Gabinete.access])">
<div
*ngIf="p.userPermission([permissionList.Agenda.access]) || p.userPermission([permissionList.Gabinete.access])"
class="tab mr-20 d-flex align-center cursor-pointer" (click)="changeRoute('/home/events')"
[class.active]="ActiveTabService.pages.home">
<ion-icon *ngIf="ThemeService.currentTheme == 'default' || ThemeService.currentTheme == 'doneIt' "
class="font-40-rem" src='assets/images/icons-nav-home-active-black.svg'></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="font-40-rem"
src='assets/images/theme/gov/icons-nav-home-active-black.svg'></ion-icon>
<span>Início</span>
</div>
<div *ngIf="p.userPermission([permissionList.Agenda.access])"
class="tab mr-20 d-flex align-center cursor-pointer" (click)="changeRoute('/home/agenda')"
[class.active]="ActiveTabService.pages.agenda">
<ion-icon *ngIf="ThemeService.currentTheme == 'default' || ThemeService.currentTheme == 'doneIt' "
class="font-40-rem" src='assets/images/icons-nav-agenda-inactive.svg'></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="font-40-rem"
src='assets/images/theme/gov/icons-nav-agenda-inactive.svg'></ion-icon>
<span>Agenda</span>
</div>
<div *ngIf="p.userPermission([permissionList.Gabinete.access])"
class="tab mr-20 d-flex align-center cursor-pointer" (click)="changeRoute('/home/gabinete-digital')"
[class.active]="ActiveTabService.pages.gabinete">
<ion-icon *ngIf="ThemeService.currentTheme == 'default' || ThemeService.currentTheme == 'doneIt' "
class="font-40-rem" src='assets/images/icons-nav-home-dk.svg'></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="font-40-rem"
src='assets/images/theme/gov/icons-nav-home-dk.svg'></ion-icon>
<span>Gabinete</span>
</div>
<div *ngIf="p.userPermission([permissionList.Actions.access])"
class="tab mr-20 d-flex align-center cursor-pointer" (click)="changeRoute('/home/publications')"
[class.active]="ActiveTabService.pages.publication">
<ion-icon *ngIf="ThemeService.currentTheme == 'default' || ThemeService.currentTheme == 'doneIt' "
class="font-40-rem" src='assets/images/icons-nav-a-es-inactive.svg'></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="font-40-rem"
src='assets/images/theme/gov/icons-nav-a-es-inactive.svg'></ion-icon>
<span>Acções</span>
</div>
<div *ngIf="p.userPermission([permissionList.Chat.access])"
class="tab mr-20 d-flex align-center cursor-pointer" (click)="changeRoute('/home/chat')"
[class.active]="ActiveTabService.pages.chat">
<ion-icon *ngIf="ThemeService.currentTheme == 'default' || ThemeService.currentTheme == 'doneIt' "
class="font-40-rem" src='assets/images/icons-nav-grupos-inactive-dk-white.svg'></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="font-40-rem"
src='assets/images/theme/gov/icons-nav-grupos-inactive-dk-white.svg'></ion-icon>
<span>Chat</span>
</div>
</div>
<div class="header-btns d-flex">
<div *ngIf="PublicationHolderService.count != 0" style="color: black" >
<span *ngIf="!PublicationHolderService.PublicationFormMV?.[0]?.retry">{{ PublicationHolderService.count }}%</span>
<span style="padding-right: 12px" *ngIf="PublicationHolderService.PublicationFormMV?.[0]?.retry" (click)="PublicationHolderService.PublicationFormMV?.[0]?.retryFunction()" ><ion-icon src="assets/images/retry-svgrepo-com.svg" > </ion-icon></span>
<span style="padding-right: 7px" *ngIf="PublicationHolderService.PublicationFormMV?.[0]?.retry" (click)="PublicationHolderService.remove(PublicationHolderService.PublicationFormMV?.[0]?.id)">X</span>
</div>
<div title="Pesquisa" *ngIf="!hideSearchBtn" class="mr-20 d-flex align-center cursor-pointer">
<div style="padding-top: 5px;" (click)="openSearch();showSearch=true" *ngIf="!showSearch">
<ion-icon title="Perfil" *ngIf="ThemeService.currentTheme == 'doneIt' " class="font-45-rem"
src="assets/images/theme/doneIt/icons-search.svg"></ion-icon>
<ion-icon title="Perfil" *ngIf="ThemeService.currentTheme == 'default' " class="font-45-rem"
src='assets/images/icons-search.svg'></ion-icon>
<ion-icon title="Perfil" *ngIf="ThemeService.currentTheme == 'gov' " class="font-45-rem"
src='assets/images/theme/gov/icons-search.svg'></ion-icon>
</div>
<button title="Fechar" class="btn-no-color" (click)="closeSearch();showSearch=false;searchSubject=''"
*ngIf="showSearch">
<ion-icon *ngIf="ThemeService.currentTheme == 'default' || ThemeService.currentTheme == 'doneIt' "
class="font-40-rem" name="restaurant-outline" src="assets/images/icons-search-close.svg"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="font-40-rem" name="restaurant-outline"
src="assets/images/theme/gov/icons-search-close.svg"></ion-icon>
</button>
<div *ngIf="showSearch">
<div class="d-flex search-input-container ml-10 justify-between" *ngIf="showSearch">
<!-- <div class="icon" (click)="basicSearch()">
<ion-icon class="icon-z" slot="end" name="search"></ion-icon>
</div> -->
<!-- <div class="input-text d-flex ion-align-items-center">
<ion-input (keyup.enter)="basicSearch()" [(ngModel)]='searchSubject' (ngModelChange)="dynamicSearch()"
class="search-input text-black" type="search" placeholder="Pesquisar assunto"></ion-input>
</div> -->
<!-- <div class="icon" (click)="clearSearchInput()">
<ion-icon title="Limpar" *ngIf="ThemeService.currentTheme == 'default' "name="restaurant-outline" src="assets/images/icons-search-close.svg"></ion-icon>
<ion-icon title="Limpar" *ngIf="ThemeService.currentTheme == 'doneIt' "name="restaurant-outline" src="assets/images/theme/doneIt/icons-search.svg"></ion-icon>
<ion-icon title="Limpar" *ngIf="ThemeService.currentTheme == 'gov' " name="restaurant-outline" src="assets/images/theme/gov/icons-search-close.svg"></ion-icon>
</div> -->
<!-- <div (click)="basicSearch()" class="d-flex align-center icon">
<ion-icon class="icon-z" slot="end" src="assets/images/theme/gov/search.svg"></ion-icon>
</div> -->
</div>
</div>
</div>
<div title="Perfil" class="div-profile d-flex cursor-pointer font-45-rem" (click)="openProfile()">
<!-- <ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="icon" src='assets/images/icons-profile.svg'></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'doneIt' " class="icon" src='assets/images/theme/doneIt/icons-profile.svg'></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="icon" src='assets/images/theme/gov/icons-profile.svg'></ion-icon> -->
<div *ngIf="profilePictureSubject == undefined " class="profile-image">
<!-- <img *ngIf="loggeduser.RoleDescription == 'Presidente da República' " class="profile-image"
src='assets/images/presidente.png'>
<img *ngIf="loggeduser.RoleDescription == 'Ministro e Director do Gabinete do PR' " class="profile-image"
src='assets/images/ministro.png'>
<img *ngIf="loggeduser.RoleDescription == 'Secretário Geral' " class="profile-image"
src='assets/images/secretaria_geral.png'> -->
<ion-icon
class="icon" src='assets/images/theme/gov/icons-profile.svg'></ion-icon>
</div>
<div *ngIf="(profilePictureSubject | async) as calendarData" class="profile-image">
<img class="profile-image font-45-em image-prety" src={{calendarData.base64}}>
</div>
<div class="profile-text" *ngIf="(notificationCount$ | async) as notificationCount ">
<div *ngIf="notificationCount > 0" class="icon-badge" style="right: -6px;top: 38px;top: -6px;">
{{notificationCount}} </div>
</div>
</div>
</div>
</div>
</div>
</div>
<div [class.header-bottom-line]="ThemeService.currentTheme == 'gov'" style="height: 5px;"></div>
</div>
@@ -0,0 +1,180 @@
@import "~src/function.scss";
.div-top-header {
margin: 0 em(20);
// background-color: #0782c9;
//padding-top: em(15px);
border: 0 !important;
}
.profile-image {
vertical-align: middle;
width: 40px;
height: 40px;
border-radius: 50%;
display: block; /* Torna a imagem um elemento de bloco */
margin: 0 auto;
}
.div-logo {
background: transparent;
width: em(140);
justify-content: center;
display: flex;
color: black;
overflow: auto;
.logo-icon {
width: 25.33%;
overflow: auto;
img {
width: 100%;
margin: 0px auto;
}
}
.logo-description {
width: 74.67%;
margin: 0 auto;
overflow: auto;
font-size: 8.5px;
font-family: Bahnschrift;
.logo-description-content {
width: 100%;
.logo-description-text {
font-weight: 700;
text-align: center;
width: 100%;
margin: 0 !important;
padding: 0 !important;
}
.add-line {
width: 100%;
border-bottom: 1px solid #000;
margin-bottom: 2.5px !important;
padding: 0 !important;
}
.add-line-white {
width: 100%;
border-bottom: 1px solid #fff;
margin-bottom: 2.5px !important;
padding: 0 !important;
}
}
.color-white {
color: #fff !important;
}
.add-botton-border {
border-bottom: 1px solid #000;
}
.add-botton-border-white {
border-bottom: 1px solid #fff;
}
}
}
.header-btns {
justify-content: center;
align-items: center;
}
.div-profile {
text-align: center;
background-color: transparent;
display: flex !important;
justify-content:space-around;
border-radius: 50px;
.icon {
position: relative;
border: none !important;
}
.icon-badge {
background-color: red;
font-size: rem(12);
color: white;
text-align: center;
width: 20px;
height: 20px;
border-radius: 35%;
position: absolute; /* changed */
top: 5px; /* changed */
right: 27px; /* changed */
}
.profile-text {
font-size: rem(20);
font-weight: 300;
width: fit-content;
position: absolute;
color: var(--profile-text-color);
}
}
.main-tab {
//border: 1px solid red;
}
.desktop {
display: none;
}
@media only screen and (min-width: 1366px) {
.mobile {
display: none !important;
}
.desktop {
display: block;
}
}
.tab {
height: 65px;
cursor: pointer;
user-select: none;
}
.tab:hover {
border-top: 7px solid var(--header-tab-text-white);
}
.active {
border-top: 7px solid var(--header-tab-text-white);
span {
font-weight: 650;
}
}
.search-input-container {
background-color: white;
border-radius: 27.5px;
border: solid 1px #ebebeb;
.icon {
color: #797979;
width: rem(45);
height: rem(45);
display: flex;
justify-content: center;
font-size: rem(25);
align-items: center;
}
.input-text {
width: 100%;
}
.icon-z {
width: 20px;
}
}
.tab {
color: var(--header-tab-text-white);
}
@@ -0,0 +1,24 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { IonicModule } from '@ionic/angular';
import { HeaderPage } from './header.page';
describe('HeaderPage', () => {
let component: HeaderPage;
let fixture: ComponentFixture<HeaderPage>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ HeaderPage ],
imports: [IonicModule.forRoot()]
}).compileComponents();
fixture = TestBed.createComponent(HeaderPage);
component = fixture.componentInstance;
fixture.detectChanges();
}));
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,317 @@
import { Component, OnInit, ChangeDetectorRef, NgZone } from '@angular/core';
import { AnimationController, ModalController, Platform } from '@ionic/angular';
import { SearchPage } from 'src/app/pages/search/search.page';
import { Router } from '@angular/router';
import { LoginUserRespose } from 'src/app/models/user.model';
import { ProfilePage } from 'src/app/modals/profile/profile.page';
import { StorageService } from '../../../../services/storage.service';
import { SessionStore } from 'src/app/store/session.service';
import { environment } from 'src/environments/environment';
import { ThemeService } from '../../../../services/theme.service';
import { RouteService } from 'src/app/services/route.service';
import { PermissionList } from 'src/app/models/permission/permissionList';
import { PermissionService } from 'src/app/services/permission.service';
import { ActiveTabService } from 'src/app/services/active-tab.service';
import { AttachmentsService } from 'src/app/services/attachments.service';
import { NotificationHolderService } from 'src/app/store/notification-holder.service';
import { HeaderSettingsService } from "src/app/services/header-settings.service"
import { PublicationHolderService } from 'src/app/services/publication/publication-holder.service'
import { Cy } from 'cypress/enum'
import { NotificationRepositoryService } from 'src/app/module/notification/data/notification-repository.service';
import { Observable } from 'rxjs';
import { UserRepositoryService } from 'src/app/module/user/data/user-repository.service';
import { UserProfilePicture } from 'src/app/module/user/data/datasource/user-local-repository.service';
import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
import { isHttpError } from 'src/app/services/http.service';
@Component({
selector: 'app-header',
templateUrl: './header.page.html',
styleUrls: ['./header.page.scss'],
})
export class HeaderPage implements OnInit {
searchSubject: string = '';
showSearch = false;
loggeduser: LoginUserRespose;
hideSearchBtn: boolean = false;
notificationdata: any[] = [];
DataArray: Array<object> = [];
notificationLength: number = 0;
SessionStore = SessionStore
check: boolean;
production = environment.production
environment = environment
canOpenSearch = false
showProfileModal = false
permissionList = new PermissionList();
notificationCount: number = 0;
profilePicture = "";
hideHeader = false
hideHeaderValidation() {
const result = this.HeaderSettingsService.hideHeader && this.ActiveTabService.pages.gabineteDetails
if(result != this.hideHeader) {
this.hideHeader = true
}
}
Cy = Cy
notificationCount$: Observable<number>
profilePictureSubject: Observable<UserProfilePicture>
constructor(
private router: Router,
private modalController: ModalController,
private animationController: AnimationController,
public platform: Platform,
public ThemeService: ThemeService,
public RouteService: RouteService,
public p: PermissionService,
public ActiveTabService: ActiveTabService,
private storageService: StorageService,
private zone: NgZone,
private attachmentService: AttachmentsService,
public NotificationHolderService: NotificationHolderService,
public HeaderSettingsService: HeaderSettingsService,
public PublicationHolderService: PublicationHolderService,
private notificationRepositoryService: NotificationRepositoryService,
private UserRepositoryService: UserRepositoryService
) {
this.profilePictureSubject = this.UserRepositoryService.getProfilePictureLive() as any
this.notificationCount$ = this.notificationRepositoryService.getNotificationLiveCount()
this.loggeduser = SessionStore.user;
router.events.subscribe((val) => {
this.hideSearch();
this.showSearch = false;
this.canOpenSearch = true;
this.showProfileModal = false
});
this.updateReciveNotification();
this.updateDeleteNotification();
/* this.notificationService.notificationReceived.subscribe(() => {
console.log('header', 'event.notification')
this.notificationLengthData()
}); */
window['header-updateCount'] = () => {
this.updateCount()
}
}
updateCount = () => {
}
ngOnInit() {
this.hideSearch();
// console.log('Profile picture guid ', this.SessionStore.user.UserPhoto)
this.getProfilpicture();
}
reloadComponent(self: boolean, urlToNavigateTo?: string) {
//skipLocationChange:true means dont update the url to / when navigating
console.log("Current route I am on header:", this.router.url);
const url = self ? this.router.url : urlToNavigateTo;
this.zone.run(() => this.router.navigateByUrl('/', { skipLocationChange: true }).then(() => {
this.zone.run(() => this.router.navigate([`/${url}`]).then(() => {
console.log(`After navigation I am on header:${this.router.url}`)
}))
}))
}
@XTracerAsync({name:'header/getPrfilePicture', bugPrint: true})
async getProfilpicture(tracing?: TracingType) {
if (this.SessionStore.user.UserPhoto) {
const base = await this.UserRepositoryService.getUserProfilePhoto(this.SessionStore.user.UserPhoto, tracing)
if(base.isOk()) {
tracing.addEvent('download image')
this.profilePicture = 'data:image/jpeg;base64,' + base.value;
tracing.setAttribute("picture.save", "true")
tracing.setAttribute("outcome", "success")
} else {
if(!isHttpError(base.error)) {
// this.toastService._badRequest('Pedimos desculpa mas não foi possível executar a acção. Por favor, contacte o apoio técnico.')
} else {
// this.httpErrorHandle.httpStatusHandle(base.error)
}
}
}
}
updateReciveNotification() {
}
updateDeleteNotification() {
}
hideSearch() {
if (this.router.url.startsWith('/home/events') || this.router.url.startsWith('/home/chat')) {
this.hideSearchBtn = true;
} else {
this.hideSearchBtn = false;
}
}
async openSearch() {
let classs, showSearchInput, type;
if (window.innerWidth < 1366) {
classs = 'modal modal-width-100'
showSearchInput = true
} else {
classs = 'modal modal-desktop desktop-search'
showSearchInput = false
}
if (window.location.pathname.startsWith('/home/agenda')) {
type = "Agenda"
} else if (window.location.pathname.startsWith('/home/gabinete-digital')) {
type = "AccoesPresidenciais & ArquivoDespachoElect"
} else if (window.location.pathname.startsWith('/home/publications')) {
type = "AccoesPresidenciais"
}
if (this.canOpenSearch) {
this.canOpenSearch = false
const modal = await this.modalController.create({
component: SearchPage,
cssClass: classs,
componentProps: {
type: type,
showSearchInput: showSearchInput,
select: false
}
});
modal.onDidDismiss().then(() => {
this.canOpenSearch = true;
});
await modal.present();
}
}
changeRoute(path) {
this.router.navigateByUrl(path)
}
async openProfile() {
const enterAnimation = (baseEl: any) => {
const backdropAnimation = this.animationController.create()
.addElement(baseEl.querySelector('ion-backdrop')!)
.fromTo('opacity', '0.01', 'var(--backdrop-opacity)');
const wrapperAnimation = this.animationController.create()
.addElement(baseEl.querySelector('.modal-wrapper')!)
.keyframes([
{ offset: 0, opacity: '1', right: '-100%' },
{ offset: 1, opacity: '1', right: '0px' }
]);
return this.animationController.create()
.addElement(baseEl)
.easing('ease-out')
.duration(500)
.addAnimation([backdropAnimation, wrapperAnimation]);
}
const leaveAnimation = (baseEl: any) => {
return enterAnimation(baseEl).direction('reverse');
}
if (!this.showProfileModal) {
this.showProfileModal = true
const modal = await this.modalController.create({
component: ProfilePage,
cssClass: 'model profile-modal search-submodal',
componentProps: {
}
});
modal.onDidDismiss().then(() => {
this.showProfileModal = false
})
await modal.present();
}
}
async dynamicSearch() {
if (window['dynamicSearch']) {
window['dynamicSearch'](this.searchSubject)
} else {
setTimeout(() => {
this.dynamicSearch()
}, 100)
}
}
async closeSearch() {
this.modalController.dismiss()
}
/**
* @description set empty value to searchSubject
*/
clearSearchInput() {
this.searchSubject = "";
window['dynamicSearch'](this.searchSubject)
}
async basicSearch() {
if (window['searchTriger']) {
window['searchTriger']()
} else {
setTimeout(() => {
this.basicSearch()
}, 100)
}
}
getProfilePictureSorage() {
this.storageService.get(this.SessionStore.user.RoleID.toString()).then((picture) => {
/* console.log(picture) */
this.profilePicture = picture
}).catch((error) => {
this.profilePicture = "";
})
}
}