Major rework of media handelling, and collections
This commit is contained in:
1 parent
b42e055691
commit
f7cb2bed53
37 files changed
+1120
-411
No files matched your search
@@ -4,7 +4,7 @@ import { CommonModule } from '@angular/common';
|
||||
import { TmdbService } from './services/tmdb.service';
|
||||
import { LibraryService } from './services/library.service';
|
||||
import { EntryService } from './services/entry.service';
|
||||
import { UserCollectionService } from './services/userCollection.service';
|
||||
import { CollectionService } from './services/userCollection.service';
|
||||
import { ToggleService } from './services/toggle.service';
|
||||
import { SidebarComponent } from './components/sidebar/sidebar.component';
|
||||
import { NavbarComponent } from './components/navbar/navbar.component';
|
||||
@@ -32,7 +32,7 @@ import { SharedModule } from '../shared/shared.module';
|
||||
LibraryService,
|
||||
EntryService,
|
||||
EntrySeenService,
|
||||
UserCollectionService,
|
||||
CollectionService,
|
||||
ToggleService,
|
||||
EpisodeService,
|
||||
EpisodeSeenService,
|
||||
|
||||
@@ -65,7 +65,7 @@ export class EntryService {
|
||||
// update entry
|
||||
refrechEntryById(entryId: number) {
|
||||
return this.http.get<Entry>(
|
||||
`${this.backend_apiUrl}/${this.apiAction}/${entryId}/refrech`
|
||||
`${this.backend_apiUrl}/${this.apiAction}/${entryId}/refresh`
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,9 +9,9 @@ import { environment } from '../../../environments/environment.prod';
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class UserCollectionService {
|
||||
export class CollectionService {
|
||||
private backend_apiUrl = environment.API_URL;
|
||||
private apiAction = 'user-collections';
|
||||
private apiAction = 'collections';
|
||||
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
@@ -23,68 +23,84 @@ export class UserCollectionService {
|
||||
}
|
||||
|
||||
// get a list by id
|
||||
getCollection(userCollectionId: string) {
|
||||
getCollection(collectionId: string) {
|
||||
return this.http.get<UserCollection>(
|
||||
`${this.backend_apiUrl}/${this.apiAction}/${userCollectionId}`
|
||||
`${this.backend_apiUrl}/${this.apiAction}/${collectionId}`
|
||||
);
|
||||
}
|
||||
|
||||
// Create a new list
|
||||
createCollection(userCollection: UserCollection): Observable<UserCollection> {
|
||||
createCollection(collection: UserCollection): Observable<UserCollection> {
|
||||
return this.http.post<UserCollection>(
|
||||
`${this.backend_apiUrl}/${this.apiAction}`,
|
||||
userCollection
|
||||
collection
|
||||
);
|
||||
}
|
||||
|
||||
// * PUT - update a collection
|
||||
updateCollection(
|
||||
userCollectionId: number,
|
||||
collectionId: number,
|
||||
formData: FormData
|
||||
): Observable<UserCollection> {
|
||||
return this.http.put<UserCollection>(
|
||||
`${this.backend_apiUrl}/${this.apiAction}/${userCollectionId}`,
|
||||
`${this.backend_apiUrl}/${this.apiAction}/${collectionId}`,
|
||||
formData
|
||||
);
|
||||
}
|
||||
|
||||
// * PUT - REFRESH COLLECTION
|
||||
refreshCollection(collectionId: number): Observable<UserCollection> {
|
||||
return this.http.put<UserCollection>(
|
||||
`${this.backend_apiUrl}/${this.apiAction}/${collectionId}/refresh`,
|
||||
{}
|
||||
);
|
||||
}
|
||||
|
||||
// * PUT - GET COLLECTION PARTS
|
||||
getCollectionParts(collectionId: number): Observable<UserCollection> {
|
||||
return this.http.put<UserCollection>(
|
||||
`${this.backend_apiUrl}/${this.apiAction}/${collectionId}/parts`,
|
||||
{}
|
||||
);
|
||||
}
|
||||
|
||||
// Delete a list by ID
|
||||
deleteCollection(userCollectionId: number): Observable<any> {
|
||||
deleteCollection(collectionId: number): Observable<any> {
|
||||
return this.http.delete(
|
||||
`${this.backend_apiUrl}/${this.apiAction}/${userCollectionId}`
|
||||
`${this.backend_apiUrl}/${this.apiAction}/${collectionId}`
|
||||
);
|
||||
}
|
||||
|
||||
// Add an entry to a list
|
||||
addEntryToCollection(
|
||||
userCollectionId: number,
|
||||
collectionId: number,
|
||||
entryId: number
|
||||
): Observable<UserCollectionEntry> {
|
||||
return this.http.post<UserCollectionEntry>(
|
||||
`${this.backend_apiUrl}/${this.apiAction}/${userCollectionId}/entries/${entryId}`,
|
||||
`${this.backend_apiUrl}/${this.apiAction}/${collectionId}/entries/${entryId}`,
|
||||
{}
|
||||
);
|
||||
}
|
||||
|
||||
// Update an entry's order in a list
|
||||
updateEntryOrder(
|
||||
userCollectionId: string,
|
||||
collectionId: string,
|
||||
entryId: number,
|
||||
newOrder: number
|
||||
): Observable<any> {
|
||||
return this.http.patch(
|
||||
`${this.backend_apiUrl}/${this.apiAction}/${userCollectionId}/entries/${entryId}`,
|
||||
`${this.backend_apiUrl}/${this.apiAction}/${collectionId}/entries/${entryId}`,
|
||||
{ newOrder: newOrder }
|
||||
);
|
||||
}
|
||||
|
||||
// Remove an entry from a list
|
||||
removeEntryFromCollection(
|
||||
userCollectionId: string,
|
||||
collectionId: string,
|
||||
entryId: number
|
||||
): Observable<Entry> {
|
||||
return this.http.delete<Entry>(
|
||||
`${this.backend_apiUrl}/${this.apiAction}/${userCollectionId}/entries/${entryId}`
|
||||
`${this.backend_apiUrl}/${this.apiAction}/${collectionId}/entries/${entryId}`
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user