Skip to content

Commit

Permalink
optimized GUI layout
Browse files Browse the repository at this point in the history
  • Loading branch information
NilsRo committed May 8, 2022
1 parent 12cc245 commit ca1cb58
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 28 deletions.
18 changes: 10 additions & 8 deletions octoprint_SlicerEstimator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"))



Expand Down Expand Up @@ -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:
Expand Down
40 changes: 23 additions & 17 deletions octoprint_SlicerEstimator/static/js/SlicerEstimator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down
Binary file modified octoprint_SlicerEstimator/translations/de/LC_MESSAGES/messages.mo
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: OctoPrint-SlicerEstimator 1.3.5\n"
"Report-Msgid-Bugs-To: [email protected]\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 <EMAIL@ADDRESS>\n"
"Language: de\n"
Expand Down Expand Up @@ -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"
Expand Down
Binary file modified translations/de/LC_MESSAGES/messages.mo
Binary file not shown.
6 changes: 5 additions & 1 deletion translations/de/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: OctoPrint-SlicerEstimator 1.3.5\n"
"Report-Msgid-Bugs-To: [email protected]\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 <EMAIL@ADDRESS>\n"
"Language: de\n"
Expand Down Expand Up @@ -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"
Expand Down
6 changes: 5 additions & 1 deletion translations/messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ msgid ""
msgstr ""
"Project-Id-Version: OctoPrint-SlicerEstimator 1.4.0\n"
"Report-Msgid-Bugs-To: [email protected]\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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -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 ""
Expand Down

0 comments on commit ca1cb58

Please sign in to comment.