From ca1cb5802653872bfe1bd2fd11a67a424b6367be Mon Sep 17 00:00:00 2001 From: NilsRo Date: Sun, 8 May 2022 12:57:34 +0200 Subject: [PATCH] optimized GUI layout --- octoprint_SlicerEstimator/__init__.py | 18 ++++---- .../static/js/SlicerEstimator.js | 40 ++++++++++-------- .../translations/de/LC_MESSAGES/messages.mo | Bin 9158 -> 9184 bytes .../translations/de/LC_MESSAGES/messages.po | 6 ++- translations/de/LC_MESSAGES/messages.mo | Bin 9158 -> 9184 bytes translations/de/LC_MESSAGES/messages.po | 6 ++- translations/messages.pot | 6 ++- 7 files changed, 48 insertions(+), 28 deletions(-) diff --git a/octoprint_SlicerEstimator/__init__.py b/octoprint_SlicerEstimator/__init__.py index 41d6252..d6c290d 100644 --- a/octoprint_SlicerEstimator/__init__.py +++ b/octoprint_SlicerEstimator/__init__.py @@ -304,12 +304,13 @@ def on_event(self, event, payload): self._sliver_estimation_str = None self._estimator.estimated_time = -1 self._logger.debug("Event received: {}".format(event)) - if event == Events.FILE_ADDED and self._metadata: - if payload["storage"] == "local" and payload["type"][1] == "gcode": + if event == Events.FILE_ADDED and self._metadata: + if payload["storage"] == "local" and payload["type"][1] == "gcode": self._logger.debug("File uploaded and will be scanned for Metadata") + self._set_slicer(payload["storage"], payload["path"]) self._find_metadata(payload["storage"], payload["path"]) - if self._slicer == 0 or self._slicer == 1: - self._update_filament_changes_metadata(payload["storage"], payload["path"]) + if self._slicer == 0 or self._slicer == 1: + self._update_filament_changes_metadata(payload["storage"], payload["path"]) # SECTION: File metadata @@ -360,8 +361,9 @@ def _flatten_files(self, folder, filelist = dict()): # read filament change from GCODE and save to file metadata def _update_filament_changes_metadata(self, origin, path): filament_changes_arr = self._search_filament_changes(origin, path) - self._file_manager._storage_managers[origin].set_additional_metadata(path, "slicer_filament_change", filament_changes_arr, overwrite=True) - self._logger.debug("filament changes found: " + self._file_manager._storage_managers[origin].get_additional_metadata(path,"slicer_filament_change")) + if filament_changes_arr: + self._file_manager._storage_managers[origin].set_additional_metadata(path, "slicer_filament_change", filament_changes_arr, overwrite=True) + self._logger.debug("filament changes found: " + self._file_manager._storage_managers[origin].get_additional_metadata(path,"slicer_filament_change")) @@ -501,10 +503,10 @@ def _search_in_file_start_all(self, origin, path, pattern, rows = 0): # scan for filament changes def _search_filament_changes(self, origin, path): if origin == "local": - regexStr = "^(M600 |T\d|" + self._slicer_gcode + " )" + regexStr = "^(M600 |T[0-9]|" + self._slicer_gcode + " )" commands = self._search_in_file_regex(origin, path, regexStr, 0, True) change_list = list(filter(lambda p: p[1][:4] == "M600" or p[1][:1] == "T", commands)) - time_list = list(filter(lambda p: p[1][:len(self._slicer_gcode)] == self._slicer_gcode, commands)) + time_list = list(filter(lambda p: p[1][:len(self._slicer_gcode)] == self._slicer_gcode and self._parseEstimation(p[1]), commands)) return_arr = [] if len(change_list) > 0 and len(time_list) > 0: diff --git a/octoprint_SlicerEstimator/static/js/SlicerEstimator.js b/octoprint_SlicerEstimator/static/js/SlicerEstimator.js index 0e0c488..788b634 100644 --- a/octoprint_SlicerEstimator/static/js/SlicerEstimator.js +++ b/octoprint_SlicerEstimator/static/js/SlicerEstimator.js @@ -197,31 +197,37 @@ $(function() { changeList = actualFile.slicer_filament_change; if (changeList != null) { let cnt = 0 - changeList.forEach(function(item) { + for (let item of changeList) { let returnArr = []; let changeType; cnt += 1; - - if (item[0] == "M600") { - changeType = gettext("filament change (M600)"); - } else { - changeType = gettext("filament") + " (" + gettext("tool") + " " + item[0].substring(1,2) +")"; - } - returnArr["description"] = cnt + ". " + changeType; - if (self.printerStateViewModel.printTimeLeft() === null) { - changeTime = self.printerStateViewModel.estimatedPrintTime() - item[1]; + if (returnChange.length < 10) { + if (item[0] == "M600") { + changeType = gettext("filament change (M600)"); + } else { + changeType = gettext("filament") + " (" + gettext("tool") + " " + item[0].substring(1,2) +")"; + } + returnArr["description"] = cnt + ". " + changeType; + if (self.printerStateViewModel.printTimeLeft() === null) { + changeTime = self.printerStateViewModel.estimatedPrintTime() - item[1]; + } else { + changeTime = (self.printerStateViewModel.estimatedPrintTime() - item[1]) - (self.printerStateViewModel.estimatedPrintTime() - self.printerStateViewModel.printTimeLeft()); + } + if (changeTime >= 0) { + let changeTimeString = self.filamentChangeTimeFormat(changeTime); + returnArr["value"] = changeTimeString; + returnChange.push(returnArr); + } } else { - changeTime = (self.printerStateViewModel.estimatedPrintTime() - item[1]) - (self.printerStateViewModel.estimatedPrintTime() - self.printerStateViewModel.printTimeLeft()); - } - if (changeTime < 0) {changeTime = 0} - let changeTimeString = self.filamentChangeTimeFormat(changeTime); - returnArr["value"] = changeTimeString; + returnArr["description"] = gettext("up to") + " " + changeList.length; + returnArr["value"] = "..."; returnChange.push(returnArr); - }) + break; + } + } } } } - // } } return returnChange; }); diff --git a/octoprint_SlicerEstimator/translations/de/LC_MESSAGES/messages.mo b/octoprint_SlicerEstimator/translations/de/LC_MESSAGES/messages.mo index 0df80a8fd932f99dbe421f020d7a75d3280f8fc2..890f61c1050b4db9644525c8a78531f63a0f2f8e 100644 GIT binary patch delta 1092 zcmYk*T}V@59LMorIkWYmwzaJJ((FAbgu!lVR7SRt1xBG4T?k=>TBg)UkXm#R!|*C9 z8eQ1v1-dZGFesq{Es3b0H-r@p2L;Kx>7t^b@85GSI_#X!`9J48=l?wa=h@TP=UDQS z&vQW>+c>N2oXzFGqsk*~Ag;!h*ofP)3tR9G9zt)iv;ccBg{N=`OXf%`a0J)mB*w9* zMDj~XHF0Ad+i)TFAnz!N2k|V<$7yW9pKiQmuEbA`T+Jqz~XjB8NdXV<2keeUqQa5TSyn(Lwcgy{mVrvj+l5)zpWUIED7!JGVWD zO~eJXfp1;rRI&jXqdL)+=rrEMe!PU?AoYL6&GVr1Lb}rN8d}03?4SY<(GsqycAkfk zF)E5wTl?JhHne_Su6@WVDuvenBHEH<(Ed%&lHAzZe?u#gpRH?umnf#O6?fuqJc9Mh zojq_HpAe6r_3sTi9~?xh#27YXpjL|DVXVgtPGKGkSUW*B+XMF*j_rZRXnWuT7GZYS g>zODmPIQNkA3gutchVEy6p0M)@h8eX2ilM6ABZM>zyJUM delta 1065 zcmYMzOGwmF6vy#jG4|AH94&L2(q5YMFu^v{(36@1ixy>NP)zVgu!kTPLB#~M5SgL~ zd$`KM3POxBp+!)VM3NRkMT@Y)0bNuZ7vUo8d%AyUnE8L^-24CEbMHAb-x9A9so`*- zO}sYpiSj9&YSI5!Za`W^n1@R-hFkD3?#B+S#|g~EWRBE=C$SrU;}X0#O{%~Ftif?C zkW$(--95M$^O#5?b818nPvdO-g4=M+kJrqQcq_)m7Tk*D(p6l9H!z63$Rp~<%Q%SN zv2Lc6A;03YBsQCUa!jC2G~yX-!_^q%7`rfzR+(0eu(4}cO58Qaop=Zn#6NHcR zcpled2D3PfWB4+k`rC=S!qPnKMXSUhW=QZJD~X#6|Mg0pSVR024`B}FIEG2I$_#O7 z!4d4o<1D%YtBRa;7$?4ncK?ea>d$8Mi2*D5sP8y>#FI#sqltw1lCBZa#|aNo7ct zwZR|XjrQCDUk~Y?n$VuVfYypM+P~-#TFXDC_+lmcgZ4KmJ8?T^@dU0calOBd zeZ+Ur7C2h!7HmbUL^syrB(B5S#nNU>;|RXRU-+10*82Powqw12fY$rIp5nmk;Puh) Pxxm_3byZJ&!Ku(+!3=m% diff --git a/octoprint_SlicerEstimator/translations/de/LC_MESSAGES/messages.po b/octoprint_SlicerEstimator/translations/de/LC_MESSAGES/messages.po index f7cea6a..33ae160 100644 --- a/octoprint_SlicerEstimator/translations/de/LC_MESSAGES/messages.po +++ b/octoprint_SlicerEstimator/translations/de/LC_MESSAGES/messages.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: OctoPrint-SlicerEstimator 1.3.5\n" "Report-Msgid-Bugs-To: i18n@octoprint.org\n" -"POT-Creation-Date: 2022-05-08 10:41+0200\n" +"POT-Creation-Date: 2022-05-08 12:55+0200\n" "PO-Revision-Date: 2022-05-05 19:16+0200\n" "Last-Translator: FULL NAME \n" "Language: de\n" @@ -38,6 +38,10 @@ msgstr "Filament" msgid "tool" msgstr "Tool" +#: octoprint_SlicerEstimator/static/js/SlicerEstimator.js:258 +msgid "up to" +msgstr "bis" + #: octoprint_SlicerEstimator/templates/SlicerEstimator_settings.jinja2:6 msgid "Main" msgstr "Allgemein" diff --git a/translations/de/LC_MESSAGES/messages.mo b/translations/de/LC_MESSAGES/messages.mo index 0df80a8fd932f99dbe421f020d7a75d3280f8fc2..890f61c1050b4db9644525c8a78531f63a0f2f8e 100644 GIT binary patch delta 1092 zcmYk*T}V@59LMorIkWYmwzaJJ((FAbgu!lVR7SRt1xBG4T?k=>TBg)UkXm#R!|*C9 z8eQ1v1-dZGFesq{Es3b0H-r@p2L;Kx>7t^b@85GSI_#X!`9J48=l?wa=h@TP=UDQS z&vQW>+c>N2oXzFGqsk*~Ag;!h*ofP)3tR9G9zt)iv;ccBg{N=`OXf%`a0J)mB*w9* zMDj~XHF0Ad+i)TFAnz!N2k|V<$7yW9pKiQmuEbA`T+Jqz~XjB8NdXV<2keeUqQa5TSyn(Lwcgy{mVrvj+l5)zpWUIED7!JGVWD zO~eJXfp1;rRI&jXqdL)+=rrEMe!PU?AoYL6&GVr1Lb}rN8d}03?4SY<(GsqycAkfk zF)E5wTl?JhHne_Su6@WVDuvenBHEH<(Ed%&lHAzZe?u#gpRH?umnf#O6?fuqJc9Mh zojq_HpAe6r_3sTi9~?xh#27YXpjL|DVXVgtPGKGkSUW*B+XMF*j_rZRXnWuT7GZYS g>zODmPIQNkA3gutchVEy6p0M)@h8eX2ilM6ABZM>zyJUM delta 1065 zcmYMzOGwmF6vy#jG4|AH94&L2(q5YMFu^v{(36@1ixy>NP)zVgu!kTPLB#~M5SgL~ zd$`KM3POxBp+!)VM3NRkMT@Y)0bNuZ7vUo8d%AyUnE8L^-24CEbMHAb-x9A9so`*- zO}sYpiSj9&YSI5!Za`W^n1@R-hFkD3?#B+S#|g~EWRBE=C$SrU;}X0#O{%~Ftif?C zkW$(--95M$^O#5?b818nPvdO-g4=M+kJrqQcq_)m7Tk*D(p6l9H!z63$Rp~<%Q%SN zv2Lc6A;03YBsQCUa!jC2G~yX-!_^q%7`rfzR+(0eu(4}cO58Qaop=Zn#6NHcR zcpled2D3PfWB4+k`rC=S!qPnKMXSUhW=QZJD~X#6|Mg0pSVR024`B}FIEG2I$_#O7 z!4d4o<1D%YtBRa;7$?4ncK?ea>d$8Mi2*D5sP8y>#FI#sqltw1lCBZa#|aNo7ct zwZR|XjrQCDUk~Y?n$VuVfYypM+P~-#TFXDC_+lmcgZ4KmJ8?T^@dU0calOBd zeZ+Ur7C2h!7HmbUL^syrB(B5S#nNU>;|RXRU-+10*82Powqw12fY$rIp5nmk;Puh) Pxxm_3byZJ&!Ku(+!3=m% diff --git a/translations/de/LC_MESSAGES/messages.po b/translations/de/LC_MESSAGES/messages.po index f7cea6a..33ae160 100644 --- a/translations/de/LC_MESSAGES/messages.po +++ b/translations/de/LC_MESSAGES/messages.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: OctoPrint-SlicerEstimator 1.3.5\n" "Report-Msgid-Bugs-To: i18n@octoprint.org\n" -"POT-Creation-Date: 2022-05-08 10:41+0200\n" +"POT-Creation-Date: 2022-05-08 12:55+0200\n" "PO-Revision-Date: 2022-05-05 19:16+0200\n" "Last-Translator: FULL NAME \n" "Language: de\n" @@ -38,6 +38,10 @@ msgstr "Filament" msgid "tool" msgstr "Tool" +#: octoprint_SlicerEstimator/static/js/SlicerEstimator.js:258 +msgid "up to" +msgstr "bis" + #: octoprint_SlicerEstimator/templates/SlicerEstimator_settings.jinja2:6 msgid "Main" msgstr "Allgemein" diff --git a/translations/messages.pot b/translations/messages.pot index f2adb66..1199109 100644 --- a/translations/messages.pot +++ b/translations/messages.pot @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: OctoPrint-SlicerEstimator 1.4.0\n" "Report-Msgid-Bugs-To: i18n@octoprint.org\n" -"POT-Creation-Date: 2022-05-08 10:41+0200\n" +"POT-Creation-Date: 2022-05-08 12:55+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -37,6 +37,10 @@ msgstr "" msgid "tool" msgstr "" +#: octoprint_SlicerEstimator/static/js/SlicerEstimator.js:258 +msgid "up to" +msgstr "" + #: octoprint_SlicerEstimator/templates/SlicerEstimator_settings.jinja2:6 msgid "Main" msgstr ""