feat(queue): show spool grams left in filament slot mapping

This commit is contained in:
tridev
2026-02-27 13:29:39 +01:00
committed by maziggy
parent eee901fc20
commit ae9818c96c
7 changed files with 33 additions and 3 deletions
@@ -52,6 +52,21 @@ export function FilamentMapping({
return map;
}, [assignments]);
const trayRemainingWeightMap = useMemo(() => {
const map = new Map<number, number | null>();
for (const assignment of assignments || []) {
const isExternal = assignment.ams_id === 255;
const globalTrayId = getGlobalTrayId(assignment.ams_id, assignment.tray_id, isExternal);
const spool = assignment.spool;
if (!spool) {
map.set(globalTrayId, null);
continue;
}
map.set(globalTrayId, Math.max(0, Math.round((spool.label_weight ?? 0) - (spool.weight_used ?? 0))));
}
return map;
}, [assignments]);
const totalCost = useMemo(() => {
let total = 0;
for (const item of filamentComparison) {
@@ -198,11 +213,20 @@ export function FilamentMapping({
</option>
{loadedFilaments
.filter((f) => item.nozzle_id == null || f.extruderId === item.nozzle_id)
.map((f) => (
.map((f) => {
const remainingWeight = trayRemainingWeightMap.get(f.globalTrayId);
const remainingLabel = remainingWeight != null
? t('printModal.slotRemainingShort', {
grams: remainingWeight,
defaultValue: ` - ${remainingWeight}g left`,
})
: '';
return (
<option key={f.globalTrayId} value={f.globalTrayId} className="bg-bambu-dark text-white">
{f.label}: {f.type} ({f.colorName})
{f.label}: {f.type} ({f.colorName}){remainingLabel}
</option>
))}
);
})}
</select>
{/* Status icon */}
{item.status === 'match' ? (
+1
View File
@@ -2744,6 +2744,7 @@ export default {
selectPlate: 'Platte auswählen',
filamentMapping: 'Filamentzuordnung',
totalCost: 'Gesamtkosten:',
slotRemainingShort: ' - {{grams}}g übrig',
printSettings: 'Druckeinstellungen',
bedLeveling: 'Bett-Nivellierung',
flowCalibration: 'Fluss-Kalibrierung',
+1
View File
@@ -2748,6 +2748,7 @@ export default {
selectPlate: 'Select Plate',
filamentMapping: 'Filament Mapping',
totalCost: 'Total cost:',
slotRemainingShort: ' - {{grams}}g left',
printSettings: 'Print Settings',
bedLeveling: 'Bed Leveling',
flowCalibration: 'Flow Calibration',
+1
View File
@@ -2732,6 +2732,7 @@ export default {
selectPlate: 'Choisir le plateau',
filamentMapping: 'Mapping Filament',
totalCost: 'Coût total :',
slotRemainingShort: ' - {{grams}}g rest.',
printSettings: 'Réglages d\'impression',
bedLeveling: 'Nivellement plateau',
flowCalibration: 'Calibration débit',
+1
View File
@@ -2457,6 +2457,7 @@ export default {
selectPlate: 'Seleziona piatto',
filamentMapping: 'Mappatura filamento',
totalCost: 'Costo totale:',
slotRemainingShort: ' - {{grams}}g rim.',
printSettings: 'Impostazioni stampa',
bedLeveling: 'Livellamento piatto',
flowCalibration: 'Calibrazione flusso',
+1
View File
@@ -2666,6 +2666,7 @@ export default {
selectPlate: 'プレートを選択',
filamentMapping: 'フィラメントマッピング',
totalCost: '合計コスト:',
slotRemainingShort: ' - 残{{grams}}g',
printSettings: '印刷設定',
bedLeveling: 'ベッドレベリング',
layerInspection: '第一層検査',
+1
View File
@@ -2742,6 +2742,7 @@ export default {
selectPlate: 'Selecionar Placa',
filamentMapping: 'Mapeamento de Filamento',
totalCost: 'Custo total:',
slotRemainingShort: ' - {{grams}}g rest.',
printSettings: 'Configurações de Impressão',
bedLeveling: 'Nivelamento da Mesa',
flowCalibration: 'Calibração de Fluxo',