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
+89 -44

No files matched your search

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