diff --git a/frontend/src/app/core/services/collection.service.ts b/frontend/src/app/core/services/collection.service.ts index 5fa04a2..b7c9eda 100644 --- a/frontend/src/app/core/services/collection.service.ts +++ b/frontend/src/app/core/services/collection.service.ts @@ -15,21 +15,21 @@ export class CollectionService { constructor(private http: HttpClient) {} - // get all lists + // get all collections getCollections(): Observable { return this.http.get( `${this.backend_apiUrl}/${this.apiAction}` ); } - // get a list by id + // get a collection by id getCollection(collectionId: number): Observable { return this.http.get( `${this.backend_apiUrl}/${this.apiAction}/${collectionId}` ); } - // Create a new list + // Create a new collection createCollection(collection: Collection): Observable { return this.http.post( `${this.backend_apiUrl}/${this.apiAction}`, @@ -64,14 +64,14 @@ export class CollectionService { ); } - // Delete a list by ID + // Delete a collection by ID deleteCollection(collectionId: number): Observable { return this.http.delete( `${this.backend_apiUrl}/${this.apiAction}/${collectionId}` ); } - // Add an entry to a list + // Add an entry to a collection addEntryToCollection( collectionId: number, entryId: number @@ -82,7 +82,7 @@ export class CollectionService { ); } - // Update an entry's order in a list + // Update an entry's order in a collection updateEntryOrder( collectionId: number, entryId: number, @@ -94,7 +94,7 @@ export class CollectionService { ); } - // Remove an entry from a list + // Remove an entry from a collection removeEntryFromCollection( collectionId: number, entryId: number diff --git a/frontend/src/app/features/collections/collection-info/collection-info-page/collection-info-page.component.html b/frontend/src/app/features/collections/collection-info/collection-info-page/collection-info-page.component.html index 2200e99..0628c1b 100644 --- a/frontend/src/app/features/collections/collection-info/collection-info-page/collection-info-page.component.html +++ b/frontend/src/app/features/collections/collection-info/collection-info-page/collection-info-page.component.html @@ -32,7 +32,8 @@
  • Switch View
  • Delete
  • -
  • Share (as image)
  • +
  • Share (Image)
  • +
  • Share (Text)
  • Refresh Information diff --git a/frontend/src/app/features/collections/collection-info/collection-info-page/collection-info-page.component.ts b/frontend/src/app/features/collections/collection-info/collection-info-page/collection-info-page.component.ts index 34d60a1..424bcde 100644 --- a/frontend/src/app/features/collections/collection-info/collection-info-page/collection-info-page.component.ts +++ b/frontend/src/app/features/collections/collection-info/collection-info-page/collection-info-page.component.ts @@ -195,7 +195,7 @@ export class CollectionInfoPageComponent implements OnInit { this.screenshotService .capture('gridDiv') .then((dataUrl) => { - this.copyToClipboard(dataUrl); + this.copyDataUrlToClipboard(dataUrl); }) .catch((error) => { console.error('Error capturing screenshot:', error); @@ -205,7 +205,24 @@ export class CollectionInfoPageComponent implements OnInit { this.viewMode = oldViewMode; } - private copyToClipboard(dataUrl: string) { + async copyTitles() { + let str = `${this.collection.name}: \n`; + + await this.collection.entries.forEach((entry) => { + const year = new Date(entry.release_date).getFullYear(); + if (entry.is_tvseries) { + str += `${entry.title} (${year} - Seasons: ${ + entry.seasons.length + })\n`; + } else { + str += `${entry.title} (${year})\n`; + } + }); + + this.copyTextToClipboard(str); + } + + private copyDataUrlToClipboard(dataUrl: string) { const img = new Image(); img.src = dataUrl; const canvas = document.createElement('canvas'); @@ -221,6 +238,23 @@ export class CollectionInfoPageComponent implements OnInit { }; } + private async copyTextToClipboard(text: string): Promise { + try { + // Create a Blob from the text + const blob = new Blob([text], { type: 'text/plain' }); + + // Create a ClipboardItem with the Blob + const item = new ClipboardItem({ 'text/plain': blob }); + + // Write the item to the clipboard + await navigator.clipboard.write([item]); + + //console.log('Text copied to clipboard successfully!'); + } catch (error) { + console.error('Failed to copy text to clipboard:', error); + } + } + refreshCollection() { this.collectionService.refreshCollection(this.collection.id).subscribe({ next: (data) => {