Skip to content

Commit

Permalink
New Version 1.5.0
Browse files Browse the repository at this point in the history
- PR #204, #201 redesign of the Spool-Selection in the sidebar. Huge thanks to @TiziG @MarloSM
- E #125 New field "Serialnumber"
- E Spool selection from Edit-Dialog
- E #141 New Filter: Material, Vendor and Color
- E #44 Sidebar filament usage in grams instead of volume

- B #199, #198, #163, #156 some QR-Code optimisations
- B #197, #196, #188, #181, #178, #177, #172, #162, #142,  Some UI optimisations
- B #194 CSV import, behind reverse proxy
- B #175 Confirm dialog not shown
  • Loading branch information
OllisGit committed Oct 24, 2021
1 parent 0715e5f commit b1d9080
Show file tree
Hide file tree
Showing 20 changed files with 1,447 additions and 958 deletions.
86 changes: 80 additions & 6 deletions octoprint_SpoolManager/DatabaseManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from peewee import *

from octoprint_SpoolManager.api import Transformer
from octoprint_SpoolManager.common import StringUtils
from octoprint_SpoolManager.models.BaseModel import BaseModel
from octoprint_SpoolManager.models.PluginMetaDataModel import PluginMetaDataModel
from octoprint_SpoolManager.models.SpoolModel import SpoolModel
Expand Down Expand Up @@ -280,7 +281,6 @@ def _executeSQLQuietly(self, cursor, sqlStatement):
self._logger.error(sqlStatement)
self._logger.exception(e)


def _upgradeFrom4To5_HACK(self, sqlStatement):

connection = sqlite3.connect(self._databaseSettings.fileLocation)
Expand Down Expand Up @@ -814,13 +814,72 @@ def databaseCallMethode():
if (tableQuery == None):
return SpoolModel.select().order_by(SpoolModel.created.desc())

offset = int(tableQuery["from"])
limit = int(tableQuery["to"])
sortColumn = tableQuery["sortColumn"]
sortOrder = tableQuery["sortOrder"]
filterName = tableQuery["filterName"]

myQuery = SpoolModel.select().offset(offset).limit(limit)
if ("selectedPageSize" in tableQuery and StringUtils.to_native_str(tableQuery["selectedPageSize"]) == "all"):
myQuery = SpoolModel.select()
else:
offset = int(tableQuery["from"])
limit = int(tableQuery["to"])
myQuery = SpoolModel.select().offset(offset).limit(limit)

if ("materialFilter" in tableQuery):
materialFilter = tableQuery["materialFilter"]
vendorFilter = tableQuery["vendorFilter"]
colorFilter = tableQuery["colorFilter"]

# materialFilter
# u'ABS,PLA'
# u''
# u'all'
materialFilter = StringUtils.to_native_str(materialFilter)
if (materialFilter != "all"):
if (StringUtils.isEmpty(colorFilter)):
myQuery = myQuery.where( (SpoolModel.material == '') )
else:
allMaterials = materialFilter.split(",")
myQuery = myQuery.where(SpoolModel.material.in_(allMaterials))
# for material in allMaterials:
# myQuery = myQuery.orwhere((SpoolModel.material == material))
# vendorFilter
# u'MatterMost,TheFactory'
# u''
# u'all'
vendorFilter = StringUtils.to_native_str(vendorFilter)
if (vendorFilter != "all"):
if (StringUtils.isEmpty(vendorFilter)):
myQuery = myQuery.where( (SpoolModel.vendor == '') )
else:
allVendors = vendorFilter.split(",")
myQuery = myQuery.where(SpoolModel.vendor.in_(allVendors))
# for vendor in allVendors:
# myQuery = myQuery.orwhere((SpoolModel.vendor == vendor))
# colorFilter
# u'#ff0000;red,#ff0000;keinRot,#ff0000;deinRot,#ff0000;meinRot,#ffff00;yellow'
# u''
# u'all'
colorFilter = StringUtils.to_native_str(colorFilter)
if (colorFilter != "all" and StringUtils.isNotEmpty(colorFilter)):
allColorObjects = colorFilter.split(",")
allColors = []
allColorNames = []
for colorObject in allColorObjects:
colorCodeColorName = colorObject.split(";")
color = colorCodeColorName[0]
colorName = colorCodeColorName[1]
allColors.append(color)
allColorNames.append(colorName)
myQuery = myQuery.where(SpoolModel.color.in_(allColors))
myQuery = myQuery.where(SpoolModel.colorName.in_(allColorNames))

#
# myQuery = myQuery.orwhere( (SpoolModel.color == color) & (SpoolModel.colorName == colorName) )
pass

mySqlText = myQuery.sql()

if (filterName == "hideEmptySpools"):
myQuery = myQuery.where( (SpoolModel.remainingWeight > 0) | (SpoolModel.remainingWeight == None))
if (filterName == "hideInactiveSpools"):
Expand Down Expand Up @@ -943,7 +1002,6 @@ def databaseCallMethode():
def loadCatalogMaterials(self, withReusedConnection=False):
def databaseCallMethode():
result = set()
result.add("")
myQuery = SpoolModel.select(SpoolModel.material).distinct()
for spool in myQuery:
value = spool.material
Expand All @@ -956,7 +1014,6 @@ def databaseCallMethode():
def loadCatalogLabels(self, tableQuery, withReusedConnection=False):
def databaseCallMethode():
result = set()
result.add("")
myQuery = SpoolModel.select(SpoolModel.labels).distinct()
for spool in myQuery:
value = spool.labels
Expand All @@ -968,6 +1025,23 @@ def databaseCallMethode():

return self._handleReusableConnection(databaseCallMethode, withReusedConnection, "loadCatalogLabels", set())

def loadCatalogColors(self, withReusedConnection=False):
def databaseCallMethode():
result = []
myQuery = SpoolModel.select(SpoolModel.color, SpoolModel.colorName).distinct()
for spool in myQuery:
value = spool.color
if (value != None):
colorInfo = {
"colorId": spool.color + ";" + spool.colorName,
"color": spool.color,
"colorName": spool.colorName
}
result.append(colorInfo)
return result;

return self._handleReusableConnection(databaseCallMethode, withReusedConnection, "loadCatalogColors", set())

def deleteSpool(self, databaseId, withReusedConnection=False):
def databaseCallMethode():
with self._database.atomic() as transaction: # Opens new transaction.
Expand Down
Loading

0 comments on commit b1d9080

Please sign in to comment.