Initial implementation of inventree
A small IT asset inventory system built around a nested folder tree, matching the project brief: Go + html/template + Bootstrap 5 + vanilla JS, SQLite storage (WAL, FKs, migrations), embedded templates/static assets, single compiled binary. - AJAX-driven inventory tree: lazy-loaded folder expansion with per-user persisted expand state, drag-and-drop move for folders/assets, safe delete-with-relocate-or-cascade confirmation, search with breadcrumbs. - Assets: CRUD, duplicate, move, auto-generated IT-000001-style IDs, CSV import (with optional folder auto-create) and export. - Admin-defined item types with custom fields (text/long_text/number/date/ boolean/dropdown/url/ip_address). - Configurable statuses, session-based auth (bcrypt, secure cookies), admin/user roles, user management. - CLI: serve, version, database migrate, database backup; /healthz; graceful shutdown; Dockerfile/docker-compose/systemd unit; Go test suite.
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
{{define "tree_children"}}
|
||||
{{range .}}
|
||||
{{if eq .Type "folder"}}
|
||||
<li class="tree-node" data-type="folder" data-id="{{.ID}}" draggable="true">
|
||||
<div class="tree-row" data-type="folder" data-id="{{.ID}}" tabindex="0">
|
||||
{{if .HasChildren}}
|
||||
<button type="button" class="tree-toggle{{if .Expanded}} expanded{{end}}" data-id="{{.ID}}" aria-label="Toggle">
|
||||
<i class="bi bi-chevron-right"></i>
|
||||
</button>
|
||||
{{else}}
|
||||
<span class="tree-toggle-spacer"></span>
|
||||
{{end}}
|
||||
<i class="bi {{iconOr .Icon "bi-folder-fill"}} tree-icon text-warning-emphasis"></i>
|
||||
<span class="tree-label">{{.Name}}</span>
|
||||
<span class="tree-actions admin-only">
|
||||
<button type="button" class="btn-tree-action" data-action="menu" data-id="{{.ID}}" data-type="folder" title="Actions">
|
||||
<i class="bi bi-three-dots"></i>
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
<ul class="tree-children list-unstyled{{if not .Expanded}} d-none{{end}}" data-expanded="{{.Expanded}}" data-loaded="{{.Expanded}}">
|
||||
{{if .Expanded}}{{template "tree_children" .Children}}{{end}}
|
||||
</ul>
|
||||
</li>
|
||||
{{else if eq .Type "asset"}}
|
||||
<li class="tree-node" data-type="asset" data-id="{{.ID}}" draggable="true">
|
||||
<div class="tree-row" data-type="asset" data-id="{{.ID}}" tabindex="0">
|
||||
<span class="tree-toggle-spacer"></span>
|
||||
<i class="bi {{iconOr .Icon "bi-box-seam"}} tree-icon text-body-secondary"></i>
|
||||
<span class="tree-label">{{.Name}}</span>
|
||||
<span class="badge rounded-pill text-bg-{{.StatusColor}} tree-status-badge">{{.StatusName}}</span>
|
||||
</div>
|
||||
</li>
|
||||
{{else}}
|
||||
<li class="tree-node tree-node-more">
|
||||
<div class="tree-row tree-row-more text-body-secondary fst-italic">
|
||||
<span class="tree-toggle-spacer"></span>
|
||||
<i class="bi bi-three-dots"></i>
|
||||
<span class="tree-label">{{.Name}}</span>
|
||||
</div>
|
||||
</li>
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
Reference in New Issue
Block a user