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
+95 -50

No files matched your search

@@ -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;