From a94f82b4a94ec0c4109e0435ad4748dac37fc852 Mon Sep 17 00:00:00 2001 From: lightmaster Date: Wed, 24 Feb 2021 21:09:37 -0500 Subject: [PATCH 01/16] Fix Typo, `prusalicer` => `prusaslicer` --- .../static/js/prusaslicerthumbnails.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/octoprint_prusaslicerthumbnails/static/js/prusaslicerthumbnails.js b/octoprint_prusaslicerthumbnails/static/js/prusaslicerthumbnails.js index cc26185..cc5389c 100644 --- a/octoprint_prusaslicerthumbnails/static/js/prusaslicerthumbnails.js +++ b/octoprint_prusaslicerthumbnails/static/js/prusaslicerthumbnails.js @@ -101,19 +101,19 @@ $(function() { .done(function(file_data){ if(file_data){ if(self.settingsViewModel.settings.plugins.prusaslicerthumbnails.state_panel_thumbnail() && file_data.thumbnail && file_data.thumbnail_src == 'prusaslicerthumbnails'){ - if($('#prusalicer_state_thumbnail').length) { - $('#prusalicer_state_thumbnail > img').attr('src', file_data.thumbnail); + if($('#prusaslicer_state_thumbnail').length) { + $('#prusaslicer_state_thumbnail > img').attr('src', file_data.thumbnail); } else { - $('#state > div > hr:first').after('
\n
'); + $('#state > div > hr:first').after('
\n
'); } } else { - $('#prusalicer_state_thumbnail').remove(); + $('#prusaslicer_state_thumbnail').remove(); } } }) .fail(function(file_data){ - if($('#prusalicer_state_thumbnail').length) { - $('#prusalicer_state_thumbnail').remove(); + if($('#prusaslicer_state_thumbnail').length) { + $('#prusaslicer_state_thumbnail').remove(); } }); } From 99d3fc48ba9b5906559b775b9827c5b4ca2c3beb Mon Sep 17 00:00:00 2001 From: jneilliii Date: Wed, 24 Feb 2021 21:24:33 -0500 Subject: [PATCH 02/16] bump version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 8a14888..2aece2c 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ plugin_name = "PrusaSlicer Thumbnails" # The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module -plugin_version = "0.1.4" +plugin_version = "0.1.5rc1" # The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin # module From 41fa89ea04cd8494361dc86878262fb3a3eca30a Mon Sep 17 00:00:00 2001 From: jneilliii Date: Wed, 24 Feb 2021 22:50:42 -0500 Subject: [PATCH 03/16] add file list height options and print button to popup, #49 --- octoprint_prusaslicerthumbnails/__init__.py | 5 ++++- .../static/js/prusaslicerthumbnails.js | 16 +++++++++++++++- .../templates/prusaslicerthumbnails.jinja2 | 9 ++++++--- .../prusaslicerthumbnails_settings.jinja2 | 19 ++++++++++++++++++- setup.py | 2 +- 5 files changed, 44 insertions(+), 7 deletions(-) diff --git a/octoprint_prusaslicerthumbnails/__init__.py b/octoprint_prusaslicerthumbnails/__init__.py index 3794df3..588e89c 100644 --- a/octoprint_prusaslicerthumbnails/__init__.py +++ b/octoprint_prusaslicerthumbnails/__init__.py @@ -32,7 +32,10 @@ def get_settings_defaults(self): inline_thumbnail_scale_value="50", align_inline_thumbnail=False, inline_thumbnail_align_value="left", - state_panel_thumbnail=True + state_panel_thumbnail=True, + state_panel_thumbnail_scale_value="75", + resize_filelist=False, + filelist_height="306" ) ##~~ AssetPlugin mixin diff --git a/octoprint_prusaslicerthumbnails/static/js/prusaslicerthumbnails.js b/octoprint_prusaslicerthumbnails/static/js/prusaslicerthumbnails.js index cc5389c..643f7cd 100644 --- a/octoprint_prusaslicerthumbnails/static/js/prusaslicerthumbnails.js +++ b/octoprint_prusaslicerthumbnails/static/js/prusaslicerthumbnails.js @@ -15,6 +15,7 @@ $(function() { self.thumbnail_url = ko.observable('/static/img/tentacle-20x20.png'); self.thumbnail_title = ko.observable(''); self.inline_thumbnail = ko.observable(); + self.file_details = ko.observable(); self.crawling_files = ko.observable(false); self.crawl_results = ko.observableArray([]); @@ -23,6 +24,7 @@ $(function() { var thumbnail_title = data.path.replace('.gcode',''); self.thumbnail_url(data.thumbnail); self.thumbnail_title(thumbnail_title); + self.file_details(data); $('div#prusa_thumbnail_viewer').modal("show"); } } @@ -71,6 +73,11 @@ $(function() { self.filesViewModel.thumbnailAlignValue(self.settingsViewModel.settings.plugins.prusaslicerthumbnails.inline_thumbnail_align_value()); } + // assign initial filelist height + if(self.settingsViewModel.settings.plugins.prusaslicerthumbnails.resize_filelist()) { + $('#files > div > div.gcode_files > div.scroll-wrapper').css({'height': self.settingsViewModel.settings.plugins.prusaslicerthumbnails.filelist_height() + 'px'}); + } + // observe scaling changes self.settingsViewModel.settings.plugins.prusaslicerthumbnails.scale_inline_thumbnail.subscribe(function(newValue){ if (newValue == false){ @@ -95,6 +102,13 @@ $(function() { self.filesViewModel.thumbnailAlignValue(newValue); }); + // observe file list height changes + self.settingsViewModel.settings.plugins.prusaslicerthumbnails.filelist_height.subscribe(function(newValue){ + if(self.settingsViewModel.settings.plugins.prusaslicerthumbnails.resize_filelist()) { + $('#files > div > div.gcode_files > div.scroll-wrapper').css({'height': self.settingsViewModel.settings.plugins.prusaslicerthumbnails.filelist_height() + 'px'}); + } + }); + self.printerStateViewModel.filepath.subscribe(function(data){ if(data){ OctoPrint.files.get('local',data) @@ -104,7 +118,7 @@ $(function() { if($('#prusaslicer_state_thumbnail').length) { $('#prusaslicer_state_thumbnail > img').attr('src', file_data.thumbnail); } else { - $('#state > div > hr:first').after('
\n
'); + $('#state > div > hr:first').after('
\n
'); } } else { $('#prusaslicer_state_thumbnail').remove(); diff --git a/octoprint_prusaslicerthumbnails/templates/prusaslicerthumbnails.jinja2 b/octoprint_prusaslicerthumbnails/templates/prusaslicerthumbnails.jinja2 index cb7a9ec..87c9463 100644 --- a/octoprint_prusaslicerthumbnails/templates/prusaslicerthumbnails.jinja2 +++ b/octoprint_prusaslicerthumbnails/templates/prusaslicerthumbnails.jinja2 @@ -4,9 +4,12 @@

- \ No newline at end of file + diff --git a/octoprint_prusaslicerthumbnails/templates/prusaslicerthumbnails_settings.jinja2 b/octoprint_prusaslicerthumbnails/templates/prusaslicerthumbnails_settings.jinja2 index 497e499..6228579 100644 --- a/octoprint_prusaslicerthumbnails/templates/prusaslicerthumbnails_settings.jinja2 +++ b/octoprint_prusaslicerthumbnails/templates/prusaslicerthumbnails_settings.jinja2 @@ -5,6 +5,12 @@ Show thumbnail in state panel. +
+ + + % + +
+
+ +
+
+ + + px + +
@@ -61,4 +78,4 @@
- \ No newline at end of file + diff --git a/setup.py b/setup.py index 2aece2c..00af117 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ plugin_name = "PrusaSlicer Thumbnails" # The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module -plugin_version = "0.1.5rc1" +plugin_version = "0.1.5rc2" # The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin # module From 2cdd53c8fddb6c6bd378d877b31b50ef1c3d5fa0 Mon Sep 17 00:00:00 2001 From: jneilliii Date: Thu, 25 Feb 2021 00:07:28 -0500 Subject: [PATCH 04/16] subscribe to state panel changes to automatically apply change --- .../static/js/prusaslicerthumbnails.js | 3 +++ setup.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/octoprint_prusaslicerthumbnails/static/js/prusaslicerthumbnails.js b/octoprint_prusaslicerthumbnails/static/js/prusaslicerthumbnails.js index 643f7cd..90b0564 100644 --- a/octoprint_prusaslicerthumbnails/static/js/prusaslicerthumbnails.js +++ b/octoprint_prusaslicerthumbnails/static/js/prusaslicerthumbnails.js @@ -89,6 +89,9 @@ $(function() { self.settingsViewModel.settings.plugins.prusaslicerthumbnails.inline_thumbnail_scale_value.subscribe(function(newValue){ self.filesViewModel.thumbnailScaleValue(newValue + "%"); }); + self.settingsViewModel.settings.plugins.prusaslicerthumbnails.state_panel_thumbnail_scale_value.subscribe(function(newValue){ + $('#prusaslicer_state_thumbnail > img').attr({'width': self.settingsViewModel.settings.plugins.prusaslicerthumbnails.state_panel_thumbnail_scale_value() + '%'}) + }); // observe alignment changes self.settingsViewModel.settings.plugins.prusaslicerthumbnails.align_inline_thumbnail.subscribe(function(newValue){ diff --git a/setup.py b/setup.py index 00af117..577eed6 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ plugin_name = "PrusaSlicer Thumbnails" # The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module -plugin_version = "0.1.5rc2" +plugin_version = "0.1.5rc3" # The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin # module From 6e99d7b925a3e0303b2a8b9e64bdf67ef6e8db84 Mon Sep 17 00:00:00 2001 From: jneilliii Date: Fri, 5 Mar 2021 21:08:19 -0500 Subject: [PATCH 05/16] add position inline thumbnail on left of text option, #68 --- octoprint_prusaslicerthumbnails/__init__.py | 4 ++- .../static/css/prusaslicerthumbnails.css | 12 ++++++++ .../static/js/prusaslicerthumbnails.js | 28 ++++++++++++++----- .../prusaslicerthumbnails_settings.jinja2 | 5 ++++ setup.py | 2 +- 5 files changed, 42 insertions(+), 9 deletions(-) diff --git a/octoprint_prusaslicerthumbnails/__init__.py b/octoprint_prusaslicerthumbnails/__init__.py index 588e89c..8ab5b6a 100644 --- a/octoprint_prusaslicerthumbnails/__init__.py +++ b/octoprint_prusaslicerthumbnails/__init__.py @@ -30,12 +30,14 @@ def get_settings_defaults(self): inline_thumbnail=False, scale_inline_thumbnail=False, inline_thumbnail_scale_value="50", + inline_thumbnail_position_left=False, align_inline_thumbnail=False, inline_thumbnail_align_value="left", state_panel_thumbnail=True, state_panel_thumbnail_scale_value="75", resize_filelist=False, - filelist_height="306" + filelist_height="306", + scale_inline_thumbnail_position=False ) ##~~ AssetPlugin mixin diff --git a/octoprint_prusaslicerthumbnails/static/css/prusaslicerthumbnails.css b/octoprint_prusaslicerthumbnails/static/css/prusaslicerthumbnails.css index e345739..13241fd 100644 --- a/octoprint_prusaslicerthumbnails/static/css/prusaslicerthumbnails.css +++ b/octoprint_prusaslicerthumbnails/static/css/prusaslicerthumbnails.css @@ -6,3 +6,15 @@ #prusa_thumbnail_viewer h3 { overflow: hidden; } + +#files .gcode_files .entry { + overflow: hidden; +} + +#files .gcode_files .entry img { + width: auto; +} + +.inline_prusa_thumbnail.pull-left { + padding-right: 5px; +} diff --git a/octoprint_prusaslicerthumbnails/static/js/prusaslicerthumbnails.js b/octoprint_prusaslicerthumbnails/static/js/prusaslicerthumbnails.js index 90b0564..a674822 100644 --- a/octoprint_prusaslicerthumbnails/static/js/prusaslicerthumbnails.js +++ b/octoprint_prusaslicerthumbnails/static/js/prusaslicerthumbnails.js @@ -29,11 +29,14 @@ $(function() { } } - self.DEFAULT_THUMBNAIL_SCALE = "100%" - self.filesViewModel.thumbnailScaleValue = ko.observable(self.DEFAULT_THUMBNAIL_SCALE) + self.DEFAULT_THUMBNAIL_SCALE = "100%"; + self.filesViewModel.thumbnailScaleValue = ko.observable(self.DEFAULT_THUMBNAIL_SCALE); - self.DEFAULT_THUMBNAIL_ALIGN = "left" - self.filesViewModel.thumbnailAlignValue = ko.observable(self.DEFAULT_THUMBNAIL_ALIGN) + self.DEFAULT_THUMBNAIL_ALIGN = "left"; + self.filesViewModel.thumbnailAlignValue = ko.observable(self.DEFAULT_THUMBNAIL_ALIGN); + + self.DEFAULT_THUMBNAIL_POSITION = false; + self.filesViewModel.thumbnailPositionLeft = ko.observable(self.DEFAULT_THUMBNAIL_POSITION); self.crawl_files = function(){ self.crawling_files(true); @@ -78,6 +81,11 @@ $(function() { $('#files > div > div.gcode_files > div.scroll-wrapper').css({'height': self.settingsViewModel.settings.plugins.prusaslicerthumbnails.filelist_height() + 'px'}); } + // assign initial position + if(self.settingsViewModel.settings.plugins.prusaslicerthumbnails.inline_thumbnail_position_left()==true) { + self.filesViewModel.thumbnailPositionLeft(true); + } + // observe scaling changes self.settingsViewModel.settings.plugins.prusaslicerthumbnails.scale_inline_thumbnail.subscribe(function(newValue){ if (newValue == false){ @@ -105,6 +113,11 @@ $(function() { self.filesViewModel.thumbnailAlignValue(newValue); }); + // observe position changes + self.settingsViewModel.settings.plugins.prusaslicerthumbnails.inline_thumbnail_position_left.subscribe(function(newValue){ + self.filesViewModel.thumbnailPositionLeft(newValue); + }); + // observe file list height changes self.settingsViewModel.settings.plugins.prusaslicerthumbnails.filelist_height.subscribe(function(newValue){ if(self.settingsViewModel.settings.plugins.prusaslicerthumbnails.resize_filelist()) { @@ -141,9 +154,10 @@ $(function() { $(document).ready(function(){ let regex = /
([\s\S]*)<.div>/mi; let template = ''; - let inline_thumbnail_template = '
' + - '' + + '
' diff --git a/octoprint_prusaslicerthumbnails/templates/prusaslicerthumbnails_settings.jinja2 b/octoprint_prusaslicerthumbnails/templates/prusaslicerthumbnails_settings.jinja2 index 6228579..7521f8f 100644 --- a/octoprint_prusaslicerthumbnails/templates/prusaslicerthumbnails_settings.jinja2 +++ b/octoprint_prusaslicerthumbnails/templates/prusaslicerthumbnails_settings.jinja2 @@ -27,6 +27,11 @@ %
+
+ +