5 Commits

Author SHA1 Message Date
bb15c55e46 Improve asset sorting by brand, model, and QR code with null handling
All checks were successful
Build / build (push) Successful in 2m27s
Deploy / build (push) Successful in 3m1s
2025-06-15 09:48:07 +02:00
35c2e07c05 Update build view to link part types for better navigation
All checks were successful
Build / build (push) Successful in 2m2s
Deploy / build (push) Successful in 2m43s
2025-06-15 09:27:32 +02:00
92187fd345 Handle non-positive capacities in idealUnitForCapacity method 2025-06-15 09:27:29 +02:00
0dbab45651 Enhance asset display by handling null builds and sorting assets by QR code 2025-06-15 09:26:08 +02:00
14ac78982f Reorder fields in HddAsset for clarity
All checks were successful
Build / build (push) Successful in 1m20s
2025-06-15 09:14:13 +02:00
5 changed files with 21 additions and 8 deletions

View File

@@ -1,5 +1,6 @@
package be.seeseepuff.pcinv.controllers;
import be.seeseepuff.pcinv.models.Asset;
import be.seeseepuff.pcinv.models.WorkLogEntry;
import be.seeseepuff.pcinv.services.AssetService;
import be.seeseepuff.pcinv.services.BuildService;
@@ -94,7 +95,12 @@ public class WebController {
model.addAttribute(DESCRIPTOR, assetService.getAssetDescriptor(type));
model.addAttribute(DESCRIPTORS, tree);
model.addAttribute(PROPERTIES, tree.stream().flatMap(d -> d.getProperties().stream()).toList());
model.addAttribute(ASSETS, assetService.getAssetsByType(type));
var assets = assetService.getAssetsByType(type);
assets.sort(Comparator
.comparing((Asset a) -> a.getAsset().getBrand(), Comparator.nullsFirst(Comparator.naturalOrder()))
.thenComparing((Asset a) -> a.getAsset().getModel(), Comparator.nullsFirst(Comparator.naturalOrder()))
.thenComparing(Asset::getQr));
model.addAttribute(ASSETS, assets);
return "browse_type";
}

View File

@@ -44,6 +44,10 @@ public class CapacityInfo {
}
public static CapacityUnit idealUnitForCapacity(long capacity, CapacityUnit[] units) {
if (capacity <= 0) {
return CapacityUnit.BYTES; // Default to bytes for non-positive capacities
}
return Arrays.stream(units)
.sorted(Comparator.comparing(CapacityUnit::getBytes).reversed())
.filter(unit -> capacity % unit.getBytes() == 0)

View File

@@ -57,16 +57,16 @@ public class HddAsset implements Asset
@InputList
private String driveType;
@Description("Number of heads in the drive.")
@Property("Heads")
@HideInOverview
private Integer heads;
@Description("Number of cylinders in the drive.")
@Property("Cylinders")
@HideInOverview
private Integer cylinders;
@Description("Number of heads in the drive.")
@Property("Heads")
@HideInOverview
private Integer heads;
@Description("Number of sectors in the drive.")
@Property("Sectors")
@HideInOverview

View File

@@ -15,7 +15,7 @@
</tr>
<tr th:each="p : ${build.getParts()}">
<td><a th:href="'/view/' + ${p.qr}" th:text="${p.qr}"></a></td>
<td th:text="${descriptors.getDescriptorForType(p.type).displayName}"></td>
<td><a th:href="'/browse/' + ${p.type}" th:text="${descriptors.getDescriptorForType(p.type).displayName}"></a></td>
<td th:text="${descriptors.getGenericProperty('brand').renderValue(p)}"></td>
<td th:text="${descriptors.getGenericProperty('model').renderValue(p)}"></td>
</tr>

View File

@@ -7,7 +7,10 @@
<table border="1" cellpadding="4">
<tr th:each="p : ${d.properties}">
<th bgcolor="lightgray"><b th:text="${p.displayName}"></b></th>
<td th:if="${p.name == 'build'}"><a th:href="'/build/' + ${asset.getAsset().getBuild().id}" th:text="${p.renderValue(asset)}"></a></td>
<td th:if="${p.name == 'build'}">
<a th:if="${asset.getAsset().getBuild() != null}" th:href="'/build/' + ${asset.getAsset().getBuild().id}" th:text="${p.renderValue(asset)}"></a>
<span th:if="${asset.getAsset().getBuild() == null}" th:text="${p.renderValue(asset)}"></span>
</td>
<td th:if="${p.name != 'build'}" th:text="${p.renderValue(asset)}"></td>
</tr>
</table>