Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 13617eed6d | |||
| 698f6a3903 | |||
| d702544f2c | |||
| 7fca7c4ff0 | |||
| 3789fee73b | |||
| 18baf239e8 | |||
| c57c429dae | |||
| 5d1c65a4c5 | |||
| 85de1c0c9f | |||
| a4b88f6dfd | |||
| b9bf2f1d38 | |||
| d45b2cc068 | |||
| 9c376b3a97 |
@@ -17,13 +17,16 @@ jobs:
|
||||
java-version: '21'
|
||||
cache: 'gradle'
|
||||
|
||||
- name: Build Jar
|
||||
run: ./gradlew bootJar
|
||||
|
||||
- name: Build Container
|
||||
run: docker build --tag gitea.seeseepuff.be/seeseemelk/pcinv:${{github.ref_name}} .
|
||||
|
||||
- name: Login
|
||||
with: # Set the secret as an input
|
||||
package_rw: ${{ secrets.PACKAGE_RW }}
|
||||
run: docker login gitea.seeseepuff.be -u seeseemelk -p ${{ secrets.PACKAGE_RW }}
|
||||
|
||||
- name: Build
|
||||
run: ./gradlew bootBuildImage --no-daemon --imageName=gitea.seeseepuff.be/seeseemelk/pcinv:${{github.ref_name}}
|
||||
|
||||
- name: Push
|
||||
- name: Push Container
|
||||
run: docker push gitea.seeseepuff.be/seeseemelk/pcinv:${{github.ref_name}}
|
||||
|
||||
10
Dockerfile
10
Dockerfile
@@ -1,9 +1,5 @@
|
||||
FROM eclipse-temurin:21-jdk-alpine AS builder
|
||||
WORKDIR /app
|
||||
COPY . /app
|
||||
RUN ./gradlew jar --no-daemon
|
||||
|
||||
FROM eclipse-temurin:21-alpine
|
||||
COPY --from=builder /app/build/libs/pcinv-0.0.1-SNAPSHOT.jar ./
|
||||
ENTRYPOINT ["java", "-jar", "pcinv-0.0.1-SNAPSHOT.jar"]
|
||||
WORKDIR /app
|
||||
ADD ./build/libs/pcinv-0.0.1-SNAPSHOT.jar /app/pcinv.jar
|
||||
ENTRYPOINT ["java", "-jar", "pcinv.jar"]
|
||||
EXPOSE 8088/tcp
|
||||
|
||||
@@ -28,6 +28,8 @@ dependencies {
|
||||
implementation("org.springframework.boot:spring-boot-starter-thymeleaf")
|
||||
implementation("org.springframework.boot:spring-boot-starter-web")
|
||||
implementation("org.springframework.boot:spring-boot-starter-actuator")
|
||||
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.8.8")
|
||||
implementation("org.modelmapper:modelmapper:3.2.3")
|
||||
compileOnly("org.projectlombok:lombok")
|
||||
developmentOnly("org.springframework.boot:spring-boot-devtools")
|
||||
runtimeOnly("org.postgresql:postgresql")
|
||||
|
||||
15
src/main/java/be/seeseepuff/pcinv/PcinvConfig.java
Normal file
15
src/main/java/be/seeseepuff/pcinv/PcinvConfig.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package be.seeseepuff.pcinv;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
@EnableWebMvc
|
||||
public class PcinvConfig implements WebMvcConfigurer {
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package be.seeseepuff.pcinv.controllers;
|
||||
|
||||
import be.seeseepuff.pcinv.meta.AssetDescriptor;
|
||||
import be.seeseepuff.pcinv.models.Asset;
|
||||
import be.seeseepuff.pcinv.services.AssetService;
|
||||
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.info.Info;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/api")
|
||||
@RestController
|
||||
@OpenAPIDefinition(
|
||||
info = @Info(
|
||||
title = "PC Inventory API",
|
||||
version = "1.0",
|
||||
description = "API for managing PC inventory assets. Assets are identified by QR or ID codes."
|
||||
)
|
||||
)
|
||||
public class ApiController {
|
||||
private final AssetService assetService;
|
||||
|
||||
@Operation(summary = "Lists all types of assets available in the system.")
|
||||
@GetMapping("/assetTypes")
|
||||
public List<String> assets() {
|
||||
return assetService.getAssetDescriptors().getAssets().stream()
|
||||
.map(AssetDescriptor::getType)
|
||||
.toList();
|
||||
}
|
||||
|
||||
@Operation(summary = "Lists all information of a specific asset.")
|
||||
@GetMapping("/asset/{qr}")
|
||||
public Asset getAsset(
|
||||
@PathVariable @Parameter(name = "qr", description = "The QR number of the asset") long qr
|
||||
) {
|
||||
return assetService.getAssetByQr(qr);
|
||||
}
|
||||
|
||||
@Operation(summary = "Adds a work log entry to an asset.")
|
||||
@PostMapping("/asset/worklog")
|
||||
public String addWorkLogEntry(
|
||||
@RequestBody Entry entry
|
||||
) {
|
||||
var qr = entry.qr;
|
||||
var asset = assetService.getAssetByQr(qr);
|
||||
if (asset == null) {
|
||||
throw new IllegalArgumentException("Asset with QR code " + qr + " not found.");
|
||||
}
|
||||
if (entry.entry == null || entry.entry.isBlank()) {
|
||||
throw new IllegalArgumentException("Work log entry comment cannot be empty.");
|
||||
}
|
||||
assetService.addWorkLogEntry(asset, entry.entry);
|
||||
return "";
|
||||
}
|
||||
|
||||
public static class Entry {
|
||||
@Parameter(name = "qr", description = "The QR number of the asset")
|
||||
public long qr;
|
||||
@Parameter(name = "entry", description = "The work log entry text")
|
||||
public String entry;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package be.seeseepuff.pcinv.controllers;
|
||||
|
||||
import be.seeseepuff.pcinv.models.WorkLogEntry;
|
||||
import be.seeseepuff.pcinv.services.AssetService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
@@ -12,6 +13,8 @@ import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
@@ -37,6 +40,13 @@ public class WebController {
|
||||
private static final String TIME = "time";
|
||||
/// The name of the model attribute that holds the input lists for creating or editing assets.
|
||||
private static final String INPUT_LIST = "inputLists";
|
||||
/// The name of the model attribute that holds the current work log entries.
|
||||
private static final String WORKLOG = "worklog";
|
||||
|
||||
/// The name of the input field for the current size of the work log.
|
||||
private static final String WORKLOG_SIZE = "worklog_size";
|
||||
|
||||
private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("dd MMM yyyy 'at' HH:mm");
|
||||
|
||||
private final AssetService assetService;
|
||||
|
||||
@@ -93,6 +103,35 @@ public class WebController {
|
||||
return renderView(model, qr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the form submission for adding a work log entry to an asset.
|
||||
*
|
||||
* @param qr The QR code of the asset to which the work log entry is added.
|
||||
*/
|
||||
@PostMapping("/view/{qr}")
|
||||
public String viewPost(Model model, @PathVariable long qr, @RequestBody MultiValueMap<String, String> formData) {
|
||||
model.addAttribute(TIME, System.currentTimeMillis());
|
||||
model.addAttribute(ACTION, "view");
|
||||
|
||||
var asset = assetService.getAssetByQr(qr);
|
||||
if (asset == null) {
|
||||
return "redirect:/";
|
||||
}
|
||||
|
||||
var workLogSizeStr = formData.getFirst(WORKLOG_SIZE);
|
||||
if (workLogSizeStr != null) {
|
||||
var workLogSize = Integer.parseInt(workLogSizeStr);
|
||||
if (asset.getAsset().getWorkLog().size() == workLogSize) {
|
||||
var comment = formData.getFirst("comment");
|
||||
if (comment != null && !comment.isBlank()) {
|
||||
assetService.addWorkLogEntry(asset, comment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return renderView(model, qr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a page asking if the user wants to delete an asset.
|
||||
*
|
||||
@@ -130,6 +169,9 @@ public class WebController {
|
||||
model.addAttribute(ASSET, asset);
|
||||
model.addAttribute(DESCRIPTORS, assetService.getAssetDescriptorTree(asset.getAsset().getType()));
|
||||
model.addAttribute(DESCRIPTOR, assetService.getAssetDescriptor(asset.getAsset().getType()));
|
||||
model.addAttribute(WORKLOG, asset.getAsset().getWorkLog().stream()
|
||||
.sorted(Comparator.comparing(WorkLogEntry::getDate).reversed())
|
||||
.toList());
|
||||
return "view";
|
||||
}
|
||||
|
||||
@@ -184,6 +226,27 @@ public class WebController {
|
||||
return "create_asset";
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows a view where the user can edit an existing asset.
|
||||
*
|
||||
* @param qr The QR code of the asset to edit.
|
||||
*/
|
||||
@GetMapping("/duplicate/{qr}")
|
||||
public String duplicate(Model model, @PathVariable long qr) {
|
||||
model.addAttribute(TIME, System.currentTimeMillis());
|
||||
var asset = assetService.getAssetByQr(qr);
|
||||
if (asset == null) {
|
||||
throw new RuntimeException("Asset not found");
|
||||
}
|
||||
String assetType = asset.getAsset().getType();
|
||||
model.addAttribute(ACTION, "duplicate");
|
||||
model.addAttribute(ASSET, asset);
|
||||
model.addAttribute(DESCRIPTORS, assetService.getAssetDescriptorTree(assetType));
|
||||
model.addAttribute(DESCRIPTOR, assetService.getAssetDescriptor(assetType));
|
||||
model.addAttribute(INPUT_LIST, assetService.getInputList(assetType));
|
||||
return "create_asset";
|
||||
}
|
||||
|
||||
/**
|
||||
* Actually edits an asset based on the form data submitted.
|
||||
*
|
||||
|
||||
@@ -99,7 +99,7 @@ public class AssetProperty {
|
||||
.setter((obj, value) -> {
|
||||
try {
|
||||
property.setAccessible(true);
|
||||
property.set(obj, value);
|
||||
property.set(obj, Converters.convert(value, property.getType()));
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -203,13 +203,13 @@ public class AssetProperty {
|
||||
}
|
||||
var value = getValue(asset);
|
||||
if (value == null) {
|
||||
return "Unknown";
|
||||
return "?";
|
||||
} 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) {
|
||||
return String.format("%s bytes", value);
|
||||
return convertCapacity((Long) value).toString();
|
||||
} else if (type.isEnum) {
|
||||
if (value instanceof AssetEnum assetEnum) {
|
||||
return assetEnum.getDisplayName();
|
||||
@@ -220,6 +220,24 @@ public class AssetProperty {
|
||||
}
|
||||
}
|
||||
|
||||
public CapacityInfo convertCapacity(Long value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
if (type != Type.CAPACITY) {
|
||||
throw new IllegalStateException("Property '" + name + "' is not a capacity type.");
|
||||
}
|
||||
return CapacityInfo.of(value, capacityAsIEC, capacityAsSI);
|
||||
}
|
||||
|
||||
public CapacityInfo asCapacity(@Nullable Object object) {
|
||||
var value = getValue(object);
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
return convertCapacity((Long) value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
var enumOptions = "";
|
||||
|
||||
62
src/main/java/be/seeseepuff/pcinv/meta/CapacityInfo.java
Normal file
62
src/main/java/be/seeseepuff/pcinv/meta/CapacityInfo.java
Normal file
@@ -0,0 +1,62 @@
|
||||
package be.seeseepuff.pcinv.meta;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
* Represents a capacity in bytes, with various units for display.
|
||||
* This class is used to encapsulate the capacity information and provide
|
||||
* a way to represent it in different units.
|
||||
*/
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public class CapacityInfo {
|
||||
private final long capacity;
|
||||
private final CapacityUnit idealUnit;
|
||||
|
||||
public static CapacityInfo of(long capacity, CapacityUnit idealUnit) {
|
||||
return new CapacityInfo(capacity, idealUnit);
|
||||
}
|
||||
|
||||
public static CapacityInfo of(long capacity) {
|
||||
return of(capacity, idealUnitForCapacity(capacity, CapacityUnit.values()));
|
||||
}
|
||||
|
||||
public static CapacityInfo ofSI(long capacity) {
|
||||
return of(capacity, idealUnitForCapacity(capacity, CapacityUnit.SI_UNITS));
|
||||
}
|
||||
|
||||
public static CapacityInfo ofIEC(long capacity) {
|
||||
return of(capacity, idealUnitForCapacity(capacity, CapacityUnit.IEC_UNITS));
|
||||
}
|
||||
|
||||
public static CapacityInfo of(long capacity, boolean iec, boolean si) {
|
||||
if (iec && !si) {
|
||||
return ofIEC(capacity);
|
||||
} else if (si && !iec) {
|
||||
return ofSI(capacity);
|
||||
} else {
|
||||
return of(capacity);
|
||||
}
|
||||
}
|
||||
|
||||
public static CapacityUnit idealUnitForCapacity(long capacity, CapacityUnit[] units) {
|
||||
return Arrays.stream(units)
|
||||
.sorted(Comparator.comparing(CapacityUnit::getBytes).reversed())
|
||||
.filter(unit -> capacity % unit.getBytes() == 0)
|
||||
.findFirst()
|
||||
.orElse(CapacityUnit.BYTES);
|
||||
}
|
||||
|
||||
public long getCapacityInUnit() {
|
||||
return capacity / idealUnit.getBytes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%d %s", capacity / idealUnit.getBytes(), idealUnit.getDisplayName());
|
||||
}
|
||||
}
|
||||
28
src/main/java/be/seeseepuff/pcinv/meta/CapacityUnit.java
Normal file
28
src/main/java/be/seeseepuff/pcinv/meta/CapacityUnit.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package be.seeseepuff.pcinv.meta;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
/**
|
||||
* Represents a unit of capacity, either in binary (IEC) or decimal (SI) format.
|
||||
*/
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public enum CapacityUnit {
|
||||
BYTES("Bytes", 1),
|
||||
KIBIBYTES("KiB", 1024),
|
||||
MEBIBYTES("MiB", 1024 * 1024),
|
||||
GIBIBYTES("GiB", 1024 * 1024 * 1024),
|
||||
TEBIBYTES("TiB", 1024L * 1024 * 1024 * 1024),
|
||||
KILOBYTES("kB", 1000),
|
||||
MEGABYTES("MB", 1000 * 1000),
|
||||
GIGABYTES("GB", 1000 * 1000 * 1000),
|
||||
TERABYTES("TB", 1000L * 1000 * 1000 * 1000),
|
||||
;
|
||||
|
||||
public static final CapacityUnit[] SI_UNITS = {BYTES, KILOBYTES, MEGABYTES, GIGABYTES, TERABYTES};
|
||||
public static final CapacityUnit[] IEC_UNITS = {BYTES, KIBIBYTES, MEBIBYTES, GIBIBYTES, TEBIBYTES};
|
||||
|
||||
private final String displayName;
|
||||
private final long bytes;
|
||||
}
|
||||
66
src/main/java/be/seeseepuff/pcinv/meta/Converters.java
Normal file
66
src/main/java/be/seeseepuff/pcinv/meta/Converters.java
Normal file
@@ -0,0 +1,66 @@
|
||||
package be.seeseepuff.pcinv.meta;
|
||||
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
/**
|
||||
* Utility class for converting values to different types.
|
||||
*/
|
||||
@UtilityClass
|
||||
public class Converters {
|
||||
/**
|
||||
* Converts a value to the specified target type.
|
||||
*
|
||||
* @param value The value to convert.
|
||||
* @param target The target class to convert the value to.
|
||||
* @return The converted value, or null if conversion is not possible.
|
||||
*/
|
||||
public static Object convert(Object value, Class<?> target) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
if (target.isInstance(value)) {
|
||||
return value; // No conversion needed
|
||||
}
|
||||
if (value instanceof Long longValue) {
|
||||
return convertLong(longValue, target);
|
||||
}
|
||||
if (value instanceof Integer intValue) {
|
||||
return convertInteger(intValue, target);
|
||||
}
|
||||
throw new ClassCastException("Cannot convert " + value.getClass().getName() + " to " + target.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a Long value to the specified target type.
|
||||
*
|
||||
* @param value The Long value to convert.
|
||||
* @param target The target class to convert the value to.
|
||||
* @return The converted value, or throws ClassCastException if conversion is not possible.
|
||||
*/
|
||||
private static Object convertLong(Long value, Class<?> target) {
|
||||
if (target == Long.class || target == long.class) {
|
||||
return value; // No conversion needed
|
||||
}
|
||||
if (target == Integer.class || target == int.class) {
|
||||
return value.intValue();
|
||||
}
|
||||
throw new ClassCastException("Cannot convert " + value.getClass().getName() + " to " + target.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an Integer value to the specified target type.
|
||||
*
|
||||
* @param value The Integer value to convert.
|
||||
* @param target The target class to convert the value to.
|
||||
* @return The converted value, or throws ClassCastException if conversion is not possible.
|
||||
*/
|
||||
private static Object convertInteger(Integer value, Class<?> target) {
|
||||
if (target == Integer.class || target == int.class) {
|
||||
return value; // No conversion needed
|
||||
}
|
||||
if (target == Long.class || target == long.class) {
|
||||
return value.longValue();
|
||||
}
|
||||
throw new ClassCastException("Cannot convert " + value.getClass().getName() + " to " + target.getName());
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ public enum AssetCondition implements AssetEnum
|
||||
/// The asset is in perfect working order.
|
||||
HEALTHY("healthy", "Healthy"),
|
||||
/// The condition of the asset is unknown. E.g.: it is untested.
|
||||
UNKNOWN("unknown", "Not known"),
|
||||
UNKNOWN("unknown", "?"),
|
||||
/// The asset generally works, but has some known issues.
|
||||
PARTIAL("partial", "Partially working"),
|
||||
/// The asset is in need of repair, but is not completely broken.
|
||||
|
||||
@@ -4,6 +4,7 @@ import be.seeseepuff.pcinv.meta.AssetInfo;
|
||||
import be.seeseepuff.pcinv.meta.Description;
|
||||
import be.seeseepuff.pcinv.meta.HideInOverview;
|
||||
import be.seeseepuff.pcinv.meta.Property;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -21,6 +22,7 @@ public class ChassisAsset implements Asset
|
||||
{
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@JsonIgnore
|
||||
private long id;
|
||||
|
||||
/// The generic asset associated with this RAM.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package be.seeseepuff.pcinv.models;
|
||||
|
||||
import be.seeseepuff.pcinv.meta.*;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -21,6 +22,7 @@ public class CpuAsset implements Asset
|
||||
{
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@JsonIgnore
|
||||
private long id;
|
||||
|
||||
@OneToOne(orphanRemoval = true)
|
||||
|
||||
30
src/main/java/be/seeseepuff/pcinv/models/CustomAsset.java
Normal file
30
src/main/java/be/seeseepuff/pcinv/models/CustomAsset.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package be.seeseepuff.pcinv.models;
|
||||
|
||||
import be.seeseepuff.pcinv.meta.*;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
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
|
||||
@JsonIgnore
|
||||
private long id;
|
||||
|
||||
@OneToOne(orphanRemoval = true)
|
||||
private GenericAsset asset;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package be.seeseepuff.pcinv.models;
|
||||
|
||||
import be.seeseepuff.pcinv.meta.*;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -18,6 +19,7 @@ public class DisplayAdapterAsset implements Asset
|
||||
{
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@JsonIgnore
|
||||
private long id;
|
||||
|
||||
/// The generic asset associated with this RAM.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package be.seeseepuff.pcinv.models;
|
||||
|
||||
import be.seeseepuff.pcinv.meta.*;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -18,6 +19,7 @@ public class FloppyDriveAsset implements Asset
|
||||
{
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@JsonIgnore
|
||||
private long id;
|
||||
|
||||
/// The generic asset associated with this RAM.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package be.seeseepuff.pcinv.models;
|
||||
|
||||
import be.seeseepuff.pcinv.meta.*;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -27,7 +28,9 @@ public class GenericAsset
|
||||
{
|
||||
public static final String TYPE = "asset";
|
||||
|
||||
@Id @GeneratedValue
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@JsonIgnore
|
||||
private long id;
|
||||
|
||||
/// The QR code attached to the asset, used for identification.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package be.seeseepuff.pcinv.models;
|
||||
|
||||
import be.seeseepuff.pcinv.meta.*;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -21,6 +22,7 @@ public class HddAsset implements Asset
|
||||
{
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@JsonIgnore
|
||||
private long id;
|
||||
|
||||
@OneToOne(orphanRemoval = true)
|
||||
@@ -40,12 +42,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 +56,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;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package be.seeseepuff.pcinv.models;
|
||||
|
||||
import be.seeseepuff.pcinv.meta.*;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -18,6 +19,7 @@ public class MotherboardAsset implements Asset
|
||||
{
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@JsonIgnore
|
||||
private long id;
|
||||
|
||||
/// The generic asset associated with this RAM.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package be.seeseepuff.pcinv.models;
|
||||
|
||||
import be.seeseepuff.pcinv.meta.*;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -18,6 +19,7 @@ public class NICAsset implements Asset
|
||||
{
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@JsonIgnore
|
||||
private long id;
|
||||
|
||||
/// The generic asset associated with this RAM.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package be.seeseepuff.pcinv.models;
|
||||
|
||||
import be.seeseepuff.pcinv.meta.*;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -18,6 +19,7 @@ public class OpticalDriveAsset implements Asset
|
||||
{
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@JsonIgnore
|
||||
private long id;
|
||||
|
||||
/// The generic asset associated with this RAM.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package be.seeseepuff.pcinv.models;
|
||||
|
||||
import be.seeseepuff.pcinv.meta.*;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -18,6 +19,7 @@ public class PowerSupplyAsset implements Asset
|
||||
{
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@JsonIgnore
|
||||
private long id;
|
||||
|
||||
/// The generic asset associated with this RAM.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package be.seeseepuff.pcinv.models;
|
||||
|
||||
import be.seeseepuff.pcinv.meta.*;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -21,6 +22,7 @@ public class RamAsset implements Asset
|
||||
{
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@JsonIgnore
|
||||
private long id;
|
||||
|
||||
@OneToOne(orphanRemoval = true)
|
||||
@@ -37,5 +39,5 @@ public class RamAsset implements Asset
|
||||
|
||||
@Description("The speed of the memory in MHz.")
|
||||
@Property("Speed")
|
||||
private Long speed;
|
||||
private Integer speed;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import lombok.RequiredArgsConstructor;
|
||||
@RequiredArgsConstructor
|
||||
public enum ReadWrite implements AssetEnum {
|
||||
/// The capacbilities are unknown.
|
||||
UNKNOWN("unknown", "Unknown"),
|
||||
UNKNOWN("unknown", "?"),
|
||||
/// The device can only read data.
|
||||
READ("read", "Read Only"),
|
||||
/// The device can only write data.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package be.seeseepuff.pcinv.models;
|
||||
|
||||
import be.seeseepuff.pcinv.meta.*;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -18,6 +19,7 @@ public class SoundAdapterAsset implements Asset
|
||||
{
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@JsonIgnore
|
||||
private long id;
|
||||
|
||||
/// The generic asset associated with this RAM.
|
||||
|
||||
@@ -1,27 +1,36 @@
|
||||
package be.seeseepuff.pcinv.models;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
/**
|
||||
* Represents a work log entry in the system.
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
@Entity
|
||||
public class WorkLogEntry {
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@JsonIgnore
|
||||
private long id;
|
||||
|
||||
@JsonIgnore
|
||||
@ManyToOne(optional = false)
|
||||
private GenericAsset asset;
|
||||
|
||||
/// The description of the work log entry.
|
||||
private String description;
|
||||
private String comment;
|
||||
|
||||
/// The date and time when the work log entry was created.
|
||||
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
private ZonedDateTime date;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package be.seeseepuff.pcinv.repositories;
|
||||
|
||||
import be.seeseepuff.pcinv.models.WorkLogEntry;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface WorkLogRepository extends JpaRepository<WorkLogEntry, Long> {
|
||||
}
|
||||
@@ -6,12 +6,18 @@ import be.seeseepuff.pcinv.meta.AssetInfo;
|
||||
import be.seeseepuff.pcinv.meta.AssetProperty;
|
||||
import be.seeseepuff.pcinv.models.Asset;
|
||||
import be.seeseepuff.pcinv.models.GenericAsset;
|
||||
import be.seeseepuff.pcinv.models.WorkLogEntry;
|
||||
import be.seeseepuff.pcinv.repositories.AssetRepository;
|
||||
import be.seeseepuff.pcinv.repositories.GenericAssetRepository;
|
||||
import be.seeseepuff.pcinv.repositories.WorkLogRepository;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@@ -22,7 +28,9 @@ import java.util.*;
|
||||
@RequiredArgsConstructor
|
||||
public class AssetService {
|
||||
private final GenericAssetRepository genericRepository;
|
||||
private final WorkLogRepository workLogRepository;
|
||||
private final Collection<AssetRepository<?>> repositories;
|
||||
private final EntityManager entityManager;
|
||||
|
||||
/**
|
||||
* Returns the count of all assets in the repository.
|
||||
@@ -48,6 +56,30 @@ public class AssetService {
|
||||
return getRepositoryFor(genericAsset.getType()).findByAsset(genericAsset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves an asset by its QR code and duplicates the object.
|
||||
*
|
||||
* @param qr the QR code of the asset to retrieve
|
||||
* @return the Asset associated with the given QR code, or null if no duplicate is found
|
||||
*/
|
||||
@SneakyThrows
|
||||
public Asset getAssetDuplicateByQr(long qr) {
|
||||
var mapper = new ModelMapper();
|
||||
var originalGenericAsset = genericRepository.findByQr(qr);
|
||||
if (originalGenericAsset == null) {
|
||||
throw new IllegalArgumentException("No asset found with QR code: " + qr);
|
||||
}
|
||||
var originalAsset = getRepositoryFor(originalGenericAsset.getType()).findByAsset(originalGenericAsset);
|
||||
|
||||
var genericAsset = mapper.map(originalGenericAsset, GenericAsset.class);
|
||||
genericAsset.setId(0); // Reset ID to create a new instance
|
||||
genericAsset.setQr(0);
|
||||
var asset = mapper.map(originalAsset, originalAsset.getClass());
|
||||
asset.setAsset(genericAsset);
|
||||
|
||||
return asset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves all assets of a specific type.
|
||||
*
|
||||
@@ -260,7 +292,7 @@ public class AssetService {
|
||||
for (var descriptor : tree) {
|
||||
for (var property : descriptor.getProperties()) {
|
||||
if (property.isInputList()) {
|
||||
var inputList = getInputList(descriptor, property);
|
||||
var inputList = getInputList(descriptor, property, type);
|
||||
map.put(descriptor.asString(property), inputList);
|
||||
}
|
||||
}
|
||||
@@ -273,9 +305,10 @@ public class AssetService {
|
||||
*
|
||||
* @param descriptor the asset descriptor containing the property
|
||||
* @param property the asset property to retrieve the input list for
|
||||
* @param type Limit the search to a specific type
|
||||
* @return a set of input values for the specified property
|
||||
*/
|
||||
private Set<String> getInputList(AssetDescriptor descriptor, AssetProperty property) {
|
||||
private Set<String> getInputList(AssetDescriptor descriptor, AssetProperty property, String type) {
|
||||
List<?> entries;
|
||||
if (descriptor.getType().equals(GenericAsset.TYPE)) {
|
||||
entries = genericRepository.findAll();
|
||||
@@ -284,8 +317,21 @@ public class AssetService {
|
||||
entries = repository.findAll();
|
||||
}
|
||||
|
||||
Set<String> inputList = new TreeSet<>();
|
||||
var inputList = new TreeSet<String>(Comparator.comparing(String::toLowerCase));
|
||||
for (var entry : entries) {
|
||||
String entryType;
|
||||
if (entry instanceof Asset asset) {
|
||||
entryType = asset.getAsset().getType();
|
||||
} else if (entry instanceof GenericAsset asset) {
|
||||
entryType = asset.getType();
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unsupported entry type: " + entry.getClass().getName());
|
||||
}
|
||||
|
||||
if (!entryType.equals(type)) {
|
||||
continue; // Skip entries that do not match the specified type
|
||||
}
|
||||
|
||||
var value = property.getValue(entry);
|
||||
if (value != null) {
|
||||
inputList.add(value.toString());
|
||||
@@ -293,4 +339,23 @@ public class AssetService {
|
||||
}
|
||||
return inputList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a work log entry to the asset with the specified QR code.
|
||||
*
|
||||
* @param asset the asset to which the work log entry will be added
|
||||
* @param comment the comment for the work log entry
|
||||
*/
|
||||
@Transactional
|
||||
public void addWorkLogEntry(Asset asset, String comment) {
|
||||
var genericAsset = asset.getAsset();
|
||||
|
||||
var workLogEntry = new WorkLogEntry();
|
||||
workLogEntry.setAsset(genericAsset);
|
||||
workLogEntry.setComment(comment);
|
||||
workLogEntry.setDate(ZonedDateTime.now());
|
||||
|
||||
workLogRepository.saveAndFlush(workLogEntry);
|
||||
entityManager.refresh(genericAsset);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
<td>
|
||||
<a th:href="'/view/'+${a.getQr()}">View</a>
|
||||
<a th:href="'/edit/'+${a.getQr()}">Edit</a>
|
||||
<a th:href="'/duplicate/'+${a.getQr()}">Duplicate</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<body th:replace="~{fragments :: base(title='Create '+${descriptor.displayName}, content=~{::content})}">
|
||||
<div th:fragment="content">
|
||||
<h2>Create a <span th:text="${descriptor.displayName}"></span></h2>
|
||||
<form th:action="'/'+${action}+'/'+${asset != null ? asset.getQr() : descriptor.getType()}" method="post">
|
||||
<form th:action="'/'+${(action == 'duplicate') ? 'create' : action}+'/'+${(asset != null && action != 'duplicate') ? asset.getQr() : descriptor.getType()}" method="post">
|
||||
<div th:each="d : ${descriptors}">
|
||||
<h2 th:text="${d.displayName}"></h2>
|
||||
<table border="1" cellpadding="4">
|
||||
@@ -17,7 +17,7 @@
|
||||
<input 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}"/>
|
||||
</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="INTEGER" type="number" th:id="${d.asString(p)}" th:name="${d.asString(p)}" th:value="${(p.name == 'qr' && action == 'duplicate') ? null : 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)}">
|
||||
@@ -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}"/>
|
||||
<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">Bytes</option>
|
||||
<option th:if="${p.capacityAsSI}">kB</option>
|
||||
<option th:if="${p.capacityAsIEC}">KiB</option>
|
||||
<option th:if="${p.capacityAsSI}">MB</option>
|
||||
<option th:if="${p.capacityAsIEC}">MiB</option>
|
||||
<option th:if="${p.capacityAsSI}">GB</option>
|
||||
<option th:if="${p.capacityAsIEC}">GiB</option>
|
||||
<option th:if="${p.capacityAsSI}">TB</option>
|
||||
<option th:if="${p.capacityAsIEC}">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>
|
||||
@@ -50,7 +50,7 @@
|
||||
</table>
|
||||
</div>
|
||||
<p>
|
||||
<input th:if="${action == 'create'}" type="submit" value="Create">
|
||||
<input th:if="${action == 'create' || action == 'duplicate'}" type="submit" value="Create">
|
||||
<input th:if="${action == 'edit'}" type="submit" value="Save Changes">
|
||||
</p>
|
||||
</form>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<h2 th:text="${d.displayName}"></h2>
|
||||
<table border="1" cellpadding="4">
|
||||
<tr th:each="p : ${d.properties}">
|
||||
<td bgcolor="lightgray"><b th:text="${p.displayName}"></b></td>
|
||||
<th bgcolor="lightgray"><b th:text="${p.displayName}"></b></th>
|
||||
<td th:text="${p.renderValue(asset)}"></td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -15,6 +15,8 @@
|
||||
<ul th:if="${action == 'view'}">
|
||||
<li><a th:href="'/edit/'+${asset.getQr()}">Edit</a></li>
|
||||
<li><a th:href="'/delete/'+${asset.getQr()}">Delete</a></li>
|
||||
<li><a th:href="'/create/'+${asset.getAsset().type}">Create another <span th:text="${descriptor.displayName}">Hard Drive</span></a></li>
|
||||
<li><a th:href="'/duplicate/'+${asset.getQr()}">Duplicate this <span th:text="${descriptor.displayName}">Hard Drive</span></a></li>
|
||||
<li><a th:href="'/browse/'+${descriptor.type}">Browse all <span th:text="${descriptor.pluralName}">Hard Drives</span></a></li>
|
||||
</ul>
|
||||
<ul th:if="${action == 'delete'}">
|
||||
@@ -22,5 +24,25 @@
|
||||
<li><a th:href="'/delete/'+${asset.getQr()}+'?confirm=true'">Yes, delete it</a></li>
|
||||
</ul>
|
||||
</p>
|
||||
<p th:if="${action == 'view'}">
|
||||
<h2>Work Log</h2>
|
||||
<form th:action="'/view/'+${asset.getQr()}" method="post">
|
||||
<input type="hidden" th:value="${worklog.size()}" name="worklog_size">
|
||||
<table border="1" cellpadding="4">
|
||||
<tr>
|
||||
<th bgcolor="lightgray"><b>Date</b></th>
|
||||
<th bgcolor="lightgray"><b>Comment</b></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center"><input type="submit" value="Post Entry"></td>
|
||||
<td><input type="text" name="comment" placeholder="Comment"></td>
|
||||
</tr>
|
||||
<tr th:each="w : ${worklog}">
|
||||
<td th:text="${#temporals.format(w.date, 'dd/MM/yyyy')} + ' at ' + ${#temporals.format(w.date, 'HH:mm')}"></td>
|
||||
<td th:text="${w.comment}"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user