-
-
![]()
-
-
-
-
{{ entry.title }}
-
-
- {{ entry.release_date }}
-
+
+ Movies & Tv-Series
+
+
+
+
+
+
+
{{ entry.title }}
+
+
+ {{ entry.release_date | dateFormat }}
+
+
+
+
+
+
+
+ Please search for movies and TV series.
+
+
-
-
\ No newline at end of file
diff --git a/frontend/src/app/core/components/search-popup/search-popup.component.ts b/frontend/src/app/core/components/search-popup/search-popup.component.ts
index fa0aeeb..022ef94 100644
--- a/frontend/src/app/core/components/search-popup/search-popup.component.ts
+++ b/frontend/src/app/core/components/search-popup/search-popup.component.ts
@@ -2,7 +2,6 @@ import {
AfterViewInit,
Component,
ElementRef,
- Input,
OnInit,
ViewChild,
} from '@angular/core';
@@ -26,6 +25,8 @@ export class SearchPopupComponent implements OnInit, AfterViewInit {
searchedEntries: Entry[] = [] as Entry[];
recentSearches: SearchItem[] = [] as SearchItem[];
+ isAddLocked: boolean = false;
+
@ViewChild('scrollContainer', { static: true }) scrollContainer!: ElementRef;
private ps!: PerfectScrollbar;
@@ -37,6 +38,14 @@ export class SearchPopupComponent implements OnInit, AfterViewInit {
) {}
ngOnInit(): void {
+ this.getSearchHisotry();
+ }
+
+ ngAfterViewInit(): void {
+ this.ps = new PerfectScrollbar(this.scrollContainer.nativeElement);
+ }
+
+ getSearchHisotry() {
this.historyService.getSearchHistory().subscribe({
next: (result) => {
this.recentSearches = [
@@ -56,10 +65,7 @@ export class SearchPopupComponent implements OnInit, AfterViewInit {
});
}
- ngAfterViewInit(): void {
- this.ps = new PerfectScrollbar(this.scrollContainer.nativeElement);
- }
-
+ // ! search value is passed from parent by calling this function
triggerSearch(searchTerm: string) {
this.searchTerm = searchTerm;
this.searchedEntries = [] as Entry[];
@@ -93,4 +99,37 @@ export class SearchPopupComponent implements OnInit, AfterViewInit {
error: (error) => {},
});
}
+
+ addToLibrary(tmdbId: string, isTvSerie: boolean) {
+ this.isAddLocked = true;
+ let obs = this.libraryService.addEntry(tmdbId, isTvSerie).subscribe({
+ next: (entry) => {
+ if (entry != null) {
+ entry.isInLibrary = true;
+ this.libraryService.refreshEntries().subscribe();
+ this.searchedEntries.forEach((e) => {
+ if (e.entryId.tmdb_id == entry.entryId.tmdb_id) {
+ e.isInLibrary = true;
+ }
+ });
+ this.isAddLocked = false;
+ obs.unsubscribe();
+ }
+ },
+ error: (error) => {
+ // TODO error notification
+ console.error('Error adding entry:', error);
+ this.isAddLocked = false;
+ obs.unsubscribe();
+ },
+ });
+ }
+
+ doShowSearchPage() {
+ if (this.searchTerm) {
+ this.router.navigate(['/search'], {
+ queryParams: { title: this.searchTerm },
+ });
+ }
+ }
}
diff --git a/frontend/src/app/core/services/library.service.ts b/frontend/src/app/core/services/library.service.ts
index bb669ab..df310ae 100644
--- a/frontend/src/app/core/services/library.service.ts
+++ b/frontend/src/app/core/services/library.service.ts
@@ -17,12 +17,14 @@ export class LibraryService implements OnInit {
private backend_apiUrl = environment.API_URL;
private apiAction = 'entries';
- constructor(private http: HttpClient) {}
-
- ngOnInit() {
- this.fetchAllEntries();
+ constructor(private http: HttpClient) {
+ this.fetchAllEntries().subscribe(() => {
+ console.log(`Library Service: Loaded ${this.entries.length} entry.`);
+ });
}
+ ngOnInit() {}
+
getAllEntries(forceFetch: boolean = false): Observable
{
if (!forceFetch && this.entriesLoaded) {
return of(this.entries);
@@ -169,6 +171,7 @@ export class LibraryService implements OnInit {
// );
// }
public isInLibrary(tmdb_id: string): Observable {
+ console.log(`is in library called`);
const existingEntry = this.entries.find(
(entry) => entry.entryId.tmdb_id == tmdb_id
);