entry card: add redifrect to entry page + inlibrary badge

This commit is contained in:
X4Lo committed 2024-04-16 10:22:23 +01:00
1 parent d695e6fa0f
commit 7dec0d6149
3 files changed
+56 -14

No files matched your search

@@ -4,6 +4,7 @@ import { MatDialog } from '@angular/material/dialog';
import { trigger, transition, style, animate } from '@angular/animations';
import { Entry } from '../../../models/entry.model';
import { LibraryService } from '../../../../core/services/library.service';
import { Router } from '@angular/router';
@Component({
selector: 'app-main-card',
@@ -28,7 +29,8 @@ export class MainCardComponent implements OnInit {
constructor(
private libraryService: LibraryService,
public dialog: MatDialog
public dialog: MatDialog,
private router: Router
) {}
ngOnInit(): void {
@@ -59,6 +61,7 @@ export class MainCardComponent implements OnInit {
entry.isInLibrary = true;
this.entry = entry;
this.libraryService.getAllEntries(true);
console.log(entry);
}
},
error: (error) => {
@@ -77,9 +80,7 @@ export class MainCardComponent implements OnInit {
this.entry.isInLibrary = false;
},
error: (error) => {
// Handle error scenario
console.error('Error deleting entry:', error);
// Optionally, display an error message to the user using a service or a component
},
});
}
@@ -101,7 +102,8 @@ export class MainCardComponent implements OnInit {
}
cardClick() {
console.log(this.entry);
if (this.entry.isInLibrary)
this.router.navigate([`/entry/${this.entry.id}`]);
}
getTmdbLink() {
@@ -109,9 +111,15 @@ export class MainCardComponent implements OnInit {
return `https://www.themoviedb.org/${type}/${this.entry.entryId.tmdb_id}`;
}
getPostPath() {
if (this.entry.poster_path == null) return 'assets/images/default/default-poster.png';
get postPath() {
if (this.entry.poster_path == null)
return 'assets/images/default/default-poster.png';
return `https://image.tmdb.org/t/p/w500` + this.entry.poster_path;
return `https://image.tmdb.org/t/p/w154` + this.entry.poster_path;
}
get runtime() {
if (this.entry.runtime == null) return '';
return this.entry.runtime;
}
}