Skip to content

Commit

Permalink
New Version 1.4.0
Browse files Browse the repository at this point in the history
- PR #161, #117, #133, #134, #153 multi tool support. Big thanks goes to @codingcatgirl
- PR #61, #59 temperature offset. Thanks a lot @WyattNielsen

- E/B #118 use newodometer.py
- E add "implementation-api"

- B #150, #116 CSV import fixed

..other tickets
- #102, #132, #135, #140, #142
  • Loading branch information
OllisGit committed May 24, 2021
1 parent daf677e commit 3dbd15c
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 22 deletions.
2 changes: 1 addition & 1 deletion octoprint_SpoolManager/DatabaseManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ def backupDatabaseFile(self):
else:
self._logger.info("No database backup needed, because there is no databasefile '"+str(self._databaseSettings.fileLocation)+"'")

def reCreateDatabase(self, databaseSettings):
def reCreateDatabase(self, databaseSettings = None):
self._currentErrorMessageDict = None
self._logger.info("ReCreating Database")

Expand Down
1 change: 0 additions & 1 deletion octoprint_SpoolManager/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ def _sendDataToClient(self, payloadDict):

def _sendMessageToClient(self, type, title, message):
self._logger.warning("SendToClient: " + type + "#" + title + "#" + message)
title = "SPM:" + title
self._sendDataToClient(dict(action="showPopUp",
type=type,
title= title,
Expand Down
4 changes: 4 additions & 0 deletions octoprint_SpoolManager/api/SpoolManagerAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ def allowed_to_print(self):
infoData = {
"toolIndex": toolIndex,
"spoolName": spoolModel.displayName if spoolModel else '(no spool selected)',
"material": spoolModel.material if spoolModel else '',
"remainingWeight": spoolModel.remainingWeight if spoolModel else '',
"toolOffset": spoolModel.offsetTemperature if spoolModel.offsetTemperature is not None else 0,
"bedOffset": spoolModel.offsetBedTemperature if spoolModel.offsetBedTemperature is not None else 0,
"enclosureOffset": spoolModel.offsetEnclosureTemperature if spoolModel.offsetEnclosureTemperature is not None else 0
Expand Down Expand Up @@ -535,6 +537,8 @@ def updateParsingStatus(lineNumber):
spool.remainingWeight = remainingWeight
# spool.save()

spool.isActive = True

databaseManager.saveSpool(spool)
pass
else:
Expand Down
9 changes: 5 additions & 4 deletions octoprint_SpoolManager/common/CSVExportImporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from octoprint_SpoolManager.models.SpoolModel import SpoolModel

FORMAT_DATETIME = "%d.%m.%Y %H:%M"
FORMAT_DATE = "%d.%m.%Y"

COLUMN_DISPLAY_NAME = "Spool Name"
COLUMN_COLOR_NAME = "Color Name"
Expand Down Expand Up @@ -115,7 +116,7 @@ def parseAndAssignFieldValue(self, fieldLabel, fieldName, fieldValue, printJobMo
setattr(printJobModel, fieldName, fieldDateTime)
pass
else:
fieldDateTime = datetime.datetime.fromtimestamp(float(fieldValue))
fieldDateTime = datetime.datetime.strptime(fieldValue, FORMAT_DATE)
setattr(printJobModel, fieldName, fieldDateTime)
pass
pass
Expand Down Expand Up @@ -327,7 +328,7 @@ def parseCSV(csvFile4Import, updateParsingStatus, errorCollection, logger, delet
errorCollection.append("Mandatory column is missing! <br/><b>'" + "".join(mandatoryFieldMissing) + "'</b><br/>")
break
else:
printJobModel = SpoolModel()
spoolModel = SpoolModel()
# parse line with header defined order
columnIndex = 0
for columnValue in row:
Expand All @@ -342,13 +343,13 @@ def parseCSV(csvFile4Import, updateParsingStatus, errorCollection, logger, delet
errorCollection.append("["+str(lineNumber)+"] Mandatory value for column '" + columnName + "' is missing!")
pass
else:
csvColumn.parseAndAssignFieldValue(columnValue, printJobModel, errorCollection, lineNumber)
csvColumn.parseAndAssignFieldValue(columnValue, spoolModel, errorCollection, lineNumber)
pass
columnIndex += 1
if (len(errorCollection) != 0):
logger.error("Reading error line '" + str(lineNumber) + "' in Column '" + column + "' ")
else:
result.append(printJobModel)
result.append(spoolModel)
pass
except Exception as e:
errorMessage = "CSV Parsing error. Line:'" + str(lineNumber) + "' Error:'" + str(e) + "' File:'" + csvFile4Import + "'"
Expand Down
49 changes: 42 additions & 7 deletions octoprint_SpoolManager/static/js/SpoolManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,35 @@ $(function() {


////////////////////////////////////////////////////////////////////////////////////////////////HELPER FUNCTION

loadSettingsFromBrowserStore = function(){
// TODO maybe in a separate js-file
// load all settings from browser storage
if (!Modernizr.localstorage) {
// damn!!!
return false;
}
// Table visibility
self.initTableVisibilities();

var storageKey = "spoolmanager.table.selectedPageSize";
if (localStorage[storageKey] == null){
localStorage[storageKey] = "25"; // default page size
} else {
self.spoolItemTableHelper.selectedPageSize(localStorage[storageKey]);
}
self.spoolItemTableHelper.selectedPageSize.subscribe(function(newValue){
localStorage[storageKey] = newValue;
});
}

// Typs: error
self.showPopUp = function(popupType, popupTitle, message){
var title = popupType.toUpperCase() + ": " + popupTitle;
var popupId = (title+message).replace(/([^a-z0-9]+)/gi, '-');
if($("."+popupId).length <1) {
new PNotify({
title: title,
title: "SPM:" + title,
text: message,
type: popupType,
hide: false,
Expand All @@ -98,7 +120,6 @@ $(function() {
};



// found here: https://stackoverflow.com/questions/19491336/how-to-get-url-parameter-using-jquery-or-plain-javascript?rq=1
var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = window.location.search.substring(1),
Expand Down Expand Up @@ -646,10 +667,22 @@ $('.dropdown-menu.keep-open').click(function(e) {
}
}

buildSpoolLabel = function(item){
var label = item.toolIndex+": '" + item.material + " - " + item.spoolName;

if (item.remainingWeight != null && typeof item.remainingWeight === 'number'){
label = label + " ("+item.remainingWeight.toFixed(2) +"g)";
}
label = label + "'";
return label;
}

if (result.filamentNotEnough.length) {
itemList = [];
for (item of result.filamentNotEnough) {
itemList.push("'" + item.spoolName + "' (tool "+item.toolIndex+")");
var spoolLabel = buildSpoolLabel(item);
// itemList.push("'" + item.spoolName + "' (tool "+item.toolIndex+")");
itemList.push(spoolLabel);
}
if (itemList.length === 1) {
check = confirm(
Expand Down Expand Up @@ -685,15 +718,15 @@ $('.dropdown-menu.keep-open').click(function(e) {
// }
// build message for each tool
for (item of result.reminderSpoolSelection) {
var toolMessage = item.toolIndex+": '" + item.spoolName + "'";
var toolMessage = buildSpoolLabel(item);
if (responseData.toolOffsetEnabled) toolMessage += "\n-- Tool Offset: "+item.toolOffset+'\u00B0';
if (responseData.bedOffsetEnabled) toolMessage += "\n-- Bed Offset: "+item.bedOffset+'\u00B0';
if (responseData.enclosureOffsetEnabled) toolMessage += "\n-- Enclosure Offset: "+item.enclosureOffset+'\u00B0';
itemList.push(toolMessage);
}
check = confirm(
"Do you want to start the print with following selected spools?\n" +
'- '+ itemList.join('\n- ')
"- "+ itemList.join("\n- ")
);

if (!check) {
Expand Down Expand Up @@ -782,8 +815,10 @@ $('.dropdown-menu.keep-open').click(function(e) {
self.onBeforeBinding = function() {
// assign current pluginSettings
self.pluginSettings = self.settingsViewModel.settings.plugins[PLUGIN_ID];
// Table visibility
self. initTableVisibilities();

// load browser stored settings (includs TabelVisibility and pageSize, ...)
loadSettingsFromBrowserStore();

// resetSettings-Stuff
new ResetSettingsUtilV3(self.pluginSettings).assignResetSettingsFeature(PLUGIN_ID, function(data){
// no additional reset function needed in V2
Expand Down
14 changes: 6 additions & 8 deletions octoprint_SpoolManager/templates/SpoolManager_tab_dialogs.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -155,16 +155,14 @@
</label>
</div>
</div>




</div>

<div class="modal-body hack-flowbreak" >
<form class="form-horizontal" id="spool-form" >
<div class="row" >
<input type="hidden" data-bind="value: spoolDialog.spoolItemForEditing.version" />
<div class="row-fluid" >
<!-- LEFT COLUMN -->
<input type="hidden" data-bind="value: spoolDialog.spoolItemForEditing.version" />

<div class="span6" >
<div class="control-group">
<label class="control-label">Displayname <sup>1</sup></label>
Expand Down Expand Up @@ -228,7 +226,7 @@
</div>

<div class="control-group no-bottom-gap">
<label class="control-label">Best Temperature<sup>4</sup> Tool/Bed</label>
<label class="control-label">Tool/Bed<sup>4</sup></label>
<div class="row controls">
<div class="input-append">
<input type="number" step="1" min="0" class="input-mini text-right" data-bind="value: spoolDialog.spoolItemForEditing.temperature" />
Expand Down Expand Up @@ -444,7 +442,7 @@


<div class="row">
<div class="span6 text-center">
<div class="span12 text-center">
<div class="" style="margin-top:10px">
<div class="">
<!-- <div class="spool-note-editor-container">-->
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
#
plugin_version = "1.4.0rc1"
plugin_version = "1.4.0"

# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
# module
Expand Down

0 comments on commit 3dbd15c

Please sign in to comment.