diff --git a/frontend/src/app/core/components/navbar/navbar.component.html b/frontend/src/app/core/components/navbar/navbar.component.html index d8de4bd..c7a18de 100644 --- a/frontend/src/app/core/components/navbar/navbar.component.html +++ b/frontend/src/app/core/components/navbar/navbar.component.html @@ -17,13 +17,14 @@
diff --git a/frontend/src/app/core/components/navbar/navbar.component.ts b/frontend/src/app/core/components/navbar/navbar.component.ts index f7fbea6..793df41 100644 --- a/frontend/src/app/core/components/navbar/navbar.component.ts +++ b/frontend/src/app/core/components/navbar/navbar.component.ts @@ -1,22 +1,42 @@ -import { Component, ElementRef, HostListener } from '@angular/core'; +import { Component, ElementRef, HostListener, OnInit, ViewChild } from '@angular/core'; import { ToggleService } from '../../services/toggle.service'; import { Location } from '@angular/common'; +import { Router } from '@angular/router'; +import { FormControl } from '@angular/forms'; +import { debounceTime, distinctUntilChanged } from 'rxjs'; +import { SearchPopupComponent } from '../search-popup/search-popup.component'; @Component({ selector: 'app-navbar', templateUrl: './navbar.component.html', styleUrls: ['./navbar.component.css'], }) -export class NavbarComponent { +export class NavbarComponent implements OnInit { showSearchPopup: boolean = false; searchTerm: string = ''; + searchControl = new FormControl(); + @ViewChild(SearchPopupComponent) searchPopupComponent!: SearchPopupComponent; + constructor( private toggleService: ToggleService, private eRef: ElementRef, - private location: Location + private location: Location, + private router: Router ) {} + ngOnInit() { + this.searchControl.valueChanges + .pipe( + debounceTime(300), // Delay the API call by 300 milliseconds + distinctUntilChanged() // Only emit when the current value is different from the last + ) + .subscribe((value) => { + this.searchTerm = value; + this.searchPopupComponent.triggerSearch(value); + }); + } + toggleSidebar() { this.toggleService.toggleSidebar(); } @@ -29,6 +49,15 @@ export class NavbarComponent { // if (this.showSearchPopup) this.showSearchPopup = !this.showSearchPopup; } + doShowSearchPage() { + const searchTerm = this.searchControl.value.trim(); + if (searchTerm) { + this.router.navigate(['/search'], { + queryParams: { title: searchTerm }, + }); + } + } + @HostListener('document:click', ['$event']) clickout(event: { target: any }) { if ( diff --git a/frontend/src/app/core/components/search-popup/search-popup.component.css b/frontend/src/app/core/components/search-popup/search-popup.component.css index e69de29..5ae1fb1 100644 --- a/frontend/src/app/core/components/search-popup/search-popup.component.css +++ b/frontend/src/app/core/components/search-popup/search-popup.component.css @@ -0,0 +1,7 @@ +.circle { + width: 5px; + height: 5px; + background-color: #6c757d; + border-radius: 50%; + display: inline-block; +} \ No newline at end of file diff --git a/frontend/src/app/core/components/search-popup/search-popup.component.html b/frontend/src/app/core/components/search-popup/search-popup.component.html index 56b8c8b..4d88d9a 100644 --- a/frontend/src/app/core/components/search-popup/search-popup.component.html +++ b/frontend/src/app/core/components/search-popup/search-popup.component.html @@ -19,7 +19,28 @@Tutorials
+ +Movies & Tv-Series
++ {{ entry.release_date }} +
+