Can create devices nicely

This commit is contained in:
2025-03-24 09:43:41 +01:00
parent 6405e7d692
commit c459148d33
9 changed files with 233 additions and 54 deletions

View File

@@ -1,37 +1,8 @@
{{- /*gotype: main.CreateDeviceVM */}}
{{define "create_device"}}
{{template "header" "Create Device"}}
{{/*<form action="/create?id={{.Qr}}" method="post">*/}}
{{/* <label for="qr">QR Code:</label>*/}}
{{/* <input type="text" id="qr" name="qr" value="{{.Qr}}" required disabled>*/}}
{{/* <br>*/}}
{{/* <label for="type">Type:</label>*/}}
{{/* <input type="text" id="type" name="type" required>*/}}
{{/* <br>*/}}
{{/* <label for="brand">Brand:</label>*/}}
{{/* <input type="text" id="brand" name="brand">*/}}
{{/* <br>*/}}
{{/* <label for="name">Name:</label>*/}}
{{/* <input type="text" id="name" name="name">*/}}
{{/* <br>*/}}
{{/* <label for="description">Description:</label>*/}}
{{/* <textarea id="description" name="description"></textarea>*/}}
{{/* <br>*/}}
{{/* <button type="submit">Create</button>*/}}
{{/*</form>*/}}
<ul>
{{template "create_device_link" createDeviceLink "ram" "Random Access Memory" .Qr}}
</ul>
{{template "footer"}}
{{end}}
{{define "create_device_link"}}
{{if .Qr}}
<li><a href="/create?type=ram&qr={{.Qr}}">Random Access Memory</a></li>
{{- else}}
<li><a href="/create?type=ram">Random Access Memory</a></li>
{{- end}}
{{if .Type}}
{{template "create_device_step2" .}}
{{else}}
{{template "create_device_step1" .}}
{{end}}
{{end}}

View File

@@ -0,0 +1,16 @@
{{- /*gotype: main.CreateDeviceVM */}}
{{define "create_device_step1"}}
{{template "header" "Create Device - Choose Device Type"}}
<ul>
{{template "create_device_link" createDeviceLink "ram" "Random Access Memory" .Qr}}
</ul>
{{template "footer"}}
{{end}}
{{define "create_device_link"}}
{{if .Qr}}
<li><a href="/create?type=ram&qr={{.Qr}}">Random Access Memory</a></li>
{{- else}}
<li><a href="/create?type=ram">Random Access Memory</a></li>
{{- end}}
{{end}}

View File

@@ -0,0 +1,73 @@
{{- /*gotype: main.CreateDeviceVM */}}
{{define "create_device_step2"}}
{{template "header" "Create Device - Enter Device Data"}}
<form action="/create" method="post">
<h2>General Information</h2>
<table>
<tr>
<td><label for="qr">QR Code:</label></td>
{{if .Qr}}
<td><input type="number" id="qr" name="qr" value="{{.Qr}}" required readonly></td>
{{else}}
<td><input type="number" id="qr" name="qr" required></td>
{{end}}
</tr>
<tr>
<td><label for="asset_type">Type:</label></td>
<td><input type="text" id="asset_type" name="asset_type" required readonly value="{{.Type}}"></td>
</tr>
<tr>
<td><label for="asset_brand">Brand:</label></td>
<td><select id="asset_brand" name="asset_brand" onchange="newOption('asset_brand', 'Brand')">
<option value="Unknown" selected>Unknown</option>
{{range .Brands}}
{{if ne . "Unknown"}}
<option value="{{.}}">{{.}}</option>
{{end}}
{{end}}
<option>New...</option>
</select></td>
</tr>
<tr>
<td><label for="asset_name">Name:</label></td>
<td><input type="text" id="asset_name" name="asset_name"></td>
</tr>
<tr>
<td><label for="asset_description">Description:</label></td>
<td><textarea id="asset_description" name="asset_description"></textarea></td>
</tr>
</table>
<h2>Memory Information</h2>
<table>
<tr>
<td><label for="ram_type">Type:</label></td>
<td><select id="ram_type" name="ram_type" onchange="newOption('ram_type', 'Memory Type')">
<option value="Unknown" selected>Unknown</option>
{{range .RamTypes}}
{{if ne . "Unknown"}}
<option value="{{.}}">{{.}}</option>
{{end}}
{{end}}
<option>New...</option>
</select></td>
</tr>
<tr>
<td><label for="ram_capacity">Capacity:</label></td>
<td>
<input type="number" id="ram_capacity" name="ram_capacity">
<select id="ram_capacity_unit" name="ram_capacity_unit">
<option value="B">B</option>
<option value="KB">KB</option>
<option value="MB" selected>MB</option>
<option value="GB">GB</option>
<option value="TB">TB</option>
</select>
</td>
</tr>
</table>
<button type="submit">Create</button>
</form>
{{template "footer"}}
{{end}}

View File

@@ -1,10 +1,11 @@
{{define "header"}}
<html>
<head>
<title>PC Inventory{{if .}} - {{.}}{{- end}}</title>
<title>PC Inventory{{if .}} - {{.}}{{end}}</title>
<script src="/static/scripts.js" type="application/javascript"></script>
</head>
<body>
<h1>PC Inventory - <i>{{.}}</i></h1>
<h1><a href="/">PC Inventory</a>{{if .}} - <i>{{.}}{{end}}</i></h1>
<form action="/device" method="get">
<label for="id">Device ID:</label>
<input type="text" id="id" name="id">