6 Commits

14 changed files with 340 additions and 141 deletions

View File

@@ -1,5 +1,8 @@
name: Build name: Build
on: [push] on:
push:
branches:
- '*'
jobs: jobs:
build: build:
runs-on: standard-latest runs-on: standard-latest

View File

@@ -10,13 +10,20 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '21'
cache: 'gradle'
- name: Login - name: Login
with: # Set the secret as an input with: # Set the secret as an input
package_rw: ${{ secrets.PACKAGE_RW }} package_rw: ${{ secrets.PACKAGE_RW }}
run: docker login gitea.seeseepuff.be -u seeseemelk -p ${{ secrets.PACKAGE_RW }} run: docker login gitea.seeseepuff.be -u seeseemelk -p ${{ secrets.PACKAGE_RW }}
- name: Build - name: Build
run: docker build -t gitea.seeseepuff.be/seeseemelk/pcinv:${{github.ref_name}} . run: ./gradlew bootBuildImage --no-daemon --imageName=gitea.seeseepuff.be/seeseemelk/pcinv:${{github.ref_name}}
- name: Push - name: Push
run: docker push gitea.seeseepuff.be/seeseemelk/pcinv:${{github.ref_name}} run: docker push gitea.seeseepuff.be/seeseemelk/pcinv:${{github.ref_name}}

View File

@@ -3,6 +3,7 @@ package be.seeseepuff.pcinv.meta;
import be.seeseepuff.pcinv.models.Asset; import be.seeseepuff.pcinv.models.Asset;
import be.seeseepuff.pcinv.models.AssetCondition; import be.seeseepuff.pcinv.models.AssetCondition;
import be.seeseepuff.pcinv.models.GenericAsset; import be.seeseepuff.pcinv.models.GenericAsset;
import be.seeseepuff.pcinv.models.ReadWrite;
import jakarta.annotation.Nonnull; import jakarta.annotation.Nonnull;
import jakarta.annotation.Nullable; import jakarta.annotation.Nullable;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@@ -58,6 +59,7 @@ public class AssetProperty {
BOOLEAN(false), BOOLEAN(false),
CAPACITY(false), CAPACITY(false),
CONDITION(true), CONDITION(true),
READWRITE(true),
; ;
/// Set to `true` if the type is an enum, `false` otherwise. /// Set to `true` if the type is an enum, `false` otherwise.
public final boolean isEnum; public final boolean isEnum;
@@ -155,6 +157,8 @@ public class AssetProperty {
return Type.BOOLEAN; return Type.BOOLEAN;
} else if (property.getType() == AssetCondition.class) { } else if (property.getType() == AssetCondition.class) {
return Type.CONDITION; return Type.CONDITION;
} else if (property.getType() == ReadWrite.class) {
return Type.READWRITE;
} else { } else {
throw new IllegalArgumentException("Unsupported property type: " + property.getType()); throw new IllegalArgumentException("Unsupported property type: " + property.getType());
} }

View File

@@ -1,127 +0,0 @@
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;
}

View File

@@ -0,0 +1,65 @@
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 = "Central Processing Unit",
pluralName = "Central Processing Units",
type = "cpu"
)
@Table(name = "cpu_assets")
public class CpuAsset implements Asset
{
@Id
@GeneratedValue
private long id;
@OneToOne(orphanRemoval = true)
private GenericAsset asset;
@Description("The number of cores in the CPU.")
@Property("Cores")
private int cores;
@Description("The number of threads in the CPU.")
@Property("Threads")
private int threads;
@Description("The base clock speed of the CPU in MHz.")
@Property("Base Clock Speed (MHz)")
private int baseClockSpeed;
@Description("The boost clock speed of the CPU in MHz.")
@Property("Boost Clock Speed (MHz)")
@HideInOverview
private int boostClockSpeed;
@Description("The thermal design power (TDP) of the CPU in watts.")
@Property("Thermal Design Power (TDP) (W)")
private int tdp;
@Description("The socket type of the CPU.")
@Property("Socket Type")
@InputList
private String socketType;
@Description("The architecture of the CPU, e.g., x86, ARM, etc.")
@Property("Architecture")
@HideInOverview
@InputList
private String architecture;
@Description("The manufacturing process of the CPU in nanometers.")
@Property("Manufacturing Process (nm)")
@HideInOverview
private int manufacturingProcess;
}

View File

@@ -5,6 +5,8 @@ import jakarta.persistence.*;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.util.List;
/** /**
* Represents a generic asset in the inventory system. * Represents a generic asset in the inventory system.
*/ */
@@ -65,4 +67,7 @@ public class GenericAsset
@Property("Warranty Expiration Date") @Property("Warranty Expiration Date")
@HideInOverview @HideInOverview
private String warrantyExpirationDate; private String warrantyExpirationDate;
@OneToMany(mappedBy = "asset", cascade = CascadeType.ALL, orphanRemoval = true)
private List<WorkLogEntry> workLog;
} }

View File

@@ -0,0 +1,97 @@
package be.seeseepuff.pcinv.models;
import be.seeseepuff.pcinv.meta.*;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@Entity
@AssetInfo(
displayName = "Optical Drive",
pluralName = "Optical Drives",
type = "optical_drive"
)
@Table(name = "optical_drive_assets")
public class OpticalDriveAsset 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 CD-ROM discs.")
@Property("CD-ROM Supported")
@HideInOverview
private ReadWrite supportsCdRom;
@Description("Indicates if the drive supports CD-R discs.")
@Property("CD-R Supported")
@HideInOverview
private ReadWrite supportsCdR;
@Description("Indicates if the drive supports CD-RW discs.")
@Property("CD-RW Supported")
@HideInOverview
private ReadWrite supportsCdRw;
@Description("Indicates if the drive supports DVD discs.")
@Property("DVD Supported")
@HideInOverview
private ReadWrite supportsDvd;
@Description("Indicates if the drive supports DVD-R discs.")
@Property("DVD-R Supported")
@HideInOverview
private ReadWrite supportsDvdR;
@Description("Indicates if the drive supports DVD-RW discs.")
@Property("DVD-RW Supported")
@HideInOverview
private ReadWrite supportsDvdRw;
@Description("Indicates if the drive supports DVD+R discs.")
@Property("DVD+R Supported")
@HideInOverview
private ReadWrite supportsDvdPlusR;
@Description("Indicates if the drive supports DVD+RW discs.")
@Property("DVD+RW Supported")
@HideInOverview
private ReadWrite supportsDvdPlusRw;
@Description("Indicates if the drive supports DVD-RAM discs.")
@Property("DVD-RAM Supported")
@HideInOverview
private ReadWrite supportsDvdRam;
@Description("Indicates if the drive supports Blu-ray discs.")
@Property("Blu-ray Supported")
@HideInOverview
private ReadWrite supportsBluRay;
@Description("Indicates if the drive supports HD DVD discs.")
@Property("HD DVD Supported")
@HideInOverview
private ReadWrite supportsHdDvd;
@Description("Indicates if the drive supports Ultra HD Blu-ray discs.")
@Property("Ultra HD Blu-ray Supported")
@HideInOverview
private ReadWrite supportsUltraHdBluRay;
@Description("The type of interface used by the drive. E.g.: SATA, IDE, etc.")
@Property("Interface Type")
@InputList
private String interfaceType;
@Description("The form factor of the CD drive. E.g.: 5.25\", 3.5\", etc.")
@Property("Form Factor")
@HideInOverview
@InputList
private String formFactor;
}

View File

@@ -0,0 +1,64 @@
package be.seeseepuff.pcinv.models;
import be.seeseepuff.pcinv.meta.*;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@Entity
@AssetInfo(
displayName = "Power Supply",
pluralName = "Power Supplies",
type = "psu"
)
@Table(name = "psu_assets")
public class PowerSupplyAsset implements Asset
{
@Id
@GeneratedValue
private long id;
/// The generic asset associated with this RAM.
@OneToOne(orphanRemoval = true)
private GenericAsset asset;
@Description("The wattage rating of the power supply in watts.")
@Property("Wattage")
private int wattage;
@Description("The efficiency rating of the power supply, e.g., 80 Plus Bronze, Silver, Gold, Platinum, Titanium.")
@Property("Efficiency Rating")
@InputList
private String efficiencyRating;
@Description("The form factor of the power supply, e.g., ATX, SFX, etc.")
@Property("Form Factor")
@InputList
private String formFactor;
@Description("The number number of Molex connectors.")
@Property("4-pin Molex Connectors")
private int molexConnectors;
@Description("The number of 4-pin floppy connectors.")
@Property("4-pin Floppy Connectors")
private int floppyConnectors;
@Description("The number of SATA power connectors.")
@Property("15-pin SATA Connectors")
private int sataConnectors;
@Description("The number of 6-pin PCIe connectors.")
@Property("6-pin PCIe Connectors")
private int pcie6Connectors;
@Description("The number of 8-pin PCIe connectors.")
@Property("8-pin PCIe Connectors")
private int pcie8Connectors;
@Description("The number of 4-pin ATX 12V connectors.")
@Property("4-pin ATX 12V Connectors")
private int atx12vConnectors;
}

View File

@@ -0,0 +1,30 @@
package be.seeseepuff.pcinv.models;
import be.seeseepuff.pcinv.meta.AssetEnum;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
/**
* An enum representing the read/write capabilities of a device.
* This is used to indicate whether a device can read, write, or both.
*/
@Getter
@RequiredArgsConstructor
public enum ReadWrite implements AssetEnum {
/// The capacbilities are unknown.
UNKNOWN("unknown", "Unknown"),
/// The device can only read data.
READ("read", "Read Only"),
/// The device can only write data.
WRITE("write", "Write Only"),
/// The device can both read and write data.
READ_WRITE("read_write", "Read and Write")
;
private final String value;
private final String displayName;
@Override
public boolean isDefaultValue() {
return this == UNKNOWN;
}
}

View File

@@ -0,0 +1,27 @@
package be.seeseepuff.pcinv.models;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne;
import java.time.ZonedDateTime;
/**
* Represents a work log entry in the system.
*/
@Entity
public class WorkLogEntry {
@Id
@GeneratedValue
private long id;
@ManyToOne(optional = false)
private GenericAsset asset;
/// The description of the work log entry.
private String description;
/// The date and time when the work log entry was created.
private ZonedDateTime date;
}

View File

@@ -1,12 +0,0 @@
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;
}
}

View File

@@ -0,0 +1,12 @@
package be.seeseepuff.pcinv.repositories;
import be.seeseepuff.pcinv.models.CpuAsset;
import org.springframework.data.jpa.repository.JpaRepository;
@SuppressWarnings("unused")
public interface CpuRepository extends JpaRepository<CpuAsset, Long>, AssetRepository<CpuAsset> {
@Override
default Class<CpuAsset> getAssetType() {
return CpuAsset.class;
}
}

View File

@@ -0,0 +1,12 @@
package be.seeseepuff.pcinv.repositories;
import be.seeseepuff.pcinv.models.OpticalDriveAsset;
import org.springframework.data.jpa.repository.JpaRepository;
@SuppressWarnings("unused")
public interface OpticalDriveRepository extends JpaRepository<OpticalDriveAsset, Long>, AssetRepository<OpticalDriveAsset> {
@Override
default Class<OpticalDriveAsset> getAssetType() {
return OpticalDriveAsset.class;
}
}

View File

@@ -0,0 +1,12 @@
package be.seeseepuff.pcinv.repositories;
import be.seeseepuff.pcinv.models.PowerSupplyAsset;
import org.springframework.data.jpa.repository.JpaRepository;
@SuppressWarnings("unused")
public interface PowerSupplyRepository extends JpaRepository<PowerSupplyAsset, Long>, AssetRepository<PowerSupplyAsset> {
@Override
default Class<PowerSupplyAsset> getAssetType() {
return PowerSupplyAsset.class;
}
}