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
@@ -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 { }
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
.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;
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
<div class="movies-container" cdkDropList [cdkDropListData]="entries" (cdkDropListDropped)="drop($any($event))">
|
||||
<app-userCollection-grid-card cdkDrag *ngFor="let entry of entries" [entry]="entry" [listId]="listId"
|
||||
(refrechEvent)="refrechEventReceiver()">
|
||||
</app-userCollection-grid-card>
|
||||
</div>
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { UserCollectionEntryGridComponent } from './userCollection-entry-grid.component';
|
||||
|
||||
describe('UserCollectionEntryGridComponent', () => {
|
||||
let component: UserCollectionEntryGridComponent;
|
||||
let fixture: ComponentFixture<UserCollectionEntryGridComponent>;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [UserCollectionEntryGridComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(UserCollectionEntryGridComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { Entry } from '../../../../shared/models/entry.model';
|
||||
import {
|
||||
CdkDragDrop,
|
||||
CdkDragEnd,
|
||||
CdkDragStart,
|
||||
moveItemInArray,
|
||||
} from '@angular/cdk/drag-drop';
|
||||
|
||||
@Component({
|
||||
selector: 'app-userCollection-entry-grid',
|
||||
templateUrl: './userCollection-entry-grid.component.html',
|
||||
styleUrls: ['./userCollection-entry-grid.component.css'],
|
||||
})
|
||||
export class UserCollectionEntryGridComponent {
|
||||
@Input() entries: Entry[] = [];
|
||||
@Input() listId: string = '';
|
||||
|
||||
refrechEventReceiver() {
|
||||
console.log('event recieved');
|
||||
}
|
||||
|
||||
drop(event: CdkDragDrop<any[]>) {
|
||||
moveItemInArray(this.entries, event.previousIndex, event.currentIndex);
|
||||
}
|
||||
|
||||
dragStart(event: CdkDragStart): void {
|
||||
event.source.element.nativeElement.classList.add('custom-dragging-class');
|
||||
}
|
||||
|
||||
dragEnd(event: CdkDragEnd): void {
|
||||
event.source.element.nativeElement.classList.remove(
|
||||
'custom-dragging-class'
|
||||
);
|
||||
}
|
||||
}
|
||||
+176
@@ -0,0 +1,176 @@
|
||||
.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;
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
<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">
|
||||
<i class='bx bxs-trash' (click)="removeEntryFromList()" 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>
|
||||
+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();
|
||||
});
|
||||
});
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
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 { trigger, transition, style, animate } from '@angular/animations';
|
||||
import { ListService } from '../../../../core/services/list.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-userCollection-grid-card',
|
||||
templateUrl: './userCollection-grid-card.component.html',
|
||||
styleUrls: ['./userCollection-grid-card.component.css'],
|
||||
animations: [
|
||||
trigger('fadeInOut', [
|
||||
transition(':enter', [
|
||||
style({ opacity: 0 }),
|
||||
animate('0.5s ease-out', style({ opacity: 1 })),
|
||||
]),
|
||||
transition(':leave', [animate('0.5s ease-in', style({ opacity: 0 }))]),
|
||||
]),
|
||||
],
|
||||
})
|
||||
export class UserCollectionGridCardComponent {
|
||||
@Input() entry!: Entry;
|
||||
@Input() listId: string = '';
|
||||
@Output() refrechEvent = new EventEmitter();
|
||||
|
||||
constructor(
|
||||
private libraryService: LibraryService,
|
||||
private listService: ListService,
|
||||
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);
|
||||
}
|
||||
|
||||
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 'https://pic.pnnet.dev/256x256';
|
||||
|
||||
return `https://image.tmdb.org/t/p/w500` + this.entry.poster_path;
|
||||
}
|
||||
|
||||
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);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
removeEntryFromList() {
|
||||
// todo: add confirm modal
|
||||
this.listService.removeEntryFromList(this.listId, this.entry.id).subscribe({
|
||||
next: (response) => {
|
||||
console.log('Entry successfully removed from list.', response);
|
||||
this.entry.id = 0;
|
||||
this.entry.isInLibrary = false;
|
||||
},
|
||||
error: (error) => {
|
||||
console.error('Error removing entry from list:', error);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// ? EVENTS
|
||||
cardClick() {}
|
||||
|
||||
// ? EVENT EMITTER
|
||||
emitRefrechEvent() {
|
||||
this.refrechEvent.emit();
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
+34
@@ -0,0 +1,34 @@
|
||||
<!--breadcrumb-->
|
||||
<div class="page-breadcrumb d-none d-sm-flex align-items-center mb-3">
|
||||
<div class="breadcrumb-title pe-3">Library</div>
|
||||
<div class="ps-3">
|
||||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb mb-0 p-0">
|
||||
<li class="breadcrumb-item">
|
||||
<a href="javascript:;">
|
||||
</a>
|
||||
</li>
|
||||
<li class="breadcrumb-item active" aria-current="page">List: {{list.name}}</li>
|
||||
</ol>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
<!--end breadcrumb-->
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="d-flex justify-content-between align-items-center mb-2">
|
||||
<h5 class="mb-0">{{list.name}}</h5>
|
||||
<button type="button" class="btn btn-primary btn-sm">
|
||||
<span class="material-symbols-outlined">
|
||||
edit
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
<div>Created - {{createdAt}} | Updated - {{updatedAt}}</div>
|
||||
<div *ngIf="list.description != ''">{{list.description}}</div>
|
||||
<hr>
|
||||
<div>
|
||||
<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();
|
||||
});
|
||||
});
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
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-userCollection-info-page',
|
||||
templateUrl: './userCollection-info-page.component.html',
|
||||
styleUrls: ['./userCollection-info-page.component.css'],
|
||||
providers: [DatePipe],
|
||||
})
|
||||
export class UserCollectionInfoPageComponent {
|
||||
list: UserCollection = {} as UserCollection;
|
||||
createdAt: string = '';
|
||||
updatedAt: string = '';
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private listService: ListService,
|
||||
private datePipe: DatePipe
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
const id = this.route.snapshot.paramMap.get('id');
|
||||
if (id == null) return;
|
||||
|
||||
this.listService.getList(id.toString()).subscribe(
|
||||
(data) => {
|
||||
// Handle the successful reception of data.
|
||||
this.list = data as unknown as UserCollection;
|
||||
this.list.entries = this.list.entries as Entry[];
|
||||
|
||||
this.createdAt = this.getCreatedDate()?.toString() || '';
|
||||
this.updatedAt = this.getUpdatedAt()?.toString() || '';
|
||||
console.log('Data received:', this.list);
|
||||
},
|
||||
(error) => {
|
||||
// Handle any error that occurs during the subscription
|
||||
console.error('Error occurred:', error);
|
||||
},
|
||||
() => {
|
||||
// Handle completion of the Observable
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
getListId() {
|
||||
return this.list.id + '';
|
||||
}
|
||||
|
||||
getCreatedDate() {
|
||||
return this.datePipe.transform(this.list.createdAt, 'dd MMMM, yyyy');
|
||||
}
|
||||
|
||||
getUpdatedAt() {
|
||||
console.log(1);
|
||||
const updatedAt = this.list.updatedAt;
|
||||
// First, check if updatedAt is a valid date string or timestamp
|
||||
const modifiedDate = new Date(updatedAt);
|
||||
|
||||
// Check if the date is invalid
|
||||
if (isNaN(modifiedDate.getTime())) {
|
||||
console.error('Invalid date:', updatedAt);
|
||||
// Handle invalid date, perhaps return a fallback message or undefined
|
||||
return 'Date not available';
|
||||
}
|
||||
|
||||
const now = new Date();
|
||||
const diffInMs = now.getTime() - modifiedDate.getTime();
|
||||
const diffInDays = diffInMs / (1000 * 60 * 60 * 24);
|
||||
|
||||
if (diffInDays < 7) {
|
||||
// Less than a week, show relative time
|
||||
if (diffInDays < 1) {
|
||||
const diffInHours = diffInMs / (1000 * 60 * 60);
|
||||
if (diffInHours < 1) {
|
||||
const diffInMinutes = diffInMs / (1000 * 60);
|
||||
return `${Math.floor(diffInMinutes)} minutes ago`;
|
||||
}
|
||||
return `${Math.floor(diffInHours)} hours ago`;
|
||||
}
|
||||
return `${Math.floor(diffInDays)} days ago`;
|
||||
} else {
|
||||
// More than a week, show formatted date
|
||||
// Ensure datePipe is properly injected and available in the component
|
||||
return this.datePipe.transform(modifiedDate, 'dd MMMM, yyyy');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 {}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
.list-item-1 {
|
||||
padding-top: 1px;
|
||||
}
|
||||
|
||||
.list-title{
|
||||
font-size: 20px;
|
||||
}
|
||||
.list-title:hover {
|
||||
color: var(--aruze-blue)
|
||||
}
|
||||
|
||||
.list-line{
|
||||
border-radius: 1px;
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
.list-line:hover {
|
||||
background-color: aliceblue;
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
<div class="d-flex align-items-start gap-2 list-line" @fadeInOut>
|
||||
<img [src]="getPostPath()" width="70" height="105" class="" alt="List poster" (click)="redirectTo()">
|
||||
<div class="flex-grow-1 list-item-1">
|
||||
<h6 class="mb-0 list-title" (click)="redirectTo()">{{list.name}}</h6>
|
||||
<p class="mb-0">Created: {{getCreatedDate() | dateFormat}}</p>
|
||||
<p class="mb-0">Contains: {{list.listEntries.length}} title(s)</p>
|
||||
</div>
|
||||
<!-- <div class="form-check form-check-inline me-0">
|
||||
<input class="form-check-input ms-0" type="checkbox">
|
||||
</div> -->
|
||||
</div>
|
||||
+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();
|
||||
});
|
||||
});
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
import { Component, Input} from '@angular/core';
|
||||
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-userCollections-list-item',
|
||||
templateUrl: './userCollections-list-item.component.html',
|
||||
styleUrls: ['./userCollections-list-item.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 UserCollectionsListItemComponent {
|
||||
@Input() list!: UserCollection;
|
||||
|
||||
constructor(private listService: ListService, private router: Router) {}
|
||||
|
||||
getPostPath() {
|
||||
if (this.list.poster_path == null) return 'https://pic.pnnet.dev/256x256';
|
||||
|
||||
return `https://image.tmdb.org/t/p/w500` + this.list.poster_path;
|
||||
}
|
||||
|
||||
getCreatedDate(): string {
|
||||
if (this.list.createdAt == null) return '';
|
||||
|
||||
return this.list.createdAt.toString();
|
||||
}
|
||||
|
||||
redirectTo(): void {
|
||||
this.router.navigate([`/lists/${this.list.id}`]);
|
||||
}
|
||||
|
||||
deleteList() {
|
||||
this.listService.deleteList(this.list.id);
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
+40
@@ -0,0 +1,40 @@
|
||||
<!--breadcrumb-->
|
||||
<div class="page-breadcrumb d-none d-sm-flex align-items-center mb-3">
|
||||
<div class="breadcrumb-title pe-3">Library</div>
|
||||
<div class="ps-3">
|
||||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb mb-0 p-0">
|
||||
<li class="breadcrumb-item">
|
||||
<a href="javascript:;">
|
||||
</a>
|
||||
</li>
|
||||
<li class="breadcrumb-item active" aria-current="page">Lists</li>
|
||||
</ol>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
<!--end breadcrumb-->
|
||||
|
||||
<div>
|
||||
<div class="col d-flex ">
|
||||
<div class="card w-100">
|
||||
<div class="card-header border-0 p-3 border-bottom">
|
||||
<div class="position-relative">
|
||||
<input [formControl]="searchControl" matInput class="form-control rounded-5 px-5" type="text"
|
||||
placeholder="Search">
|
||||
<span class="material-icons-outlined position-absolute ms-3 translate-middle-y start-0 top-50">search</span>
|
||||
<!-- <span class="material-icons-outlined position-absolute me-3 translate-middle-y end-0 top-50">Library</span> -->
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body p-0">
|
||||
<div class="p-3 ps ps--active-y">
|
||||
<div class="d-flex flex-column gap-3">
|
||||
<!-- item start -->
|
||||
<app-userCollections-list-item *ngFor="let list of listsToShow" [list]="list"></app-userCollections-list-item>
|
||||
<!-- item end -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</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();
|
||||
});
|
||||
});
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { FormControl } from '@angular/forms';
|
||||
import { UserCollection } from '../../../../shared/models/userCollection.model';
|
||||
import { ListService } from '../../../../core/services/list.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-userCollections-page',
|
||||
templateUrl: './userCollections-page.component.html',
|
||||
styleUrls: ['./userCollections-page.component.css'],
|
||||
})
|
||||
export class UserCollectionsPageComponent implements OnInit {
|
||||
searchControl = new FormControl('');
|
||||
showAddButton: boolean = false;
|
||||
listsCount: number = 0;
|
||||
|
||||
lists: UserCollection[] = [];
|
||||
listsToShow: UserCollection[] = [];
|
||||
|
||||
constructor(private listService: ListService) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.getLists();
|
||||
this.searchControl.valueChanges.subscribe(() => {
|
||||
this.applyFilter();
|
||||
});
|
||||
}
|
||||
|
||||
getLists() {
|
||||
this.listService.getLists().subscribe({
|
||||
next: (l) => {
|
||||
console.log(`Loaded ${l.length} lists.`);
|
||||
this.lists = l;
|
||||
this.listsToShow = this.lists;
|
||||
this.applyFilter();
|
||||
},
|
||||
error: (error) => {
|
||||
console.log("Counldn't get lists from backend.");
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
applyFilter() {
|
||||
let filterValue = this.searchControl.value;
|
||||
if (filterValue == null) {
|
||||
this.listsToShow = [...this.lists];
|
||||
return;
|
||||
}
|
||||
|
||||
const normalizedFilter = filterValue.toLowerCase().trim();
|
||||
|
||||
this.listsToShow = this.lists.filter((collection) =>
|
||||
collection.name.toLowerCase().trim().includes(normalizedFilter)
|
||||
);
|
||||
this.listsCount = this.listsToShow.length;
|
||||
}
|
||||
|
||||
createList() {
|
||||
// const listName = this.searchControl.value; // string
|
||||
// let myNewList = { name: listName } as List;
|
||||
// this.listService.createList(myNewList).subscribe(async (list) => {
|
||||
// await this.getLists();
|
||||
// });
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user