Skip to content

Commit

Permalink
Additional Thumbnail Support (#601)
Browse files Browse the repository at this point in the history
* Changes necessary to support both PrusaSlicerThumbnails and UltimakerFormatPackage plugin's extracted thumbnails

* Update src/app/files/files.component.html

Co-Authored-By: Timon G. <timon.gaebelein@icloud.com>

* Update src/app/files.service.ts

Co-Authored-By: Timon G. <timon.gaebelein@icloud.com>

* Update src/app/files.service.ts

Co-Authored-By: Timon G. <timon.gaebelein@icloud.com>

* change to string for thumbnail

Co-authored-by: Timon G. <timon.gaebelein@icloud.com>
  • Loading branch information
jneilliii and UnchartedBull authored Apr 27, 2020
1 parent b9cb8a6 commit 898e242
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
16 changes: 8 additions & 8 deletions src/app/files.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
Expand All @@ -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 => {
Expand Down
2 changes: 1 addition & 1 deletion src/app/files/files.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<span class="file__name">{{ fileDetail.name }}</span>
<span class="file__directory">{{ fileDetail.path }}</span>
<span class="file__creation-date" *ngIf="fileDetail.hasOwnProperty('date')">{{ fileDetail.date }}</span>
<img src="{{fileDetail.thumbnail ? fileDetail.thumbnail : 'assets/object.svg'}}" class="file__render"/>
<img [src]="fileDetail.thumbnail" class="file__render"/>
<table class="file__details">
<tr>
<td>{{ fileDetail.size }}<span class="file__details-name">mb</span></td>
Expand Down
1 change: 1 addition & 0 deletions src/app/octoprint-api/filesAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface OctoprintFilesAPI {
statistics?: object;
type: string;
typePath: [string];
thumbnail?: string;
}

export interface OctoprintFolderAPI {
Expand Down

0 comments on commit 898e242

Please sign in to comment.