diff --git a/octoprint_SpoolManager/static/css/SpoolManager.css b/octoprint_SpoolManager/static/css/SpoolManager.css index b894f37..8ede284 100644 --- a/octoprint_SpoolManager/static/css/SpoolManager.css +++ b/octoprint_SpoolManager/static/css/SpoolManager.css @@ -1,4 +1,3 @@ - /* Small line on top of a div-box */ .custom-divider { border-top: solid 1px; @@ -184,3 +183,34 @@ /*#checkboxes label:hover {*/ /* background-color: #1e90ff;*/ /*}*/ + +/* Spool remaining bar styles */ +.spool-remaining-container { + margin-top: 5px; + width: 100%; +} + +.spool-remaining-text { + font-size: 12px; + color: #666; + margin-bottom: 2px; +} + +.spool-remaining-bar-container { + width: 100%; + height: 4px; + background-color: #eee; + border-radius: 2px; + overflow: hidden; +} + +.spool-remaining-bar { + height: 100%; + background-color: #2196F3; + transition: width 0.3s ease; +} + +/* Düşük miktar için kırmızı renk */ +.spool-remaining-bar.low-amount { + background-color: #f44336; +} diff --git a/octoprint_SpoolManager/static/js/SpoolManager.js b/octoprint_SpoolManager/static/js/SpoolManager.js index f337954..298e381 100644 --- a/octoprint_SpoolManager/static/js/SpoolManager.js +++ b/octoprint_SpoolManager/static/js/SpoolManager.js @@ -586,17 +586,26 @@ $(function() { } self.remainingText = function(spoolItem){ - var remainingInfo = "("+_buildRemainingText(spoolItem) + ")"; + var remainingWeight = _buildRemainingText(spoolItem); + var remainingLength = (Number(self.buildTooltipForSpoolItem(spoolItem, '', 'remainingLength'))/1000).toFixed(2); + var remainingInfo = "(" + remainingWeight + ", " + remainingLength + "m)"; return remainingInfo; } - self.buildTooltipForSpoolItem = function(spoolItem, textPrefix, attribute){ - var value = ""; + self.buildTooltipForSpoolItem = function(spoolItem, textPrefix, attribute, unit, textPrefix2, attribute2, unit2){ + var tooltip = ""; + + // İlk özellik için tooltip if (spoolItem[attribute]() != null){ - value = spoolItem[attribute](); + tooltip = textPrefix + spoolItem[attribute]() + (unit || ""); } - var toolTip = textPrefix + value; - return toolTip; + + // İkinci özellik varsa ekle + if (attribute2 && spoolItem[attribute2]() != null){ + tooltip += (tooltip ? ", " : "") + textPrefix2 + spoolItem[attribute2]() + (unit2 || ""); + } + + return tooltip; } self.getSpoolItemSelectedTool = function(databaseId) { @@ -1218,6 +1227,21 @@ $(function() { //} } + self.calculateRemainingPercentage = function(spoolItem) { + if (!spoolItem.remainingLength() || !spoolItem.totalLength()) { + return { + width: 0, + isLow: true + }; + } + var percentage = (Number(spoolItem.remainingLength()) / Number(spoolItem.totalLength())) * 100; + percentage = Math.min(Math.max(percentage, 0), 100); + return { + width: percentage, + isLow: percentage < 20 + }; + }; + } /* view model class, parameters for constructor, container to bind to diff --git a/octoprint_SpoolManager/templates/SpoolManager_dialog_selectSpool.jinja2 b/octoprint_SpoolManager/templates/SpoolManager_dialog_selectSpool.jinja2 index 23adc04..fad78ea 100644 --- a/octoprint_SpoolManager/templates/SpoolManager_dialog_selectSpool.jinja2 +++ b/octoprint_SpoolManager/templates/SpoolManager_dialog_selectSpool.jinja2 @@ -20,9 +20,7 @@ () - + diff --git a/octoprint_SpoolManager/templates/SpoolManager_sidebar.jinja2 b/octoprint_SpoolManager/templates/SpoolManager_sidebar.jinja2 index b068d01..57ba555 100644 --- a/octoprint_SpoolManager/templates/SpoolManager_sidebar.jinja2 +++ b/octoprint_SpoolManager/templates/SpoolManager_sidebar.jinja2 @@ -32,8 +32,12 @@ () - +