update image

This commit is contained in:
peter.maquiran
2025-09-05 11:42:36 +01:00
parent 430adf394d
commit d1e5387d11
18 changed files with 652 additions and 399 deletions
+1 -1
View File
@@ -98,7 +98,7 @@ const UserSessionSchema = z.object({
Inactivity: z.boolean(),
UrlBeforeInactivity: z.string(),
UserPermissions: z.unknown(), // Again, you can define it more explicitly if needed
UserPhoto: z.string(),
UserPhoto: z.string().nullable(),
RefreshToken: z.string(),
});
@@ -17,7 +17,7 @@ const UserSchema = z.object({
wxeMail: z.string(),
role: z.string(),
roleId: z.number(),
userPhoto: z.string(),
userPhoto: z.string().nullable(),
adUserSID: z.string(),
});
@@ -0,0 +1,39 @@
import { Injectable } from '@angular/core';
import { z, ZodError, ZodSchema } from 'zod';
const UserGetByIdInputSchema = z.object({
username: z.string(),
password: z.string()
})
export type UserGetByIdInput = z.infer<typeof UserGetByIdInputSchema>
export const UserGetByIdOutputSchema = z.object({
success: z.boolean(),
message: z.string(),
data: z.object({
wxUserId: z.number(),
wxFullName: z.string(),
wxUser: z.string(),
wxeMail: z.string().email(),
role: z.string(),
roleId: z.number(),
userPhoto: z.string(), // base64 image string
adUserSID: z.string().nullable(),
organicEntityID: z.number(),
organicEntityName: z.string(),
managerId: z.number(),
managerName: z.string(),
status: z.string()
})
});
export type UserGetByIdOutput = z.infer<typeof UserGetByIdOutputSchema>
@Injectable({
providedIn: 'root'
})
export class UserGetByIdService {
constructor() { }
}
@@ -62,21 +62,10 @@
<div mat-icon-button [matMenuTriggerFor]="menu" aria-label="Example icon-button with a menu">
<div class="d-flex align-center flex-column" >
<div *ngIf="profilePictureSubject == undefined ">
<img
class="profile-pic" src="assets/images/theme/gov/icons-profile.svg">
<!-- <img *ngIf="SessionStore.user.RoleDescription == 'Presidente da República' " class="profile-pic"
src='assets/images/presidente.png'>
<img *ngIf="SessionStore.user.RoleDescription == 'Ministro e Director do Gabinete do PR' "
class="profile-pic" src='assets/images/ministro.png'>
<img *ngIf="SessionStore.user.RoleDescription == 'Secretário Geral' " class="profile-pic"
src='assets/images/secretaria_geral.png'> -->
</div>
<div *ngIf="(profilePictureSubject | async) as calendarData">
<img class="profile-pic" src={{calendarData.base64}}>
<img *ngIf="calendarData.base64 != null" class="profile-pic" src={{calendarData.base64}}>
<img *ngIf="calendarData.base64 == null" class="profile-pic" src="assets/images/theme/gov/icons-profile.svg">
</div>
@@ -125,29 +114,6 @@
</div>
</div>
<!-- <div class="profile-title d-flex justify-space-between align-center width-100">
<div class="d-flex align-center">
<div>Tema</div>
</div>
</div>
<div class="profile-title d-flex justify-space-between align-center width-100">
<div class="d-flex align-center">
<div class="btn-close d-flex cursor-pointer" (click)="changeTheme('gov')">
<img style="width: 40px;" src="assets/images/theme/gov/governoangola_A.png">
</div>
<div class="btn-close d-flex cursor-pointer pr-10 pl-10" (click)="changeTheme('default')">
<img style="width: 40px;" src="assets/images/logo-removebg-preview.png" />
</div>
<div class="btn-close d-flex cursor-pointer pr-10 pl-10" (click)="changeTheme('default')">
<img style="width: 40px;" src="assets/images/logo-removebg-preview.png" />
</div>
</div>
</div> -->
</div>
+2 -23
View File
@@ -38,31 +38,10 @@
<div class="profile-content">
<div class="d-flex align-center flex-column">
<div *ngIf="profilePictureSubject == undefined ">
<img
class="profile-pic" src="assets/images/theme/gov/icons-profile.svg">
<!-- <img *ngIf="SessionStore.user.RoleDescription == 'Presidente da República' " class="profile-pic"
src='assets/images/presidente.png'>
<img *ngIf="SessionStore.user.RoleDescription == 'Ministro e Director do Gabinete do PR' " class="profile-pic"
src='assets/images/ministro.png'>
<img *ngIf="SessionStore.user.RoleDescription == 'Secretário Geral' " class="profile-pic"
src='assets/images/secretaria_geral.png'> -->
</div>
<div *ngIf="(profilePictureSubject | async) as calendarData"class="profile-pic">
<img class="profile-pic"
src={{calendarData.base64}}>
<img *ngIf="calendarData.base64 != null" class="profile-pic" src={{calendarData.base64}}>
<img *ngIf="calendarData.base64 == null" class="profile-pic" src="assets/images/theme/gov/icons-profile.svg">
</div>
<!-- <ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="profile-pic"
src="assets/images/icons-default-profile.svg"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="profile-pic"
src="assets/images/theme/gov/icons-profile.svg"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'doneIt' " class="profile-pic"
src="assets/images/theme/{{ThemeService.currentTheme}}/icons-profile.svg"></ion-icon> -->
</div>
<div class="profile-name d-flex justify-content-center width-100">
@@ -160,7 +160,7 @@ const OwnerSchema = z.object({
wxUserId: z.number(),
wxFullName: z.string(),
wxeMail: z.string(),
userPhoto: z.string(),
userPhoto: z.string().nullable(),
});
@@ -28,14 +28,14 @@ const OwnerSchema = z.object({
wxUserId: z.number(),
wxFullName: z.string(),
wxeMail: z.string(),
userPhoto: z.string(),
userPhoto: z.string().nullable(),
});
const OrganizerSchema = z.object({
wxUserId: z.number(),
wxFullName: z.string(),
wxeMail: z.string(),
userPhoto: z.string(),
userPhoto: z.string().nullable(),
});
const EventRecurrenceSchema = z.object({
@@ -5,7 +5,7 @@ const OwnerSchema = z.object({
wxUserId: z.number(),
wxFullName: z.string(),
wxeMail: z.string(),
userPhoto: z.string(),
userPhoto: z.string().nullable(),
});
@@ -5,7 +5,7 @@ const OwnerSchema = z.object({
wxUserId: z.number(),
wxFullName: z.string(),
wxeMail: z.string(),
userPhoto: z.string(),
userPhoto: z.string().nullable(),
});
@@ -8,6 +8,7 @@ import { HttpAdapter } from 'src/app/infra/http/adapter';
import { IUserRepositoryLoginParams, UserRefreshTokenInputDTO } from 'src/app/core/user/repository/user-remote-repository';
import { UserLoginOutput } from 'src/app/core/user/use-case/user-login-use-case.service';
import { SessionStore } from 'src/app/store/session.service';
import { UserGetByIdOutput } from 'src/app/core/user/use-case/user-get-by-id.service';
@Injectable({
providedIn: 'root'
})
@@ -38,14 +39,8 @@ export class UserRemoteRepositoryService {
return await this.http.post<UserLoginOutput>(`${this.baseUrl}/Users/RefreshToken`, input)
}
getUserProfilePhoto(guid: string, tracing?: TracingType) {
const geturl = environment.apiURL + 'UserAuthentication/GetPhoto';
const params = {
UserPhoto: guid
}
return this.httpService.get<string>(`${geturl}`, params, tracing);
async getUserProfilePhoto(guid: string, tracing?: TracingType) {
return await this.http.get<UserGetByIdOutput>(`${this.baseUrl}/Users/${SessionStore.user.UserId}`, {})
}
addUserProfilePhoto(data: IProfilePictureInputDTO) {
@@ -18,7 +18,7 @@ export class UserRepositoryService {
const result = await this.remote.getUserProfilePhoto(guid, tracing)
if(result.isOk()) {
this.local.addProfilePicture({base64: 'data:image/jpeg;base64,' + result.value})
this.local.addProfilePicture({base64: result.value.data.data.userPhoto})
} else {
tracing?.setAttribute("picture.upload", "false")
tracing?.hasError("cant upload picture")
@@ -16,31 +16,12 @@ const tracerNotificationInstance = OpentelemetryNotificationProvider.getTracer('
const tracerChat = OpentelemetryChatProvider.getTracer('OpentelemetryChatProvider','some' ,{})
const tracerUser = OpentelemetryUserProvider.getTracer('OpentelemetryUserProvider','some' ,{})
let device: DeviceInfo;
Device.getInfo().then(e => {
device = e
});
function convertAttributesToString(obj) {
const result = {};
for (const key in obj) {
if (obj.hasOwnProperty(key)) {
if (typeof obj[key] === 'object' && obj[key] !== null) {
// Convert only the object attribute to string
result[key] = JSON.stringify(obj[key], null, 2);
} else {
// Convert primitive values to string
result[key] = obj[key];
}
}
}
return result;
}
const createTracingInstance = ({bugPrint, name, module, autoFinish, waitNThrow = 0}): TracingType => {
@@ -51,30 +51,15 @@
<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
<div (click)="openProfile()" *ngIf="(profilePictureSubject | async) as calendarData" class="profile-image d-flex">
<img *ngIf="calendarData.base64 != null" class="profile-image image-prety" src={{calendarData.base64}}>
<ion-icon *ngIf="calendarData.base64 == null"
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>
@@ -200,53 +185,14 @@
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 title="Perfil" class="div-profile d-flex cursor-pointer font-45-rem d-flex align-center" (click)="openProfile()">
<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>
<ion-icon
class="icon" src='assets/images/theme/gov/icons-profile.svg'></ion-icon>
<div *ngIf="(profilePictureSubject | async) as calendarData" class="profile-image">
<img class="profile-image font-45-em image-prety" src={{calendarData.base64}}>
<div *ngIf="(profilePictureSubject | async) as calendarData" class="profile-image d-flex">
<img *ngIf="calendarData.base64 != null" class="profile-image image-prety" src={{calendarData.base64}}>
<ion-icon *ngIf="calendarData.base64 == null"
class="icon font-45 image-prety" src='assets/images/theme/gov/icons-profile.svg'></ion-icon>
</div>
<div class="profile-text" *ngIf="(notificationCount$ | async) as notificationCount ">
@@ -9,8 +9,6 @@
.profile-image {
vertical-align: middle;
width: 40px;
height: 40px;
border-radius: 50%;
display: block; /* Torna a imagem um elemento de bloco */
margin: 0 auto;
@@ -136,25 +136,21 @@ export class HeaderPage implements OnInit {
@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)
const base = await this.UserRepositoryService.getUserProfilePhoto(this.SessionStore.user.UserPhoto, tracing)
if(base.isOk()) {
tracing.addEvent('download image')
this.profilePicture = base.value.data.data.userPhoto;
if(base.isOk()) {
tracing.addEvent('download image')
this.profilePicture = 'data:image/jpeg;base64,' + base.value;
tracing.setAttribute("picture.save", "true")
tracing.setAttribute("outcome", "success")
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 {
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)
}
// this.httpErrorHandle.httpStatusHandle(base.error)
}
}
}