minor style/functions renaming changes

This commit is contained in:
X4Lo committed 2024-04-16 19:13:56 +01:00
1 parent 3374aa9944
commit 8b4c0792c0
13 files changed
+86 -41

No files matched your search

@@ -1,5 +1,4 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
@Injectable({ @Injectable({
providedIn: 'root', providedIn: 'root',
@@ -18,7 +17,6 @@ export class ToggleService {
document.body.classList.add('toggled'); document.body.classList.add('toggled');
this.isToggeled = true; this.isToggeled = true;
} }
// document.body.classList.toggle('toggled');
} }
hoverSidebar(isHovering: boolean) { hoverSidebar(isHovering: boolean) {
@@ -15,21 +15,21 @@ export class UserCollectionService {
constructor(private http: HttpClient) {} constructor(private http: HttpClient) {}
// get all lists // get all lists
getLists(): Observable<UserCollection[]> { getCollections(): Observable<UserCollection[]> {
return this.http.get<UserCollection[]>( return this.http.get<UserCollection[]>(
`${this.backend_apiUrl}/${this.apiAction}` `${this.backend_apiUrl}/${this.apiAction}`
); );
} }
// get a list by id // get a list by id
getList(userCollectionId: string) { getCollection(userCollectionId: string) {
return this.http.get<UserCollection[]>( return this.http.get<UserCollection>(
`${this.backend_apiUrl}/${this.apiAction}/${userCollectionId}` `${this.backend_apiUrl}/${this.apiAction}/${userCollectionId}`
); );
} }
// Create a new list // Create a new list
createList(userCollection: UserCollection): Observable<UserCollection> { createCollection(userCollection: UserCollection): Observable<UserCollection> {
return this.http.post<UserCollection>( return this.http.post<UserCollection>(
`${this.backend_apiUrl}/${this.apiAction}`, `${this.backend_apiUrl}/${this.apiAction}`,
userCollection userCollection
@@ -37,14 +37,14 @@ export class UserCollectionService {
} }
// Delete a list by ID // Delete a list by ID
deleteList(userCollectionId: number): Observable<any> { deleteCollection(userCollectionId: number): Observable<any> {
return this.http.delete( return this.http.delete(
`${this.backend_apiUrl}/${this.apiAction}/${userCollectionId}` `${this.backend_apiUrl}/${this.apiAction}/${userCollectionId}`
); );
} }
// Add an entry to a list // Add an entry to a list
addEntryToList( addEntryToCollection(
userCollectionId: number, userCollectionId: number,
entryId: number, entryId: number,
order: number order: number
@@ -68,7 +68,7 @@ export class UserCollectionService {
} }
// Remove an entry from a list // Remove an entry from a list
removeEntryFromList( removeEntryFromCollection(
userCollectionId: string, userCollectionId: string,
entryId: number entryId: number
): Observable<Entry> { ): Observable<Entry> {
@@ -78,8 +78,8 @@ export class UserCollectionGridCardComponent {
} }
removeEntryFromList() { removeEntryFromList() {
// todo: add confirm modal // TODO: add confirm modal
this.listService.removeEntryFromList(this.listId, this.entry.id).subscribe({ this.listService.removeEntryFromCollection(this.listId, this.entry.id).subscribe({
next: (response) => { next: (response) => {
console.log('Entry successfully removed from list.', response); console.log('Entry successfully removed from list.', response);
this.entry.id = 0; this.entry.id = 0;
@@ -1,4 +1,4 @@
import { Component } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { UserCollectionService } from '../../../../core/services/userCollection.service'; import { UserCollectionService } from '../../../../core/services/userCollection.service';
import { UserCollection } from '../../../../shared/models/userCollection.model'; import { UserCollection } from '../../../../shared/models/userCollection.model';
@@ -11,7 +11,7 @@ import { DatePipe } from '@angular/common';
styleUrls: ['./userCollection-info-page.component.css'], styleUrls: ['./userCollection-info-page.component.css'],
providers: [DatePipe], providers: [DatePipe],
}) })
export class UserCollectionInfoPageComponent { export class UserCollectionInfoPageComponent implements OnInit{
list: UserCollection = {} as UserCollection; list: UserCollection = {} as UserCollection;
createdAt: string = ''; createdAt: string = '';
updatedAt: string = ''; updatedAt: string = '';
@@ -26,7 +26,7 @@ export class UserCollectionInfoPageComponent {
const id = this.route.snapshot.paramMap.get('id'); const id = this.route.snapshot.paramMap.get('id');
if (id == null) return; if (id == null) return;
this.listService.getList(id.toString()).subscribe( this.listService.getCollection(id.toString()).subscribe(
(data) => { (data) => {
// Handle the successful reception of data. // Handle the successful reception of data.
this.list = data as unknown as UserCollection; this.list = data as unknown as UserCollection;
@@ -55,7 +55,6 @@ export class UserCollectionInfoPageComponent {
} }
getUpdatedAt() { getUpdatedAt() {
console.log(1);
const updatedAt = this.list.updatedAt; const updatedAt = this.list.updatedAt;
// First, check if updatedAt is a valid date string or timestamp // First, check if updatedAt is a valid date string or timestamp
const modifiedDate = new Date(updatedAt); const modifiedDate = new Date(updatedAt);
@@ -71,20 +70,24 @@ export class UserCollectionInfoPageComponent {
const diffInMs = now.getTime() - modifiedDate.getTime(); const diffInMs = now.getTime() - modifiedDate.getTime();
const diffInDays = diffInMs / (1000 * 60 * 60 * 24); const diffInDays = diffInMs / (1000 * 60 * 60 * 24);
let isPlural = '';
if (diffInDays < 7) { if (diffInDays < 7) {
// Less than a week, show relative time // Less than a week, show relative time
if (diffInDays < 1) { if (diffInDays < 1) {
const diffInHours = diffInMs / (1000 * 60 * 60); const diffInHours = diffInMs / (1000 * 60 * 60);
if (diffInHours < 1) { if (diffInHours < 1) {
const diffInMinutes = diffInMs / (1000 * 60); const diffInMinutes = diffInMs / (1000 * 60);
return `${Math.floor(diffInMinutes)} minutes ago`; if(diffInMinutes >= 2) isPlural = 's'
return `${Math.floor(diffInMinutes)} minute${isPlural} ago`;
} }
return `${Math.floor(diffInHours)} hours ago`; if(diffInHours >= 2) isPlural = 's'
return `${Math.floor(diffInHours)} hour${isPlural} ago`;
} }
return `${Math.floor(diffInDays)} days ago`;
if(diffInDays >= 2) isPlural = 's'
return `${Math.floor(diffInDays)} day${isPlural} ago`;
} else { } else {
// More than a week, show formatted date // 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'); return this.datePipe.transform(modifiedDate, 'dd MMMM, yyyy');
} }
} }
@@ -5,9 +5,6 @@
.list-title { .list-title {
font-size: 20px; font-size: 20px;
} }
.list-title:hover {
color: var(--aruze-blue)
}
.list-line { .list-line {
border-radius: 1px; border-radius: 1px;
@@ -15,5 +12,9 @@
} }
.list-line:hover { .list-line:hover {
background-color: aliceblue; background-color: var(--shz-light-bgh);
}
:host-context([data-bs-theme="dark"]) .list-line:hover {
background-color: var(--shz-dark-bgh);
} }
@@ -25,7 +25,10 @@ import { trigger, transition, style, animate } from '@angular/animations';
export class UserCollectionsListItemComponent { export class UserCollectionsListItemComponent {
@Input() list!: UserCollection; @Input() list!: UserCollection;
constructor(private listService: UserCollectionService, private router: Router) {} constructor(
private listService: UserCollectionService,
private router: Router
) {}
getPostPath() { getPostPath() {
if (this.list.poster_path == null) return 'https://pic.pnnet.dev/256x256'; if (this.list.poster_path == null) return 'https://pic.pnnet.dev/256x256';
@@ -44,6 +47,6 @@ export class UserCollectionsListItemComponent {
} }
deleteList() { deleteList() {
this.listService.deleteList(this.list.id); this.listService.deleteCollection(this.list.id);
} }
} }
@@ -8,7 +8,7 @@
<a href="javascript:;"> <a href="javascript:;">
</a> </a>
</li> </li>
<li class="breadcrumb-item active" aria-current="page">Lists</li> <li class="breadcrumb-item active" aria-current="page">Collections</li>
</ol> </ol>
</nav> </nav>
</div> </div>
@@ -30,7 +30,8 @@
<div class="p-3 ps ps--active-y"> <div class="p-3 ps ps--active-y">
<div class="d-flex flex-column gap-3"> <div class="d-flex flex-column gap-3">
<!-- item start --> <!-- item start -->
<app-userCollections-list-item *ngFor="let list of listsToShow" [list]="list"></app-userCollections-list-item> <app-userCollections-list-item *ngFor="let list of listsToShow"
[list]="list"></app-userCollections-list-item>
<!-- item end --> <!-- item end -->
</div> </div>
</div> </div>
@@ -26,7 +26,7 @@ export class UserCollectionsPageComponent implements OnInit {
} }
getLists() { getLists() {
this.listService.getLists().subscribe({ this.listService.getCollections().subscribe({
next: (l) => { next: (l) => {
console.log(`Loaded ${l.length} lists.`); console.log(`Loaded ${l.length} lists.`);
this.lists = l; this.lists = l;
@@ -0,0 +1,38 @@
/* Custom CSS to visually connect the elements */
.custom-group .form-select {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
.custom-group .form-select,
.custom-group .input-group-text {
border: 1px black solid;
}
.custom-group .btn-group .btn {
border-radius: 0;
}
.custom-group .btn-group .left-btn {
/* border-top-left-radius: 0.25rem; */
/* border-bottom-left-radius: 0.25rem; */
border-left: 0;
border-right: 0;
}
.custom-group .btn-group .right-btn {
border-top-right-radius: 0.25rem;
border-bottom-right-radius: 0.25rem;
border-left: 0;
}
.custom-group .form-select,
.custom-group .btn-outline-dark {
margin-right: -1px;
}
/* Adjust the select width as needed */
#single-select-field {
max-width: 120px;
}
@@ -13,6 +13,8 @@
</nav> </nav>
</div> </div>
<div class="ms-auto"> <div class="ms-auto">
<div class="input-group custom-group">
<div class="input-group-text">Show</div>
<select class="form-select" id="single-select-field" data-placeholder="Choose one thing" style="max-width: 150px;" <select class="form-select" id="single-select-field" data-placeholder="Choose one thing" style="max-width: 150px;"
[(ngModel)]="pageSize" (change)="setPageSize($event)"> [(ngModel)]="pageSize" (change)="setPageSize($event)">
<option value="20">20</option> <option value="20">20</option>
@@ -24,19 +26,18 @@
</select> </select>
<div class="btn-group"> <div class="btn-group">
<button type="button" class="btn btn-outline-dark" [class.active]="entryType === 0" <button type="button" class="btn btn-outline-dark left-btn" [class.active]="entryType === 0"
(click)="setEntryType(0)">All</button> (click)="setEntryType(0)">All</button>
<button type="button" class="btn btn-outline-dark" [class.active]="entryType === 1" <button type="button" class="btn btn-outline-dark" [class.active]="entryType === 1"
(click)="setEntryType(1)">Movies</button> (click)="setEntryType(1)">Movies</button>
<button type="button" class="btn btn-outline-dark right-btn" [class.active]="entryType === 2"
<button type="button" class="btn btn-outline-dark" [class.active]="entryType === 2"
(click)="setEntryType(2)">TV-Series</button> (click)="setEntryType(2)">TV-Series</button>
</div> </div>
</div> </div>
</div> </div>
</div>
<!--end breadcrumb--> <!--end breadcrumb-->
<!-- Pagination --> <!-- Pagination -->
<div class="pagination-container d-flex justify-content-end" *ngIf="maxPage != 1"> <div class="pagination-container d-flex justify-content-end" *ngIf="maxPage != 1">
<ul class="pagination pagination-sm"> <ul class="pagination pagination-sm">
@@ -1,6 +1,6 @@
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { TmdbService } from '../../../core/services/tmdb.service'; import { TmdbService } from '../../../../core/services/tmdb.service';
import { Entry } from '../../../shared/models/entry.model'; import { Entry } from '../../../../shared/models/entry.model';
@Component({ @Component({
selector: 'app-entry-list', selector: 'app-entry-list',
@@ -19,7 +19,7 @@
</mat-dialog-actions> --> </mat-dialog-actions> -->
<div class="modal-content user-lists"> <div class="modal-content user-lists">
<div class="modal-header"> <div class="modal-header">
<h2 class="modal-title">Choose a list</h2> <h2 class="modal-title">Choose a Collection</h2>
<button type="button" class="btn-close" (click)="closeDialog()"></button> <button type="button" class="btn-close" (click)="closeDialog()"></button>
</div> </div>
@@ -28,9 +28,9 @@
<div class="input-group mb-3 "> <div class="input-group mb-3 ">
<!-- <label for="listNameInput" class="form-label">List Name</label> --> <!-- <label for="listNameInput" class="form-label">List Name</label> -->
<input type="text" class="form-control" id="listNameInput" [formControl]="searchControl" <input type="text" class="form-control" id="listNameInput" [formControl]="searchControl"
placeholder="List name..." @scaleInOut> placeholder="Collection name..." @scaleInOut>
<button class="btn btn-success growing-width-element" type="button" *ngIf="doShowAddButton()" (click)="createList()" @scaleInOut>Create <button class="btn btn-success growing-width-element" type="button" *ngIf="doShowAddButton()" (click)="createList()" @scaleInOut>Create
List</button> Collection</button>
</div> </div>
<div class="d-grid gap-2" *ngIf="doShowAddButton()"> <div class="d-grid gap-2" *ngIf="doShowAddButton()">
@@ -63,7 +63,7 @@ export class UserCollectionsModalComponent implements OnInit {
} }
getLists() { getLists() {
this.listService.getLists().subscribe({ this.listService.getCollections().subscribe({
next: (c) => { next: (c) => {
c.forEach((collection) => { c.forEach((collection) => {
if ( if (
@@ -106,7 +106,7 @@ export class UserCollectionsModalComponent implements OnInit {
let myNewList = { name: listName } as UserCollection; let myNewList = { name: listName } as UserCollection;
this.listService.createList(myNewList).subscribe(async (list) => { this.listService.createCollection(myNewList).subscribe(async (list) => {
await this.getLists(); await this.getLists();
}); });
} }
@@ -124,7 +124,7 @@ export class UserCollectionsModalComponent implements OnInit {
`Adding Entry ${this.entryId} to list: ${userCollection.name}` `Adding Entry ${this.entryId} to list: ${userCollection.name}`
); );
this.listService this.listService
.addEntryToList( .addEntryToCollection(
userCollection.id, userCollection.id,
this.entryId, this.entryId,
userCollection.userCollectionEntries.length + 1 userCollection.userCollectionEntries.length + 1
@@ -149,7 +149,7 @@ export class UserCollectionsModalComponent implements OnInit {
`Removing Entry ${this.entryId} from list: ${userCollection.name}` `Removing Entry ${this.entryId} from list: ${userCollection.name}`
); );
this.listService this.listService
.removeEntryFromList(userCollection.id.toString(), this.entryId) .removeEntryFromCollection(userCollection.id.toString(), this.entryId)
.subscribe({ .subscribe({
next: (_) => { next: (_) => {
this.showNotification( this.showNotification(