Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5e902dd8b0 | |||
| 7f4954a98d | |||
| af5cd88691 | |||
| c1af87f82a |
@@ -55,6 +55,7 @@ public class AssetProperty {
|
||||
public enum Type {
|
||||
STRING(false),
|
||||
INTEGER(false),
|
||||
BOOLEAN(false),
|
||||
CAPACITY(false),
|
||||
CONDITION(true),
|
||||
;
|
||||
@@ -150,6 +151,8 @@ public class AssetProperty {
|
||||
return Type.CAPACITY;
|
||||
} else if (property.getType() == Integer.class || property.getType() == int.class || property.getType() == Long.class || property.getType() == long.class) {
|
||||
return Type.INTEGER;
|
||||
} else if (property.getType() == Boolean.class || property.getType() == boolean.class) {
|
||||
return Type.BOOLEAN;
|
||||
} else if (property.getType() == AssetCondition.class) {
|
||||
return Type.CONDITION;
|
||||
} else {
|
||||
@@ -197,6 +200,8 @@ public class AssetProperty {
|
||||
var value = getValue(asset);
|
||||
if (value == null) {
|
||||
return "Unknown";
|
||||
} else if (type == Type.BOOLEAN) {
|
||||
return (boolean) value ? "Yes" : "No";
|
||||
} else if (type == Type.INTEGER || type == Type.STRING) {
|
||||
return value.toString();
|
||||
} else if (type == Type.CAPACITY) {
|
||||
|
||||
127
src/main/java/be/seeseepuff/pcinv/models/CdDriveAsset.java
Normal file
127
src/main/java/be/seeseepuff/pcinv/models/CdDriveAsset.java
Normal file
@@ -0,0 +1,127 @@
|
||||
package be.seeseepuff.pcinv.models;
|
||||
|
||||
import be.seeseepuff.pcinv.meta.*;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@AssetInfo(
|
||||
displayName = "CD Drive",
|
||||
pluralName = "CD Drives",
|
||||
type = "cd_drive"
|
||||
)
|
||||
@Table(name = "cd_drive_assets")
|
||||
public class CdDriveAsset implements Asset
|
||||
{
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private long id;
|
||||
|
||||
/// The generic asset associated with this RAM.
|
||||
@OneToOne(orphanRemoval = true)
|
||||
private GenericAsset asset;
|
||||
|
||||
@Description("Indicates if the drive supports reading CD-ROM discs.")
|
||||
@Property("CD-ROM Supported")
|
||||
@HideInOverview
|
||||
private Boolean supportsCdRom;
|
||||
|
||||
@Description("Indicates if the drive supports reading CD-R discs.")
|
||||
@Property("CD-R Supported")
|
||||
@HideInOverview
|
||||
private Boolean supportsCdR;
|
||||
|
||||
@Description("Indicates if the drive supports writing CD-R discs.")
|
||||
@Property("CD-R Writing Supported")
|
||||
@HideInOverview
|
||||
private Boolean supportsCdRwriting;
|
||||
|
||||
@Description("Indicates if the drive supports reading CD-RW discs.")
|
||||
@Property("CD-RW Supported")
|
||||
@HideInOverview
|
||||
private Boolean supportsCdRw;
|
||||
|
||||
@Description("Indicates if the drive supports writing CD-RW discs.")
|
||||
@Property("CD-RW Writing Supported")
|
||||
@HideInOverview
|
||||
private Boolean supportsCdRwwriting;
|
||||
|
||||
@Description("Indicates if the drive supports reading DVD discs.")
|
||||
@Property("DVD Supported")
|
||||
@HideInOverview
|
||||
private Boolean supportsDvd;
|
||||
|
||||
@Description("Indicates if the drive supports reading DVD-R discs.")
|
||||
@Property("DVD-R Supported")
|
||||
@HideInOverview
|
||||
private Boolean supportsDvdR;
|
||||
|
||||
@Description("Indicates if the drive supports writing DVD-R discs.")
|
||||
@Property("DVD-R Writing Supported")
|
||||
@HideInOverview
|
||||
private Boolean supportsDvdRwriting;
|
||||
|
||||
@Description("Indicates if the drive supports reading DVD-RW discs.")
|
||||
@Property("DVD-RW Supported")
|
||||
@HideInOverview
|
||||
private Boolean supportsDvdRw;
|
||||
|
||||
@Description("Indicates if the drive supports writing DVD-RW discs.")
|
||||
@Property("DVD-RW Writing Supported")
|
||||
@HideInOverview
|
||||
private Boolean supportsDvdRwwriting;
|
||||
|
||||
@Description("Indicates if the drive supports reading DVD+R discs.")
|
||||
@Property("DVD+R Supported")
|
||||
@HideInOverview
|
||||
private Boolean supportsDvdPlusR;
|
||||
|
||||
@Description("Indicates if the drive supports writing DVD+R discs.")
|
||||
@Property("DVD+R Writing Supported")
|
||||
@HideInOverview
|
||||
private Boolean supportsDvdPlusRwriting;
|
||||
|
||||
@Description("Indicates if the drive supports reading DVD+RW discs.")
|
||||
@Property("DVD+RW Supported")
|
||||
@HideInOverview
|
||||
private Boolean supportsDvdPlusRw;
|
||||
|
||||
@Description("Indicates if the drive supports writing DVD+RW discs.")
|
||||
@Property("DVD+RW Writing Supported")
|
||||
@HideInOverview
|
||||
private Boolean supportsDvdPlusRwwriting;
|
||||
|
||||
@Description("Indicates if the drive supports reading DVD-RAM discs.")
|
||||
@Property("DVD-RAM Supported")
|
||||
@HideInOverview
|
||||
private Boolean supportsDvdRam;
|
||||
|
||||
@Description("Indicates if the drive supports reading Blu-ray discs.")
|
||||
@Property("Blu-ray Supported")
|
||||
@HideInOverview
|
||||
private Boolean supportsBluRay;
|
||||
|
||||
@Description("Indicates if the drive supports reading HD DVD discs.")
|
||||
@Property("HD DVD Supported")
|
||||
@HideInOverview
|
||||
private Boolean supportsHdDvd;
|
||||
|
||||
@Description("Indicates if the drive supports reading Ultra HD Blu-ray discs.")
|
||||
@Property("Ultra HD Blu-ray Supported")
|
||||
@HideInOverview
|
||||
private Boolean supportsUltraHdBluRay;
|
||||
|
||||
@Description("The type of interface used by the drive. E.g.: SATA, IDE, etc.")
|
||||
@Property("Interface Type")
|
||||
@HideInOverview
|
||||
@InputList
|
||||
private String interfaceType;
|
||||
|
||||
@Description("The form factor of the CD drive. E.g.: 5.25\", 3.5\", etc.")
|
||||
@Property("Form Factor")
|
||||
@InputList
|
||||
private String formFactor;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package be.seeseepuff.pcinv.models;
|
||||
|
||||
import be.seeseepuff.pcinv.meta.*;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@AssetInfo(
|
||||
displayName = "Floppy Drive",
|
||||
pluralName = "Floppy Drives",
|
||||
type = "floppy_drive"
|
||||
)
|
||||
@Table(name = "floppy_drive_assets")
|
||||
public class FloppyDriveAsset implements Asset
|
||||
{
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private long id;
|
||||
|
||||
/// The generic asset associated with this RAM.
|
||||
@OneToOne(orphanRemoval = true)
|
||||
private GenericAsset asset;
|
||||
|
||||
@Description("Indicates if the floppy drive supports double density (DD) disks.")
|
||||
@Property("doubleDensitySupported")
|
||||
@HideInOverview
|
||||
private Boolean supportsDoubleDensity;
|
||||
|
||||
@Description("Indicates if the floppy drive supports high density (HD) disks.")
|
||||
@Property("highDensitySupported")
|
||||
@HideInOverview
|
||||
private Boolean supportsHighDensity;
|
||||
|
||||
@Description("Indicates if the floppy drive supports extra high density (ED) disks.")
|
||||
@Property("extraHighDensitySupported")
|
||||
@HideInOverview
|
||||
private Boolean supportsExtraHighDensity;
|
||||
|
||||
@Description("The type of interface used by the floppy drive. E.g.: 34-pin, 50-pin, etc.")
|
||||
@Property("Interface Type")
|
||||
@HideInOverview
|
||||
@InputList
|
||||
private String interfaceType;
|
||||
|
||||
@Description("The form factor of the floppy drive. E.g.: 3.5\", 5.25\", etc.")
|
||||
@Property("Form Factor")
|
||||
@InputList
|
||||
private String formFactor;
|
||||
}
|
||||
37
src/main/java/be/seeseepuff/pcinv/models/NICAsset.java
Normal file
37
src/main/java/be/seeseepuff/pcinv/models/NICAsset.java
Normal file
@@ -0,0 +1,37 @@
|
||||
package be.seeseepuff.pcinv.models;
|
||||
|
||||
import be.seeseepuff.pcinv.meta.*;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@AssetInfo(
|
||||
displayName = "Network Interface Controller",
|
||||
pluralName = "Network Interface Controllers",
|
||||
type = "nic"
|
||||
)
|
||||
@Table(name = "nic_assets")
|
||||
public class NICAsset implements Asset
|
||||
{
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private long id;
|
||||
|
||||
/// The generic asset associated with this RAM.
|
||||
@OneToOne(orphanRemoval = true)
|
||||
private GenericAsset asset;
|
||||
|
||||
@Description("The MAC address of the network interface controller.")
|
||||
@Property("MAC Address")
|
||||
@HideInOverview
|
||||
private String macAddress;
|
||||
|
||||
@Description("The type of interface used by the drive. E.g.: SATA, IDE, etc.")
|
||||
@Property("Interface Type")
|
||||
@HideInOverview
|
||||
@InputList
|
||||
private String interfaceType;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package be.seeseepuff.pcinv.repositories;
|
||||
|
||||
import be.seeseepuff.pcinv.models.CdDriveAsset;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public interface CdDriveRepository extends JpaRepository<CdDriveAsset, Long>, AssetRepository<CdDriveAsset> {
|
||||
@Override
|
||||
default Class<CdDriveAsset> getAssetType() {
|
||||
return CdDriveAsset.class;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package be.seeseepuff.pcinv.repositories;
|
||||
|
||||
import be.seeseepuff.pcinv.models.FloppyDriveAsset;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public interface FloppyDriveRepository extends JpaRepository<FloppyDriveAsset, Long>, AssetRepository<FloppyDriveAsset> {
|
||||
@Override
|
||||
default Class<FloppyDriveAsset> getAssetType() {
|
||||
return FloppyDriveAsset.class;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package be.seeseepuff.pcinv.repositories;
|
||||
|
||||
import be.seeseepuff.pcinv.models.NICAsset;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public interface NICRepository extends JpaRepository<NICAsset, Long>, AssetRepository<NICAsset> {
|
||||
@Override
|
||||
default Class<NICAsset> getAssetType() {
|
||||
return NICAsset.class;
|
||||
}
|
||||
}
|
||||
@@ -216,6 +216,12 @@ public class AssetService {
|
||||
return Integer.parseInt(stringValue);
|
||||
} else if (property.getType() == AssetProperty.Type.STRING) {
|
||||
return stringValue;
|
||||
} else if (property.getType() == AssetProperty.Type.BOOLEAN) {
|
||||
return switch (stringValue.toLowerCase()) {
|
||||
case "true" -> true;
|
||||
case "false" -> false;
|
||||
default -> null;
|
||||
};
|
||||
} else if (property.getType().isEnum) {
|
||||
for (var option : property.getOptions()) {
|
||||
if (option.getValue().equals(stringValue)) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body th:replace="~{fragments :: base(title='Browse assets', content=~{::content})}">
|
||||
<div th:fragment="content">
|
||||
View device details
|
||||
<h2>View device details</h2>
|
||||
<ul>
|
||||
<li th:each="d : ${descriptors.getAssets()}" th:if="${d.visible}">
|
||||
<a th:href="'/browse/'+${d.getType()}" th:text="${d.pluralName}"></a>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body th:replace="~{fragments :: base(title='View '+${descriptor.pluralName}, content=~{::content})}">
|
||||
<div th:fragment="content">
|
||||
There are <span th:text="${assets.size()}"></span> <span th:text="${descriptor.pluralName}"></span> in the database.
|
||||
<h2>There are <span th:text="${assets.size()}"></span> <span th:text="${descriptor.pluralName}"></span> in the database.</h2>
|
||||
<table border="1" cellpadding="4">
|
||||
<tr bgcolor="#d3d3d3">
|
||||
<th th:each="p : ${properties}" th:if="${!p.hideInOverview}" th:text="${p.displayName}"></th>
|
||||
@@ -17,5 +17,8 @@
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p>
|
||||
<a th:href="'/create/'+${descriptor.type}">Create a new <span th:text="${descriptor.displayName}"></span></a>
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body th:replace="~{fragments :: base(title='Create '+${descriptor.displayName}, content=~{::content})}">
|
||||
<div th:fragment="content">
|
||||
Create a <span th:text="${descriptor.displayName}"></span>
|
||||
<h2>Create a <span th:text="${descriptor.displayName}"></span></h2>
|
||||
<form th:action="'/'+${action}+'/'+${asset != null ? asset.getQr() : descriptor.getType()}" method="post">
|
||||
<div th:each="d : ${descriptors}">
|
||||
<h2 th:text="${d.displayName}"></h2>
|
||||
@@ -18,6 +18,15 @@
|
||||
</span>
|
||||
<input th:case="STRING" type="text" th:id="${d.asString(p)}" th:name="${d.asString(p)}" th:value="${p.getValue(asset)}" th:placeholder="${p.displayName}" th:required="${p.required}"/>
|
||||
<input th:case="INTEGER" type="number" th:id="${d.asString(p)}" th:name="${d.asString(p)}" th:value="${p.getValue(asset)}" th:required="${p.required}"/>
|
||||
<!-- <input th:case="BOOLEAN" type="checkbox" th:id="${d.asString(p)}" th:name="${d.asString(p)}" th:value="true" th:checked="${asset != null ? p.getValue(asset) : p.defaultValue}"/>-->
|
||||
<span th:case="BOOLEAN">
|
||||
<input th:name="${d.asString(p)}" th:id="${d.asString(p)}+'-null'" type="radio" value="null" th:checked="${asset == null || (p.getValue(asset) == null)}">
|
||||
<label th:for="${d.asString(p)}+'-null'">Not known</label>
|
||||
<input th:name="${d.asString(p)}" th:id="${d.asString(p)}+'-true'" type="radio" value="true" th:checked="${asset != null && (p.getValue(asset) == true)}">
|
||||
<label th:for="${d.asString(p)}+'-true'">Yes</label>
|
||||
<input th:name="${d.asString(p)}" th:id="${d.asString(p)}+'-false'" type="radio" value="false" th:checked="${asset != null && (p.getValue(asset) == false)}">
|
||||
<label th:for="${d.asString(p)}+'-false'">No</label>
|
||||
</span>
|
||||
<select th:case="enum" th:id="${d.asString(p)}" th:name="${d.asString(p)}">
|
||||
<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>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body th:replace="~{fragments :: base(title='Select type to create', content=~{::content})}">
|
||||
<div th:fragment="content">
|
||||
Create a new device
|
||||
<h2>Create a new device</h2>
|
||||
<ul>
|
||||
<li th:each="d : ${descriptors.getAssets()}" th:if="${d.visible}"><a th:href="'/create/'+${d.getType()}" th:text="${d.displayName}"></a></li>
|
||||
</ul>
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
package be.seeseepuff.pcinv;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class PcinvApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user