rename model list to usercollection & fixed redlated errors

This commit is contained in:
X4Lo committed 2024-04-06 08:56:16 +00:00
1 parent 60b517500f
commit b48b395574
37 files changed
+2479 -1210

No files matched your search

@@ -1,65 +0,0 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { UserCollection } from '../../shared/models/userCollection.model';
import { ListEntry } from '../../shared/models/listEntry.model';
import { Entry } from '../../shared/models/entry.model';
@Injectable({
providedIn: 'root',
})
export class ListService {
private backend_apiUrl = 'http://localhost:4000/api/v1';
constructor(private http: HttpClient) {}
// get all lists
getLists(): Observable<UserCollection[]> {
return this.http.get<UserCollection[]>(`${this.backend_apiUrl}/lists`);
}
// get a list by id
getList(id: string) {
return this.http.get<UserCollection[]>(`${this.backend_apiUrl}/lists/${id}`);
}
// Create a new list
createList(list: UserCollection): Observable<UserCollection> {
return this.http.post<UserCollection>(`${this.backend_apiUrl}/lists`, list);
}
// Delete a list by ID
deleteList(id: number): Observable<any> {
return this.http.delete(`${this.backend_apiUrl}/lists/${id}`);
}
// Add an entry to a list
addEntryToList(
listId: number,
entryId: number,
order: number
): Observable<ListEntry> {
return this.http.post<ListEntry>(
`${this.backend_apiUrl}/lists/${listId}/entries/${entryId}`,
{ order: order }
);
}
// Update an entry's order in a list
updateEntryOrder(
listId: number,
entryId: number,
newOrder: number
): Observable<any> {
return this.http.patch(
`${this.backend_apiUrl}/lists/${listId}/entries/${entryId}/order`,
{ newOrder }
);
}
// Remove an entry from a list
removeEntryFromList(listId: string, entryId: number): Observable<Entry> {
return this.http.delete<Entry>(
`${this.backend_apiUrl}/lists/${listId}/entries/${entryId}`
);
}
}
@@ -0,0 +1,79 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { UserCollection } from '../../shared/models/userCollection.model';
import { UserCollectionEntry } from '../../shared/models/userCollectionEntry.model';
import { Entry } from '../../shared/models/entry.model';
@Injectable({
providedIn: 'root',
})
export class UserCollectionService {
private backend_apiUrl = 'http://localhost:4000/api/v1';
private apiAction = 'user-collections';
constructor(private http: HttpClient) {}
// get all lists
getLists(): 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[]>(
`${this.backend_apiUrl}/${this.apiAction}/${userCollectionId}`
);
}
// Create a new list
createList(userCollection: UserCollection): Observable<UserCollection> {
return this.http.post<UserCollection>(
`${this.backend_apiUrl}/${this.apiAction}`,
userCollection
);
}
// Delete a list by ID
deleteList(userCollectionId: number): Observable<any> {
return this.http.delete(
`${this.backend_apiUrl}/${this.apiAction}/${userCollectionId}`
);
}
// Add an entry to a list
addEntryToList(
userCollectionId: number,
entryId: number,
order: number
): Observable<UserCollectionEntry> {
return this.http.post<UserCollectionEntry>(
`${this.backend_apiUrl}/${this.apiAction}/${userCollectionId}/entries/${entryId}`,
{ order: order }
);
}
// Update an entry's order in a list
updateEntryOrder(
userCollectionId: string,
entryId: number,
newOrder: number
): Observable<any> {
return this.http.patch(
`${this.backend_apiUrl}/${this.apiAction}/${userCollectionId}/entries/${entryId}/order`,
{ newOrder }
);
}
// Remove an entry from a list
removeEntryFromList(
userCollectionId: string,
entryId: number
): Observable<Entry> {
return this.http.delete<Entry>(
`${this.backend_apiUrl}/${this.apiAction}/${userCollectionId}/entries/${entryId}`
);
}
}