Files
pcinv/templates/create_device_step2.gohtml
Sebastiaan de Schaetzen ff1d95edab
All checks were successful
Build / build (push) Successful in 1m30s
Add ability to add hard drives
2025-03-24 16:15:52 +01:00

131 lines
4.9 KiB
Plaintext

{{- /*gotype: pcinv.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" {{if eq .AssetBrand "Unknown"}}selected{{end}}>Unknown</option>
{{range .AssetBrands}}
{{if ne . "Unknown"}}
<option value="{{.}}" {{if eq . $.AssetBrand}}selected{{end}}>{{.}}</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" value="{{.AssetName}}"></td>
</tr>
<tr>
<td><label for="asset_description">Description:</label></td>
<td><textarea id="asset_description" name="asset_description">{{.AssetDescription}}</textarea></td>
</tr>
</table>
{{if eq .Type "ram"}}
<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" {{if eq .RamType "Unknown"}}selected{{end}}>Unknown</option>
{{range .RamTypes}}
{{if ne . "Unknown"}}
<option value="{{.}}" {{if eq . $.RamType}}selected{{end}}>{{.}}</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" value="{{if .RamCapacity}}{{.RamCapacity | formatMemoryPlainSize}}{{end}}">
<select id="ram_capacity_unit" name="ram_capacity_unit">
<option value="B" {{if isRamType .RamCapacity "B"}}selected{{end}}>B</option>
<option value="KB" {{if isRamType .RamCapacity "KB"}}selected{{end}}>KB</option>
<option value="MB" {{if isRamType .RamCapacity "MB"}}selected{{end}} selected>MB</option>
<option value="GB" {{if isRamType .RamCapacity "GB"}}selected{{end}}>GB</option>
<option value="TB" {{if isRamType .RamCapacity "TB"}}selected{{end}}>TB</option>
</select>
</td>
</tr>
</table>
{{end}}
{{if eq .Type "hdd"}}
<h2>Hard Drive Information</h2>
<table>
<tr>
<td><label for="hdd_capacity">Capacity:</label></td>
<td>
<input type="number" id="hdd_capacity" name="hdd_capacity" value="{{if .HddCapacity}}{{.HddCapacity | formatMemoryPlainSize}}{{end}}">
<select id="hdd_capacity_unit" name="hdd_capacity_unit">
<option value="B" {{if isRamType .HddCapacity "B"}}selected{{end}}>B</option>
<option value="KB" {{if isRamType .HddCapacity "KB"}}selected{{end}}>KB</option>
<option value="MB" {{if isRamType .HddCapacity "MB"}}selected{{end}} selected>MB</option>
<option value="GB" {{if isRamType .HddCapacity "GB"}}selected{{end}}>GB</option>
<option value="TB" {{if isRamType .HddCapacity "TB"}}selected{{end}}>TB</option>
</select>
</td>
</tr>
<tr>
<td><label for="hdd_type">Type:</label></td>
<td>{{template "create_device_select" createSelectMenu "hdd_type" "HDD Type" .HddType .HddTypes}}</td>
</tr>
<tr>
<td><label for="hdd_form_factor">Form Factor:</label></td>
<td>{{template "create_device_select" createSelectMenu "hdd_form_factor" "HDD Form Factor" .HddFormFactor .HddFormFactors}}</td>
</tr>
<tr>
<td><label for="hdd_connection">Connection:</label></td>
<td>{{template "create_device_select" createSelectMenu "hdd_connection" "HDD Connection" .HddConnection .HddConnections}}</td>
</tr>
<tr>
<td><label for="hdd_rpm">RPM:</label></td>
<td>{{template "create_device_select" createSelectMenuDefault "hdd_rpm" "HDD RPM" .HddRpm .HddRpms "Not Applicable"}}</td>
</tr>
</table>
{{end}}
{{if .IsEdit}}
<button type="submit">Edit</button>
{{else}}
<button type="submit">Create</button>
{{end}}
</form>
{{template "footer"}}
{{end}}
{{define "create_device_select"}}
<select id="{{.Name}}" name="{{.Name}}" onchange="newOption('{{.Name}}', '{{.Label}}')">
<option value="Unknown" {{if eq .Selected "Unknown"}}selected{{end}}>{{.DefaultValue}}</option>
{{range .Options}}
{{if ne . "Unknown"}}
<option value="{{.}}" {{if eq . $.Selected}}selected{{end}}>{{.}}</option>
{{end}}
{{end}}
<option>New...</option>
</select>
{{end}}