From 2f27c4cfdf71e43a341fb7624727689e892613a6 Mon Sep 17 00:00:00 2001 From: X4Lo Date: Wed, 3 Apr 2024 21:45:19 +0000 Subject: [PATCH] various changes --- frontend/src/app/app.module.ts | 12 ++- .../features/pages/lists/lists.component.ts | 4 +- .../list-selection-modal.component.css | 3 - .../list-selection-modal.component.html | 19 ----- .../list-selection-modal.component.spec.ts | 21 ----- .../list-selection-modal.component.ts | 77 ------------------- frontend/src/app/shared/models/list.model.ts | 6 ++ frontend/src/app/shared/shared.module.ts | 9 +-- 8 files changed, 21 insertions(+), 130 deletions(-) delete mode 100644 frontend/src/app/list-selection-modal/list-selection-modal.component.css delete mode 100644 frontend/src/app/list-selection-modal/list-selection-modal.component.html delete mode 100644 frontend/src/app/list-selection-modal/list-selection-modal.component.spec.ts delete mode 100644 frontend/src/app/list-selection-modal/list-selection-modal.component.ts diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts index a073ecb..b551159 100644 --- a/frontend/src/app/app.module.ts +++ b/frontend/src/app/app.module.ts @@ -4,7 +4,7 @@ import { BrowserModule } from '@angular/platform-browser'; import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; import { HttpClientModule } from '@angular/common/http'; -import { ReactiveFormsModule } from '@angular/forms'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { EntryListComponent } from './features/lists/entry-list/entry-list.component'; import { HomeComponent } from './features/pages/home/home.component'; import { SidebarComponent } from './core/components/sidebar/sidebar.component'; @@ -16,7 +16,7 @@ import { MainCardComponent } from './features/cards/main-card/main-card.componen import { DynamicEntryListComponent } from './features/lists/dynamic-entry-list/dynamic-entry-list.component'; import { LibraryComponent } from './features/pages/library/library.component'; import { CoreModule } from './core/core.module'; -import { ListSelectionModalComponent } from './list-selection-modal/list-selection-modal.component'; +import { ListSelectionModalComponent } from './features/modals/list-selection-modal/list-selection-modal.component'; import { MatDialogModule } from '@angular/material/dialog'; import { MatInputModule } from '@angular/material/input'; @@ -29,6 +29,7 @@ import { ListsComponent } from './features/pages/lists/lists.component'; import { UserListItemComponent } from './features/cards/user-list-item/user-list-item.component'; import { UserListItemCardComponent } from './features/cards/user-list-item-card/user-list-item-card.component'; import { DateFormatPipe } from './core/pipes/date-format/date-format.pipe'; +import { SharedModule } from './shared/shared.module'; @NgModule({ declarations: [ @@ -50,12 +51,15 @@ import { DateFormatPipe } from './core/pipes/date-format/date-format.pipe'; DateFormatPipe, ], imports: [ + CoreModule, + SharedModule, + BrowserModule, AppRoutingModule, HttpClientModule, ReactiveFormsModule, - CoreModule , - + FormsModule, + MatDialogModule, MatInputModule, MatButtonModule, diff --git a/frontend/src/app/features/pages/lists/lists.component.ts b/frontend/src/app/features/pages/lists/lists.component.ts index 00c9fbb..6eb0e8f 100644 --- a/frontend/src/app/features/pages/lists/lists.component.ts +++ b/frontend/src/app/features/pages/lists/lists.component.ts @@ -11,6 +11,7 @@ import { ListService } from '../../../core/services/list.service'; export class ListsComponent implements OnInit { searchControl = new FormControl(''); showAddButton: boolean = false; + listsCount: number = 0; lists: List[] = []; listsToShow: List[] = []; @@ -27,8 +28,8 @@ export class ListsComponent implements OnInit { getLists() { this.listService.getLists().subscribe({ next: (l) => { + console.log(`Loaded ${l.length} lists.`); this.lists = l; - console.log(this.lists); this.listsToShow = this.lists; this.applyFilter(); }, @@ -50,6 +51,7 @@ export class ListsComponent implements OnInit { this.listsToShow = this.lists.filter((collection) => collection.name.toLowerCase().trim().includes(normalizedFilter) ); + this.listsCount = this.listsToShow.length; } createList() { diff --git a/frontend/src/app/list-selection-modal/list-selection-modal.component.css b/frontend/src/app/list-selection-modal/list-selection-modal.component.css deleted file mode 100644 index 53a4bc5..0000000 --- a/frontend/src/app/list-selection-modal/list-selection-modal.component.css +++ /dev/null @@ -1,3 +0,0 @@ -mat-form-field { - width: 100%; -} \ No newline at end of file diff --git a/frontend/src/app/list-selection-modal/list-selection-modal.component.html b/frontend/src/app/list-selection-modal/list-selection-modal.component.html deleted file mode 100644 index a436eb4..0000000 --- a/frontend/src/app/list-selection-modal/list-selection-modal.component.html +++ /dev/null @@ -1,19 +0,0 @@ -

Choose a list

- - - List Name - - - - - - - - {{list.name}} - - - - - - - \ No newline at end of file diff --git a/frontend/src/app/list-selection-modal/list-selection-modal.component.spec.ts b/frontend/src/app/list-selection-modal/list-selection-modal.component.spec.ts deleted file mode 100644 index 8cd84ea..0000000 --- a/frontend/src/app/list-selection-modal/list-selection-modal.component.spec.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { ListSelectionModalComponent } from './list-selection-modal.component'; - -describe('ListSelectionModalComponent', () => { - let component: ListSelectionModalComponent; - let fixture: ComponentFixture; - - beforeEach(() => { - TestBed.configureTestingModule({ - declarations: [ListSelectionModalComponent] - }); - fixture = TestBed.createComponent(ListSelectionModalComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/frontend/src/app/list-selection-modal/list-selection-modal.component.ts b/frontend/src/app/list-selection-modal/list-selection-modal.component.ts deleted file mode 100644 index afb5f53..0000000 --- a/frontend/src/app/list-selection-modal/list-selection-modal.component.ts +++ /dev/null @@ -1,77 +0,0 @@ -import { Component, Inject, OnInit } from '@angular/core'; -import { FormControl } from '@angular/forms'; -import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; -import { ListService } from '../core/services/list.service'; -import { List } from '../shared/models/list.model'; - -@Component({ - selector: 'app-list-selection-modal', - templateUrl: './list-selection-modal.component.html', - styleUrls: ['./list-selection-modal.component.css'], -}) -export class ListSelectionModalComponent implements OnInit { - searchControl = new FormControl(''); - showAddButton: boolean = false; - - lists: List[] = []; - listsToShow: List[] = []; - - constructor( - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: any, - private listService: ListService - ) {} - - ngOnInit() { - this.getLists(); - - this.searchControl.valueChanges.subscribe((value) => { - this.applyFilter(value); - }); - } - - getLists() { - this.listService.getLists().subscribe({ - next: (l) => { - this.lists = l; - this.listsToShow = this.lists; - this.applyFilter(this.searchControl.value); - - }, - error: (error) => { - console.log("Counldn't get lists from backend."); - }, - }); - } - - applyFilter(filterValue: string | null) { - if (filterValue == null) { - this.listsToShow = [...this.lists]; // Show all lists if filter is cleared or null - this.showAddButton = false; // Assuming you want to hide the button when there's no filter - return; - } - - const normalizedFilter = filterValue.toLowerCase().trim(); - - this.listsToShow = this.lists.filter((collection) => - collection.name.toLowerCase().trim().includes(normalizedFilter) - ); - - this.showAddButton = this.listsToShow.length === 0; - } - - createList() { - const listName = this.searchControl.value; // string - - let myNewList = { name: listName } as List; - - this.listService.createList(myNewList).subscribe(async (list) => { - await this.getLists(); - console.log(this.searchControl.value); - }); - } - - doShowAddButton(): boolean { - return this.showAddButton; - } -} diff --git a/frontend/src/app/shared/models/list.model.ts b/frontend/src/app/shared/models/list.model.ts index f5e501e..cee6471 100644 --- a/frontend/src/app/shared/models/list.model.ts +++ b/frontend/src/app/shared/models/list.model.ts @@ -1,3 +1,5 @@ +import { ListEntry } from './listEntry.model'; + export interface List { id: number; @@ -7,6 +9,10 @@ export interface List { poster_path: string; + listEntries: ListEntry[]; + changed: boolean; + isChecked: boolean; + createdAt: Date; modifiedAt: Date; } diff --git a/frontend/src/app/shared/shared.module.ts b/frontend/src/app/shared/shared.module.ts index 4f435be..cfeba23 100644 --- a/frontend/src/app/shared/shared.module.ts +++ b/frontend/src/app/shared/shared.module.ts @@ -1,11 +1,10 @@ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; +import { NotificationPopupComponent } from './notification-popup/notification-popup.component'; @NgModule({ - declarations: [], - imports: [ - CommonModule, // Common module for common directives - ], - exports: [], + declarations: [NotificationPopupComponent], + imports: [CommonModule], + exports: [NotificationPopupComponent], }) export class SharedModule {}