Skip to content

Commit

Permalink
feat: Delete photos
Browse files Browse the repository at this point in the history
  • Loading branch information
Clashsoft committed Jul 12, 2024
1 parent 115bf1b commit 4a4820c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 27 deletions.
1 change: 1 addition & 0 deletions src/app/audit/photos/photos.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
:
(item.auditName.auditName | uppercase)
}}
<button class="btn btn-link bi-trash" ngbTooltip="Delete" (click)="deletePhoto(item.id)"></button>
</div>
</div>
}
Expand Down
32 changes: 5 additions & 27 deletions src/app/audit/photos/photos.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,18 @@
.image-box {
position: relative;
overflow: hidden;
// padding: 4px;
// margin: 6px 3px;
// width: 50%;
// max-width: 300px;
min-height: 100px;
}

// img {
// display: block;
// width: 100%;
// height: auto;
// min-height: 230px;
// padding: 4px;
// }

// .imagee {
// background-color: #ebebeb;
// background-size: cover;
// background-position: center center;
// background-repeat: no-repeat;
// }

.overlay {
position: absolute;
bottom: 0;
// background: rgb(0, 0, 0);
background: rgba(0, 0, 0, 0.5); /* Black see-through */
color: #f1f1f1;
width: 100%;
transition: 0.7s ease;
opacity: 0;
color: white;
font-size: 15px;
padding: 10px;
text-align: center;
color: white;
background: rgba(0, 0, 0, 0.5); /* Black see-through */
opacity: 0;
transition: opacity 0.7s ease;
}

.image-box:hover .overlay {
Expand Down
8 changes: 8 additions & 0 deletions src/app/audit/photos/photos.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,12 @@ export class PhotosComponent implements OnInit {
changeSubType() {
this.getData({pageIndex: 0, pageSize: 8});
}

deletePhoto(id: number) {
this.auditService.deletePhoto(id).subscribe(() => {
this.data = this.data.filter((a: any) => a.id !== id);
this.data2 = this.data2.filter((a: any) => a.id !== id);
this.dataForLength = this.dataForLength.filter((a: any) => a.id !== id);
});
}
}
3 changes: 3 additions & 0 deletions src/app/shared/services/audit.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ export class AuditService {
getPhotos(auditId: Number): Observable<any> {
return this.http.get(`${this.rootUrl}api/auditPhoto?auditId=${auditId}`);
}
deletePhoto(id: number): Observable<any> {
return this.http.delete(`${this.rootUrl}api/auditPhoto`, {params: {id}});
}
uploadPhoto(auditId: Number, formData: any): Observable<any> {
return this.http.post(`${this.rootUrl}api/auditPhoto?auditId=${auditId}`, formData);
}
Expand Down

0 comments on commit 4a4820c

Please sign in to comment.