Can create, edit, view, and delete assets

This commit is contained in:
2025-06-08 14:20:29 +02:00
parent 72f4a1cd28
commit afd36bcb0c
11 changed files with 223 additions and 34 deletions

View File

@@ -1,30 +1,30 @@
<body th:replace="~{fragments :: base(title='Create '+${descriptor.displayName}, content=~{::content})}">
<div th:fragment="content">
Create a <span th:text="${descriptor.displayName}"></span>
<form th:action="'/create/'+${descriptor.getType()}" method="post">
<form th:action="'/'+${action}+'/'+${asset != null ? asset.getQr() : descriptor.getType()}" method="post">
<div th:each="d : ${descriptors}">
<h2 th:text="${d.displayName}"></h2>
<table border="1">
<table border="1" cellpadding="4">
<tr th:each="p : ${d.getProperties()}">
<td><label th:text="${p.displayName}" th:for="${d.asString(p)}"></label></td>
<td bgcolor="#d3d3d3"><b><label th:text="${p.displayName}" th:for="${d.asString(p)}"></label></b></td>
<td th:switch="${p.type.nameOrEnum()}">
<input th:case="STRING" type="text" th:id="${d.asString(p)}" th:name="${d.asString(p)}" 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:required="${p.required}"/>
<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}"/>
<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="${o.defaultValue}">Good</option>
<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}"/>
<select th:id="${d.asString(p)}+'-unit'" th:name="${d.asString(p)}+'-unit'">
<option value="1">Bytes</option>
<option th:if="${p.capacityAsSI}" value="1000">kB</option>
<option th:if="${p.capacityAsIEC}" value="1024">KiB</option>
<option th:if="${p.capacityAsSI}" value="1000000">MB</option>
<option th:if="${p.capacityAsIEC}" value="1048576">MiB</option>
<option th:if="${p.capacityAsSI}" value="1000000000">GB</option>
<option th:if="${p.capacityAsIEC}" value="1073741824">GiB</option>
<option th:if="${p.capacityAsSI}" value="1000000000000">TB</option>
<option th:if="${p.capacityAsIEC}" value="1099511627776">TiB</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>
</select>
</span>
<b th:case="*">Bad input type for <span th:text="${d.type}+'-'+${p.type}"></span></b>
@@ -33,7 +33,8 @@
</table>
</div>
<p>
<input type="submit" value="Create">
<input th:if="${action == 'create'}" type="submit" value="Create">
<input th:if="${action == 'edit'}" type="submit" value="Save Changes">
</p>
</form>
</div>