Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3789fee73b | |||
| 18baf239e8 | |||
| c57c429dae |
28
src/main/java/be/seeseepuff/pcinv/models/CustomAsset.java
Normal file
28
src/main/java/be/seeseepuff/pcinv/models/CustomAsset.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package be.seeseepuff.pcinv.models;
|
||||
|
||||
import be.seeseepuff.pcinv.meta.*;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* Represents a CPU or similar device.
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@AssetInfo(
|
||||
displayName = "Custom Device",
|
||||
pluralName = "Custom Devices",
|
||||
type = "custom"
|
||||
)
|
||||
@Table(name = "custom_assets")
|
||||
public class CustomAsset implements Asset
|
||||
{
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private long id;
|
||||
|
||||
@OneToOne(orphanRemoval = true)
|
||||
private GenericAsset asset;
|
||||
}
|
||||
@@ -40,12 +40,12 @@ public class HddAsset implements Asset
|
||||
@InputList
|
||||
private String formFactor;
|
||||
|
||||
@Description("The drive's RPM (Revolutions Per Minute) speed, if applicable.")
|
||||
@Description("The drive's RPM (Revolutions Per Minute) speed.")
|
||||
@Property("RPM Speed")
|
||||
@HideInOverview
|
||||
private Long rpmSpeed;
|
||||
|
||||
@Description("The drive's cache size, if applicable.")
|
||||
@Description("The drive's cache size.")
|
||||
@Property("Cache Size")
|
||||
@HideInOverview
|
||||
private Long cacheSize;
|
||||
@@ -54,4 +54,19 @@ public class HddAsset implements Asset
|
||||
@Property("Drive Type")
|
||||
@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 sectors in the drive.")
|
||||
@Property("Sectors")
|
||||
@HideInOverview
|
||||
private Integer sectors;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package be.seeseepuff.pcinv.repositories;
|
||||
|
||||
import be.seeseepuff.pcinv.models.CustomAsset;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public interface CustomRepository extends JpaRepository<CustomAsset, Long>, AssetRepository<CustomAsset> {
|
||||
@Override
|
||||
default Class<CustomAsset> getAssetType() {
|
||||
return CustomAsset.class;
|
||||
}
|
||||
}
|
||||
@@ -31,17 +31,17 @@
|
||||
<option th:each="o : ${p.options}" th:value="${o.value}" th:text="${o.displayName}" th:selected="${asset != null ? (p.getValue(asset) == o.enumConstant) : o.defaultValue}">Good</option>
|
||||
</select>
|
||||
<span th:case="CAPACITY">
|
||||
<input type="number" th:id="${d.asString(p)+'-value'}" th:name="${d.asString(p)+'-value'}" th:required="${p.required}" th:value="${p.asCapacity(asset).getCapacityInUnit()}"/>
|
||||
<input type="number" th:id="${d.asString(p)+'-value'}" th:name="${d.asString(p)+'-value'}" th:required="${p.required}" th:value="${p.asCapacity(asset)?.getCapacityInUnit() ?: ''}"/>
|
||||
<select th:id="${d.asString(p)}+'-unit'" th:name="${d.asString(p)}+'-unit'">
|
||||
<option value="1" th:selected="${p.asCapacity(asset).getIdealUnit().name() == 'BYTES'}">Bytes</option>
|
||||
<option th:value="${1000}" th:if="${p.capacityAsSI}" th:selected="${p.asCapacity(asset).getIdealUnit().name() == 'KILOBYTES'}">kB</option>
|
||||
<option th:value="${1024}" th:if="${p.capacityAsIEC}" th:selected="${p.asCapacity(asset).getIdealUnit().name() == 'KIBIBYTES'}">KiB</option>
|
||||
<option th:value="${1000*1000}" th:if="${p.capacityAsSI}" th:selected="${p.asCapacity(asset).getIdealUnit().name() == 'MEGABYTES'}">MB</option>
|
||||
<option th:value="${1024*1024}" th:if="${p.capacityAsIEC}" th:selected="${p.asCapacity(asset).getIdealUnit().name() == 'MEBIBYTES'}">MiB</option>
|
||||
<option th:value="${1000*1000*1000}" th:if="${p.capacityAsSI}" th:selected="${p.asCapacity(asset).getIdealUnit().name() == 'GIGABYTES'}">GB</option>
|
||||
<option th:value="${1024*1024*1024}" th:if="${p.capacityAsIEC}" th:selected="${p.asCapacity(asset).getIdealUnit().name() == 'GIBIBYTES'}">GiB</option>
|
||||
<option value="1000000000000" th:if="${p.capacityAsSI}" th:selected="${p.asCapacity(asset).getIdealUnit().name() == 'TERABYTES'}">TB</option>
|
||||
<option value="1099511627776" th:if="${p.capacityAsIEC}" th:selected="${p.asCapacity(asset).getIdealUnit().name() == 'TEBIBYTES'}">TiB</option>
|
||||
<option value="1" th:selected="${p.asCapacity(asset)?.getIdealUnit()?.name() == 'BYTES'}">Bytes</option>
|
||||
<option th:value="${1000}" th:if="${p.capacityAsSI}" th:selected="${p.asCapacity(asset)?.getIdealUnit()?.name() == 'KILOBYTES'}">kB</option>
|
||||
<option th:value="${1024}" th:if="${p.capacityAsIEC}" th:selected="${p.asCapacity(asset)?.getIdealUnit()?.name() == 'KIBIBYTES'}">KiB</option>
|
||||
<option th:value="${1000*1000}" th:if="${p.capacityAsSI}" th:selected="${p.asCapacity(asset)?.getIdealUnit()?.name() == 'MEGABYTES'}">MB</option>
|
||||
<option th:value="${1024*1024}" th:if="${p.capacityAsIEC}" th:selected="${p.asCapacity(asset)?.getIdealUnit()?.name() == 'MEBIBYTES'}">MiB</option>
|
||||
<option th:value="${1000*1000*1000}" th:if="${p.capacityAsSI}" th:selected="${p.asCapacity(asset)?.getIdealUnit()?.name() == 'GIGABYTES'}">GB</option>
|
||||
<option th:value="${1024*1024*1024}" th:if="${p.capacityAsIEC}" th:selected="${p.asCapacity(asset)?.getIdealUnit()?.name() == 'GIBIBYTES'}">GiB</option>
|
||||
<option value="1000000000000" th:if="${p.capacityAsSI}" th:selected="${p.asCapacity(asset)?.getIdealUnit()?.name() == 'TERABYTES'}">TB</option>
|
||||
<option value="1099511627776" th:if="${p.capacityAsIEC}" th:selected="${p.asCapacity(asset)?.getIdealUnit()?.name() == 'TEBIBYTES'}">TiB</option>
|
||||
</select>
|
||||
</span>
|
||||
<b th:case="*">Bad input type for <span th:text="${d.type}+'-'+${p.type}"></span></b>
|
||||
|
||||
Reference in New Issue
Block a user