Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 350e5a8

Browse files
committedDec 28, 2024
feat(album): adiciona funcionalidade para marcar pessoas em fotos
closed #119
1 parent 6edf51c commit 350e5a8

37 files changed

+759
-236
lines changed
 

‎apps/devmx/public/icons/tag-minus.svg

+3
Loading

‎apps/devmx/public/icons/tag-plus.svg

+3
Loading

‎apps/devmx/public/icons/tag.svg

+3
Loading
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { provideFacades, provideServices, provideUseCases } from './providers';
1+
import { providePhoto, provideAlbum as $provideAlbum } from './providers';
22

33
export function provideAlbum() {
4-
return [...provideServices(), ...provideUseCases(), ...provideFacades()];
4+
return [...providePhoto(), ...$provideAlbum()];
55
}

‎packages/album/data-access/src/lib/application/photo.facade.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,20 @@ import {
55
DeletePhotoUseCase,
66
FindPhotoByIDUseCase,
77
FindPhotosUseCase,
8+
UpdatePhotoTagsUseCase,
89
UpdatePhotoUseCase,
910
UploadPhoto,
1011
UploadPhotoUseCase,
1112
} from '@devmx/album-domain/client';
13+
import { take } from 'rxjs';
1214

1315
export class PhotoFacade extends EntityFacade<Photo> {
1416
constructor(
1517
private createPhotoUseCase: CreatePhotoUseCase,
1618
private findPhotosUseCase: FindPhotosUseCase,
1719
private findPhotoByIdUseCase: FindPhotoByIDUseCase,
1820
private updatePhotoUseCase: UpdatePhotoUseCase,
21+
private updatePhotoTagsUseCase: UpdatePhotoTagsUseCase,
1922
private deletePhotoUseCase: DeletePhotoUseCase,
2023
private uploadPhotoUseCase: UploadPhotoUseCase
2124
) {
@@ -49,11 +52,15 @@ export class PhotoFacade extends EntityFacade<Photo> {
4952
update(data: EditablePhoto) {
5053
const request$ = this.updatePhotoUseCase.execute(data);
5154

52-
this.onUpdate(request$);
55+
// this.onUpdate(request$);
5356

5457
this.loadOne(data.id);
5558

56-
return request$;
59+
return request$.pipe(take(1));
60+
}
61+
62+
updateTags(data: EditablePhoto) {
63+
this.onUpdate(this.updatePhotoTagsUseCase.execute(data));
5764
}
5865

5966
delete(id: string) {
@@ -67,6 +74,7 @@ export function providePhotoFacade() {
6774
FindPhotosUseCase,
6875
FindPhotoByIDUseCase,
6976
UpdatePhotoUseCase,
77+
UpdatePhotoTagsUseCase,
7078
DeletePhotoUseCase,
7179
UploadPhotoUseCase,
7280
]);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { provideAlbumHttpService } from '../infrastrucure';
2+
import { provideAlbumFacade } from '../application';
3+
import {
4+
provideCreateAlbumUseCase,
5+
provideDeleteAlbumUseCase,
6+
provideFindAlbumByIDUseCase,
7+
provideFindAlbumsUseCase,
8+
provideUpdateAlbumUseCase,
9+
} from '@devmx/album-domain/client';
10+
11+
export function provideAlbum() {
12+
return [
13+
provideAlbumHttpService(),
14+
15+
provideCreateAlbumUseCase(),
16+
provideDeleteAlbumUseCase(),
17+
provideFindAlbumByIDUseCase(),
18+
provideFindAlbumsUseCase(),
19+
provideUpdateAlbumUseCase(),
20+
21+
provideAlbumFacade(),
22+
];
23+
}

‎packages/album/data-access/src/lib/providers/facades.ts

-5
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
export * from './facades';
2-
export * from './services';
3-
export * from './use-cases';
1+
export * from './album';
2+
export * from './photo';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { providePhotoHttpService } from '../infrastrucure';
2+
import { providePhotoFacade } from '../application';
3+
import {
4+
provideCreatePhotoUseCase,
5+
provideDeletePhotoUseCase,
6+
provideFindPhotoByIDUseCase,
7+
provideFindPhotosUseCase,
8+
provideUpdatePhotoTagsUseCase,
9+
provideUpdatePhotoUseCase,
10+
provideUploadPhotoUseCase,
11+
} from '@devmx/album-domain/client';
12+
13+
export function providePhoto() {
14+
return [
15+
providePhotoHttpService(),
16+
17+
provideCreatePhotoUseCase(),
18+
provideDeletePhotoUseCase(),
19+
provideFindPhotoByIDUseCase(),
20+
provideFindPhotosUseCase(),
21+
provideUpdatePhotoTagsUseCase(),
22+
provideUpdatePhotoUseCase(),
23+
provideUploadPhotoUseCase(),
24+
25+
providePhotoFacade(),
26+
];
27+
}

‎packages/album/data-access/src/lib/providers/services.ts

-8
This file was deleted.

‎packages/album/data-access/src/lib/providers/use-cases.ts

-73
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
11
@if (album$ | async; as album) {
2-
3-
<!-- -->
4-
5-
@for (photo of album.photos; track photo.id) {
6-
7-
<figure>
8-
<img loading="lazy" [src]="photo.data" [alt]="photo.caption" />
9-
10-
<figcaption>{{ photo.caption }}</figcaption>
11-
</figure>
12-
13-
}
14-
152
<!-- -->
3+
@let auth = (authFacade.auth$ | async)!;
164

5+
<div class="grid">
6+
@for (photo of album.photos; track photo.id) {
7+
<devmx-photo class="photo" [photo]="photo" (click)="open(photo, auth)" />
8+
}
9+
</div>
1710
}
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
11
:host {
2-
gap: 1em;
2+
flex: 1;
33
padding: 1em;
4-
display: grid;
5-
grid-auto-flow: dense;
4+
display: flex;
5+
flex-direction: column;
66

7-
grid-template-columns: repeat(4, 1fr);
7+
.grid {
8+
gap: 1em;
9+
display: grid;
10+
grid-auto-flow: dense;
811

9-
@media (max-width: 1918px) {
10-
grid-template-columns: repeat(3, 1fr);
11-
}
12+
grid-template-columns: repeat(4, 1fr);
1213

13-
@media (max-width: 1278px) {
14-
grid-template-columns: repeat(2, 1fr);
15-
}
14+
@media (max-width: 1918px) {
15+
grid-template-columns: repeat(3, 1fr);
16+
}
17+
18+
@media (max-width: 1278px) {
19+
grid-template-columns: repeat(2, 1fr);
20+
}
1621

17-
@media (max-width: 767px) {
18-
grid-template-columns: repeat(1, 1fr);
22+
@media (max-width: 767px) {
23+
grid-template-columns: repeat(1, 1fr);
24+
}
1925
}
2026

21-
figure {
27+
.photo {
2228
margin: 0;
2329
// width: calc(100% - 1em);
2430
box-sizing: border-box;
@@ -29,34 +35,5 @@
2935
background-color: rgba(0, 0, 0, 0.04);
3036

3137
transition: width 300ms ease-in-out;
32-
33-
&.selected {
34-
width: 16em;
35-
transition: width 300ms ease-in-out;
36-
}
37-
38-
img {
39-
width: 100%;
40-
display: flex;
41-
object-fit: cover;
42-
height: 24em;
43-
}
44-
45-
figcaption {
46-
display: flex;
47-
width: 100%;
48-
padding: 0.4em;
49-
position: absolute;
50-
bottom: 0;
51-
52-
background-color: rgba(0, 0, 0, 0.4);
53-
color: rgba(255, 255, 255, 0.6);
54-
55-
z-index: 100;
56-
57-
&:empty {
58-
display: none;
59-
}
60-
}
6138
}
6239
}
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,47 @@
1-
import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
1+
import { inject, Component, ChangeDetectionStrategy } from '@angular/core';
2+
import { Album, Authentication, Photo } from '@devmx/shared-api-interfaces';
3+
import { AlbumFacade, PhotoFacade } from '@devmx/album-data-access';
4+
import { AuthenticationFacade } from '@devmx/account-data-access';
25
import { ActivatedRoute, RouterModule } from '@angular/router';
3-
import { Album } from '@devmx/shared-api-interfaces';
6+
import { MatButtonModule } from '@angular/material/button';
47
import { AsyncPipe } from '@angular/common';
5-
import { filter, map } from 'rxjs';
8+
import { filter, map, take } from 'rxjs';
9+
import {
10+
PhotoComponent,
11+
PhotoViewerService,
12+
providePhotoViewer,
13+
} from '@devmx/album-ui-shared';
614

715
@Component({
816
selector: 'devmx-album',
917
templateUrl: './album.container.html',
1018
styleUrl: './album.container.scss',
1119
changeDetection: ChangeDetectionStrategy.OnPush,
12-
imports: [RouterModule, AsyncPipe],
20+
imports: [RouterModule, MatButtonModule, PhotoComponent, AsyncPipe],
21+
providers: [providePhotoViewer()],
1322
})
1423
export class AlbumContainer {
1524
route = inject(ActivatedRoute);
1625

26+
authFacade = inject(AuthenticationFacade);
27+
albumFacade = inject(AlbumFacade);
28+
photoFacade = inject(PhotoFacade);
29+
30+
photoViewer = inject(PhotoViewerService);
31+
1732
album$ = this.route.data.pipe(
1833
filter((data) => 'album' in data),
1934
map((data) => data['album'] as Album)
2035
);
36+
37+
open(photo: Photo, auth: Authentication) {
38+
this.photoViewer
39+
.open({ photo, auth })
40+
.closed.pipe(take(1))
41+
.subscribe(this.updateTags);
42+
}
43+
44+
updateTags = (photo?: Photo) => {
45+
if (photo) this.photoFacade.updateTags(photo);
46+
};
2147
}

‎packages/album/ui-shared/.eslintrc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"@angular-eslint/component-selector": [
2121
"error",
2222
{
23-
"type": "element",
23+
"type": ["element", "attribute"],
2424
"prefix": "devmx",
2525
"style": "kebab-case"
2626
}

‎packages/album/ui-shared/package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
"@angular/core": "19.0.0",
77
"@devmx/shared-ui-global": "0.0.1",
88
"@angular/material": "19.0.0",
9-
"@devmx/shared-api-interfaces": "0.0.1"
9+
"@devmx/shared-api-interfaces": "0.0.1",
10+
"@angular/cdk": "19.0.0",
11+
"@devmx/account-ui-shared": "0.0.1",
12+
"@devmx/shared-util-data": "0.0.1"
1013
},
1114
"sideEffects": false
1215
}
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1+
export * from './photo-viewer/photo-viewer.component';
2+
export * from './photo-viewer/photo-viewer.service';
13
export * from './album-card/album-card.component';
4+
export * from './tag-user/tag-user.component';
5+
export * from './tag-user/tag-user.service';
6+
export * from './photo/photo.component';
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Please sign in to comment.