From 898e242e9b1da9a17322d18a2f62ba628f028bf5 Mon Sep 17 00:00:00 2001 From: jneilliii Date: Mon, 27 Apr 2020 18:43:40 -0400 Subject: [PATCH] Additional Thumbnail Support (#601) * Changes necessary to support both PrusaSlicerThumbnails and UltimakerFormatPackage plugin's extracted thumbnails * Update src/app/files/files.component.html Co-Authored-By: Timon G. * Update src/app/files.service.ts Co-Authored-By: Timon G. * Update src/app/files.service.ts Co-Authored-By: Timon G. * change to string for thumbnail Co-authored-by: Timon G. --- src/app/files.service.ts | 16 ++++++++-------- src/app/files/files.component.html | 2 +- src/app/octoprint-api/filesAPI.ts | 1 + 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/app/files.service.ts b/src/app/files.service.ts index 7fe88f260..98d2d4720 100644 --- a/src/app/files.service.ts +++ b/src/app/files.service.ts @@ -161,11 +161,11 @@ export class FilesService { filamentWeight: this.service.convertFilamentLengthToAmount(filamentLength), } : {}), - thumbnail: data.path.endsWith('.ufp.gcode') + thumbnail: data.thumbnail ? this.configService - .getURL('plugin/UltimakerFormatPackage/thumbnail/') - .replace('/api/', '/') + data.path.replace('.ufp.gcode', '.png') - : undefined, + .getURL(data.thumbnail) + .replace('/api/', '/') + : 'assets/object.svg', } as unknown) as File; resolve(file); }, @@ -191,11 +191,11 @@ export class FilesService { .get(this.configService.getURL('files' + filePath), this.configService.getHTTPHeaders()) .subscribe( (data: OctoprintFilesAPI): void => { - let thumbnail = data.path.endsWith('.ufp.gcode') + let thumbnail = data.thumbnail ? this.configService - .getURL('plugin/UltimakerFormatPackage/thumbnail/') - .replace('/api/', '/') + data.path.replace('.ufp.gcode', '.png') - : undefined; + .getURL(data.thumbnail) + .replace('/api/', '/') + : 'assets/object.svg'; resolve(thumbnail); }, (error: HttpErrorResponse): void => { diff --git a/src/app/files/files.component.html b/src/app/files/files.component.html index 9566dbecf..7e833f5df 100644 --- a/src/app/files/files.component.html +++ b/src/app/files/files.component.html @@ -70,7 +70,7 @@ {{ fileDetail.name }} {{ fileDetail.path }} {{ fileDetail.date }} - + diff --git a/src/app/octoprint-api/filesAPI.ts b/src/app/octoprint-api/filesAPI.ts index bd6cfff86..0dbcc3142 100644 --- a/src/app/octoprint-api/filesAPI.ts +++ b/src/app/octoprint-api/filesAPI.ts @@ -14,6 +14,7 @@ export interface OctoprintFilesAPI { statistics?: object; type: string; typePath: [string]; + thumbnail?: string; } export interface OctoprintFolderAPI {
{{ fileDetail.size }}mb