Skip to content

Commit

Permalink
Fix for missing print preview thumbnail
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Roth <developer@freakydu.de>
  • Loading branch information
freakydude committed Dec 2, 2023
1 parent 2776207 commit 0349dfb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
15 changes: 13 additions & 2 deletions src/lib/commons/Values.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,20 @@ export class Values {

if (Array.isArray(thumbnails) && thumbnails.length > 0) {
const thumbnail = thumbnails.sort((n1, n2) => n2.width - n1.width)[0];

path = this.buildAbsoluteThumbnailUrl(moonrakerApi, thumbnail);
}

return path;
}

public buildAbsoluteThumbnailUrl(moonrakerApi: URL, thumbnail: IThumbnail): string {
let path = '';

if (thumbnail.relative_path !== undefined) {
path = moonrakerApi + 'server/files/gcodes/' + thumbnail.relative_path;
} else if (thumbnail.thumbnail_path !== undefined) {
path = moonrakerApi + 'server/files/gcodes/' + thumbnail.thumbnail_path;
} else {
path = '';
}

return path;
Expand Down
3 changes: 2 additions & 1 deletion src/lib/moonraker/types/IThumbnail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ export interface IThumbnail {
width: number;
height: number;
size: number;
thumbnail_path: string;
thumbnail_path?: string;
relative_path?: string;
}
2 changes: 1 addition & 1 deletion src/routes/printstate/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
let apiUrl = bootParams.moonrakerApi;
let loadDialog = false;
let sortedFileNames = ['File 1', 'File 2', 'File 3', 'File 4', 'File 5', 'File 6'];
let sortedFileNames: string[] = [];
let thumbnails: string[] = [];
let selectedFilename = 1;
Expand Down

0 comments on commit 0349dfb

Please sign in to comment.