Renamed many components + started implementing lazy loading
This commit is contained in:
1 parent
c8578ccf77
commit
60b517500f
80 files changed
+274
-242
No files matched your search
@@ -1,21 +0,0 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ListEntryCardComponent } from './list-entry-card.component';
|
||||
|
||||
describe('ListEntryCardComponent', () => {
|
||||
let component: ListEntryCardComponent;
|
||||
let fixture: ComponentFixture<ListEntryCardComponent>;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ListEntryCardComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(ListEntryCardComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -1,176 +0,0 @@
|
||||
.movie-card {
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.movie-card .card-head {
|
||||
position: relative;
|
||||
border-radius: 10px;
|
||||
height: auto;
|
||||
overflow: hidden;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
.movie-card .card-img {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
aspect-ratio: 2 / 3;
|
||||
object-fit: cover;
|
||||
transition: transform 0.3s ease;
|
||||
}
|
||||
|
||||
.movie-card .card-body {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
color: #fff;
|
||||
padding: 10px;
|
||||
box-sizing: border-box;
|
||||
|
||||
transition: max-height 0.3s ease, padding 0.3s ease;
|
||||
overflow: hidden;
|
||||
max-height: 60px;
|
||||
}
|
||||
|
||||
/* * HOVER */
|
||||
.movie-card:hover .card-img {
|
||||
transform: scale(1.1);
|
||||
}
|
||||
.movie-card .card-overlay {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
opacity: 0;
|
||||
backdrop-filter: blur(2px);
|
||||
}
|
||||
|
||||
.movie-card:hover .card-overlay {
|
||||
opacity: 1;
|
||||
transition: 0.3s ease;
|
||||
}
|
||||
|
||||
.movie-card:hover .card-body {
|
||||
max-height: 100px;
|
||||
padding: 12px;
|
||||
}
|
||||
.movie-card:hover .card-title {
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
/* ! HOVER END*/
|
||||
|
||||
/* * BUTTONS */
|
||||
.movie-card .bookmark,
|
||||
.movie-card .info,
|
||||
.movie-card .rating {
|
||||
position: absolute;
|
||||
top: 15px;
|
||||
padding: 6px;
|
||||
border-radius: 10px;
|
||||
color: var(--light-azure);
|
||||
transform: scale(var(--mv-card-scale));
|
||||
background: rgba(51, 50, 50, 0.224);
|
||||
color: var(--white);
|
||||
}
|
||||
|
||||
.movie-card .bookmark {
|
||||
left: 15px;
|
||||
}
|
||||
.movie-card .info {
|
||||
left: 15px;
|
||||
top: 60px;
|
||||
}
|
||||
|
||||
.movie-card .bookmark i,
|
||||
.movie-card .info i {
|
||||
size: 50px;
|
||||
font-size: 30px;
|
||||
}
|
||||
|
||||
.movie-card .bookmark:hover,
|
||||
.movie-card .info:hover {
|
||||
color: var(--light-azure);
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
transition: color 0.3s ease, background-color 0.3s ease;
|
||||
}
|
||||
.movie-card:hover :is(.bookmark, .rating, .info) {
|
||||
--mv-card-scale: 1;
|
||||
}
|
||||
.bookmark,
|
||||
.info {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
/* ? rating */
|
||||
.movie-card .rating {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
right: 15px;
|
||||
/* color: var(--light-azure); */
|
||||
color: var(--white);
|
||||
}
|
||||
.movie-card .rating span {
|
||||
/* color: var(--light-azure); */
|
||||
color: var(--white);
|
||||
font-size: 15px;
|
||||
font-weight: var(--fw-5);
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
.movie-card .rating i {
|
||||
font-size: 15px;
|
||||
font-weight: var(--fw-5);
|
||||
}
|
||||
|
||||
/* ! BUTTONS */
|
||||
|
||||
.movie-card .card-title {
|
||||
font-size: 1.05em;
|
||||
font-weight: var(--fw-5);
|
||||
margin-bottom: 5px;
|
||||
|
||||
width: auto;
|
||||
white-space: nowrap;
|
||||
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.movie-card:hover .card-title,
|
||||
.movie-card:hover .card-info {
|
||||
text-overflow: clip;
|
||||
color: var(--white);
|
||||
}
|
||||
|
||||
.movie-card:hover .card-title {
|
||||
color: var(--yellow);
|
||||
}
|
||||
.movie-card .card-info {
|
||||
display: flex;
|
||||
font-family: -apple-system, "Segoe UI", BlinkMacSystemFont, sans-serif;
|
||||
font-size: 15px;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.movie-card .duration {
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.card-dot {
|
||||
width: 3px;
|
||||
height: 3px;
|
||||
vertical-align: 2px;
|
||||
border-radius: 50%;
|
||||
display: inline-block;
|
||||
background: #6d7583;
|
||||
content: "";
|
||||
margin: 9px 6px;
|
||||
}
|
||||
|
||||
.movie-card .card-title,
|
||||
.movie-card .card-info {
|
||||
color: #fff;
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
<div class="movie-card" @fadeInOut>
|
||||
<div class="card-head">
|
||||
<img class="card-img" [src]="getPostPath()" alt="Movie Poster">
|
||||
|
||||
<div class="card-overlay" (click)="cardClick()">
|
||||
<div class="rating">
|
||||
<i class='bx bx-star'></i>
|
||||
<span>{{formattedRate}}</span>
|
||||
</div>
|
||||
<div class="bookmark" *ngIf="!entry.isInLibrary">
|
||||
<i class='bx bxs-add-to-queue' (click)="addEntry(entry.entryId.tmdb_id, entry.is_tvseries)"></i>
|
||||
</div>
|
||||
<div class="bookmark" *ngIf="entry.isInLibrary">
|
||||
<i class='bx bxs-trash' (click)="removeEntry(entry.id)" style="color: #d42f50;"></i>
|
||||
</div>
|
||||
|
||||
<!-- <div [ngClass]="{'info': !entry.isInLibrary, 'bookmark': entry.isInLibrary}"> -->
|
||||
<div class="info" *ngIf="entry.isInLibrary">
|
||||
<i class='bx bx-list-plus' (click)="showAddToListModal()"></i>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- card body moved inside card head -->
|
||||
<div class="card-body" (click)="cardClick()">
|
||||
<a [href]="getTmdbLink()" target="_blank" rel="noopener noreferrer">
|
||||
<h3 class="card-title">{{ entry.title }}</h3>
|
||||
</a>
|
||||
<div class="card-info">
|
||||
<span class="Year">{{releaseYear}}</span>
|
||||
<i class="card-dot"></i>
|
||||
<span class="duration">137 min</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,21 +0,0 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { MainCardComponent } from './main-card.component';
|
||||
|
||||
describe('MainCardComponent', () => {
|
||||
let component: MainCardComponent;
|
||||
let fixture: ComponentFixture<MainCardComponent>;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [MainCardComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(MainCardComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -1,117 +0,0 @@
|
||||
import { Component, Input, OnInit } from '@angular/core';
|
||||
import { Entry } from '../../../shared/models/entry.model';
|
||||
import { LibraryService } from '../../../core/services/library.service';
|
||||
import { ListSelectionModalComponent } from '../../modals/list-selection-modal/list-selection-modal.component';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { trigger, transition, style, animate } from '@angular/animations';
|
||||
|
||||
@Component({
|
||||
selector: 'app-main-card',
|
||||
templateUrl: './main-card.component.html',
|
||||
styleUrls: ['./main-card.component.css'],
|
||||
animations: [
|
||||
trigger('fadeInOut', [
|
||||
transition(':enter', [
|
||||
// :enter is alias for 'void => *'
|
||||
style({ opacity: 0 }),
|
||||
animate('0.5s ease-out', style({ opacity: 1 })),
|
||||
]),
|
||||
transition(':leave', [
|
||||
// :leave is alias for '* => void'
|
||||
animate('0.5s ease-in', style({ opacity: 0 })),
|
||||
]),
|
||||
]),
|
||||
],
|
||||
})
|
||||
export class MainCardComponent implements OnInit {
|
||||
@Input() entry!: Entry;
|
||||
|
||||
constructor(
|
||||
private libraryService: LibraryService,
|
||||
public dialog: MatDialog
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.libraryService.isInLibrary(this.entry.entryId.tmdb_id).subscribe({
|
||||
next: (e) => {
|
||||
if (e != null) {
|
||||
e.isInLibrary = true;
|
||||
this.entry = e;
|
||||
}
|
||||
},
|
||||
error: (error) => {},
|
||||
});
|
||||
}
|
||||
|
||||
get releaseYear(): number {
|
||||
return new Date(this.entry.release_date).getFullYear();
|
||||
}
|
||||
|
||||
get formattedRate(): string {
|
||||
return this.entry.entryRating.tmdb_rating.toFixed(1);
|
||||
}
|
||||
|
||||
addEntry(tmdb_id: string, is_tvserie: boolean) {
|
||||
console.log('Adding Entry To Library.');
|
||||
this.libraryService.addEntry(tmdb_id, is_tvserie).subscribe({
|
||||
next: (entry) => {
|
||||
if (entry != null) {
|
||||
entry.isInLibrary = true;
|
||||
this.entry = entry;
|
||||
this.libraryService.getAllEntries(true);
|
||||
}
|
||||
},
|
||||
error: (error) => {
|
||||
console.error('Error adding entry:', error);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
removeEntry(id: number) {
|
||||
console.log('Deleting Entry From Library.');
|
||||
this.libraryService.deleteEntry(id).subscribe({
|
||||
next: (response) => {
|
||||
// Handle successful deletion
|
||||
console.log('Entry successfully deleted.', response);
|
||||
this.entry.id = 0;
|
||||
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
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
showAddToListModal() {
|
||||
if (this.entry) {
|
||||
const dialogRef = this.dialog.open(ListSelectionModalComponent, {
|
||||
width: '400px',
|
||||
height: '55%',
|
||||
data: {
|
||||
entryId: this.entry.id,
|
||||
},
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe((result) => {
|
||||
console.log('Modal Closed: ', result);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
cardClick() {
|
||||
console.log(this.entry);
|
||||
}
|
||||
|
||||
getTmdbLink() {
|
||||
let type = this.entry.is_tvseries ? 'tv' : 'movie';
|
||||
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';
|
||||
|
||||
return `https://image.tmdb.org/t/p/w500` + this.entry.poster_path;
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
<p>user-list-item-card works!</p>
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { UserListItemCardComponent } from './user-list-item-card.component';
|
||||
|
||||
describe('UserListItemCardComponent', () => {
|
||||
let component: UserListItemCardComponent;
|
||||
let fixture: ComponentFixture<UserListItemCardComponent>;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [UserListItemCardComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(UserListItemCardComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -1,10 +0,0 @@
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-user-list-item-card',
|
||||
templateUrl: './user-list-item-card.component.html',
|
||||
styleUrls: ['./user-list-item-card.component.css']
|
||||
})
|
||||
export class UserListItemCardComponent {
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { UserListItemComponent } from './user-list-item.component';
|
||||
|
||||
describe('UserListItemComponent', () => {
|
||||
let component: UserListItemComponent;
|
||||
let fixture: ComponentFixture<UserListItemComponent>;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [UserListItemComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(UserListItemComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,21 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { Routes, RouterModule } from '@angular/router';
|
||||
import { UserCollectionsPageComponent } from './user-collections/userCollections-page/userCollections-page.component';
|
||||
import { UserCollectionInfoPageComponent } from './user-collection-info/userCollection-info-page/userCollection-info-page.component';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: UserCollectionsPageComponent
|
||||
},
|
||||
{
|
||||
path: ':id',
|
||||
component: UserCollectionInfoPageComponent
|
||||
}
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forChild(routes)],
|
||||
exports: [RouterModule]
|
||||
})
|
||||
export class CollectionsRoutingModule { }
|
||||
File renamed without changes.
+2
-2
@@ -1,5 +1,5 @@
|
||||
<div class="movies-container" cdkDropList [cdkDropListData]="entries" (cdkDropListDropped)="drop($any($event))">
|
||||
<app-list-entry-card cdkDrag *ngFor="let entry of entries" [entry]="entry" [listId]="listId"
|
||||
<app-userCollection-grid-card cdkDrag *ngFor="let entry of entries" [entry]="entry" [listId]="listId"
|
||||
(refrechEvent)="refrechEventReceiver()">
|
||||
</app-list-entry-card>
|
||||
</app-userCollection-grid-card>
|
||||
</div>
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { UserCollectionEntryGridComponent } from './user-collection-entry-grid.component';
|
||||
import { UserCollectionEntryGridComponent } from './userCollection-entry-grid.component';
|
||||
|
||||
describe('UserCollectionEntryGridComponent', () => {
|
||||
let component: UserCollectionEntryGridComponent;
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { Entry } from '../../../shared/models/entry.model';
|
||||
import { Entry } from '../../../../shared/models/entry.model';
|
||||
import {
|
||||
CdkDragDrop,
|
||||
CdkDragEnd,
|
||||
@@ -8,9 +8,9 @@ import {
|
||||
} from '@angular/cdk/drag-drop';
|
||||
|
||||
@Component({
|
||||
selector: 'app-user-collection-entry-grid',
|
||||
templateUrl: './user-collection-entry-grid.component.html',
|
||||
styleUrls: ['./user-collection-entry-grid.component.css'],
|
||||
selector: 'app-userCollection-entry-grid',
|
||||
templateUrl: './userCollection-entry-grid.component.html',
|
||||
styleUrls: ['./userCollection-entry-grid.component.css'],
|
||||
})
|
||||
export class UserCollectionEntryGridComponent {
|
||||
@Input() entries: Entry[] = [];
|
||||
File renamed without changes.
File renamed without changes.
+21
@@ -0,0 +1,21 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { UserCollectionGridCardComponent } from './userCollection-grid-card.component';
|
||||
|
||||
describe('UserCollectionGridCardComponent', () => {
|
||||
let component: UserCollectionGridCardComponent;
|
||||
let fixture: ComponentFixture<UserCollectionGridCardComponent>;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [UserCollectionGridCardComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(UserCollectionGridCardComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
+7
-7
@@ -1,14 +1,14 @@
|
||||
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { LibraryService } from '../../../core/services/library.service';
|
||||
import { Entry } from '../../../shared/models/entry.model';
|
||||
import { LibraryService } from '../../../../core/services/library.service';
|
||||
import { Entry } from '../../../../shared/models/entry.model';
|
||||
import { trigger, transition, style, animate } from '@angular/animations';
|
||||
import { ListService } from '../../../core/services/list.service';
|
||||
import { ListService } from '../../../../core/services/list.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-list-entry-card',
|
||||
templateUrl: './list-entry-card.component.html',
|
||||
styleUrls: ['./list-entry-card.component.css'],
|
||||
selector: 'app-userCollection-grid-card',
|
||||
templateUrl: './userCollection-grid-card.component.html',
|
||||
styleUrls: ['./userCollection-grid-card.component.css'],
|
||||
animations: [
|
||||
trigger('fadeInOut', [
|
||||
transition(':enter', [
|
||||
@@ -19,7 +19,7 @@ import { ListService } from '../../../core/services/list.service';
|
||||
]),
|
||||
],
|
||||
})
|
||||
export class ListEntryCardComponent {
|
||||
export class UserCollectionGridCardComponent {
|
||||
@Input() entry!: Entry;
|
||||
@Input() listId: string = '';
|
||||
@Output() refrechEvent = new EventEmitter();
|
||||
File renamed without changes.
+1
-1
@@ -28,7 +28,7 @@
|
||||
<div *ngIf="list.description != ''">{{list.description}}</div>
|
||||
<hr>
|
||||
<div>
|
||||
<app-user-collection-entry-grid [entries]="list.entries" [listId]="getListId()"></app-user-collection-entry-grid>
|
||||
<app-userCollection-entry-grid [entries]="list.entries" [listId]="getListId()"></app-userCollection-entry-grid>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { UserCollectionInfoPageComponent } from './userCollection-info-page.component';
|
||||
|
||||
describe('UserCollectionInfoPageComponent', () => {
|
||||
let component: UserCollectionInfoPageComponent;
|
||||
let fixture: ComponentFixture<UserCollectionInfoPageComponent>;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [UserCollectionInfoPageComponent],
|
||||
});
|
||||
fixture = TestBed.createComponent(UserCollectionInfoPageComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
+9
-9
@@ -1,18 +1,18 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { ListService } from '../../core/services/list.service';
|
||||
import { List } from '../../shared/models/list.model';
|
||||
import { Entry } from '../../shared/models/entry.model';
|
||||
import { ListService } from '../../../../core/services/list.service';
|
||||
import { UserCollection } from '../../../../shared/models/userCollection.model';
|
||||
import { Entry } from '../../../../shared/models/entry.model';
|
||||
import { DatePipe } from '@angular/common';
|
||||
|
||||
@Component({
|
||||
selector: 'app-list-info',
|
||||
templateUrl: './list-info.component.html',
|
||||
styleUrls: ['./list-info.component.css'],
|
||||
selector: 'app-userCollection-info-page',
|
||||
templateUrl: './userCollection-info-page.component.html',
|
||||
styleUrls: ['./userCollection-info-page.component.css'],
|
||||
providers: [DatePipe],
|
||||
})
|
||||
export class ListInfoComponent {
|
||||
list: List = {} as List;
|
||||
export class UserCollectionInfoPageComponent {
|
||||
list: UserCollection = {} as UserCollection;
|
||||
createdAt: string = '';
|
||||
updatedAt: string = '';
|
||||
|
||||
@@ -29,7 +29,7 @@ export class ListInfoComponent {
|
||||
this.listService.getList(id.toString()).subscribe(
|
||||
(data) => {
|
||||
// Handle the successful reception of data.
|
||||
this.list = data as unknown as List;
|
||||
this.list = data as unknown as UserCollection;
|
||||
this.list.entries = this.list.entries as Entry[];
|
||||
|
||||
this.createdAt = this.getCreatedDate()?.toString() || '';
|
||||
@@ -0,0 +1,33 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { AppRoutingModule } from '../../app-routing.module';
|
||||
import { CollectionsRoutingModule } from './collections-routing.module';
|
||||
import { SharedModule } from '../../shared/shared.module';
|
||||
import { UserCollectionsPageComponent } from './user-collections/userCollections-page/userCollections-page.component';
|
||||
import { UserCollectionsListItemComponent } from './user-collections/userCollection-list-item/userCollections-list-item.component';
|
||||
import { UserCollectionEntryGridComponent } from './user-collection-info/userCollection-entry-grid/userCollection-entry-grid.component';
|
||||
import { UserCollectionGridCardComponent } from './user-collection-info/userCollection-grid-card/userCollection-grid-card.component';
|
||||
import { UserCollectionInfoPageComponent } from './user-collection-info/userCollection-info-page/userCollection-info-page.component';
|
||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
import { DragDropModule } from '@angular/cdk/drag-drop';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
UserCollectionEntryGridComponent,
|
||||
UserCollectionGridCardComponent,
|
||||
UserCollectionInfoPageComponent,
|
||||
|
||||
UserCollectionsPageComponent,
|
||||
UserCollectionsListItemComponent,
|
||||
],
|
||||
imports: [
|
||||
CommonModule,
|
||||
SharedModule,
|
||||
CollectionsRoutingModule,
|
||||
FormsModule,
|
||||
ReactiveFormsModule,
|
||||
DragDropModule,
|
||||
],
|
||||
exports: [],
|
||||
})
|
||||
export class UserCollectionsModule {}
|
||||
File renamed without changes.
File renamed without changes.
+21
@@ -0,0 +1,21 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { UserCollectionsListItemComponent } from './userCollections-list-item.component';
|
||||
|
||||
describe('UserCollectionsListItemComponent', () => {
|
||||
let component: UserCollectionsListItemComponent;
|
||||
let fixture: ComponentFixture<UserCollectionsListItemComponent>;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [UserCollectionsListItemComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(UserCollectionsListItemComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
+7
-7
@@ -1,13 +1,13 @@
|
||||
import { Component, Input} from '@angular/core';
|
||||
import { List } from '../../../shared/models/list.model';
|
||||
import { ListService } from '../../../core/services/list.service';
|
||||
import { UserCollection } from '../../../../shared/models/userCollection.model';
|
||||
import { ListService } from '../../../../core/services/list.service';
|
||||
import { Router } from '@angular/router';
|
||||
import { trigger, transition, style, animate } from '@angular/animations';
|
||||
|
||||
@Component({
|
||||
selector: 'app-user-list-item',
|
||||
templateUrl: './user-list-item.component.html',
|
||||
styleUrls: ['./user-list-item.component.css'],
|
||||
selector: 'app-userCollections-list-item',
|
||||
templateUrl: './userCollections-list-item.component.html',
|
||||
styleUrls: ['./userCollections-list-item.component.css'],
|
||||
animations: [
|
||||
trigger('fadeInOut', [
|
||||
transition(':enter', [
|
||||
@@ -22,8 +22,8 @@ import { trigger, transition, style, animate } from '@angular/animations';
|
||||
]),
|
||||
],
|
||||
})
|
||||
export class UserListItemComponent {
|
||||
@Input() list!: List;
|
||||
export class UserCollectionsListItemComponent {
|
||||
@Input() list!: UserCollection;
|
||||
|
||||
constructor(private listService: ListService, private router: Router) {}
|
||||
|
||||
File renamed without changes.
+1
-1
@@ -30,7 +30,7 @@
|
||||
<div class="p-3 ps ps--active-y">
|
||||
<div class="d-flex flex-column gap-3">
|
||||
<!-- item start -->
|
||||
<app-user-list-item *ngFor="let list of listsToShow" [list]="list"></app-user-list-item>
|
||||
<app-userCollections-list-item *ngFor="let list of listsToShow" [list]="list"></app-userCollections-list-item>
|
||||
<!-- item end -->
|
||||
</div>
|
||||
</div>
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { UserCollectionsPageComponent } from './userCollections-page.component';
|
||||
|
||||
describe('UserCollectionsPageComponent', () => {
|
||||
let component: UserCollectionsPageComponent;
|
||||
let fixture: ComponentFixture<UserCollectionsPageComponent>;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [UserCollectionsPageComponent],
|
||||
});
|
||||
fixture = TestBed.createComponent(UserCollectionsPageComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
+8
-8
@@ -1,20 +1,20 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { FormControl } from '@angular/forms';
|
||||
import { List } from '../../../shared/models/list.model';
|
||||
import { ListService } from '../../../core/services/list.service';
|
||||
import { UserCollection } from '../../../../shared/models/userCollection.model';
|
||||
import { ListService } from '../../../../core/services/list.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-lists',
|
||||
templateUrl: './lists.component.html',
|
||||
styleUrls: ['./lists.component.css'],
|
||||
selector: 'app-userCollections-page',
|
||||
templateUrl: './userCollections-page.component.html',
|
||||
styleUrls: ['./userCollections-page.component.css'],
|
||||
})
|
||||
export class ListsComponent implements OnInit {
|
||||
export class UserCollectionsPageComponent implements OnInit {
|
||||
searchControl = new FormControl('');
|
||||
showAddButton: boolean = false;
|
||||
listsCount: number = 0;
|
||||
|
||||
lists: List[] = [];
|
||||
listsToShow: List[] = [];
|
||||
lists: UserCollection[] = [];
|
||||
listsToShow: UserCollection[] = [];
|
||||
|
||||
constructor(private listService: ListService) {}
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { Entry } from '../../../shared/models/entry.model';
|
||||
import { TmdbService } from '../../../core/services/tmdb.service';
|
||||
import { Entry } from '../../../shared/models/entry.model';
|
||||
|
||||
@Component({
|
||||
selector: 'app-popular',
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { TmdbService } from '../../../core/services/tmdb.service';
|
||||
import { Entry } from '../../../shared/models/entry.model';
|
||||
import { TmdbService } from '../../../core/services/tmdb.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-search',
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+2
-2
@@ -1,6 +1,6 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { Entry } from '../../../shared/models/entry.model';
|
||||
import { LibraryService } from '../../../core/services/library.service';
|
||||
import { Entry } from '../../shared/models/entry.model';
|
||||
import { LibraryService } from '../../core/services/library.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-library',
|
||||
@@ -1,21 +0,0 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ListInfoComponent } from './list-info.component';
|
||||
|
||||
describe('ListInfoComponent', () => {
|
||||
let component: ListInfoComponent;
|
||||
let fixture: ComponentFixture<ListInfoComponent>;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ListInfoComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(ListInfoComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -1,12 +0,0 @@
|
||||
.movies-container {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill,
|
||||
minmax(160px, 2fr));
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.pagination-container {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
<!-- Entries Container/Grid -->
|
||||
<div class="movies-container">
|
||||
<app-main-card *ngFor="let entry of entries" [entry]="entry"></app-main-card>
|
||||
</div>
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { DynamicEntryListComponent } from './dynamic-entry-list.component';
|
||||
|
||||
describe('DynamicEntryListComponent', () => {
|
||||
let component: DynamicEntryListComponent;
|
||||
let fixture: ComponentFixture<DynamicEntryListComponent>;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [DynamicEntryListComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(DynamicEntryListComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -1,11 +0,0 @@
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { Entry } from '../../../shared/models/entry.model';
|
||||
|
||||
@Component({
|
||||
selector: 'app-dynamic-entry-list',
|
||||
templateUrl: './dynamic-entry-list.component.html',
|
||||
styleUrls: ['./dynamic-entry-list.component.css'],
|
||||
})
|
||||
export class DynamicEntryListComponent {
|
||||
@Input() entries: Entry[] = [];
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
|
||||
.movies-container {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(
|
||||
auto-fill,
|
||||
minmax(200px, 1fr)
|
||||
); /* Creates a responsive grid */
|
||||
gap: 20px; /* Space between items */
|
||||
/* padding: 20px;Padding around the grid */
|
||||
}
|
||||
|
||||
.pagination-container {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
<!-- Entries Container/Grid -->
|
||||
<div class="movies-container">
|
||||
<app-main-card *ngFor="let entry of entries" [entry]="entry"></app-main-card>
|
||||
</div>
|
||||
|
||||
<!-- Pagination -->
|
||||
<div class="pagination-container">
|
||||
<ul class="pagination pagination-sm">
|
||||
<li class="page-item" [class.disabled]="currentPage === 1">
|
||||
<a class="page-link" href="javascript:;" (click)="goToPage(currentPage - 1)">Previous</a>
|
||||
</li>
|
||||
<!-- Dynamically generate page numbers -->
|
||||
<li class="page-item" *ngFor="let page of pageNumbers" [class.active]="currentPage === page">
|
||||
<a class="page-link" href="javascript:;" (click)="goToPage(page)">{{ page }}</a>
|
||||
</li>
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="javascript:;" (click)="goToPage(currentPage + 1)">Next</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -1,21 +0,0 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { EntryListComponent } from './entry-list.component';
|
||||
|
||||
describe('EntryListComponent', () => {
|
||||
let component: EntryListComponent;
|
||||
let fixture: ComponentFixture<EntryListComponent>;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [EntryListComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(EntryListComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -1,59 +0,0 @@
|
||||
import { Component, Input, OnInit } from '@angular/core';
|
||||
import { TmdbService } from '../../../core/services/tmdb.service';
|
||||
import { Entry } from '../../../shared/models/entry.model';
|
||||
|
||||
@Component({
|
||||
selector: 'app-entry-list',
|
||||
templateUrl: './entry-list.component.html',
|
||||
styleUrls: ['./entry-list.component.css'],
|
||||
})
|
||||
export class EntryListComponent implements OnInit {
|
||||
@Input() isMovies: boolean = true;
|
||||
@Input() type: string = '';
|
||||
entries: Entry[] = [];
|
||||
pages: Record<number, Entry[]> = {};
|
||||
currentPage: number = 1;
|
||||
|
||||
constructor(private tmdbService: TmdbService) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.fetchMovies();
|
||||
}
|
||||
|
||||
fetchMovies() {
|
||||
if (this.type == 'popular') {
|
||||
if (this.pages[this.currentPage]) {
|
||||
console.log('page existe deja');
|
||||
this.entries = this.pages[this.currentPage];
|
||||
} else {
|
||||
console.log("page n'existe pas");
|
||||
this.tmdbService
|
||||
.getPopular(this.currentPage, this.isMovies)
|
||||
.subscribe((myEntries) => {
|
||||
this.pages[this.currentPage] = myEntries;
|
||||
this.entries = this.pages[this.currentPage];
|
||||
});
|
||||
}
|
||||
} else if (this.type == 'trending') {
|
||||
this.tmdbService
|
||||
.getTrending(this.currentPage, this.isMovies, 'day')
|
||||
.subscribe((myEntries) => (this.entries = myEntries));
|
||||
}
|
||||
}
|
||||
|
||||
goToPage(page: number) {
|
||||
this.currentPage = page;
|
||||
this.fetchMovies();
|
||||
}
|
||||
|
||||
get pageNumbers(): number[] {
|
||||
this.currentPage = this.currentPage <= 0 ? 1 : this.currentPage; // page <= 0 fix
|
||||
let startPage = this.currentPage <= 3 ? 1 : this.currentPage - 2;
|
||||
let endPage = startPage + 4;
|
||||
|
||||
return Array.from(
|
||||
{ length: endPage - startPage + 1 },
|
||||
(_, i) => startPage + i
|
||||
);
|
||||
}
|
||||
}
|
||||
-36
@@ -1,36 +0,0 @@
|
||||
.modal-content {
|
||||
padding: 20px 20px 0 20px;
|
||||
}
|
||||
|
||||
.modal-body {
|
||||
padding-right: 5px;
|
||||
padding-left: 5px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.modal-footer {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.modal-input {
|
||||
padding-right: 10px !important;
|
||||
}
|
||||
|
||||
.simplebar-content-wrapper {
|
||||
padding-right: 10px;
|
||||
}
|
||||
|
||||
.simplebar-content-wrapper {
|
||||
max-height: 300px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.user-lists {
|
||||
height: 100%;
|
||||
background-color: var(--bs-body-bg) !important;
|
||||
border-right: 1px solid var(--bs-border-color);
|
||||
}
|
||||
|
||||
.user-lists .btn {
|
||||
color: var(--bs-border-color);
|
||||
}
|
||||
-57
@@ -1,57 +0,0 @@
|
||||
<!-- <h2 mat-dialog-title>Choose a list</h2>
|
||||
<mat-dialog-content>
|
||||
<mat-form-field appearance="fill">
|
||||
<mat-label>List Name</mat-label>
|
||||
<input [formControl]="searchControl" matInput>
|
||||
</mat-form-field>
|
||||
<mat-dialog-actions align="center" *ngIf="doShowAddButton()">
|
||||
<button mat-button (click)="createList()" *ngIf="doShowAddButton()">Create List</button>
|
||||
</mat-dialog-actions>
|
||||
<mat-selection-list #shoes (selectionChange)="onSelectionChange($event)">
|
||||
<mat-list-option *ngFor="let list of listsToShow" [value]="list.id" checkboxPosition="before">
|
||||
{{list.name}}
|
||||
</mat-list-option>
|
||||
</mat-selection-list>
|
||||
</mat-dialog-content>
|
||||
<mat-dialog-actions align="end">
|
||||
<button mat-button [mat-dialog-close]="true">OK</button>
|
||||
<button mat-button mat-dialog-close>Cancel</button>
|
||||
</mat-dialog-actions> -->
|
||||
<div class="modal-content user-lists">
|
||||
<div class="modal-header">
|
||||
<h2 class="modal-title">Choose a list</h2>
|
||||
<button type="button" class="btn-close" (click)="closeDialog()"></button>
|
||||
</div>
|
||||
|
||||
<!-- Modal Body -->
|
||||
<div class="modal-body">
|
||||
<div class="input-group mb-3 ">
|
||||
<!-- <label for="listNameInput" class="form-label">List Name</label> -->
|
||||
<input type="text" class="form-control" id="listNameInput" [formControl]="searchControl"
|
||||
placeholder="List name..." @scaleInOut>
|
||||
<button class="btn btn-success growing-width-element" type="button" *ngIf="doShowAddButton()" (click)="createList()" @scaleInOut>Create
|
||||
List</button>
|
||||
|
||||
</div>
|
||||
<div class="d-grid gap-2" *ngIf="doShowAddButton()">
|
||||
</div>
|
||||
<div data-simplebar class="simplebar-content-wrapper">
|
||||
<div class="list-group">
|
||||
|
||||
<label *ngFor="let list of listsToShow" class="list-group-item">
|
||||
<input class="form-check-input me-1" type="checkbox" [value]="list.id"
|
||||
(change)="onSelectionChange(list, $event)" [checked]="list.isChecked">
|
||||
{{ list.name }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal Footer -->
|
||||
<div class="modal-footer">
|
||||
<div class="btn-group">
|
||||
<!-- <button type="button" class="btn btn-secondary" (click)="closeDialog()">Cancel</button> -->
|
||||
<button type="button" class="btn btn-primary" (click)="confirmSelection()">OK</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
-21
@@ -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<ListSelectionModalComponent>;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ListSelectionModalComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(ListSelectionModalComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
-168
@@ -1,168 +0,0 @@
|
||||
import { Component, Inject, Input, OnInit, ViewChild } 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';
|
||||
import { NotificationPopupComponent } from '../../../shared/notification-popup/notification-popup.component';
|
||||
import { NotificationService } from '../../../shared/services/notification.service';
|
||||
import {
|
||||
trigger,
|
||||
state,
|
||||
style,
|
||||
transition,
|
||||
animate,
|
||||
} from '@angular/animations';
|
||||
|
||||
@Component({
|
||||
selector: 'app-list-selection-modal',
|
||||
templateUrl: './list-selection-modal.component.html',
|
||||
styleUrls: ['./list-selection-modal.component.css'],
|
||||
animations: [
|
||||
trigger('fadeInOut', [
|
||||
state('in', style({ opacity: 1 })),
|
||||
transition(':enter', [style({ opacity: 0 }), animate(600)]),
|
||||
transition(':leave', [animate(600, style({ opacity: 0 }))]),
|
||||
]),
|
||||
trigger('scaleInOut', [
|
||||
transition(':enter', [
|
||||
state('in', style({ opacity: 1 })),
|
||||
style({ transform: 'scale(0)' }),
|
||||
animate('200ms ease-in-out', style({ transform: 'scale(1)' })),
|
||||
]),
|
||||
transition(':leave', [
|
||||
animate('200ms ease-in-out', style({ transform: 'scale(0)' })),
|
||||
]),
|
||||
]),
|
||||
],
|
||||
})
|
||||
export class ListSelectionModalComponent implements OnInit {
|
||||
@Input() entryId: number = 0;
|
||||
@ViewChild(NotificationPopupComponent)
|
||||
notificationComponent!: NotificationPopupComponent;
|
||||
searchControl = new FormControl('');
|
||||
showAddButton: boolean = false;
|
||||
|
||||
lists: List[] = [];
|
||||
listsToShow: List[] = [];
|
||||
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<ListSelectionModalComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: any,
|
||||
private listService: ListService,
|
||||
private notificationService: NotificationService
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.entryId = this.data.entryId;
|
||||
this.getLists();
|
||||
|
||||
this.searchControl.valueChanges.subscribe((value) => {
|
||||
this.applyFilter(value);
|
||||
});
|
||||
}
|
||||
|
||||
getLists() {
|
||||
this.listService.getLists().subscribe({
|
||||
next: (l) => {
|
||||
l.forEach((list) => {
|
||||
if (
|
||||
list.listEntries.some((entry) => entry.entry_id == this.entryId)
|
||||
) {
|
||||
list.isChecked = true;
|
||||
}
|
||||
});
|
||||
|
||||
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((list) =>
|
||||
list.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();
|
||||
});
|
||||
}
|
||||
|
||||
doShowAddButton(): boolean {
|
||||
return this.showAddButton;
|
||||
}
|
||||
|
||||
onSelectionChange(list: List, event: Event): void {
|
||||
const inputElement = event.target as HTMLInputElement;
|
||||
const isChecked = inputElement.checked;
|
||||
|
||||
if (isChecked || isChecked == null) {
|
||||
console.log(`Adding Entry ${this.entryId} to list: ${list.name}`);
|
||||
this.listService
|
||||
.addEntryToList(list.id, this.entryId, list.listEntries.length + 1)
|
||||
.subscribe({
|
||||
next: (response) => {
|
||||
console.log('Success:', response);
|
||||
this.getLists();
|
||||
this.showNotification(
|
||||
'Entry Added',
|
||||
'Entry added successfully',
|
||||
'success'
|
||||
);
|
||||
},
|
||||
error: (error) => {
|
||||
console.error('Error:', error);
|
||||
this.showNotification('Error', 'Failed to add entry', 'error');
|
||||
},
|
||||
});
|
||||
} else {
|
||||
console.log(`Removing Entry ${this.entryId} from list: ${list.name}`);
|
||||
this.listService.removeEntryFromList(list.id.toString(), this.entryId).subscribe({
|
||||
next: (_) => {
|
||||
this.showNotification(
|
||||
'Entry Removed',
|
||||
'Entry removed successfully',
|
||||
'success'
|
||||
);
|
||||
},
|
||||
error: (error) => {
|
||||
console.error('Error removing entry:', error);
|
||||
this.showNotification('Error', 'Failed to remove entry', 'error');
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
closeDialog(): void {
|
||||
this.dialogRef.close();
|
||||
}
|
||||
|
||||
confirmSelection(): void {
|
||||
this.dialogRef.close(/* Optionally pass back some data */);
|
||||
}
|
||||
|
||||
showNotification(title: string, message: string, type: string): void {
|
||||
// this.notificationComponent.showNotification(message, type);
|
||||
this.notificationService.showNotification(title, message, type);
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -1,21 +0,0 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ListsComponent } from './lists.component';
|
||||
|
||||
describe('ListsComponent', () => {
|
||||
let component: ListsComponent;
|
||||
let fixture: ComponentFixture<ListsComponent>;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ListsComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(ListsComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user