Skip to content

Commit 9bc7b69

Browse files
authored
Merge pull request #401 from Ketteiteki/add_showing_full_size_avatar_frontend
Add showing full size avatar frontend
2 parents a2290ab + ce5a3de commit 9bc7b69

9 files changed

Lines changed: 151 additions & 24 deletions

File tree

MangoAPI.Client/src/app/components/chats/chats.component.html

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
<div class="d-flex">
22
<div class="menu" id="menu">
3+
<div
4+
*ngIf="_modalWindowStateService.isModalWindowShowing"
5+
class="black-cover"
6+
(click)="closeModalWindowrClick()"
7+
>
8+
<img
9+
*ngIf="_modalWindowStateService.picture"
10+
src="{{ _modalWindowStateService.picture }}"
11+
class="profile-avatar"
12+
alt=""
13+
(click)="$event.stopPropagation()"
14+
/>
15+
</div>
316
<app-navbar [activeComponent]="'chats'"></app-navbar>
417
<aside class="sidebar">
518
<header class="sidebar-header p-3">
@@ -45,9 +58,9 @@ <h5>Chats</h5>
4558
(click)="loadChat(chat.chatId)"
4659
*ngIf="activeChatId === chat.chatId; else chatElse"
4760
>
48-
<div class="last-message-time" *ngIf="chatContainsMessages(chat)">
49-
{{ toShortTimeString(chat.lastMessageTime) }}
50-
</div>
61+
<div class="last-message-time" *ngIf="chatContainsMessages(chat)">
62+
{{ toShortTimeString(chat.lastMessageTime) }}
63+
</div>
5164
<img alt="Chat avatar" class="avatar" src="{{ chat.chatLogoImageUrl }}" />
5265
<div class="content">
5366
<div class="title" *ngIf="chat.communityType === 2; else elseBlock">
@@ -206,12 +219,18 @@ <h5>Chats</h5>
206219
<img
207220
alt="User Avatar"
208221
class="user-avatar"
222+
(click)="onOpenImageClick(message.messageAuthorPictureUrl)"
209223
src="{{ message.messageAuthorPictureUrl }}"
210224
/>
211225
<div class="message-wrapper">
212226
<div class="message-content">
213-
<span *ngIf="message.messageAttachmentUrl"><img class="message-image"
214-
(click)="onImageClick(message.messageAttachmentUrl)" src="{{message.messageAttachmentUrl}}" alt=""></span>
227+
<span *ngIf="message.messageAttachmentUrl"
228+
><img
229+
class="message-image"
230+
(click)="onOpenImageClick(message.messageAttachmentUrl)"
231+
src="{{ message.messageAttachmentUrl }}"
232+
alt=""
233+
/></span>
215234
<span>{{ message.messageText }}</span>
216235
</div>
217236
<div class="message-options gap-fix">
@@ -271,17 +290,26 @@ <h5>Chats</h5>
271290
<img
272291
alt="User Avatar"
273292
class="user-avatar"
293+
(click)="onOpenImageClick(message.messageAuthorPictureUrl)"
274294
src="{{ message.messageAuthorPictureUrl }}"
275295
/>
276296
<div class="message-wrapper">
277297
<div class="message-content">
278298
<div
299+
*ngIf="!message.messageAttachmentUrl"
279300
class="display-name {{
280301
getDisplayNameColour(message.userDisplayNameColour)
281302
}}"
282303
>
283304
{{ message.userDisplayName }}
284305
</div>
306+
<span *ngIf="message.messageAttachmentUrl"
307+
><img
308+
class="message-image"
309+
(click)="onOpenImageClick(message.messageAttachmentUrl)"
310+
src="{{ message.messageAttachmentUrl }}"
311+
alt=""
312+
/></span>
285313
<span>{{ message.messageText }}</span>
286314
</div>
287315
<div class="message-options gap-fix">
@@ -307,7 +335,12 @@ <h5>Chats</h5>
307335
</button>
308336
<div class="dropdown-menu">
309337
<div class="dropdown-item">
310-
<input id="attachment" accept="image/png, image/gif, image/jpeg" (change)="imageSelected($event)" type="file" />
338+
<input
339+
id="attachment"
340+
accept="image/png, image/gif, image/jpeg"
341+
(change)="imageSelected($event)"
342+
type="file"
343+
/>
311344
</div>
312345
</div>
313346
</div>

MangoAPI.Client/src/app/components/chats/chats.component.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { ModalWindowStateService } from './../../services/states/modalWindowState.service';
12
import { Component, OnDestroy, OnInit } from '@angular/core';
23
import { TokensService } from '../../services/messenger/tokens.service';
34
import { Chat } from '../../types/models/Chat';
@@ -33,12 +34,12 @@ export class ChatsComponent implements OnInit, OnDestroy {
3334
private _communitiesService: CommunitiesService,
3435
private _userChatsService: UserChatsService,
3536
private _messagesService: MessagesService,
36-
private _usersService: UsersService,
3737
private _errorNotificationService: ErrorNotificationService,
3838
private _router: Router,
3939
private _validationService: ValidationService,
4040
private _documentsService: DocumentsService,
41-
private _apiBaseService: ApiBaseService
41+
private _apiBaseService: ApiBaseService,
42+
public _modalWindowStateService: ModalWindowStateService
4243
) {}
4344

4445
private connectionBuilder: signalR.HubConnectionBuilder = new signalR.HubConnectionBuilder();
@@ -150,8 +151,14 @@ export class ChatsComponent implements OnInit, OnDestroy {
150151
this.messageAttachment = event.target.files[0];
151152
}
152153

153-
onImageClick(imageUrl: string) {
154-
window.open(imageUrl);
154+
onOpenImageClick(imageLink: string): void {
155+
this._modalWindowStateService.setIsModalWindowShowing(true)
156+
this._modalWindowStateService.setPicture(imageLink)
157+
}
158+
159+
closeModalWindowrClick(): void {
160+
this._modalWindowStateService.setIsModalWindowShowing(false)
161+
this._modalWindowStateService.setPictureNull()
155162
}
156163

157164
async uploadFile(file: File) {

MangoAPI.Client/src/app/components/contacts/contacts.component.html

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<body class="d-flex">
22
<div class="menu" id="menu">
3+
<div *ngIf="_modalWindowStateService.isModalWindowShowing" class="black-cover" (click)="closeModalWindowrClick()">
4+
<img
5+
*ngIf="_modalWindowStateService.picture"
6+
src="{{ _modalWindowStateService.picture }}"
7+
class="profile-avatar"
8+
alt=""
9+
(click)="$event.stopPropagation()"
10+
/>
11+
</div>
312
<app-navbar [activeComponent]="'contacts'"></app-navbar>
413
<aside class="sidebar contacts">
514
<header class="sidebar-header p-3">
@@ -39,7 +48,7 @@ <h5>Contacts</h5>
3948
*ngIf="contact.userId === activeUserId; else elseContact"
4049
(click)="onContactTabClick(contact)"
4150
>
42-
<img alt="Chat avatar" class="avatar" src="{{ contact.pictureUrl }}" />
51+
<img alt="Chat avatar" class="avatar" src="{{ contact.pictureUrl }}"/>
4352
<div class="content">
4453
<div class="title">
4554
<div class="info pl-1">
@@ -90,7 +99,7 @@ <h5>Contacts</h5>
9099
</div>
91100
<main class="contact">
92101
<div class="main-info background-pattern">
93-
<img src="{{ activeUser.pictureUrl }}" alt="User Avatar" class="avatar" />
102+
<img src="{{ activeUser.pictureUrl }}" alt="User Avatar" class="avatar" (click)="onOpenAvatarClick()"/>
94103
<div class="d-flex flex-column">
95104
<p>{{ activeUser.displayName }}</p>
96105
<p>{{ activeUser.bio }}</p>

MangoAPI.Client/src/app/components/contacts/contacts.component.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { Router } from '@angular/router';
1111
import { StartDirectChatQueryObject } from '../../types/query-objects/StartDirectChatQueryObject';
1212
import { RoutingService } from '../../services/messenger/routing.service';
1313
import { Subject, takeUntil } from 'rxjs';
14+
import { ModalWindowStateService } from 'src/app/services/states/modalWindowState.service';
1415

1516
@Component({
1617
selector: 'app-contacts',
@@ -24,7 +25,8 @@ export class ContactsComponent implements OnInit, OnDestroy {
2425
private _tokensService: TokensService,
2526
private _communitiesService: CommunitiesService,
2627
private _router: Router,
27-
private _routingService: RoutingService
28+
private _routingService: RoutingService,
29+
public _modalWindowStateService: ModalWindowStateService,
2830
) {}
2931

3032
public contacts: Contact[] = [];
@@ -88,6 +90,16 @@ export class ContactsComponent implements OnInit, OnDestroy {
8890
});
8991
}
9092

93+
onOpenAvatarClick(): void {
94+
this._modalWindowStateService.setIsModalWindowShowing(true)
95+
this._modalWindowStateService.setPicture(this.activeUser.pictureUrl)
96+
}
97+
98+
closeModalWindowrClick(): void {
99+
this._modalWindowStateService.setIsModalWindowShowing(false)
100+
this._modalWindowStateService.setPictureNull()
101+
}
102+
91103
getUsersContacts(): void {
92104
this._contactsService
93105
.getCurrentUserContacts()

MangoAPI.Client/src/app/components/navbar/navbar.component.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<ul class="text-center menu-buttons">
66
<li>
77
<a [routerLink]="[routingConstants.Chats]">
8-
<!-- <a routerLink="{{ routingConstants.Chats }}"> -->
98
<svg fill="none" stroke="currentColor" viewBox="0 0 24 24">
109
<path
1110
[ngClass]="activeComponent === 'chats' ? 'path active' : 'path'"

MangoAPI.Client/src/app/components/settings/settings.component.html

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<div class="d-flex">
22
<div class="menu" id="menu">
3+
<div *ngIf="_modalWindowStateService.isModalWindowShowing" class="black-cover" (click)="closeModalWindowClick()">
4+
<img
5+
*ngIf="_modalWindowStateService.picture"
6+
src="{{ _modalWindowStateService.picture }}"
7+
class="profile-avatar"
8+
alt=""
9+
(click)="$event.stopPropagation()"
10+
/>
11+
</div>
312
<app-navbar [activeComponent]="'settings'"></app-navbar>
413
<aside class="sidebar">
514
<header class="sidebar-header p-3">
@@ -10,7 +19,12 @@ <h5>Profile</h5>
1019
</header>
1120
<div class="p-3 overflow height-fix">
1221
<div class="main-info background-pattern">
13-
<img src="{{ currentUser.pictureUrl }}" alt="User Avatar" class="avatar" />
22+
<img
23+
src="{{ currentUser.pictureUrl }}"
24+
alt="User Avatar"
25+
class="avatar"
26+
(click)="onOpenAvatarClick()"
27+
/>
1428
<div class="d-flex flex-column">
1529
<p>{{ currentUser.displayName }}</p>
1630
</div>
@@ -92,7 +106,7 @@ <h5>Profile</h5>
92106
<li>
93107
<div class="info">
94108
<p class="title">Api Version</p>
95-
<p>{{apiVersion}}</p>
109+
<p>{{ apiVersion }}</p>
96110
</div>
97111
<img src="./../../../assets/svg/api.svg" alt="Api Icon" />
98112
</li>
@@ -116,12 +130,13 @@ <h5 class="mb-2">Account</h5>
116130
<li class="d-flex flex-column w-50 profile-form-group">
117131
<label for="BirthdayDate">Birthday</label>
118132
<input
119-
class='profile-form-input'
120-
type='date'
121-
value="{{currentUser.birthdayDate}}"
122-
id='BirthdayDate'
123-
placeholder='Type your birthday'
124-
[(ngModel)]="currentUser.birthdayDate">
133+
class="profile-form-input"
134+
type="date"
135+
value="{{ currentUser.birthdayDate }}"
136+
id="BirthdayDate"
137+
placeholder="Type your birthday"
138+
[(ngModel)]="currentUser.birthdayDate"
139+
/>
125140
</li>
126141

127142
<li class="d-flex flex-column w-50 profile-form-group">

MangoAPI.Client/src/app/components/settings/settings.component.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,25 @@ import { User } from '../../types/models/User';
1010
import { ValidationService } from '../../services/messenger/validation.service';
1111
import { UpdateAccountInformationCommand } from '../../types/requests/UpdateAccountInformationCommand';
1212
import { SessionService } from '../../services/api/session.service';
13-
import { Router } from '@angular/router';
13+
import { Event, Router } from '@angular/router';
1414
import { Subject, takeUntil } from 'rxjs';
1515
import { RoutingConstants } from 'src/app/types/constants/RoutingConstants';
1616
import { AppInfoService } from 'src/app/services/api/app-info.service';
17+
import { ModalWindowStateService } from 'src/app/services/states/modalWindowState.service';
1718

1819
@Component({
1920
selector: 'app-settings',
2021
templateUrl: './settings.component.html'
2122
})
2223
export class SettingsComponent implements OnInit, OnDestroy {
2324
constructor(
24-
private _contactsService: ContactsService,
2525
private _errorNotificationService: ErrorNotificationService,
2626
private _usersService: UsersService,
2727
private _appInfoService: AppInfoService,
2828
private _tokensService: TokensService,
2929
private _validationService: ValidationService,
3030
private _sessionService: SessionService,
31+
public _modalWindowStateService: ModalWindowStateService,
3132
private _router: Router
3233
) {}
3334

@@ -106,6 +107,16 @@ export class SettingsComponent implements OnInit, OnDestroy {
106107
this.componentDestroyed$.complete();
107108
}
108109

110+
onOpenAvatarClick(): void {
111+
this._modalWindowStateService.setIsModalWindowShowing(true)
112+
this._modalWindowStateService.setPicture(this.currentUser.pictureUrl)
113+
}
114+
115+
closeModalWindowClick(): void {
116+
this._modalWindowStateService.setIsModalWindowShowing(false)
117+
this._modalWindowStateService.setPictureNull()
118+
}
119+
109120
onLogoutClick(): void {
110121
const refreshToken = this._tokensService.getTokens()?.refreshToken as string;
111122
this._sessionService
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { Injectable } from '@angular/core';
2+
3+
4+
@Injectable({
5+
providedIn: 'root'
6+
})
7+
export class ModalWindowStateService {
8+
public isModalWindowShowing: boolean = false;
9+
public picture: string | null = null;
10+
11+
12+
public setIsModalWindowShowing = (value: boolean) => {
13+
this.isModalWindowShowing = value;
14+
}
15+
16+
public setPicture = (fileName: string) => {
17+
this.picture = fileName;
18+
}
19+
20+
public setPictureNull = () => {
21+
this.picture = null;
22+
}
23+
}

MangoAPI.Client/src/styles.scss

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ $dark-gray: #505558;
55
$orange: #cf7d1f;
66
$orange-dark: #c18d1a;
77
$red: #ff3333;
8+
$transparentBlackLight: rgba(0, 0, 0, 0.300);
89

910
* {
1011
box-sizing: border-box;
@@ -127,6 +128,20 @@ i {
127128
height: 50px;
128129
}
129130

131+
.black-cover {
132+
display: flex;
133+
position: absolute;
134+
z-index: 3;
135+
width: 100vw;
136+
height: 100vh;
137+
background-color: $transparentBlackLight;
138+
139+
.profile-avatar {
140+
margin: auto;
141+
max-height: 80%;
142+
}
143+
}
144+
130145
.contacts {
131146
.list {
132147
li {
@@ -207,6 +222,7 @@ i {
207222
height: 80px;
208223
margin-bottom: 25px;
209224
object-fit: cover;
225+
cursor: pointer;
210226
}
211227
p {
212228
font-size: 16px;
@@ -489,6 +505,7 @@ i {
489505
flex-direction: column;
490506
.message-image {
491507
max-width: 200px;
508+
cursor: pointer;
492509
}
493510
.display-name {
494511
font-weight: bold;
@@ -521,6 +538,7 @@ i {
521538
border-radius: 50%;
522539
align-self: flex-end;
523540
object-fit: cover;
541+
cursor: pointer;
524542
}
525543
}
526544
}

0 commit comments

Comments
 (0)