Front: renamed most collection related files
This commit is contained in:
1 parent
75de013f82
commit
8724a96b81
55 files changed
+294
-394
No files matched your search
@@ -52,8 +52,8 @@ const routes: Routes = [
|
|||||||
{
|
{
|
||||||
path: 'collections',
|
path: 'collections',
|
||||||
loadChildren: () =>
|
loadChildren: () =>
|
||||||
import('./features/collections/user-collections.module').then(
|
import('./features/collections/collections.module').then(
|
||||||
(m) => m.UserCollectionsModule
|
(m) => m.CollectionsModule
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { CommonModule } from '@angular/common';
|
|||||||
import { TmdbService } from './services/tmdb.service';
|
import { TmdbService } from './services/tmdb.service';
|
||||||
import { LibraryService } from './services/library.service';
|
import { LibraryService } from './services/library.service';
|
||||||
import { EntryService } from './services/entry.service';
|
import { EntryService } from './services/entry.service';
|
||||||
import { CollectionService } from './services/userCollection.service';
|
import { CollectionService } from './services/collection.service';
|
||||||
import { ToggleService } from './services/toggle.service';
|
import { ToggleService } from './services/toggle.service';
|
||||||
import { SidebarComponent } from './components/sidebar/sidebar.component';
|
import { SidebarComponent } from './components/sidebar/sidebar.component';
|
||||||
import { NavbarComponent } from './components/navbar/navbar.component';
|
import { NavbarComponent } from './components/navbar/navbar.component';
|
||||||
|
|||||||
+17
-17
@@ -1,8 +1,8 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { UserCollection } from '../../shared/models/userCollection.model';
|
import { Collection } from '../../shared/models/collection.model';
|
||||||
import { UserCollectionEntry } from '../../shared/models/userCollectionEntry.model';
|
import { CollectionEntry } from '../../shared/models/collection-entry.model';
|
||||||
import { Entry } from '../../shared/models/entry.model';
|
import { Entry } from '../../shared/models/entry.model';
|
||||||
import { environment } from '../../../environments/environment.prod';
|
import { environment } from '../../../environments/environment.prod';
|
||||||
|
|
||||||
@@ -16,22 +16,22 @@ export class CollectionService {
|
|||||||
constructor(private http: HttpClient) {}
|
constructor(private http: HttpClient) {}
|
||||||
|
|
||||||
// get all lists
|
// get all lists
|
||||||
getCollections(): Observable<UserCollection[]> {
|
getCollections(): Observable<Collection[]> {
|
||||||
return this.http.get<UserCollection[]>(
|
return this.http.get<Collection[]>(
|
||||||
`${this.backend_apiUrl}/${this.apiAction}`
|
`${this.backend_apiUrl}/${this.apiAction}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// get a list by id
|
// get a list by id
|
||||||
getCollection(collectionId: string) {
|
getCollection(collectionId: string) {
|
||||||
return this.http.get<UserCollection>(
|
return this.http.get<Collection>(
|
||||||
`${this.backend_apiUrl}/${this.apiAction}/${collectionId}`
|
`${this.backend_apiUrl}/${this.apiAction}/${collectionId}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new list
|
// Create a new list
|
||||||
createCollection(collection: UserCollection): Observable<UserCollection> {
|
createCollection(collection: Collection): Observable<Collection> {
|
||||||
return this.http.post<UserCollection>(
|
return this.http.post<Collection>(
|
||||||
`${this.backend_apiUrl}/${this.apiAction}`,
|
`${this.backend_apiUrl}/${this.apiAction}`,
|
||||||
collection
|
collection
|
||||||
);
|
);
|
||||||
@@ -41,24 +41,24 @@ export class CollectionService {
|
|||||||
updateCollection(
|
updateCollection(
|
||||||
collectionId: number,
|
collectionId: number,
|
||||||
formData: FormData
|
formData: FormData
|
||||||
): Observable<UserCollection> {
|
): Observable<Collection> {
|
||||||
return this.http.put<UserCollection>(
|
return this.http.put<Collection>(
|
||||||
`${this.backend_apiUrl}/${this.apiAction}/${collectionId}`,
|
`${this.backend_apiUrl}/${this.apiAction}/${collectionId}`,
|
||||||
formData
|
formData
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// * PUT - REFRESH COLLECTION
|
// * PUT - REFRESH COLLECTION
|
||||||
refreshCollection(collectionId: number): Observable<UserCollection> {
|
refreshCollection(collectionId: number): Observable<Collection> {
|
||||||
return this.http.put<UserCollection>(
|
return this.http.put<Collection>(
|
||||||
`${this.backend_apiUrl}/${this.apiAction}/${collectionId}/refresh`,
|
`${this.backend_apiUrl}/${this.apiAction}/${collectionId}/refresh`,
|
||||||
{}
|
{}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// * PUT - GET COLLECTION PARTS
|
// * PUT - GET COLLECTION PARTS
|
||||||
getCollectionParts(collectionId: number): Observable<UserCollection> {
|
getCollectionParts(collectionId: number): Observable<Collection> {
|
||||||
return this.http.put<UserCollection>(
|
return this.http.put<Collection>(
|
||||||
`${this.backend_apiUrl}/${this.apiAction}/${collectionId}/parts`,
|
`${this.backend_apiUrl}/${this.apiAction}/${collectionId}/parts`,
|
||||||
{}
|
{}
|
||||||
);
|
);
|
||||||
@@ -75,8 +75,8 @@ export class CollectionService {
|
|||||||
addEntryToCollection(
|
addEntryToCollection(
|
||||||
collectionId: number,
|
collectionId: number,
|
||||||
entryId: number
|
entryId: number
|
||||||
): Observable<UserCollectionEntry> {
|
): Observable<CollectionEntry> {
|
||||||
return this.http.post<UserCollectionEntry>(
|
return this.http.post<CollectionEntry>(
|
||||||
`${this.backend_apiUrl}/${this.apiAction}/${collectionId}/entries/${entryId}`,
|
`${this.backend_apiUrl}/${this.apiAction}/${collectionId}/entries/${entryId}`,
|
||||||
{}
|
{}
|
||||||
);
|
);
|
||||||
@@ -84,7 +84,7 @@ export class CollectionService {
|
|||||||
|
|
||||||
// Update an entry's order in a list
|
// Update an entry's order in a list
|
||||||
updateEntryOrder(
|
updateEntryOrder(
|
||||||
collectionId: string,
|
collectionId: number,
|
||||||
entryId: number,
|
entryId: number,
|
||||||
newOrder: number
|
newOrder: number
|
||||||
): Observable<any> {
|
): Observable<any> {
|
||||||
@@ -96,7 +96,7 @@ export class CollectionService {
|
|||||||
|
|
||||||
// Remove an entry from a list
|
// Remove an entry from a list
|
||||||
removeEntryFromCollection(
|
removeEntryFromCollection(
|
||||||
collectionId: string,
|
collectionId: number,
|
||||||
entryId: number
|
entryId: number
|
||||||
): Observable<Entry> {
|
): Observable<Entry> {
|
||||||
return this.http.delete<Entry>(
|
return this.http.delete<Entry>(
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { EntryRating } from '../../shared/models/entryRating.model';
|
import { EntryRating } from '../../shared/models/entry-rating.model';
|
||||||
import { environment } from '../../../environments/environment.prod';
|
import { environment } from '../../../environments/environment.prod';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { EntrySeen } from '../../shared/models/entrySeen.model';
|
import { EntrySeen } from '../../shared/models/entry-seen.model';
|
||||||
import { environment } from '../../../environments/environment.prod';
|
import { environment } from '../../../environments/environment.prod';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { HttpClient } from '@angular/common/http';
|
|||||||
import { Observable, map } from 'rxjs';
|
import { Observable, map } from 'rxjs';
|
||||||
import { Entry } from '../../shared/models/entry.model';
|
import { Entry } from '../../shared/models/entry.model';
|
||||||
import { EntryId } from '../../shared/models/entryId.model';
|
import { EntryId } from '../../shared/models/entryId.model';
|
||||||
import { EntryRating } from '../../shared/models/entryRating.model';
|
import { EntryRating } from '../../shared/models/entry-rating.model';
|
||||||
import { environment } from '../../../environments/environment.prod';
|
import { environment } from '../../../environments/environment.prod';
|
||||||
import { Media } from '../../shared/models/media.model';
|
import { Media } from '../../shared/models/media.model';
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { EpisodeSeen } from '../../shared/models/episodeSeen.model';
|
import { EpisodeSeen } from '../../shared/models/episode-seen.model';
|
||||||
import { EpisodeSeenDto } from '../../shared/models/dtos/episode-seen.dto';
|
import { EpisodeSeenDto } from '../../shared/models/dtos/episode-seen.dto';
|
||||||
import { environment } from '../../../environments/environment.prod';
|
import { environment } from '../../../environments/environment.prod';
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { MovieDateSeen } from '../../shared/models/dtos/movieDateSeen.model';
|
import { MovieDateSeen } from '../../shared/models/dtos/movie-dateSeen.model';
|
||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { Entry } from '../../shared/models/entry.model';
|
import { Entry } from '../../shared/models/entry.model';
|
||||||
import { environment } from '../../../environments/environment.prod';
|
import { environment } from '../../../environments/environment.prod';
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { Observable, ReplaySubject, throwError, map, of } from 'rxjs';
|
|||||||
import { catchError, switchMap, tap } from 'rxjs/operators';
|
import { catchError, switchMap, tap } from 'rxjs/operators';
|
||||||
import { Entry } from '../../shared/models/entry.model';
|
import { Entry } from '../../shared/models/entry.model';
|
||||||
import { EntryId } from '../../shared/models/entryId.model';
|
import { EntryId } from '../../shared/models/entryId.model';
|
||||||
import { EntryRating } from '../../shared/models/entryRating.model';
|
import { EntryRating } from '../../shared/models/entry-rating.model';
|
||||||
import { environment } from '../../../environments/environment.prod';
|
import { environment } from '../../../environments/environment.prod';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { environment } from '../../../environments/environment.prod';
|
import { environment } from '../../../environments/environment.prod';
|
||||||
import { MaintenanceResult } from '../../shared/models/maintenanceResult.model';
|
import { MaintenanceResult } from '../../shared/models/maintenance-result.model';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { HttpClient } from '@angular/common/http';
|
|||||||
import { Observable, filter, from, map, of, switchMap, toArray } from 'rxjs';
|
import { Observable, filter, from, map, of, switchMap, toArray } from 'rxjs';
|
||||||
import { Entry } from '../../shared/models/entry.model';
|
import { Entry } from '../../shared/models/entry.model';
|
||||||
import { EntryId } from '../../shared/models/entryId.model';
|
import { EntryId } from '../../shared/models/entryId.model';
|
||||||
import { EntryRating } from '../../shared/models/entryRating.model';
|
import { EntryRating } from '../../shared/models/entry-rating.model';
|
||||||
import { environment } from '../../../environments/environment.prod';
|
import { environment } from '../../../environments/environment.prod';
|
||||||
import { LibraryService } from './library.service';
|
import { LibraryService } from './library.service';
|
||||||
|
|
||||||
|
|||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+5
-5
@@ -1,16 +1,16 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
import { UserCollectionGridCardComponent } from './userCollection-grid-card.component';
|
import { CollectionEntryCardComponent } from './collection-entry-card.component';
|
||||||
|
|
||||||
describe('UserCollectionGridCardComponent', () => {
|
describe('UserCollectionGridCardComponent', () => {
|
||||||
let component: UserCollectionGridCardComponent;
|
let component: CollectionEntryCardComponent;
|
||||||
let fixture: ComponentFixture<UserCollectionGridCardComponent>;
|
let fixture: ComponentFixture<CollectionEntryCardComponent>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
declarations: [UserCollectionGridCardComponent]
|
declarations: [CollectionEntryCardComponent]
|
||||||
});
|
});
|
||||||
fixture = TestBed.createComponent(UserCollectionGridCardComponent);
|
fixture = TestBed.createComponent(CollectionEntryCardComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
+8
-8
@@ -2,15 +2,15 @@ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
|||||||
import { MatDialog } from '@angular/material/dialog';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
import { Entry } from '../../../../shared/models/entry.model';
|
import { Entry } from '../../../../shared/models/entry.model';
|
||||||
import { trigger, transition, style, animate } from '@angular/animations';
|
import { trigger, transition, style, animate } from '@angular/animations';
|
||||||
import { CollectionService } from '../../../../core/services/userCollection.service';
|
import { CollectionService } from '../../../../core/services/collection.service';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { ConfirmModalComponent } from '../../../../shared/components/modals/confirm-modal/confirm-modal.component';
|
import { ConfirmModalComponent } from '../../../../shared/components/modals/confirm-modal/confirm-modal.component';
|
||||||
import { environment } from '../../../../../environments/environment.prod';
|
import { environment } from '../../../../../environments/environment.prod';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-userCollection-grid-card',
|
selector: 'app-collection-entry-card',
|
||||||
templateUrl: './userCollection-grid-card.component.html',
|
templateUrl: './collection-entry-card.component.html',
|
||||||
styleUrls: ['./userCollection-grid-card.component.css'],
|
styleUrls: ['./collection-entry-card.component.css'],
|
||||||
animations: [
|
animations: [
|
||||||
trigger('fadeInOut', [
|
trigger('fadeInOut', [
|
||||||
transition(':enter', [
|
transition(':enter', [
|
||||||
@@ -21,13 +21,13 @@ import { environment } from '../../../../../environments/environment.prod';
|
|||||||
]),
|
]),
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class UserCollectionGridCardComponent implements OnInit {
|
export class CollectionEntryCardComponent implements OnInit {
|
||||||
@Input() entry!: Entry;
|
@Input() entry!: Entry;
|
||||||
@Input() collectionId: string = '';
|
@Input() collectionId!: number;
|
||||||
@Output() refrechEvent = new EventEmitter();
|
@Output() refrechEvent = new EventEmitter();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private userCollectionService: CollectionService,
|
private collectionService: CollectionService,
|
||||||
public dialog: MatDialog,
|
public dialog: MatDialog,
|
||||||
private router: Router
|
private router: Router
|
||||||
) {}
|
) {}
|
||||||
@@ -90,7 +90,7 @@ export class UserCollectionGridCardComponent implements OnInit {
|
|||||||
if (result) {
|
if (result) {
|
||||||
if (result.confirmed != true) return;
|
if (result.confirmed != true) return;
|
||||||
|
|
||||||
this.userCollectionService
|
this.collectionService
|
||||||
.removeEntryFromCollection(this.collectionId, this.entry.id)
|
.removeEntryFromCollection(this.collectionId, this.entry.id)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: (response) => {
|
next: (response) => {
|
||||||
File renamed without changes.
+7
@@ -0,0 +1,7 @@
|
|||||||
|
<div class="movies-container">
|
||||||
|
<ng-container *ngFor="let entry of entries">
|
||||||
|
<app-collection-entry-card [entry]="entry" [collectionId]="collectionId" (refrechEvent)="refrechEventReceiver()"
|
||||||
|
@animateDestroy>
|
||||||
|
</app-collection-entry-card>
|
||||||
|
</ng-container>
|
||||||
|
</div>
|
||||||
+5
-5
@@ -1,16 +1,16 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
import { UserCollectionEntryGridComponent } from './userCollection-entry-grid.component';
|
import { CollectionEntryGridComponent } from './collection-entry-grid.component';
|
||||||
|
|
||||||
describe('UserCollectionEntryGridComponent', () => {
|
describe('UserCollectionEntryGridComponent', () => {
|
||||||
let component: UserCollectionEntryGridComponent;
|
let component: CollectionEntryGridComponent;
|
||||||
let fixture: ComponentFixture<UserCollectionEntryGridComponent>;
|
let fixture: ComponentFixture<CollectionEntryGridComponent>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
declarations: [UserCollectionEntryGridComponent]
|
declarations: [CollectionEntryGridComponent]
|
||||||
});
|
});
|
||||||
fixture = TestBed.createComponent(UserCollectionEntryGridComponent);
|
fixture = TestBed.createComponent(CollectionEntryGridComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
+5
-5
@@ -10,9 +10,9 @@ import {
|
|||||||
} from '@angular/animations';
|
} from '@angular/animations';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-userCollection-entry-grid',
|
selector: 'app-collection-entry-grid',
|
||||||
templateUrl: './userCollection-entry-grid.component.html',
|
templateUrl: './collection-entry-grid.component.html',
|
||||||
styleUrls: ['./userCollection-entry-grid.component.css'],
|
styleUrls: ['./collection-entry-grid.component.css'],
|
||||||
animations: [
|
animations: [
|
||||||
trigger('animateDestroy', [
|
trigger('animateDestroy', [
|
||||||
state('void', style({ opacity: '0' })),
|
state('void', style({ opacity: '0' })),
|
||||||
@@ -20,9 +20,9 @@ import {
|
|||||||
]),
|
]),
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class UserCollectionEntryGridComponent {
|
export class CollectionEntryGridComponent {
|
||||||
@Input() entries: Entry[] = [];
|
@Input() entries: Entry[] = [];
|
||||||
@Input() collectionId: string = '';
|
@Input() collectionId!: number;
|
||||||
|
|
||||||
refrechEventReceiver() {
|
refrechEventReceiver() {
|
||||||
console.log('event recieved');
|
console.log('event recieved');
|
||||||
File renamed without changes.
File renamed without changes.
+5
-5
@@ -1,18 +1,18 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
import { CollectionTableLineComponent } from './collection-table-line.component';
|
import { CollectionEntryLineComponent } from './collection-entry-line.component';
|
||||||
|
|
||||||
describe('CollectionTableLineComponent', () => {
|
describe('CollectionTableLineComponent', () => {
|
||||||
let component: CollectionTableLineComponent;
|
let component: CollectionEntryLineComponent;
|
||||||
let fixture: ComponentFixture<CollectionTableLineComponent>;
|
let fixture: ComponentFixture<CollectionEntryLineComponent>;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
imports: [CollectionTableLineComponent]
|
imports: [CollectionEntryLineComponent]
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
|
|
||||||
fixture = TestBed.createComponent(CollectionTableLineComponent);
|
fixture = TestBed.createComponent(CollectionEntryLineComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
+18
-24
@@ -7,18 +7,17 @@ import {
|
|||||||
ViewEncapsulation,
|
ViewEncapsulation,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
import { LibraryService } from '../../../../core/services/library.service';
|
|
||||||
import { Entry } from '../../../../shared/models/entry.model';
|
import { Entry } from '../../../../shared/models/entry.model';
|
||||||
import { trigger, transition, style, animate } from '@angular/animations';
|
import { trigger, transition, style, animate } from '@angular/animations';
|
||||||
import { CollectionService } from '../../../../core/services/userCollection.service';
|
import { CollectionService } from '../../../../core/services/collection.service';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { ConfirmModalComponent } from '../../../../shared/components/modals/confirm-modal/confirm-modal.component';
|
import { ConfirmModalComponent } from '../../../../shared/components/modals/confirm-modal/confirm-modal.component';
|
||||||
import { environment } from '../../../../../environments/environment.prod';
|
import { environment } from '../../../../../environments/environment.prod';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'tr [app-collection-table-line]',
|
selector: 'tr [app-collection-entry-line]',
|
||||||
templateUrl: './collection-table-line.component.html',
|
templateUrl: './collection-entry-line.component.html',
|
||||||
styleUrl: './collection-table-line.component.css',
|
styleUrl: './collection-entry-line.component.css',
|
||||||
encapsulation: ViewEncapsulation.None,
|
encapsulation: ViewEncapsulation.None,
|
||||||
animations: [
|
animations: [
|
||||||
trigger('fadeInOut', [
|
trigger('fadeInOut', [
|
||||||
@@ -30,21 +29,18 @@ import { environment } from '../../../../../environments/environment.prod';
|
|||||||
]),
|
]),
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class CollectionTableLineComponent implements OnInit {
|
export class CollectionEntryLineComponent implements OnInit {
|
||||||
@Input() entry!: Entry;
|
@Input() entry!: Entry;
|
||||||
@Input() listId: string = '';
|
@Input() collectionId!: number;
|
||||||
@Output() refrechEvent = new EventEmitter();
|
@Output() refrechEvent = new EventEmitter();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private libraryService: LibraryService,
|
private collectionService: CollectionService,
|
||||||
private userCollectionService: CollectionService,
|
|
||||||
public dialog: MatDialog,
|
public dialog: MatDialog,
|
||||||
private router: Router
|
private router: Router
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
get releaseYear(): number {
|
get releaseYear(): number {
|
||||||
return new Date(this.entry.release_date).getFullYear();
|
return new Date(this.entry.release_date).getFullYear();
|
||||||
@@ -72,14 +68,13 @@ export class CollectionTableLineComponent implements OnInit {
|
|||||||
(m) => m.type == 'logo' && m.isSelected
|
(m) => m.type == 'logo' && m.isSelected
|
||||||
);
|
);
|
||||||
|
|
||||||
if (
|
if (selectedLogos.length && selectedLogos[0] && selectedLogos[0].path) {
|
||||||
selectedLogos.length &&
|
|
||||||
selectedLogos[0] &&
|
|
||||||
selectedLogos[0].path
|
|
||||||
) {
|
|
||||||
const name = selectedLogos[0].path.split('.')[0];
|
const name = selectedLogos[0].path.split('.')[0];
|
||||||
const extention = selectedLogos[0].path.split('.')[1];
|
const extention = selectedLogos[0].path.split('.')[1];
|
||||||
return environment.API_URL + `/media/entries/logos/original/${name}.${extention}`;
|
return (
|
||||||
|
environment.API_URL +
|
||||||
|
`/media/entries/logos/original/${name}.${extention}`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,19 +96,18 @@ export class CollectionTableLineComponent implements OnInit {
|
|||||||
if (result) {
|
if (result) {
|
||||||
if (result.confirmed != true) return;
|
if (result.confirmed != true) return;
|
||||||
|
|
||||||
this.userCollectionService
|
this.collectionService
|
||||||
.removeEntryFromCollection(this.listId, this.entry.id)
|
.removeEntryFromCollection(this.collectionId, this.entry.id)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: (response) => {
|
next: (response) => {
|
||||||
// TODO confirm notification
|
// TODO TOAST: entry removed from collection
|
||||||
|
// console.log('Entry successfully removed from collection.', response);
|
||||||
console.log('Entry successfully removed from list.', response);
|
|
||||||
this.entry.id = 0;
|
this.entry.id = 0;
|
||||||
this.entry.isInLibrary = false;
|
this.entry.isInLibrary = false;
|
||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
// TODO error notification
|
// TODO error notification
|
||||||
console.error('Error removing entry from list:', error);
|
console.error('Error removing entry from collection:', error);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
File renamed without changes.
+1
-10
@@ -1,11 +1,3 @@
|
|||||||
<!-- <div class="movies-container" cdkDropList [cdkDropListData]="entries" (cdkDropListDropped)="drop($any($event))">
|
|
||||||
<ng-container>
|
|
||||||
<app-userCollection-grid-card cdkDrag [entry]="entry" [listId]="listId" (refrechEvent)="refrechEventReceiver()"
|
|
||||||
@animateDestroy>
|
|
||||||
</app-userCollection-grid-card>
|
|
||||||
</ng-container>
|
|
||||||
</div> -->
|
|
||||||
|
|
||||||
<div class="card mt-4">
|
<div class="card mt-4">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="product-table">
|
<div class="product-table">
|
||||||
@@ -30,8 +22,7 @@
|
|||||||
<tbody cdkDropList [cdkDropListData]="entries" (cdkDropListDropped)="drop($any($event))">
|
<tbody cdkDropList [cdkDropListData]="entries" (cdkDropListDropped)="drop($any($event))">
|
||||||
<!-- * table body start -->
|
<!-- * table body start -->
|
||||||
<ng-container *ngFor="let entry of entries">
|
<ng-container *ngFor="let entry of entries">
|
||||||
<tr app-collection-table-line cdkDrag [entry]="entry"></tr>
|
<tr app-collection-entry-line cdkDrag [entry]="entry" [collectionId]="collectionId"></tr>
|
||||||
<!-- <app-collection-table-line cdkDrag [entry]="entry"></app-collection-table-line> -->
|
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<!-- + table body end -->
|
<!-- + table body end -->
|
||||||
</tbody>
|
</tbody>
|
||||||
File renamed without changes.
+4
-4
@@ -1,6 +1,6 @@
|
|||||||
import { Component, Input } from '@angular/core';
|
import { Component, Input } from '@angular/core';
|
||||||
import { Entry } from '../../../../shared/models/entry.model';
|
import { Entry } from '../../../../shared/models/entry.model';
|
||||||
import { CollectionService } from '../../../../core/services/userCollection.service';
|
import { CollectionService } from '../../../../core/services/collection.service';
|
||||||
import {
|
import {
|
||||||
CdkDragDrop,
|
CdkDragDrop,
|
||||||
CdkDragEnd,
|
CdkDragEnd,
|
||||||
@@ -28,9 +28,9 @@ import {
|
|||||||
})
|
})
|
||||||
export class CollectionEntryTableComponent {
|
export class CollectionEntryTableComponent {
|
||||||
@Input() entries: Entry[] = [];
|
@Input() entries: Entry[] = [];
|
||||||
@Input() collectionId: string = '';
|
@Input() collectionId!: number;
|
||||||
|
|
||||||
constructor(private userCollectionService: CollectionService) {}
|
constructor(private collectionService: CollectionService) {}
|
||||||
|
|
||||||
refrechEventReceiver() {
|
refrechEventReceiver() {
|
||||||
console.log('event recieved');
|
console.log('event recieved');
|
||||||
@@ -40,7 +40,7 @@ export class CollectionEntryTableComponent {
|
|||||||
moveItemInArray(this.entries, event.previousIndex, event.currentIndex);
|
moveItemInArray(this.entries, event.previousIndex, event.currentIndex);
|
||||||
|
|
||||||
if (event.previousIndex != event.currentIndex) {
|
if (event.previousIndex != event.currentIndex) {
|
||||||
this.userCollectionService
|
this.collectionService
|
||||||
.updateEntryOrder(
|
.updateEntryOrder(
|
||||||
this.collectionId,
|
this.collectionId,
|
||||||
this.entries[event.currentIndex].id,
|
this.entries[event.currentIndex].id,
|
||||||
File renamed without changes.
+3
-3
@@ -58,14 +58,14 @@
|
|||||||
<!-- ! grid -->
|
<!-- ! grid -->
|
||||||
<div id="gridDiv" *ngIf="viewMode == 'grid'">
|
<div id="gridDiv" *ngIf="viewMode == 'grid'">
|
||||||
<h1 *ngIf="screenMode">{{collection.name}}</h1>
|
<h1 *ngIf="screenMode">{{collection.name}}</h1>
|
||||||
<app-userCollection-entry-grid [entries]="collection.entries"
|
<app-collection-entry-grid [entries]="collection.entries"
|
||||||
[collectionId]="getListId()"></app-userCollection-entry-grid>
|
[collectionId]="this.collection.id"></app-collection-entry-grid>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- ! table -->
|
<!-- ! table -->
|
||||||
<div *ngIf="viewMode == 'table'">
|
<div *ngIf="viewMode == 'table'">
|
||||||
<app-collection-entry-table [entries]="collection.entries"
|
<app-collection-entry-table [entries]="collection.entries"
|
||||||
[collectionId]="getListId()"></app-collection-entry-table>
|
[collectionId]="this.collection.id"></app-collection-entry-table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
+5
-5
@@ -1,16 +1,16 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
import { UserCollectionInfoPageComponent } from './userCollection-info-page.component';
|
import { CollectionInfoPageComponent } from './collection-info-page.component';
|
||||||
|
|
||||||
describe('UserCollectionInfoPageComponent', () => {
|
describe('UserCollectionInfoPageComponent', () => {
|
||||||
let component: UserCollectionInfoPageComponent;
|
let component: CollectionInfoPageComponent;
|
||||||
let fixture: ComponentFixture<UserCollectionInfoPageComponent>;
|
let fixture: ComponentFixture<CollectionInfoPageComponent>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
declarations: [UserCollectionInfoPageComponent],
|
declarations: [CollectionInfoPageComponent],
|
||||||
});
|
});
|
||||||
fixture = TestBed.createComponent(UserCollectionInfoPageComponent);
|
fixture = TestBed.createComponent(CollectionInfoPageComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
+26
-27
@@ -1,22 +1,22 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { CollectionService } from '../../../../core/services/userCollection.service';
|
import { CollectionService } from '../../../../core/services/collection.service';
|
||||||
import { UserCollection } from '../../../../shared/models/userCollection.model';
|
import { Collection } from '../../../../shared/models/collection.model';
|
||||||
import { DatePipe } from '@angular/common';
|
import { DatePipe } from '@angular/common';
|
||||||
import { CollectionEntry } from '../../../../shared/models/dtos/collection-entry.dto';
|
|
||||||
import { CollectionEditModalComponent } from '../collection-edit-modal/collection-edit-modal.component';
|
import { CollectionEditModalComponent } from '../collection-edit-modal/collection-edit-modal.component';
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
import { ConfirmModalComponent } from '../../../../shared/components/modals/confirm-modal/confirm-modal.component';
|
import { ConfirmModalComponent } from '../../../../shared/components/modals/confirm-modal/confirm-modal.component';
|
||||||
import { ScreenshotService } from '../../../../core/services/screenshot.service';
|
import { ScreenshotService } from '../../../../core/services/screenshot.service';
|
||||||
|
import { CollectionEntryDTO } from '../../../../shared/models/dtos/collection-entry-dto.model';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-userCollection-info-page',
|
selector: 'app-collection-info-page',
|
||||||
templateUrl: './userCollection-info-page.component.html',
|
templateUrl: './collection-info-page.component.html',
|
||||||
styleUrls: ['./userCollection-info-page.component.css'],
|
styleUrls: ['./collection-info-page.component.css'],
|
||||||
providers: [DatePipe],
|
providers: [DatePipe],
|
||||||
})
|
})
|
||||||
export class UserCollectionInfoPageComponent implements OnInit {
|
export class CollectionInfoPageComponent implements OnInit {
|
||||||
collection: UserCollection = {} as UserCollection;
|
collection: Collection = {} as Collection;
|
||||||
createdAt: string = '';
|
createdAt: string = '';
|
||||||
updatedAt: string = '';
|
updatedAt: string = '';
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ export class UserCollectionInfoPageComponent implements OnInit {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private userCollectionService: CollectionService,
|
private collectionService: CollectionService,
|
||||||
private screenshotService: ScreenshotService,
|
private screenshotService: ScreenshotService,
|
||||||
private datePipe: DatePipe,
|
private datePipe: DatePipe,
|
||||||
public dialog: MatDialog,
|
public dialog: MatDialog,
|
||||||
@@ -36,10 +36,10 @@ export class UserCollectionInfoPageComponent implements OnInit {
|
|||||||
const id = this.route.snapshot.paramMap.get('id');
|
const id = this.route.snapshot.paramMap.get('id');
|
||||||
if (id == null) return; // todo redirect if no id is provided
|
if (id == null) return; // todo redirect if no id is provided
|
||||||
|
|
||||||
this.userCollectionService.getCollection(id.toString()).subscribe({
|
this.collectionService.getCollection(id.toString()).subscribe({
|
||||||
next: (data) => {
|
next: (data) => {
|
||||||
this.collection = data as unknown as UserCollection;
|
this.collection = data as unknown as Collection;
|
||||||
this.collection.entries = this.collection.entries as CollectionEntry[];
|
this.collection.entries = this.collection.entries as CollectionEntryDTO[];
|
||||||
|
|
||||||
this.createdAt = this.getCreatedDate()?.toString() || '';
|
this.createdAt = this.getCreatedDate()?.toString() || '';
|
||||||
this.updatedAt = this.getUpdatedAt()?.toString() || '';
|
this.updatedAt = this.getUpdatedAt()?.toString() || '';
|
||||||
@@ -119,18 +119,17 @@ export class UserCollectionInfoPageComponent implements OnInit {
|
|||||||
if (result) {
|
if (result) {
|
||||||
if (result.formData == null) return;
|
if (result.formData == null) return;
|
||||||
|
|
||||||
this.userCollectionService
|
this.collectionService
|
||||||
.updateCollection(this.collection.id, result.formData)
|
.updateCollection(this.collection.id, result.formData)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: (userCollection) => {
|
next: (result) => {
|
||||||
if (userCollection) {
|
if (result) {
|
||||||
// TODO confirm notification
|
// TODO TOAST collection update
|
||||||
// console.log(`User Collection updated: `, userCollection);
|
this.collection = result;
|
||||||
this.collection = userCollection;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
console.error('Error updating userCollection:', error);
|
console.error('Error updating collection:', error);
|
||||||
// TODO error notification
|
// TODO error notification
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -159,7 +158,7 @@ export class UserCollectionInfoPageComponent implements OnInit {
|
|||||||
if (result) {
|
if (result) {
|
||||||
if (result.confirmed != true) return;
|
if (result.confirmed != true) return;
|
||||||
|
|
||||||
this.userCollectionService
|
this.collectionService
|
||||||
.deleteCollection(this.collection.id)
|
.deleteCollection(this.collection.id)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
@@ -167,7 +166,7 @@ export class UserCollectionInfoPageComponent implements OnInit {
|
|||||||
this.router.navigate(['/collections']);
|
this.router.navigate(['/collections']);
|
||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
console.error('Error updating userCollection:', error);
|
console.error('Error updating collection:', error);
|
||||||
// TODO error notification
|
// TODO error notification
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -210,10 +209,10 @@ export class UserCollectionInfoPageComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
refreshCollection() {
|
refreshCollection() {
|
||||||
this.userCollectionService.refreshCollection(this.collection.id).subscribe({
|
this.collectionService.refreshCollection(this.collection.id).subscribe({
|
||||||
next: (data) => {
|
next: (data) => {
|
||||||
this.collection = data as unknown as UserCollection;
|
this.collection = data as unknown as Collection;
|
||||||
this.collection.entries = this.collection.entries as CollectionEntry[];
|
this.collection.entries = this.collection.entries as CollectionEntryDTO[];
|
||||||
|
|
||||||
this.createdAt = this.getCreatedDate()?.toString() || '';
|
this.createdAt = this.getCreatedDate()?.toString() || '';
|
||||||
this.updatedAt = this.getUpdatedAt()?.toString() || '';
|
this.updatedAt = this.getUpdatedAt()?.toString() || '';
|
||||||
@@ -229,13 +228,13 @@ export class UserCollectionInfoPageComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getCollectionParts() {
|
getCollectionParts() {
|
||||||
this.userCollectionService
|
this.collectionService
|
||||||
.getCollectionParts(this.collection.id)
|
.getCollectionParts(this.collection.id)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: (data) => {
|
next: (data) => {
|
||||||
this.collection = data as unknown as UserCollection;
|
this.collection = data as unknown as Collection;
|
||||||
this.collection.entries = this.collection
|
this.collection.entries = this.collection
|
||||||
.entries as CollectionEntry[];
|
.entries as CollectionEntryDTO[];
|
||||||
|
|
||||||
this.createdAt = this.getCreatedDate()?.toString() || '';
|
this.createdAt = this.getCreatedDate()?.toString() || '';
|
||||||
this.updatedAt = this.getUpdatedAt()?.toString() || '';
|
this.updatedAt = this.getUpdatedAt()?.toString() || '';
|
||||||
@@ -1,17 +1,17 @@
|
|||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { Routes, RouterModule } from '@angular/router';
|
import { Routes, RouterModule } from '@angular/router';
|
||||||
import { UserCollectionsPageComponent } from './user-collections/userCollections-page/userCollections-page.component';
|
import { CollectionsPageComponent } from './collections/collections-page/collections-page.component';
|
||||||
import { UserCollectionInfoPageComponent } from './user-collection-info/userCollection-info-page/userCollection-info-page.component';
|
import { CollectionInfoPageComponent } from './collection-info/collection-info-page/collection-info-page.component';
|
||||||
|
|
||||||
// ! /user-collections
|
// ! /collections
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{
|
{
|
||||||
path: '',
|
path: '',
|
||||||
component: UserCollectionsPageComponent
|
component: CollectionsPageComponent
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: ':id',
|
path: ':id',
|
||||||
component: UserCollectionInfoPageComponent
|
component: CollectionInfoPageComponent
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { SharedModule } from '../../shared/shared.module';
|
||||||
|
import { CollectionsRoutingModule } from './collections-routing.module';
|
||||||
|
|
||||||
|
import { DragDropModule } from '@angular/cdk/drag-drop';
|
||||||
|
|
||||||
|
import { CollectionsPageComponent } from './collections/collections-page/collections-page.component';
|
||||||
|
import { CollectionCardComponent } from './collections/collection-card/collection-card.component';
|
||||||
|
import { CollectionEntryGridComponent } from './collection-info/collection-entry-grid/collection-entry-grid.component';
|
||||||
|
import { CollectionEntryCardComponent } from './collection-info/collection-entry-card/collection-entry-card.component';
|
||||||
|
import { CollectionInfoPageComponent } from './collection-info/collection-info-page/collection-info-page.component';
|
||||||
|
import { UserCollectionsModalComponent } from '../../shared/components/modals/list-selection-modal/user-collections-modal.component';
|
||||||
|
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||||
|
import { CollectionEntryTableComponent } from './collection-info/collection-entry-table/collection-entry-table.component';
|
||||||
|
import { CollectionEntryLineComponent } from './collection-info/collection-entry-line/collection-entry-line.component';
|
||||||
|
import { CollectionEditModalComponent } from './collection-info/collection-edit-modal/collection-edit-modal.component';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [
|
||||||
|
CommonModule,
|
||||||
|
SharedModule,
|
||||||
|
|
||||||
|
FormsModule,
|
||||||
|
ReactiveFormsModule,
|
||||||
|
|
||||||
|
CollectionsRoutingModule,
|
||||||
|
|
||||||
|
DragDropModule,
|
||||||
|
],
|
||||||
|
declarations: [
|
||||||
|
// collections list page
|
||||||
|
CollectionsPageComponent,
|
||||||
|
CollectionCardComponent,
|
||||||
|
|
||||||
|
// collection info page
|
||||||
|
CollectionInfoPageComponent,
|
||||||
|
|
||||||
|
CollectionEntryGridComponent,
|
||||||
|
CollectionEntryCardComponent,
|
||||||
|
|
||||||
|
CollectionEntryTableComponent,
|
||||||
|
CollectionEntryLineComponent,
|
||||||
|
|
||||||
|
CollectionEditModalComponent,
|
||||||
|
UserCollectionsModalComponent,
|
||||||
|
],
|
||||||
|
exports: [],
|
||||||
|
})
|
||||||
|
export class CollectionsModule {}
|
||||||
File renamed without changes.
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
<div class="list-item-1 mt-2 text-center">
|
<div class="list-item-1 mt-2 text-center">
|
||||||
<h6 class="mb-0 list-title" (click)="redirectTo()">{{collection.name}}</h6>
|
<h6 class="mb-0 list-title" (click)="redirectTo()">{{collection.name}}</h6>
|
||||||
<!-- <p class="mb-0">Created: {{getCreatedDate() | dateFormat}}</p> -->
|
<!-- <p class="mb-0">Created: {{getCreatedDate() | dateFormat}}</p> -->
|
||||||
<!-- <p class="mb-0">Contains: {{list.userCollectionEntries.length}} title(s)</p> -->
|
<!-- <p class="mb-0">Contains: {{list.collectionEntries.length}} title(s)</p> -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
+5
-5
@@ -1,16 +1,16 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
import { UserCollectionsListItemComponent } from './userCollections-list-item.component';
|
import { CollectionCardComponent } from './collection-card.component';
|
||||||
|
|
||||||
describe('UserCollectionsListItemComponent', () => {
|
describe('UserCollectionsListItemComponent', () => {
|
||||||
let component: UserCollectionsListItemComponent;
|
let component: CollectionCardComponent;
|
||||||
let fixture: ComponentFixture<UserCollectionsListItemComponent>;
|
let fixture: ComponentFixture<CollectionCardComponent>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
declarations: [UserCollectionsListItemComponent]
|
declarations: [CollectionCardComponent]
|
||||||
});
|
});
|
||||||
fixture = TestBed.createComponent(UserCollectionsListItemComponent);
|
fixture = TestBed.createComponent(CollectionCardComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
+45
@@ -0,0 +1,45 @@
|
|||||||
|
import { Component, Input } from '@angular/core';
|
||||||
|
import { Collection } from '../../../../shared/models/collection.model';
|
||||||
|
import { CollectionService } from '../../../../core/services/collection.service';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
import { trigger, transition, style, animate } from '@angular/animations';
|
||||||
|
import { environment } from '../../../../../environments/environment.prod';
|
||||||
|
import { Entry } from '../../../../shared/models/entry.model';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-collection-card',
|
||||||
|
templateUrl: './collection-card.component.html',
|
||||||
|
styleUrls: ['./collection-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 CollectionCardComponent {
|
||||||
|
@Input() collection!: Collection;
|
||||||
|
|
||||||
|
constructor(private listService: CollectionService, private router: Router) {}
|
||||||
|
|
||||||
|
getCreatedDate(): string {
|
||||||
|
if (this.collection.createdAt == null) return '';
|
||||||
|
|
||||||
|
return this.collection.createdAt.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
redirectTo(): void {
|
||||||
|
this.router.navigate([`/collections/${this.collection.id}`]);
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteList() {
|
||||||
|
this.listService.deleteCollection(this.collection.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
File renamed without changes.
+2
-2
@@ -46,8 +46,8 @@
|
|||||||
<div class="card-body p-0">
|
<div class="card-body p-0">
|
||||||
|
|
||||||
<div class="collections-container">
|
<div class="collections-container">
|
||||||
<app-userCollections-list-item *ngFor="let collection of collectionsToShow" [collection]="collection"
|
<app-collection-card *ngFor="let collection of collectionsToShow" [collection]="collection"
|
||||||
@animateDestroy></app-userCollections-list-item>
|
@animateDestroy></app-collection-card>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
+5
-5
@@ -1,16 +1,16 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
import { UserCollectionsPageComponent } from './userCollections-page.component';
|
import { CollectionsPageComponent } from './collections-page.component';
|
||||||
|
|
||||||
describe('UserCollectionsPageComponent', () => {
|
describe('UserCollectionsPageComponent', () => {
|
||||||
let component: UserCollectionsPageComponent;
|
let component: CollectionsPageComponent;
|
||||||
let fixture: ComponentFixture<UserCollectionsPageComponent>;
|
let fixture: ComponentFixture<CollectionsPageComponent>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
declarations: [UserCollectionsPageComponent],
|
declarations: [CollectionsPageComponent],
|
||||||
});
|
});
|
||||||
fixture = TestBed.createComponent(UserCollectionsPageComponent);
|
fixture = TestBed.createComponent(CollectionsPageComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
+11
-11
@@ -1,7 +1,7 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { FormControl } from '@angular/forms';
|
import { FormControl } from '@angular/forms';
|
||||||
import { UserCollection } from '../../../../shared/models/userCollection.model';
|
import { Collection } from '../../../../shared/models/collection.model';
|
||||||
import { CollectionService } from '../../../../core/services/userCollection.service';
|
import { CollectionService } from '../../../../core/services/collection.service';
|
||||||
import {
|
import {
|
||||||
animate,
|
animate,
|
||||||
state,
|
state,
|
||||||
@@ -13,9 +13,9 @@ import { Entry } from '../../../../shared/models/entry.model';
|
|||||||
import { environment } from '../../../../../environments/environment.prod';
|
import { environment } from '../../../../../environments/environment.prod';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-userCollections-page',
|
selector: 'app-collections-page',
|
||||||
templateUrl: './userCollections-page.component.html',
|
templateUrl: './collections-page.component.html',
|
||||||
styleUrls: ['./userCollections-page.component.css'],
|
styleUrls: ['./collections-page.component.css'],
|
||||||
animations: [
|
animations: [
|
||||||
trigger('animateDestroy', [
|
trigger('animateDestroy', [
|
||||||
state('void', style({ opacity: '0' })),
|
state('void', style({ opacity: '0' })),
|
||||||
@@ -23,13 +23,13 @@ import { environment } from '../../../../../environments/environment.prod';
|
|||||||
]),
|
]),
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class UserCollectionsPageComponent implements OnInit {
|
export class CollectionsPageComponent implements OnInit {
|
||||||
searchControl = new FormControl('');
|
searchControl = new FormControl('');
|
||||||
showAddButton: boolean = false;
|
showAddButton: boolean = false;
|
||||||
collectionsCount: number = 0;
|
collectionsCount: number = 0;
|
||||||
|
|
||||||
collections: UserCollection[] = [];
|
collections: Collection[] = [];
|
||||||
collectionsToShow: UserCollection[] = [];
|
collectionsToShow: Collection[] = [];
|
||||||
collectionType: string = 'All';
|
collectionType: string = 'All';
|
||||||
|
|
||||||
lockActions: boolean = false;
|
lockActions: boolean = false;
|
||||||
@@ -96,7 +96,7 @@ export class UserCollectionsPageComponent implements OnInit {
|
|||||||
this.lockActions = true;
|
this.lockActions = true;
|
||||||
// TODO add create collection from the collections list page
|
// TODO add create collection from the collections list page
|
||||||
const listName = this.searchControl.value;
|
const listName = this.searchControl.value;
|
||||||
let myNewList = { name: listName } as UserCollection;
|
let myNewList = { name: listName } as Collection;
|
||||||
this.collectionsService.createCollection(myNewList).subscribe({
|
this.collectionsService.createCollection(myNewList).subscribe({
|
||||||
next: (collection) => {
|
next: (collection) => {
|
||||||
this.collections.push(collection);
|
this.collections.push(collection);
|
||||||
@@ -123,7 +123,7 @@ export class UserCollectionsPageComponent implements OnInit {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getCollectionPosterPath(collection: UserCollection) {
|
getCollectionPosterPath(collection: Collection) {
|
||||||
if (collection.medias && collection.medias.length != 0) {
|
if (collection.medias && collection.medias.length != 0) {
|
||||||
const selectedPosters = collection.medias.filter(
|
const selectedPosters = collection.medias.filter(
|
||||||
(m) => m.type == 'poster' && m.isSelected
|
(m) => m.type == 'poster' && m.isSelected
|
||||||
@@ -154,7 +154,7 @@ export class UserCollectionsPageComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getCollectionBakcgroundPath(collection: UserCollection) {
|
getCollectionBakcgroundPath(collection: Collection) {
|
||||||
return `https://www.themoviedb.org/w1280/${collection.backdropPath}`;
|
return `https://www.themoviedb.org/w1280/${collection.backdropPath}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
-7
@@ -1,7 +0,0 @@
|
|||||||
<div class="movies-container">
|
|
||||||
<ng-container *ngFor="let entry of entries">
|
|
||||||
<app-userCollection-grid-card [entry]="entry" [collectionId]="collectionId" (refrechEvent)="refrechEventReceiver()"
|
|
||||||
@animateDestroy>
|
|
||||||
</app-userCollection-grid-card>
|
|
||||||
</ng-container>
|
|
||||||
</div>
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
import { NgModule } from '@angular/core';
|
|
||||||
import { CommonModule } from '@angular/common';
|
|
||||||
import { SharedModule } from '../../shared/shared.module';
|
|
||||||
import { CollectionsRoutingModule } from './collections-routing.module';
|
|
||||||
|
|
||||||
import { DragDropModule } from '@angular/cdk/drag-drop';
|
|
||||||
|
|
||||||
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 { UserCollectionsModalComponent } from '../../shared/components/modals/list-selection-modal/user-collections-modal.component';
|
|
||||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
||||||
import { CollectionEntryTableComponent } from './user-collection-info/collection-entry-table/collection-entry-table.component';
|
|
||||||
import { CollectionTableLineComponent } from './user-collection-info/collection-table-line/collection-table-line.component';
|
|
||||||
|
|
||||||
@NgModule({
|
|
||||||
imports: [
|
|
||||||
CommonModule,
|
|
||||||
SharedModule,
|
|
||||||
|
|
||||||
FormsModule,
|
|
||||||
ReactiveFormsModule,
|
|
||||||
|
|
||||||
CollectionsRoutingModule,
|
|
||||||
|
|
||||||
DragDropModule,
|
|
||||||
],
|
|
||||||
declarations: [
|
|
||||||
// collections list page
|
|
||||||
UserCollectionsPageComponent,
|
|
||||||
UserCollectionsListItemComponent,
|
|
||||||
|
|
||||||
// collection info page
|
|
||||||
UserCollectionInfoPageComponent,
|
|
||||||
|
|
||||||
UserCollectionEntryGridComponent,
|
|
||||||
UserCollectionGridCardComponent,
|
|
||||||
|
|
||||||
CollectionEntryTableComponent,
|
|
||||||
CollectionTableLineComponent,
|
|
||||||
|
|
||||||
|
|
||||||
UserCollectionsModalComponent,
|
|
||||||
],
|
|
||||||
exports: [],
|
|
||||||
})
|
|
||||||
export class UserCollectionsModule {}
|
|
||||||
-127
@@ -1,127 +0,0 @@
|
|||||||
import { Component, Input } from '@angular/core';
|
|
||||||
import { UserCollection } from '../../../../shared/models/userCollection.model';
|
|
||||||
import { CollectionService } from '../../../../core/services/userCollection.service';
|
|
||||||
import { Router } from '@angular/router';
|
|
||||||
import { trigger, transition, style, animate } from '@angular/animations';
|
|
||||||
import { environment } from '../../../../../environments/environment.prod';
|
|
||||||
import { Entry } from '../../../../shared/models/entry.model';
|
|
||||||
|
|
||||||
@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() collection!: UserCollection;
|
|
||||||
|
|
||||||
constructor(private listService: CollectionService, private router: Router) {}
|
|
||||||
|
|
||||||
// getCollectionPosterPath() {
|
|
||||||
// console.log(this.collection.medias);
|
|
||||||
// if (this.collection.medias.length != 0) {
|
|
||||||
// const selectedPosters = this.collection.medias.filter(
|
|
||||||
// (m) => m.type == 'poster' && m.isSelected
|
|
||||||
// );
|
|
||||||
// let selectedPoster;
|
|
||||||
// if (selectedPosters.length != 0) {
|
|
||||||
// selectedPoster = selectedPosters[0].path;
|
|
||||||
// } else {
|
|
||||||
// selectedPoster = this.collection.medias[0].path;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return (
|
|
||||||
// environment.API_URL +
|
|
||||||
// `/media/collections/posters/preview/${selectedPoster}`
|
|
||||||
// );
|
|
||||||
// } else if (this.collection.entries.length != 0) {
|
|
||||||
// // * use the poster of the first entry in the collection
|
|
||||||
// // * if the collection is empty
|
|
||||||
// return this.getEntryPosterPath(this.collection.entries[0]);
|
|
||||||
// } else if (this.collection.posterPath) {
|
|
||||||
// // * use first remote tmdb poster
|
|
||||||
// // * if collection has none and has no entry
|
|
||||||
// return `https://www.themoviedb.org/w1280/${this.collection.posterPath}`;
|
|
||||||
// } else {
|
|
||||||
// // * use default poster
|
|
||||||
// // * if collection has totaly no poster
|
|
||||||
// return 'assets/images/default/default-poster.png';
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// getCollectionBakcgroundPath() {
|
|
||||||
// return `https://www.themoviedb.org/w1280/${this.collection.backdropPath}`;
|
|
||||||
|
|
||||||
// // if (this.list.isLocal) {
|
|
||||||
// // if (this.list.backdropPath == null)
|
|
||||||
// // return 'assets/images/default/default-poster.png';
|
|
||||||
|
|
||||||
// // // * use the collection custom poster
|
|
||||||
// // return (
|
|
||||||
// // environment.API_URL +
|
|
||||||
// // `/media/collections/posters/preview/` +
|
|
||||||
// // this.list.posterPath
|
|
||||||
// // );
|
|
||||||
// // } else {
|
|
||||||
// // // * use the poster of the first entry in the collection if its no empty
|
|
||||||
// // if (this.list.entries.length != 0) {
|
|
||||||
// // return this.getEntryPosterPath(this.list.entries[0]);
|
|
||||||
// // }
|
|
||||||
|
|
||||||
// // return `https://www.themoviedb.org/w1280/${this.list.backdropPath}`;
|
|
||||||
// // // * if the collection is empty
|
|
||||||
// // return 'assets/images/default/default-poster.png';
|
|
||||||
// // }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// getEntryPosterPath(entry: Entry) {
|
|
||||||
// // * Is in library: use a local poster
|
|
||||||
// if (entry.medias) {
|
|
||||||
// const selectedPosters = entry.medias.filter(
|
|
||||||
// (m) => m.type == 'poster' && m.isSelected
|
|
||||||
// );
|
|
||||||
|
|
||||||
// if (
|
|
||||||
// selectedPosters.length &&
|
|
||||||
// selectedPosters[0] &&
|
|
||||||
// selectedPosters[0].path
|
|
||||||
// ) {
|
|
||||||
// const name = selectedPosters[0].path;
|
|
||||||
// return environment.API_URL + `/media/entries/posters/preview/${name}`;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // * No local poster available, Use TMDB poster
|
|
||||||
// if (entry.poster_path)
|
|
||||||
// return `https://image.tmdb.org/t/p/w300` + entry.poster_path;
|
|
||||||
|
|
||||||
// // * No poster found, use default poster image as a last stand
|
|
||||||
// return 'assets/images/default/default-poster.png';
|
|
||||||
// }
|
|
||||||
|
|
||||||
getCreatedDate(): string {
|
|
||||||
if (this.collection.createdAt == null) return '';
|
|
||||||
|
|
||||||
return this.collection.createdAt.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
redirectTo(): void {
|
|
||||||
this.router.navigate([`/collections/${this.collection.id}`]);
|
|
||||||
}
|
|
||||||
|
|
||||||
deleteList() {
|
|
||||||
this.listService.deleteCollection(this.collection.id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -18,11 +18,11 @@ import { EpisodeSeenService } from '../../../core/services/episode-seen.service'
|
|||||||
import { SeasonService } from '../../../core/services/season.service';
|
import { SeasonService } from '../../../core/services/season.service';
|
||||||
import { LibraryService } from '../../../core/services/library.service';
|
import { LibraryService } from '../../../core/services/library.service';
|
||||||
import { ToastrService } from 'ngx-toastr';
|
import { ToastrService } from 'ngx-toastr';
|
||||||
import { EntrySeen } from '../../../shared/models/entrySeen.model';
|
import { EntrySeen } from '../../../shared/models/entry-seen.model';
|
||||||
import { EpisodeSeenModalComponent } from '../../../shared/components/modals/episode-seen-modal/episode-seen-modal.component';
|
import { EpisodeSeenModalComponent } from '../../../shared/components/modals/episode-seen-modal/episode-seen-modal.component';
|
||||||
import { MediaModalComponent } from '../media-modal/media-modal.component';
|
import { MediaModalComponent } from '../media-modal/media-modal.component';
|
||||||
import { environment } from '../../../../environments/environment.prod';
|
import { environment } from '../../../../environments/environment.prod';
|
||||||
import { UserCollection } from '../../../shared/models/userCollection.model';
|
import { Collection } from '../../../shared/models/collection.model';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-entry-page',
|
selector: 'app-entry-page',
|
||||||
@@ -325,7 +325,7 @@ export class EntryPageComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getCollectionBackdropPath(collection: UserCollection) {
|
getCollectionBackdropPath(collection: Collection) {
|
||||||
console.log(`collection media:`, collection.medias);
|
console.log(`collection media:`, collection.medias);
|
||||||
if (collection.medias && collection.medias.length != 0) {
|
if (collection.medias && collection.medias.length != 0) {
|
||||||
const backdrops = collection.medias.filter((m) => m.type == 'backdrop');
|
const backdrops = collection.medias.filter((m) => m.type == 'backdrop');
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { LibraryService } from '../../../core/services/library.service';
|
|||||||
import { ToastrService } from 'ngx-toastr';
|
import { ToastrService } from 'ngx-toastr';
|
||||||
import { SettingsService } from '../../../core/services/settings.service';
|
import { SettingsService } from '../../../core/services/settings.service';
|
||||||
import { Settings } from '../../../shared/models/settings.model';
|
import { Settings } from '../../../shared/models/settings.model';
|
||||||
import { LibraryQueryParams } from '../../../shared/models/LibraryQueryParams';
|
import { LibraryQueryParams } from '../../../shared/models/library-query-params';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
|
|
||||||
declare var $: any;
|
declare var $: any;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { AfterViewInit, Component, OnDestroy, OnInit } from '@angular/core';
|
|||||||
import { Entry } from '../../../shared/models/entry.model';
|
import { Entry } from '../../../shared/models/entry.model';
|
||||||
import { LibraryService } from '../../../core/services/library.service';
|
import { LibraryService } from '../../../core/services/library.service';
|
||||||
import { ActivatedRoute, Event, NavigationEnd, Router } from '@angular/router';
|
import { ActivatedRoute, Event, NavigationEnd, Router } from '@angular/router';
|
||||||
import { LibraryQueryParams } from '../../../shared/models/LibraryQueryParams';
|
import { LibraryQueryParams } from '../../../shared/models/library-query-params';
|
||||||
import { SettingsService } from '../../../core/services/settings.service';
|
import { SettingsService } from '../../../core/services/settings.service';
|
||||||
import { Settings } from '../../../shared/models/settings.model';
|
import { Settings } from '../../../shared/models/settings.model';
|
||||||
import { ValueSetter } from 'date-fns/parse/_lib/Setter';
|
import { ValueSetter } from 'date-fns/parse/_lib/Setter';
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { MaintenanceService } from '../../../core/services/maintenance.service';
|
import { MaintenanceService } from '../../../core/services/maintenance.service';
|
||||||
import { MaintenanceResult } from '../../../shared/models/maintenanceResult.model';
|
import { MaintenanceResult } from '../../../shared/models/maintenance-result.model';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-settings-maintenance',
|
selector: 'app-settings-maintenance',
|
||||||
|
|||||||
+2
-2
@@ -11,7 +11,7 @@
|
|||||||
<input type="text" class="form-control" id="listNameInput" [formControl]="searchControl"
|
<input type="text" class="form-control" id="listNameInput" [formControl]="searchControl"
|
||||||
placeholder="Collection name..." @scaleInOut>
|
placeholder="Collection name..." @scaleInOut>
|
||||||
<button class="btn btn-success growing-width-element" type="button" *ngIf="doShowAddButton()"
|
<button class="btn btn-success growing-width-element" type="button" *ngIf="doShowAddButton()"
|
||||||
(click)="createList()" @scaleInOut>Create
|
(click)="createCollection()" @scaleInOut>Create
|
||||||
Collection</button>
|
Collection</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
<div data-simplebar class="simplebar-content-wrapper">
|
<div data-simplebar class="simplebar-content-wrapper">
|
||||||
<div class="list-group">
|
<div class="list-group">
|
||||||
|
|
||||||
<label *ngFor="let list of userCollectionsToShow" class="list-group-item">
|
<label *ngFor="let list of collectionsToShow" class="list-group-item">
|
||||||
<input class="form-check-input me-1" type="checkbox" [value]="list.id"
|
<input class="form-check-input me-1" type="checkbox" [value]="list.id"
|
||||||
(change)="onSelectionChange(list, $event)" [checked]="list.isChecked">
|
(change)="onSelectionChange(list, $event)" [checked]="list.isChecked">
|
||||||
{{ list.name }}
|
{{ list.name }}
|
||||||
|
|||||||
+42
-43
@@ -1,10 +1,10 @@
|
|||||||
import { Component, Inject, Input, OnInit, ViewChild } from '@angular/core';
|
import { Component, Inject, Input, OnInit, ViewChild } from '@angular/core';
|
||||||
import { FormControl } from '@angular/forms';
|
import { FormControl } from '@angular/forms';
|
||||||
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||||
import { CollectionService } from '../../../../core/services/userCollection.service';
|
import { CollectionService } from '../../../../core/services/collection.service';
|
||||||
import { NotificationPopupComponent } from '../../notification-popup/notification-popup.component';
|
import { NotificationPopupComponent } from '../../notification-popup/notification-popup.component';
|
||||||
import { NotificationService } from '../../../services/notification.service';
|
import { NotificationService } from '../../../services/notification.service';
|
||||||
import { UserCollection } from '../../../models/userCollection.model';
|
import { Collection } from '../../../models/collection.model';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
trigger,
|
trigger,
|
||||||
@@ -43,74 +43,73 @@ export class UserCollectionsModalComponent implements OnInit {
|
|||||||
searchControl = new FormControl('');
|
searchControl = new FormControl('');
|
||||||
showAddButton: boolean = false;
|
showAddButton: boolean = false;
|
||||||
|
|
||||||
userCollections: UserCollection[] = [];
|
collections: Collection[] = [];
|
||||||
userCollectionsToShow: UserCollection[] = [];
|
collectionsToShow: Collection[] = [];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public dialogRef: MatDialogRef<UserCollectionsModalComponent>,
|
public dialogRef: MatDialogRef<UserCollectionsModalComponent>,
|
||||||
@Inject(MAT_DIALOG_DATA) public data: any,
|
@Inject(MAT_DIALOG_DATA) public data: any,
|
||||||
private listService: CollectionService,
|
private collectionService: CollectionService,
|
||||||
private notificationService: NotificationService
|
private notificationService: NotificationService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.entryId = this.data.entryId;
|
this.entryId = this.data.entryId;
|
||||||
this.getLists();
|
this.getCollections();
|
||||||
|
|
||||||
this.searchControl.valueChanges.subscribe((value) => {
|
this.searchControl.valueChanges.subscribe((value) => {
|
||||||
this.applyFilter(value);
|
this.applyFilter(value);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getLists() {
|
getCollections() {
|
||||||
this.listService.getCollections().subscribe({
|
this.collectionService.getCollections().subscribe({
|
||||||
next: (result) => {
|
next: (result) => {
|
||||||
result.forEach((collection) => {
|
result.forEach((collection) => {
|
||||||
if (
|
if (collection.entries.some((entry) => entry.id == this.entryId)) {
|
||||||
collection.entries.some(
|
|
||||||
(entry) => entry.id == this.entryId
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
collection.isChecked = true;
|
collection.isChecked = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.userCollections = result;
|
this.collections = result;
|
||||||
this.userCollections = this.userCollections.filter(
|
this.collections = this.collections.filter((c) => c.isUserCollection);
|
||||||
(c) => c.isUserCollection
|
this.collectionsToShow = this.collections;
|
||||||
);
|
|
||||||
this.userCollectionsToShow = this.userCollections;
|
|
||||||
this.applyFilter(this.searchControl.value);
|
this.applyFilter(this.searchControl.value);
|
||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
console.log("Counldn't get lists from backend.");
|
console.log("Counldn't get collections from backend.");
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
applyFilter(filterValue: string | null) {
|
applyFilter(filterValue: string | null) {
|
||||||
if (filterValue == null) {
|
if (filterValue == null) {
|
||||||
this.userCollectionsToShow = [...this.userCollections];
|
this.collectionsToShow = [...this.collections];
|
||||||
this.showAddButton = false;
|
this.showAddButton = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const normalizedFilter = filterValue.toLowerCase().trim();
|
const normalizedFilter = filterValue.toLowerCase().trim();
|
||||||
|
|
||||||
this.userCollectionsToShow = this.userCollections.filter((list) =>
|
this.collectionsToShow = this.collections.filter((c) =>
|
||||||
list.name.toLowerCase().trim().includes(normalizedFilter)
|
c.name.toLowerCase().trim().includes(normalizedFilter)
|
||||||
);
|
);
|
||||||
|
|
||||||
this.showAddButton = this.userCollectionsToShow.length === 0;
|
this.showAddButton = this.collectionsToShow.length === 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
createList() {
|
createCollection() {
|
||||||
const listName = this.searchControl.value?.toString().trim(); // string
|
const name = this.searchControl.value?.toString().trim(); // string
|
||||||
|
|
||||||
let myNewList = { name: listName } as UserCollection;
|
let collectionData = { name: name } as Collection;
|
||||||
|
|
||||||
this.listService.createCollection(myNewList).subscribe(async (list) => {
|
this.collectionService.createCollection(collectionData).subscribe({
|
||||||
await this.getLists();
|
next: (result) => {
|
||||||
|
this.getCollections();
|
||||||
|
},
|
||||||
|
error: (error) => {
|
||||||
|
console.log(`error creating new collection: `, error);
|
||||||
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,44 +117,44 @@ export class UserCollectionsModalComponent implements OnInit {
|
|||||||
return this.showAddButton;
|
return this.showAddButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
onSelectionChange(userCollection: UserCollection, event: Event): void {
|
onSelectionChange(collection: Collection, event: Event): void {
|
||||||
const inputElement = event.target as HTMLInputElement;
|
const inputElement = event.target as HTMLInputElement;
|
||||||
const isChecked = inputElement.checked;
|
const isChecked = inputElement.checked;
|
||||||
|
|
||||||
if (isChecked || isChecked == null) {
|
if (isChecked || isChecked == null) {
|
||||||
console.log(
|
// console.log(`Adding Entry ${this.entryId} to collection: ${collection.name}`);
|
||||||
`Adding Entry ${this.entryId} to list: ${userCollection.name}`
|
this.collectionService
|
||||||
);
|
.addEntryToCollection(collection.id, this.entryId)
|
||||||
this.listService
|
|
||||||
.addEntryToCollection(userCollection.id, this.entryId)
|
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: (response) => {
|
next: (response) => {
|
||||||
console.log('Successfuly added Entry To Collection:', response);
|
// TODO TOAST entry added to collection
|
||||||
this.getLists();
|
|
||||||
this.showNotification(
|
this.showNotification(
|
||||||
'Entry Added',
|
'Entry Added',
|
||||||
'Entry added successfully',
|
'Entry added successfully',
|
||||||
'success'
|
'success'
|
||||||
);
|
);
|
||||||
|
// console.log('Successfuly added Entry To Collection:', response);
|
||||||
|
this.getCollections();
|
||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
console.error('Error:', error);
|
console.error('Error:', error);
|
||||||
this.showNotification('Error', 'Failed to add entry', 'error');
|
// this.showNotification('Error', 'Failed to add entry', 'error');
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
console.log(
|
// console.log(
|
||||||
`Removing Entry ${this.entryId} from list: ${userCollection.name}`
|
// `Removing Entry ${this.entryId} from collection: ${collection.name}`
|
||||||
);
|
// );
|
||||||
this.listService
|
this.collectionService
|
||||||
.removeEntryFromCollection(userCollection.id.toString(), this.entryId)
|
.removeEntryFromCollection(collection.id, this.entryId)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: (_) => {
|
next: (result) => {
|
||||||
this.showNotification(
|
this.showNotification(
|
||||||
'Entry Removed',
|
'Entry Removed',
|
||||||
'Entry removed successfully',
|
'Entry removed successfully',
|
||||||
'success'
|
'success'
|
||||||
);
|
);
|
||||||
|
// TODO TOAST ENTRY REMOVE FROM COLLECTION
|
||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
console.error('Error removing entry:', error);
|
console.error('Error removing entry:', error);
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import { DateFormatPipe } from './pipes/date-format/date-format.pipe';
|
|||||||
// * other
|
// * other
|
||||||
import { RatingModule } from 'ngx-bootstrap/rating';
|
import { RatingModule } from 'ngx-bootstrap/rating';
|
||||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||||
import { CollectionEditModalComponent } from '../features/collections/user-collection-info/collection-edit-modal/collection-edit-modal.component';
|
|
||||||
import { FloatFormatPipe } from './pipes/float-format/float-format.pipe';
|
import { FloatFormatPipe } from './pipes/float-format/float-format.pipe';
|
||||||
import { EpisodeSeenModalComponent } from './components/modals/episode-seen-modal/episode-seen-modal.component';
|
import { EpisodeSeenModalComponent } from './components/modals/episode-seen-modal/episode-seen-modal.component';
|
||||||
import { MainCardComponent } from './components/cards/main-card/main-card.component';
|
import { MainCardComponent } from './components/cards/main-card/main-card.component';
|
||||||
@@ -41,7 +40,6 @@ import { StopScrollDirective } from './directives/stop-scroll.directive';
|
|||||||
|
|
||||||
// ? modals
|
// ? modals
|
||||||
SeenModalComponent,
|
SeenModalComponent,
|
||||||
CollectionEditModalComponent,
|
|
||||||
ConfirmModalComponent,
|
ConfirmModalComponent,
|
||||||
EpisodeSeenModalComponent,
|
EpisodeSeenModalComponent,
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user