Added ability to favorite a file

Moved file filter options above the list of files, and added option to filter for favorites
This commit is contained in:
Isaac Abadi
2022-12-28 21:48:24 -06:00
parent c45e0f04be
commit 665bcc04a7
15 changed files with 173 additions and 40 deletions

View File

@@ -1,4 +1,7 @@
<h4 mat-dialog-title>{{file.title}}</h4>
<h4 mat-dialog-title>
{{file.title}}
<button [disabled]="!initialized || retrieving_file" (click)="toggleFavorite()" mat-icon-button class="favorite-button"><mat-icon>{{file.favorite ? 'favorite_filled' : 'favorite_outline'}}</mat-icon></button>
</h4>
<mat-dialog-content>
<div style="width: 100%; position: relative;">

View File

@@ -23,4 +23,10 @@
.a-wrap {
word-wrap: break-word
}
.favorite-button {
position: absolute;
right: 4px;
top: 4px;
}

View File

@@ -19,6 +19,7 @@ export class VideoInfoDialogComponent implements OnInit {
category: Category;
editing = false;
initialized = false;
retrieving_file = false;
constructor(@Inject(MAT_DIALOG_DATA) public data: any, public postsService: PostsService, private datePipe: DatePipe) { }
@@ -58,9 +59,14 @@ export class VideoInfoDialogComponent implements OnInit {
}
getFile(): void {
this.retrieving_file = true;
this.postsService.getFile(this.file.uid).subscribe(res => {
this.retrieving_file = false;
this.file = res['file'];
this.initializeFile(this.file);
}, err => {
this.retrieving_file = false;
console.error(err);
});
}
@@ -85,4 +91,12 @@ export class VideoInfoDialogComponent implements OnInit {
return JSON.stringify(this.file) !== JSON.stringify(this.new_file);
}
toggleFavorite(): void {
this.file.favorite = !this.file.favorite;
this.retrieving_file = true;
this.postsService.updateFile(this.file.uid, {favorite: this.file.favorite}).subscribe(res => {
this.getFile();
});
}
}