Implement non-destructive Remove & Archive lifecycle system across assets, locations, tags, and shortlinks
This commit is contained in:
1 parent
3391257f6c
commit
960c375557
20 files changed
+1751
-185
No files matched your search
+197
-30
@@ -9,6 +9,7 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -44,6 +45,8 @@ type PageData struct {
|
||||
SelectedStatus string
|
||||
SelectedLocation int64
|
||||
CatalogJSON string
|
||||
SlugLength int
|
||||
ShowRemoved bool
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
@@ -167,8 +170,9 @@ func (s *Server) handleLogout(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
func (s *Server) handleAdminItems(w http.ResponseWriter, r *http.Request) {
|
||||
csrf := csrfToken(w, r)
|
||||
locations, _ := s.db.ListLocations()
|
||||
tags, _ := s.db.ListTags()
|
||||
showRemoved := r.URL.Query().Get("show_removed") == "1"
|
||||
locations, _ := s.db.ListLocations(showRemoved)
|
||||
tags, _ := s.db.ListTags(showRemoved)
|
||||
|
||||
// 1. DETAIL VIEW MODE
|
||||
if viewIDStr := r.URL.Query().Get("view"); viewIDStr != "" {
|
||||
@@ -188,6 +192,7 @@ func (s *Server) handleAdminItems(w http.ResponseWriter, r *http.Request) {
|
||||
CustomFieldsMap: cfMap,
|
||||
Locations: locations,
|
||||
Tags: tags,
|
||||
ShowRemoved: showRemoved,
|
||||
Toast: r.URL.Query().Get("toast"),
|
||||
ToastType: r.URL.Query().Get("toast_type"),
|
||||
}
|
||||
@@ -202,7 +207,7 @@ func (s *Server) handleAdminItems(w http.ResponseWriter, r *http.Request) {
|
||||
statusQuery := r.URL.Query().Get("status")
|
||||
locationQuery := r.URL.Query().Get("location")
|
||||
|
||||
allItems, err := s.db.ListItems()
|
||||
allItems, err := s.db.ListItems(showRemoved)
|
||||
if err != nil {
|
||||
http.Error(w, "Failed to load assets", http.StatusInternalServerError)
|
||||
return
|
||||
@@ -239,6 +244,7 @@ func (s *Server) handleAdminItems(w http.ResponseWriter, r *http.Request) {
|
||||
SearchQuery: searchQuery,
|
||||
SelectedStatus: statusQuery,
|
||||
SelectedLocation: locFilterID,
|
||||
ShowRemoved: showRemoved,
|
||||
Toast: r.URL.Query().Get("toast"),
|
||||
ToastType: r.URL.Query().Get("toast_type"),
|
||||
}
|
||||
@@ -247,8 +253,8 @@ func (s *Server) handleAdminItems(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func (s *Server) handleItemNew(w http.ResponseWriter, r *http.Request) {
|
||||
locations, _ := s.db.ListLocations()
|
||||
tags, _ := s.db.ListTags()
|
||||
locations, _ := s.db.ListLocations(false)
|
||||
tags, _ := s.db.ListTags(false)
|
||||
|
||||
catalogJSON, err := json.Marshal(s.catalog)
|
||||
if err != nil {
|
||||
@@ -448,8 +454,8 @@ func (s *Server) handleItemEdit(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
locations, _ := s.db.ListLocations()
|
||||
tags, _ := s.db.ListTags()
|
||||
locations, _ := s.db.ListLocations(false)
|
||||
tags, _ := s.db.ListTags(false)
|
||||
|
||||
// Translate custom JSON string back to raw lines for edit comfort
|
||||
customFieldsRaw := formatCustomFields(item.CustomFields)
|
||||
@@ -570,7 +576,40 @@ func (s *Server) handleItemSave(w http.ResponseWriter, r *http.Request) {
|
||||
http.Redirect(w, r, fmt.Sprintf("/admin?view=%d&toast=Asset+updated+successfully&toast_type=success", item.ID), http.StatusSeeOther)
|
||||
}
|
||||
|
||||
func (s *Server) handleItemDelete(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *Server) handleItemRemove(w http.ResponseWriter, r *http.Request) {
|
||||
id, err := strconv.ParseInt(r.PathValue("id"), 10, 64)
|
||||
if err != nil {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
_ = s.db.SoftRemoveItem(id)
|
||||
http.Redirect(w, r, "/admin?toast=Asset+moved+to+soon-to-be-deleted+queue&toast_type=success", http.StatusSeeOther)
|
||||
}
|
||||
|
||||
func (s *Server) handleItemArchive(w http.ResponseWriter, r *http.Request) {
|
||||
id, err := strconv.ParseInt(r.PathValue("id"), 10, 64)
|
||||
if err != nil {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
_ = s.db.ArchiveItem(id)
|
||||
http.Redirect(w, r, "/admin?toast=Asset+archived+successfully&toast_type=success", http.StatusSeeOther)
|
||||
}
|
||||
|
||||
func (s *Server) handleItemRestore(w http.ResponseWriter, r *http.Request) {
|
||||
id, err := strconv.ParseInt(r.PathValue("id"), 10, 64)
|
||||
if err != nil {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
_ = s.db.RestoreItem(id)
|
||||
http.Redirect(w, r, "/admin?show_removed=1&toast=Asset+restored+successfully&toast_type=success", http.StatusSeeOther)
|
||||
}
|
||||
|
||||
func (s *Server) handleItemPermanentDelete(w http.ResponseWriter, r *http.Request) {
|
||||
id, err := strconv.ParseInt(r.PathValue("id"), 10, 64)
|
||||
if err != nil {
|
||||
http.NotFound(w, r)
|
||||
@@ -589,7 +628,7 @@ func (s *Server) handleItemDelete(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
_ = s.db.DeleteItem(id)
|
||||
http.Redirect(w, r, "/admin?toast=Asset+deleted+successfully&toast_type=success", http.StatusSeeOther)
|
||||
http.Redirect(w, r, "/admin?show_removed=1&toast=Asset+deleted+forever+successfully&toast_type=success", http.StatusSeeOther)
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
@@ -598,7 +637,8 @@ func (s *Server) handleItemDelete(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
func (s *Server) handleAdminLocations(w http.ResponseWriter, r *http.Request) {
|
||||
csrf := csrfToken(w, r)
|
||||
locations, _ := s.db.ListLocations()
|
||||
showRemoved := r.URL.Query().Get("show_removed") == "1"
|
||||
locations, _ := s.db.ListLocations(showRemoved)
|
||||
|
||||
var editLoc *db.Location
|
||||
if editIDStr := r.URL.Query().Get("edit"); editIDStr != "" {
|
||||
@@ -613,6 +653,7 @@ func (s *Server) handleAdminLocations(w http.ResponseWriter, r *http.Request) {
|
||||
ActiveNav: "locations",
|
||||
Locations: locations,
|
||||
EditingLocation: editLoc,
|
||||
ShowRemoved: showRemoved,
|
||||
Toast: r.URL.Query().Get("toast"),
|
||||
ToastType: r.URL.Query().Get("toast_type"),
|
||||
}
|
||||
@@ -658,7 +699,40 @@ func (s *Server) handleLocationEdit(w http.ResponseWriter, r *http.Request) {
|
||||
http.Redirect(w, r, "/admin/locations?toast=Location+updated+successfully&toast_type=success", http.StatusSeeOther)
|
||||
}
|
||||
|
||||
func (s *Server) handleLocationDelete(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *Server) handleLocationRemove(w http.ResponseWriter, r *http.Request) {
|
||||
id, err := strconv.ParseInt(r.PathValue("id"), 10, 64)
|
||||
if err != nil {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
_ = s.db.SoftRemoveLocation(id)
|
||||
http.Redirect(w, r, "/admin/locations?toast=Location+moved+to+soon-to-be-deleted+queue&toast_type=success", http.StatusSeeOther)
|
||||
}
|
||||
|
||||
func (s *Server) handleLocationArchive(w http.ResponseWriter, r *http.Request) {
|
||||
id, err := strconv.ParseInt(r.PathValue("id"), 10, 64)
|
||||
if err != nil {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
_ = s.db.ArchiveLocation(id)
|
||||
http.Redirect(w, r, "/admin/locations?toast=Location+archived+successfully&toast_type=success", http.StatusSeeOther)
|
||||
}
|
||||
|
||||
func (s *Server) handleLocationRestore(w http.ResponseWriter, r *http.Request) {
|
||||
id, err := strconv.ParseInt(r.PathValue("id"), 10, 64)
|
||||
if err != nil {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
_ = s.db.RestoreLocation(id)
|
||||
http.Redirect(w, r, "/admin/locations?show_removed=1&toast=Location+restored+successfully&toast_type=success", http.StatusSeeOther)
|
||||
}
|
||||
|
||||
func (s *Server) handleLocationPermanentDelete(w http.ResponseWriter, r *http.Request) {
|
||||
id, err := strconv.ParseInt(r.PathValue("id"), 10, 64)
|
||||
if err != nil {
|
||||
http.NotFound(w, r)
|
||||
@@ -666,7 +740,7 @@ func (s *Server) handleLocationDelete(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
_ = s.db.DeleteLocation(id)
|
||||
http.Redirect(w, r, "/admin/locations?toast=Location+deleted+successfully&toast_type=success", http.StatusSeeOther)
|
||||
http.Redirect(w, r, "/admin/locations?show_removed=1&toast=Location+deleted+forever+successfully&toast_type=success", http.StatusSeeOther)
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
@@ -675,7 +749,8 @@ func (s *Server) handleLocationDelete(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
func (s *Server) handleAdminTags(w http.ResponseWriter, r *http.Request) {
|
||||
csrf := csrfToken(w, r)
|
||||
tags, _ := s.db.ListTags()
|
||||
showRemoved := r.URL.Query().Get("show_removed") == "1"
|
||||
tags, _ := s.db.ListTags(showRemoved)
|
||||
|
||||
var editTag *db.Tag
|
||||
if editIDStr := r.URL.Query().Get("edit"); editIDStr != "" {
|
||||
@@ -686,12 +761,13 @@ func (s *Server) handleAdminTags(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
data := PageData{
|
||||
CSRFToken: csrf,
|
||||
ActiveNav: "tags",
|
||||
Tags: tags,
|
||||
EditingTag: editTag,
|
||||
Toast: r.URL.Query().Get("toast"),
|
||||
ToastType: r.URL.Query().Get("toast_type"),
|
||||
CSRFToken: csrf,
|
||||
ActiveNav: "tags",
|
||||
Tags: tags,
|
||||
EditingTag: editTag,
|
||||
ShowRemoved: showRemoved,
|
||||
Toast: r.URL.Query().Get("toast"),
|
||||
ToastType: r.URL.Query().Get("toast_type"),
|
||||
}
|
||||
renderTemplate(w, "tags.html", data)
|
||||
}
|
||||
@@ -725,7 +801,40 @@ func (s *Server) handleTagEdit(w http.ResponseWriter, r *http.Request) {
|
||||
http.Redirect(w, r, "/admin/tags?toast=Tag+updated+successfully&toast_type=success", http.StatusSeeOther)
|
||||
}
|
||||
|
||||
func (s *Server) handleTagDelete(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *Server) handleTagRemove(w http.ResponseWriter, r *http.Request) {
|
||||
id, err := strconv.ParseInt(r.PathValue("id"), 10, 64)
|
||||
if err != nil {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
_ = s.db.SoftRemoveTag(id)
|
||||
http.Redirect(w, r, "/admin/tags?toast=Tag+moved+to+soon-to-be-deleted+queue&toast_type=success", http.StatusSeeOther)
|
||||
}
|
||||
|
||||
func (s *Server) handleTagArchive(w http.ResponseWriter, r *http.Request) {
|
||||
id, err := strconv.ParseInt(r.PathValue("id"), 10, 64)
|
||||
if err != nil {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
_ = s.db.ArchiveTag(id)
|
||||
http.Redirect(w, r, "/admin/tags?toast=Tag+archived+successfully&toast_type=success", http.StatusSeeOther)
|
||||
}
|
||||
|
||||
func (s *Server) handleTagRestore(w http.ResponseWriter, r *http.Request) {
|
||||
id, err := strconv.ParseInt(r.PathValue("id"), 10, 64)
|
||||
if err != nil {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
_ = s.db.RestoreTag(id)
|
||||
http.Redirect(w, r, "/admin/tags?show_removed=1&toast=Tag+restored+successfully&toast_type=success", http.StatusSeeOther)
|
||||
}
|
||||
|
||||
func (s *Server) handleTagPermanentDelete(w http.ResponseWriter, r *http.Request) {
|
||||
id, err := strconv.ParseInt(r.PathValue("id"), 10, 64)
|
||||
if err != nil {
|
||||
http.NotFound(w, r)
|
||||
@@ -733,7 +842,7 @@ func (s *Server) handleTagDelete(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
_ = s.db.DeleteTag(id)
|
||||
http.Redirect(w, r, "/admin/tags?toast=Tag+deleted+successfully&toast_type=success", http.StatusSeeOther)
|
||||
http.Redirect(w, r, "/admin/tags?show_removed=1&toast=Tag+deleted+forever+successfully&toast_type=success", http.StatusSeeOther)
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
@@ -742,20 +851,18 @@ func (s *Server) handleTagDelete(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
func (s *Server) handleAdminShortener(w http.ResponseWriter, r *http.Request) {
|
||||
csrf := csrfToken(w, r)
|
||||
links, _ := s.db.ListLinks()
|
||||
showRemoved := r.URL.Query().Get("show_removed") == "1"
|
||||
links, _ := s.db.ListLinks(showRemoved)
|
||||
|
||||
var editLink *db.Link
|
||||
if editIDStr := r.URL.Query().Get("edit"); editIDStr != "" {
|
||||
id, err := strconv.ParseInt(editIDStr, 10, 64)
|
||||
if err == nil {
|
||||
editLink, _ = s.db.GetLinkBySlug(editIDStr) // Note: ListLinks uses ID, so let's match by ID instead of slug in the select queries if possible. Wait!
|
||||
// Actually let's query by id using db.Conn directly or adding a GetLinkByID function.
|
||||
// Let's query by ID in database:
|
||||
row := s.db.Conn.QueryRow("SELECT id, slug, url, item_id, created_by, clicks, created_at FROM links WHERE id = ?", id)
|
||||
row := s.db.Conn.QueryRow("SELECT id, slug, url, item_id, created_by, clicks, lifecycle_state, created_at FROM links WHERE id = ?", id)
|
||||
var l db.Link
|
||||
var itemID sql.NullInt64
|
||||
var ts string
|
||||
if row.Scan(&l.ID, &l.Slug, &l.URL, &itemID, &l.CreatedBy, &l.Clicks, &ts) == nil {
|
||||
if row.Scan(&l.ID, &l.Slug, &l.URL, &itemID, &l.CreatedBy, &l.Clicks, &l.LifecycleState, &ts) == nil {
|
||||
l.ItemID = itemID
|
||||
l.CreatedAt, _ = time.Parse("2006-01-02 15:04:05", ts)
|
||||
editLink = &l
|
||||
@@ -768,6 +875,8 @@ func (s *Server) handleAdminShortener(w http.ResponseWriter, r *http.Request) {
|
||||
ActiveNav: "shortener",
|
||||
Links: links,
|
||||
EditingLink: editLink,
|
||||
SlugLength: s.cfg.Slugs.Length,
|
||||
ShowRemoved: showRemoved,
|
||||
Toast: r.URL.Query().Get("toast"),
|
||||
ToastType: r.URL.Query().Get("toast_type"),
|
||||
}
|
||||
@@ -845,7 +954,40 @@ func (s *Server) handleLinkSave(w http.ResponseWriter, r *http.Request) {
|
||||
http.Redirect(w, r, "/admin/shortener?toast=Shortlink+updated+successfully&toast_type=success", http.StatusSeeOther)
|
||||
}
|
||||
|
||||
func (s *Server) handleLinkDelete(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *Server) handleLinkRemove(w http.ResponseWriter, r *http.Request) {
|
||||
id, err := strconv.ParseInt(r.PathValue("id"), 10, 64)
|
||||
if err != nil {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
_ = s.db.SoftRemoveLink(id)
|
||||
http.Redirect(w, r, "/admin/shortener?toast=Shortlink+moved+to+soon-to-be-deleted+queue&toast_type=success", http.StatusSeeOther)
|
||||
}
|
||||
|
||||
func (s *Server) handleLinkArchive(w http.ResponseWriter, r *http.Request) {
|
||||
id, err := strconv.ParseInt(r.PathValue("id"), 10, 64)
|
||||
if err != nil {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
_ = s.db.ArchiveLink(id)
|
||||
http.Redirect(w, r, "/admin/shortener?toast=Shortlink+archived+successfully&toast_type=success", http.StatusSeeOther)
|
||||
}
|
||||
|
||||
func (s *Server) handleLinkRestore(w http.ResponseWriter, r *http.Request) {
|
||||
id, err := strconv.ParseInt(r.PathValue("id"), 10, 64)
|
||||
if err != nil {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
_ = s.db.RestoreLink(id)
|
||||
http.Redirect(w, r, "/admin/shortener?show_removed=1&toast=Shortlink+restored+successfully&toast_type=success", http.StatusSeeOther)
|
||||
}
|
||||
|
||||
func (s *Server) handleLinkPermanentDelete(w http.ResponseWriter, r *http.Request) {
|
||||
id, err := strconv.ParseInt(r.PathValue("id"), 10, 64)
|
||||
if err != nil {
|
||||
http.NotFound(w, r)
|
||||
@@ -853,7 +995,32 @@ func (s *Server) handleLinkDelete(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
_ = s.db.DeleteLink(id)
|
||||
http.Redirect(w, r, "/admin/shortener?toast=Shortlink+deleted+successfully&toast_type=success", http.StatusSeeOther)
|
||||
http.Redirect(w, r, "/admin/shortener?show_removed=1&toast=Shortlink+deleted+forever+successfully&toast_type=success", http.StatusSeeOther)
|
||||
}
|
||||
|
||||
func (s *Server) handleSlugLengthUpdate(w http.ResponseWriter, r *http.Request) {
|
||||
lengthStr := strings.TrimSpace(r.FormValue("slug_length"))
|
||||
length, err := strconv.Atoi(lengthStr)
|
||||
if err != nil || length < 3 || length > 16 {
|
||||
http.Redirect(w, r, "/admin/shortener?toast=Slug+length+must+be+between+3+and+16&toast_type=error", http.StatusSeeOther)
|
||||
return
|
||||
}
|
||||
|
||||
// Update in-memory config
|
||||
s.cfg.Slugs.Length = length
|
||||
|
||||
// Persist to config.toml
|
||||
configPath := "config.toml"
|
||||
data, err := os.ReadFile(configPath)
|
||||
if err == nil {
|
||||
content := string(data)
|
||||
// Replace the length line in the [slugs] section
|
||||
re := regexp.MustCompile(`(?m)^(\s*length\s*=\s*)\d+`)
|
||||
content = re.ReplaceAllString(content, "${1}"+strconv.Itoa(length))
|
||||
_ = os.WriteFile(configPath, []byte(content), 0644)
|
||||
}
|
||||
|
||||
http.Redirect(w, r, "/admin/shortener?toast=Slug+length+updated+to+"+strconv.Itoa(length)+"+characters&toast_type=success", http.StatusSeeOther)
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
@@ -862,7 +1029,7 @@ func (s *Server) handleLinkDelete(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
func (s *Server) handlePrintLabels(w http.ResponseWriter, r *http.Request) {
|
||||
csrf := csrfToken(w, r)
|
||||
items, err := s.db.ListItems()
|
||||
items, err := s.db.ListItems(false)
|
||||
if err != nil {
|
||||
http.Error(w, "Failed to load labels", http.StatusInternalServerError)
|
||||
return
|
||||
|
||||
@@ -112,25 +112,42 @@ func (s *Server) Start() error {
|
||||
mux.HandleFunc("POST /admin/items/new", s.requireAuth(s.requireCSRF(s.handleItemCreate)))
|
||||
mux.HandleFunc("GET /admin/items/edit/{id}", s.requireAuth(s.handleItemEdit))
|
||||
mux.HandleFunc("POST /admin/items/edit/{id}", s.requireAuth(s.requireCSRF(s.handleItemSave)))
|
||||
mux.HandleFunc("POST /admin/items/delete/{id}", s.requireAuth(s.requireCSRF(s.handleItemDelete)))
|
||||
mux.HandleFunc("POST /admin/items/delete/{id}", s.requireAuth(s.requireCSRF(s.handleItemRemove)))
|
||||
mux.HandleFunc("POST /admin/items/remove/{id}", s.requireAuth(s.requireCSRF(s.handleItemRemove)))
|
||||
mux.HandleFunc("POST /admin/items/archive/{id}", s.requireAuth(s.requireCSRF(s.handleItemArchive)))
|
||||
mux.HandleFunc("POST /admin/items/restore/{id}", s.requireAuth(s.requireCSRF(s.handleItemRestore)))
|
||||
mux.HandleFunc("POST /admin/items/permanent-delete/{id}", s.requireAuth(s.requireCSRF(s.handleItemPermanentDelete)))
|
||||
|
||||
// 7. Admin locations management
|
||||
mux.HandleFunc("GET /admin/locations", s.requireAuth(s.handleAdminLocations))
|
||||
mux.HandleFunc("POST /admin/locations/new", s.requireAuth(s.requireCSRF(s.handleLocationCreate)))
|
||||
mux.HandleFunc("POST /admin/locations/edit/{id}", s.requireAuth(s.requireCSRF(s.handleLocationEdit)))
|
||||
mux.HandleFunc("POST /admin/locations/delete/{id}", s.requireAuth(s.requireCSRF(s.handleLocationDelete)))
|
||||
mux.HandleFunc("POST /admin/locations/delete/{id}", s.requireAuth(s.requireCSRF(s.handleLocationRemove)))
|
||||
mux.HandleFunc("POST /admin/locations/remove/{id}", s.requireAuth(s.requireCSRF(s.handleLocationRemove)))
|
||||
mux.HandleFunc("POST /admin/locations/archive/{id}", s.requireAuth(s.requireCSRF(s.handleLocationArchive)))
|
||||
mux.HandleFunc("POST /admin/locations/restore/{id}", s.requireAuth(s.requireCSRF(s.handleLocationRestore)))
|
||||
mux.HandleFunc("POST /admin/locations/permanent-delete/{id}", s.requireAuth(s.requireCSRF(s.handleLocationPermanentDelete)))
|
||||
|
||||
// 8. Admin tags management
|
||||
mux.HandleFunc("GET /admin/tags", s.requireAuth(s.handleAdminTags))
|
||||
mux.HandleFunc("POST /admin/tags/new", s.requireAuth(s.requireCSRF(s.handleTagCreate)))
|
||||
mux.HandleFunc("POST /admin/tags/edit/{id}", s.requireAuth(s.requireCSRF(s.handleTagEdit)))
|
||||
mux.HandleFunc("POST /admin/tags/delete/{id}", s.requireAuth(s.requireCSRF(s.handleTagDelete)))
|
||||
mux.HandleFunc("POST /admin/tags/delete/{id}", s.requireAuth(s.requireCSRF(s.handleTagRemove)))
|
||||
mux.HandleFunc("POST /admin/tags/remove/{id}", s.requireAuth(s.requireCSRF(s.handleTagRemove)))
|
||||
mux.HandleFunc("POST /admin/tags/archive/{id}", s.requireAuth(s.requireCSRF(s.handleTagArchive)))
|
||||
mux.HandleFunc("POST /admin/tags/restore/{id}", s.requireAuth(s.requireCSRF(s.handleTagRestore)))
|
||||
mux.HandleFunc("POST /admin/tags/permanent-delete/{id}", s.requireAuth(s.requireCSRF(s.handleTagPermanentDelete)))
|
||||
|
||||
// 9. Admin custom shortlinks manager
|
||||
mux.HandleFunc("GET /admin/shortener", s.requireAuth(s.handleAdminShortener))
|
||||
mux.HandleFunc("POST /admin/shortener/new", s.requireAuth(s.requireCSRF(s.handleLinkCreate)))
|
||||
mux.HandleFunc("POST /admin/shortener/edit/{id}", s.requireAuth(s.requireCSRF(s.handleLinkSave)))
|
||||
mux.HandleFunc("POST /admin/shortener/delete/{id}", s.requireAuth(s.requireCSRF(s.handleLinkDelete)))
|
||||
mux.HandleFunc("POST /admin/shortener/delete/{id}", s.requireAuth(s.requireCSRF(s.handleLinkRemove)))
|
||||
mux.HandleFunc("POST /admin/shortener/remove/{id}", s.requireAuth(s.requireCSRF(s.handleLinkRemove)))
|
||||
mux.HandleFunc("POST /admin/shortener/archive/{id}", s.requireAuth(s.requireCSRF(s.handleLinkArchive)))
|
||||
mux.HandleFunc("POST /admin/shortener/restore/{id}", s.requireAuth(s.requireCSRF(s.handleLinkRestore)))
|
||||
mux.HandleFunc("POST /admin/shortener/permanent-delete/{id}", s.requireAuth(s.requireCSRF(s.handleLinkPermanentDelete)))
|
||||
mux.HandleFunc("POST /admin/shortener/slug-length", s.requireAuth(s.requireCSRF(s.handleSlugLengthUpdate)))
|
||||
|
||||
// 10. QR & Labels
|
||||
mux.HandleFunc("GET /admin/qr/{slug}", s.requireAuth(s.handleQR))
|
||||
|
||||
@@ -587,3 +587,106 @@ body {
|
||||
margin-top: 4px !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
Solis Lifecycle Styles (Archive, Soft-Remove & Premium Dropdowns)
|
||||
========================================================================== */
|
||||
|
||||
/* Actions Dropdown Container */
|
||||
.actions-dropdown {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
/* Actions Menu Popup */
|
||||
.actions-dropdown-menu {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 100%;
|
||||
margin-top: 0.35rem;
|
||||
background-color: var(--color-bg-surface);
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: var(--radius-sm);
|
||||
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
|
||||
z-index: 999;
|
||||
min-width: 160px;
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
padding: 0.35rem 0;
|
||||
animation: dropdownFadeIn 0.15s cubic-bezier(0.16, 1, 0.3, 1);
|
||||
}
|
||||
|
||||
@keyframes dropdownFadeIn {
|
||||
from { opacity: 0; transform: translateY(-4px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
}
|
||||
|
||||
/* Toggle Menu Display */
|
||||
.actions-dropdown.show .actions-dropdown-menu {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
/* Menu Items (Forms & Buttons) */
|
||||
.actions-dropdown-item {
|
||||
background: none;
|
||||
border: none;
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
padding: 0.6rem 1rem;
|
||||
font-size: 0.85rem;
|
||||
font-weight: 500;
|
||||
color: var(--color-text-main);
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
transition: background-color 0.15s ease, color 0.15s ease;
|
||||
text-decoration: none;
|
||||
font-family: var(--font-sans);
|
||||
}
|
||||
|
||||
.actions-dropdown-item:hover {
|
||||
background-color: var(--color-bg-base);
|
||||
color: var(--color-brand-primary);
|
||||
}
|
||||
|
||||
/* Muted / Red text variations for drop options */
|
||||
.actions-dropdown-item.text-danger {
|
||||
color: #b91c1c;
|
||||
}
|
||||
.actions-dropdown-item.text-danger:hover {
|
||||
background-color: #fee2e2;
|
||||
color: #991b1b;
|
||||
}
|
||||
|
||||
.actions-dropdown-item.text-warning {
|
||||
color: #b45309;
|
||||
}
|
||||
.actions-dropdown-item.text-warning:hover {
|
||||
background-color: #fef3c7;
|
||||
color: #92400e;
|
||||
}
|
||||
|
||||
/* Visual States for Soft Removed Elements */
|
||||
tr.lifecycle-removed {
|
||||
opacity: 0.65;
|
||||
background-color: var(--color-bg-base) !important;
|
||||
}
|
||||
|
||||
tr.lifecycle-removed td:not(.actions-cell) {
|
||||
text-decoration: line-through;
|
||||
color: var(--color-text-light);
|
||||
}
|
||||
|
||||
/* Visual States for Archived Elements */
|
||||
tr.lifecycle-archived {
|
||||
background-color: #fcfbfb;
|
||||
}
|
||||
|
||||
.status-pill.archived {
|
||||
background-color: var(--color-bg-base);
|
||||
color: var(--color-text-muted);
|
||||
border: 1px solid var(--color-border);
|
||||
}
|
||||
|
||||
@@ -96,3 +96,30 @@ function initRoomTagLock() {
|
||||
// Run immediately on page load to lock the default/current room tag
|
||||
updateRoomTag();
|
||||
}
|
||||
|
||||
// 4. Dropdown Action Menu Manager
|
||||
function toggleActionsDropdown(btn, event) {
|
||||
if (event) {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
}
|
||||
const container = btn.parentElement;
|
||||
const isShown = container.classList.contains("show");
|
||||
|
||||
// Close any other open dropdowns first
|
||||
document.querySelectorAll(".actions-dropdown").forEach(d => {
|
||||
d.classList.remove("show");
|
||||
});
|
||||
|
||||
if (!isShown) {
|
||||
container.classList.add("show");
|
||||
}
|
||||
}
|
||||
|
||||
// Close dropdowns on outside click
|
||||
document.addEventListener("click", () => {
|
||||
document.querySelectorAll(".actions-dropdown").forEach(d => {
|
||||
d.classList.remove("show");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -100,5 +100,42 @@
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
|
||||
<!-- QR Code Preview Modal -->
|
||||
<div id="qr-modal-overlay" style="display:none; position:fixed; inset:0; z-index:9999; background:rgba(0,0,0,0.55); backdrop-filter:blur(4px); justify-content:center; align-items:center;">
|
||||
<div id="qr-modal-card" style="background:var(--color-bg-surface, #fff); border-radius:16px; padding:2.5rem 2rem 2rem; max-width:380px; width:90%; box-shadow:0 24px 48px -12px rgba(0,0,0,0.25); display:flex; flex-direction:column; align-items:center; gap:1.25rem; position:relative; animation:qrModalIn 0.25s cubic-bezier(0.16,1,0.3,1);">
|
||||
<button onclick="closeQRModal()" style="position:absolute; top:0.75rem; right:0.75rem; background:none; border:none; font-size:1.5rem; cursor:pointer; color:var(--color-text-light); line-height:1;" aria-label="Close">×</button>
|
||||
<h3 style="font-weight:700; font-size:1.15rem; color:var(--color-text-main); margin:0;">QR Code Preview</h3>
|
||||
<img id="qr-modal-image" src="" alt="QR Code" style="width:220px; height:220px; border:1px solid var(--color-border); border-radius:8px; background:#fff; padding:8px;">
|
||||
<code id="qr-modal-link" style="font-family:monospace; background:var(--color-bg-base, #f5f5f5); padding:0.4rem 0.85rem; border-radius:6px; border:1px solid var(--color-border); font-weight:600; font-size:0.95rem; word-break:break-all; text-align:center;"></code>
|
||||
<a id="qr-modal-download" download="" href="" class="btn btn-primary" style="width:100%; font-size:0.9rem; text-align:center;">Download QR Image</a>
|
||||
</div>
|
||||
</div>
|
||||
<style>
|
||||
@keyframes qrModalIn {
|
||||
from { opacity:0; transform:scale(0.92) translateY(12px); }
|
||||
to { opacity:1; transform:scale(1) translateY(0); }
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
function openQRModal(slug, name) {
|
||||
var overlay = document.getElementById('qr-modal-overlay');
|
||||
document.getElementById('qr-modal-image').src = '/admin/qr/' + slug;
|
||||
document.getElementById('qr-modal-link').textContent = '/s/' + slug;
|
||||
var dl = document.getElementById('qr-modal-download');
|
||||
dl.href = '/admin/qr/' + slug;
|
||||
dl.download = (name || slug) + '_QR.png';
|
||||
overlay.style.display = 'flex';
|
||||
}
|
||||
function closeQRModal() {
|
||||
document.getElementById('qr-modal-overlay').style.display = 'none';
|
||||
}
|
||||
document.addEventListener('click', function(e) {
|
||||
if (e.target && e.target.id === 'qr-modal-overlay') closeQRModal();
|
||||
});
|
||||
document.addEventListener('keydown', function(e) {
|
||||
if (e.key === 'Escape') closeQRModal();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -943,12 +943,18 @@
|
||||
{{end}}
|
||||
</select>
|
||||
|
||||
<label style="display: flex; align-items: center; gap: 0.35rem; font-size: 0.9rem; font-weight: 500; cursor: pointer; white-space: nowrap; margin: 0 0.5rem;">
|
||||
<input type="checkbox" name="show_removed" value="1" {{if .ShowRemoved}}checked{{end}} onchange="this.form.submit()">
|
||||
Show removed
|
||||
</label>
|
||||
|
||||
<button type="submit" class="btn btn-secondary">Filter</button>
|
||||
{{if or .SearchQuery (or .SelectedStatus .SelectedLocation)}}
|
||||
{{if or .SearchQuery (or .SelectedStatus (or .SelectedLocation .ShowRemoved))}}
|
||||
<a href="/admin" class="btn btn-secondary" style="padding: 0.625rem;">Reset</a>
|
||||
{{end}}
|
||||
</form>
|
||||
|
||||
|
||||
<!-- Assets Inventory Table -->
|
||||
<div class="card" style="padding: 0;">
|
||||
<div class="data-table-wrapper">
|
||||
@@ -967,11 +973,11 @@
|
||||
<tbody>
|
||||
{{if .Items}}
|
||||
{{range .Items}}
|
||||
<tr>
|
||||
<tr class="{{if eq .LifecycleState "removed"}}lifecycle-removed{{else if eq .LifecycleState "archived"}}lifecycle-archived{{end}}">
|
||||
<td style="text-align: center; vertical-align: middle;">
|
||||
{{if .ShortSlug}}
|
||||
<a href="/admin/qr/{{.ShortSlug}}" target="_blank">
|
||||
<img src="/admin/qr/{{.ShortSlug}}" alt="QR Label" style="width: 42px; height: 42px; border: 1px solid var(--color-border); padding: 1px; border-radius: 4px; background: white;">
|
||||
<a href="javascript:void(0)" onclick="openQRModal('{{.ShortSlug}}', '{{.Name}}')">
|
||||
<img src="/admin/qr/{{.ShortSlug}}" alt="QR Label" style="width: 42px; height: 42px; border: 1px solid var(--color-border); padding: 1px; border-radius: 4px; background: white; cursor: pointer;">
|
||||
</a>
|
||||
{{else}}
|
||||
<span style="color: var(--color-text-light); font-size: 0.75rem;">--</span>
|
||||
@@ -997,9 +1003,13 @@
|
||||
{{end}}
|
||||
</td>
|
||||
<td>
|
||||
<span class="status-pill {{if eq .Status "In Use"}}in-use{{else if eq .Status "In Storage"}}in-storage{{else if eq .Status "Borrowed"}}borrowed{{else if eq .Status "Lost"}}lost{{else}}disposed{{end}}">
|
||||
{{.Status}}
|
||||
</span>
|
||||
{{if eq .LifecycleState "archived"}}
|
||||
<span class="status-pill archived">Archived</span>
|
||||
{{else}}
|
||||
<span class="status-pill {{if eq .Status "In Use"}}in-use{{else if eq .Status "In Storage"}}in-storage{{else if eq .Status "Borrowed"}}borrowed{{else if eq .Status "Lost"}}lost{{else}}disposed{{end}}">
|
||||
{{.Status}}
|
||||
</span>
|
||||
{{end}}
|
||||
</td>
|
||||
<td style="font-weight: 600; font-size: 0.95rem; color: var(--color-text-muted); text-align: center;">
|
||||
{{.Quantity}}
|
||||
@@ -1011,20 +1021,56 @@
|
||||
{{end}}
|
||||
</div>
|
||||
</td>
|
||||
<td style="text-align: right;">
|
||||
<td class="actions-cell" style="text-align: right;">
|
||||
<div style="display: inline-flex; gap: 0.5rem; align-items: center;">
|
||||
<a href="/admin?view={{.ID}}" class="btn btn-secondary" style="padding: 0.35rem 0.65rem; font-size: 0.8rem;">
|
||||
Details
|
||||
</a>
|
||||
<a href="/admin/items/edit/{{.ID}}" class="btn btn-secondary" style="padding: 0.35rem 0.65rem; font-size: 0.8rem;">
|
||||
Edit
|
||||
</a>
|
||||
<form action="/admin/items/delete/{{.ID}}" method="POST" onsubmit="return confirm('Are you sure you want to delete this asset? This cannot be undone.')" style="margin: 0;">
|
||||
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
||||
<button type="submit" class="btn btn-danger" style="padding: 0.35rem 0.65rem; font-size: 0.8rem;">
|
||||
Delete
|
||||
</button>
|
||||
</form>
|
||||
{{if eq .LifecycleState "removed"}}
|
||||
<!-- Soft removed item actions -->
|
||||
<form action="/admin/items/restore/{{.ID}}" method="POST" style="margin: 0;">
|
||||
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
||||
<button type="submit" class="btn btn-secondary" style="padding: 0.35rem 0.65rem; font-size: 0.8rem; border-color: #10b981; color: #10b981;">
|
||||
Restore
|
||||
</button>
|
||||
</form>
|
||||
<form action="/admin/items/permanent-delete/{{.ID}}" method="POST" onsubmit="return confirm('Are you sure you want to permanently delete this asset? This will clean up all associated media files on disk and cannot be undone.')" style="margin: 0;">
|
||||
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
||||
<button type="submit" class="btn btn-danger" style="padding: 0.35rem 0.65rem; font-size: 0.8rem;">
|
||||
Delete Forever
|
||||
</button>
|
||||
</form>
|
||||
{{else}}
|
||||
<!-- Active or Archived item actions -->
|
||||
<a href="/admin?view={{.ID}}" class="btn btn-secondary" style="padding: 0.35rem 0.65rem; font-size: 0.8rem;">
|
||||
Details
|
||||
</a>
|
||||
|
||||
{{if ne .LifecycleState "archived"}}
|
||||
<a href="/admin/items/edit/{{.ID}}" class="btn btn-secondary" style="padding: 0.35rem 0.65rem; font-size: 0.8rem;">
|
||||
Edit
|
||||
</a>
|
||||
{{end}}
|
||||
|
||||
<div class="actions-dropdown">
|
||||
<button class="btn btn-danger" onclick="toggleActionsDropdown(this, event)" style="padding: 0.35rem 0.65rem; font-size: 0.8rem; display: inline-flex; align-items: center; gap: 0.25rem;">
|
||||
Delete <span style="font-size: 0.65rem;">▼</span>
|
||||
</button>
|
||||
<div class="actions-dropdown-menu">
|
||||
<form action="/admin/items/remove/{{.ID}}" method="POST" style="margin: 0;">
|
||||
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
||||
<button type="submit" class="actions-dropdown-item text-danger">
|
||||
🗑 Remove Item
|
||||
</button>
|
||||
</form>
|
||||
{{if ne .LifecycleState "archived"}}
|
||||
<form action="/admin/items/archive/{{.ID}}" method="POST" style="margin: 0;">
|
||||
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
||||
<button type="submit" class="actions-dropdown-item text-warning">
|
||||
📦 Archive Item
|
||||
</button>
|
||||
</form>
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -8,6 +8,17 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form action="/admin/locations" method="GET" class="filter-bar" style="margin-bottom: 1.5rem; justify-content: flex-end;">
|
||||
{{if .EditingLocation}}
|
||||
<input type="hidden" name="edit" value="{{.EditingLocation.ID}}">
|
||||
{{end}}
|
||||
<label style="display: flex; align-items: center; gap: 0.35rem; font-size: 0.9rem; font-weight: 500; cursor: pointer; white-space: nowrap;">
|
||||
<input type="checkbox" name="show_removed" value="1" {{if .ShowRemoved}}checked{{end}} onchange="this.form.submit()">
|
||||
Show removed locations
|
||||
</label>
|
||||
</form>
|
||||
|
||||
|
||||
<div class="detail-grid">
|
||||
<!-- Left Column: Locations List -->
|
||||
<div class="detail-main">
|
||||
@@ -25,8 +36,13 @@
|
||||
<tbody>
|
||||
{{if .Locations}}
|
||||
{{range .Locations}}
|
||||
<tr>
|
||||
<td style="font-weight: 600; color: var(--color-brand-primary);">{{.Name}}</td>
|
||||
<tr class="{{if eq .LifecycleState "removed"}}lifecycle-removed{{else if eq .LifecycleState "archived"}}lifecycle-archived{{end}}">
|
||||
<td style="font-weight: 600; color: var(--color-brand-primary);">
|
||||
{{.Name}}
|
||||
{{if eq .LifecycleState "archived"}}
|
||||
<span class="status-pill archived" style="margin-left: 0.5rem; font-size: 0.7rem; padding: 0.1rem 0.4rem;">Archived</span>
|
||||
{{end}}
|
||||
</td>
|
||||
<td>
|
||||
{{if .ParentName.Valid}}
|
||||
<span style="color: var(--color-text-muted); font-size: 0.9rem;">
|
||||
@@ -37,21 +53,53 @@
|
||||
{{end}}
|
||||
</td>
|
||||
<td style="color: var(--color-text-muted); font-size: 0.9rem;">{{.Description}}</td>
|
||||
<td style="text-align: right;">
|
||||
<div style="display: inline-flex; gap: 0.5rem;">
|
||||
<!-- Edit Location triggers loading edit state in the right-side form -->
|
||||
<a href="/admin/locations?edit={{.ID}}" class="btn btn-secondary" style="padding: 0.35rem 0.65rem; font-size: 0.8rem;">
|
||||
Edit
|
||||
</a>
|
||||
{{if ne .ID 1}}
|
||||
<form action="/admin/locations/delete/{{.ID}}" method="POST" onsubmit="return confirm('Are you sure you want to delete this location? Sub-locations and assets will be detached.')" style="margin: 0;">
|
||||
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
||||
<button type="submit" class="btn btn-danger" style="padding: 0.35rem 0.65rem; font-size: 0.8rem;">
|
||||
Delete
|
||||
</button>
|
||||
</form>
|
||||
{{else}}
|
||||
<td class="actions-cell" style="text-align: right;">
|
||||
<div style="display: inline-flex; gap: 0.5rem; align-items: center;">
|
||||
{{if eq .ID 1}}
|
||||
<span style="color: var(--color-text-light); font-size: 0.8rem; font-style: italic; padding: 0.35rem 0.65rem;">Locked</span>
|
||||
{{else if eq .LifecycleState "removed"}}
|
||||
<!-- Soft removed actions -->
|
||||
<form action="/admin/locations/restore/{{.ID}}" method="POST" style="margin: 0;">
|
||||
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
||||
<button type="submit" class="btn btn-secondary" style="padding: 0.35rem 0.65rem; font-size: 0.8rem; border-color: #10b981; color: #10b981;">
|
||||
Restore
|
||||
</button>
|
||||
</form>
|
||||
<form action="/admin/locations/permanent-delete/{{.ID}}" method="POST" onsubmit="return confirm('Are you sure you want to permanently delete this location? Associated sub-locations and assets will be detached.')" style="margin: 0;">
|
||||
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
||||
<button type="submit" class="btn btn-danger" style="padding: 0.35rem 0.65rem; font-size: 0.8rem;">
|
||||
Delete Forever
|
||||
</button>
|
||||
</form>
|
||||
{{else}}
|
||||
<!-- Active / Archived actions -->
|
||||
{{if ne .LifecycleState "archived"}}
|
||||
<a href="/admin/locations?edit={{.ID}}&show_removed={{if $.ShowRemoved}}1{{else}}0{{end}}" class="btn btn-secondary" style="padding: 0.35rem 0.65rem; font-size: 0.8rem;">
|
||||
Edit
|
||||
</a>
|
||||
{{end}}
|
||||
|
||||
<div class="actions-dropdown">
|
||||
<button class="btn btn-danger" onclick="toggleActionsDropdown(this, event)" style="padding: 0.35rem 0.65rem; font-size: 0.8rem; display: inline-flex; align-items: center; gap: 0.25rem;">
|
||||
Delete <span style="font-size: 0.65rem;">▼</span>
|
||||
</button>
|
||||
<div class="actions-dropdown-menu">
|
||||
<form action="/admin/locations/remove/{{.ID}}" method="POST" style="margin: 0;">
|
||||
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
||||
<button type="submit" class="actions-dropdown-item text-danger">
|
||||
🗑 Remove
|
||||
</button>
|
||||
</form>
|
||||
{{if ne .LifecycleState "archived"}}
|
||||
<form action="/admin/locations/archive/{{.ID}}" method="POST" style="margin: 0;">
|
||||
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
||||
<button type="submit" class="actions-dropdown-item text-warning">
|
||||
📦 Archive
|
||||
</button>
|
||||
</form>
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
</td>
|
||||
|
||||
@@ -7,6 +7,15 @@
|
||||
<p>Manage custom manual redirects (e.g. warranties, external manuals) or review auto-generated asset short URLs.</p>
|
||||
</div>
|
||||
</div>
|
||||
<form action="/admin/shortener" method="GET" class="filter-bar" style="margin-bottom: 1.5rem; justify-content: flex-end;">
|
||||
{{if .EditingLink}}
|
||||
<input type="hidden" name="edit" value="{{.EditingLink.ID}}">
|
||||
{{end}}
|
||||
<label style="display: flex; align-items: center; gap: 0.35rem; font-size: 0.9rem; font-weight: 500; cursor: pointer; white-space: nowrap;">
|
||||
<input type="checkbox" name="show_removed" value="1" {{if .ShowRemoved}}checked{{end}} onchange="this.form.submit()">
|
||||
Show removed links
|
||||
</label>
|
||||
</form>
|
||||
|
||||
<div class="detail-grid">
|
||||
<!-- Left Column: Links List -->
|
||||
@@ -26,14 +35,19 @@
|
||||
<tbody>
|
||||
{{if .Links}}
|
||||
{{range .Links}}
|
||||
<tr>
|
||||
<tr class="{{if eq .LifecycleState "removed"}}lifecycle-removed{{else if eq .LifecycleState "archived"}}lifecycle-archived{{end}}">
|
||||
<td>
|
||||
<div style="display: flex; flex-direction: column; gap: 0.15rem;">
|
||||
<a href="/s/{{.Slug}}" target="_blank" style="font-weight: 700; color: var(--color-brand-primary); text-decoration: none;">
|
||||
/s/{{.Slug}}
|
||||
</a>
|
||||
<div style="display: flex; align-items: center; gap: 0.35rem;">
|
||||
<a href="/s/{{.Slug}}" target="_blank" style="font-weight: 700; color: var(--color-brand-primary); text-decoration: none;">
|
||||
/s/{{.Slug}}
|
||||
</a>
|
||||
{{if eq .LifecycleState "archived"}}
|
||||
<span class="status-pill archived" style="font-size: 0.7rem; padding: 0.1rem 0.4rem;">Archived</span>
|
||||
{{end}}
|
||||
</div>
|
||||
<!-- QR code link quick view in printer sheet -->
|
||||
<a href="/admin/qr/{{.Slug}}" target="_blank" style="font-size: 0.75rem; color: var(--color-text-light); text-decoration: underline;">
|
||||
<a href="javascript:void(0)" onclick="openQRModal('{{.Slug}}', '{{.Slug}}')" style="font-size: 0.75rem; color: var(--color-text-light); text-decoration: underline; cursor: pointer;">
|
||||
View QR Code
|
||||
</a>
|
||||
</div>
|
||||
@@ -57,21 +71,56 @@
|
||||
<td style="text-align: center; font-weight: 600; font-size: 0.95rem; color: var(--color-text-muted);">
|
||||
{{.Clicks}}
|
||||
</td>
|
||||
<td style="text-align: right;">
|
||||
<td class="actions-cell" style="text-align: right;">
|
||||
{{if .ItemID.Valid}}
|
||||
<!-- Asset link modifications are handled through items CRUD -->
|
||||
<span style="color: var(--color-text-light); font-size: 0.85rem; font-style: italic;">Managed by Asset</span>
|
||||
{{else}}
|
||||
<div style="display: inline-flex; gap: 0.5rem;">
|
||||
<a href="/admin/shortener?edit={{.ID}}" class="btn btn-secondary" style="padding: 0.35rem 0.65rem; font-size: 0.8rem;">
|
||||
Edit
|
||||
</a>
|
||||
<form action="/admin/shortener/delete/{{.ID}}" method="POST" onsubmit="return confirm('Are you sure you want to delete this custom redirect?')" style="margin: 0;">
|
||||
{{else if eq .LifecycleState "removed"}}
|
||||
<!-- Soft removed manual redirects -->
|
||||
<div style="display: inline-flex; gap: 0.5rem; align-items: center;">
|
||||
<form action="/admin/shortener/restore/{{.ID}}" method="POST" style="margin: 0;">
|
||||
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
||||
<button type="submit" class="btn btn-danger" style="padding: 0.35rem 0.65rem; font-size: 0.8rem;">
|
||||
Delete
|
||||
<button type="submit" class="btn btn-secondary" style="padding: 0.35rem 0.65rem; font-size: 0.8rem; border-color: #10b981; color: #10b981;">
|
||||
Restore
|
||||
</button>
|
||||
</form>
|
||||
<form action="/admin/shortener/permanent-delete/{{.ID}}" method="POST" onsubmit="return confirm('Are you sure you want to permanently delete this redirect? This action cannot be undone.')" style="margin: 0;">
|
||||
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
||||
<button type="submit" class="btn btn-danger" style="padding: 0.35rem 0.65rem; font-size: 0.8rem;">
|
||||
Delete Forever
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
{{else}}
|
||||
<!-- Active / Archived manual redirects -->
|
||||
<div style="display: inline-flex; gap: 0.5rem; align-items: center;">
|
||||
{{if ne .LifecycleState "archived"}}
|
||||
<a href="/admin/shortener?edit={{.ID}}&show_removed={{if $.ShowRemoved}}1{{else}}0{{end}}" class="btn btn-secondary" style="padding: 0.35rem 0.65rem; font-size: 0.8rem;">
|
||||
Edit
|
||||
</a>
|
||||
{{end}}
|
||||
|
||||
<div class="actions-dropdown">
|
||||
<button class="btn btn-danger" onclick="toggleActionsDropdown(this, event)" style="padding: 0.35rem 0.65rem; font-size: 0.8rem; display: inline-flex; align-items: center; gap: 0.25rem;">
|
||||
Delete <span style="font-size: 0.65rem;">▼</span>
|
||||
</button>
|
||||
<div class="actions-dropdown-menu">
|
||||
<form action="/admin/shortener/remove/{{.ID}}" method="POST" style="margin: 0;">
|
||||
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
||||
<button type="submit" class="actions-dropdown-item text-danger">
|
||||
🗑 Remove
|
||||
</button>
|
||||
</form>
|
||||
{{if ne .LifecycleState "archived"}}
|
||||
<form action="/admin/shortener/archive/{{.ID}}" method="POST" style="margin: 0;">
|
||||
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
||||
<button type="submit" class="actions-dropdown-item text-warning">
|
||||
📦 Archive
|
||||
</button>
|
||||
</form>
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
</td>
|
||||
@@ -138,6 +187,20 @@
|
||||
</form>
|
||||
{{end}}
|
||||
</div>
|
||||
|
||||
<!-- Slug Length Settings -->
|
||||
<div class="card" style="margin-top: 1rem;">
|
||||
<h3 style="font-weight: 700; margin-bottom: 0.5rem; font-size: 1rem;">URL Slug Length</h3>
|
||||
<p style="font-size: 0.8rem; color: var(--color-text-light); margin-bottom: 1rem;">Controls the character length of auto-generated short URL slugs. Shorter slugs make smaller QR codes. Changes apply to newly created assets only.</p>
|
||||
<form action="/admin/shortener/slug-length" method="POST">
|
||||
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
||||
<div style="display: flex; gap: 0.5rem; align-items: center;">
|
||||
<input type="number" name="slug_length" class="form-control" value="{{.SlugLength}}" min="3" max="16" style="width: 80px; text-align: center; font-weight: 700; font-size: 1.1rem;">
|
||||
<span style="font-size: 0.85rem; color: var(--color-text-muted);">characters</span>
|
||||
<button type="submit" class="btn btn-primary" style="margin-left: auto; padding: 0.5rem 1rem; font-size: 0.85rem;">Save</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
@@ -7,6 +7,15 @@
|
||||
<p>Label and categorize assets to easily group similar items together (e.g. Tools, Electronics, Fragile)</p>
|
||||
</div>
|
||||
</div>
|
||||
<form action="/admin/tags" method="GET" class="filter-bar" style="margin-bottom: 1.5rem; justify-content: flex-end;">
|
||||
{{if .EditingTag}}
|
||||
<input type="hidden" name="edit" value="{{.EditingTag.ID}}">
|
||||
{{end}}
|
||||
<label style="display: flex; align-items: center; gap: 0.35rem; font-size: 0.9rem; font-weight: 500; cursor: pointer; white-space: nowrap;">
|
||||
<input type="checkbox" name="show_removed" value="1" {{if .ShowRemoved}}checked{{end}} onchange="this.form.submit()">
|
||||
Show removed tags
|
||||
</label>
|
||||
</form>
|
||||
|
||||
<div class="detail-grid">
|
||||
<!-- Left Column: Tags List -->
|
||||
@@ -25,11 +34,14 @@
|
||||
<tbody>
|
||||
{{if .Tags}}
|
||||
{{range .Tags}}
|
||||
<tr>
|
||||
<tr class="{{if eq .LifecycleState "removed"}}lifecycle-removed{{else if eq .LifecycleState "archived"}}lifecycle-archived{{end}}">
|
||||
<td>
|
||||
<span class="tag-pill" style="background-color: {{.Color}}; color: #1c1917; padding: 0.35rem 0.75rem; font-size: 0.85rem;">
|
||||
{{.Name}}
|
||||
</span>
|
||||
{{if eq .LifecycleState "archived"}}
|
||||
<span class="status-pill archived" style="margin-left: 0.5rem; font-size: 0.7rem; padding: 0.1rem 0.4rem;">Archived</span>
|
||||
{{end}}
|
||||
</td>
|
||||
<td>
|
||||
<code style="font-family: monospace; font-size: 0.9rem; background-color: var(--color-bg-base); padding: 0.15rem 0.35rem; border-radius: 4px; border: 1px solid var(--color-border);">
|
||||
@@ -37,20 +49,53 @@
|
||||
</code>
|
||||
</td>
|
||||
<td style="color: var(--color-text-muted); font-size: 0.9rem;">{{.Description}}</td>
|
||||
<td style="text-align: right;">
|
||||
<div style="display: inline-flex; gap: 0.5rem;">
|
||||
<a href="/admin/tags?edit={{.ID}}" class="btn btn-secondary" style="padding: 0.35rem 0.65rem; font-size: 0.8rem;">
|
||||
Edit
|
||||
</a>
|
||||
{{if ne .Name "Default Room"}}
|
||||
<form action="/admin/tags/delete/{{.ID}}" method="POST" onsubmit="return confirm('Are you sure you want to delete this tag? All associated items will lose this tag reference.')" style="margin: 0;">
|
||||
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
||||
<button type="submit" class="btn btn-danger" style="padding: 0.35rem 0.65rem; font-size: 0.8rem;">
|
||||
Delete
|
||||
</button>
|
||||
</form>
|
||||
{{else}}
|
||||
<td class="actions-cell" style="text-align: right;">
|
||||
<div style="display: inline-flex; gap: 0.5rem; align-items: center;">
|
||||
{{if eq .Name "Default Room"}}
|
||||
<span style="color: var(--color-text-light); font-size: 0.8rem; font-style: italic; padding: 0.35rem 0.65rem;">Locked</span>
|
||||
{{else if eq .LifecycleState "removed"}}
|
||||
<!-- Soft removed actions -->
|
||||
<form action="/admin/tags/restore/{{.ID}}" method="POST" style="margin: 0;">
|
||||
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
||||
<button type="submit" class="btn btn-secondary" style="padding: 0.35rem 0.65rem; font-size: 0.8rem; border-color: #10b981; color: #10b981;">
|
||||
Restore
|
||||
</button>
|
||||
</form>
|
||||
<form action="/admin/tags/permanent-delete/{{.ID}}" method="POST" onsubmit="return confirm('Are you sure you want to permanently delete this tag? All associated items will lose this tag reference.')" style="margin: 0;">
|
||||
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
||||
<button type="submit" class="btn btn-danger" style="padding: 0.35rem 0.65rem; font-size: 0.8rem;">
|
||||
Delete Forever
|
||||
</button>
|
||||
</form>
|
||||
{{else}}
|
||||
<!-- Active / Archived actions -->
|
||||
{{if ne .LifecycleState "archived"}}
|
||||
<a href="/admin/tags?edit={{.ID}}&show_removed={{if $.ShowRemoved}}1{{else}}0{{end}}" class="btn btn-secondary" style="padding: 0.35rem 0.65rem; font-size: 0.8rem;">
|
||||
Edit
|
||||
</a>
|
||||
{{end}}
|
||||
|
||||
<div class="actions-dropdown">
|
||||
<button class="btn btn-danger" onclick="toggleActionsDropdown(this, event)" style="padding: 0.35rem 0.65rem; font-size: 0.8rem; display: inline-flex; align-items: center; gap: 0.25rem;">
|
||||
Delete <span style="font-size: 0.65rem;">▼</span>
|
||||
</button>
|
||||
<div class="actions-dropdown-menu">
|
||||
<form action="/admin/tags/remove/{{.ID}}" method="POST" style="margin: 0;">
|
||||
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
||||
<button type="submit" class="actions-dropdown-item text-danger">
|
||||
🗑 Remove
|
||||
</button>
|
||||
</form>
|
||||
{{if ne .LifecycleState "archived"}}
|
||||
<form action="/admin/tags/archive/{{.ID}}" method="POST" style="margin: 0;">
|
||||
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
||||
<button type="submit" class="actions-dropdown-item text-warning">
|
||||
📦 Archive
|
||||
</button>
|
||||
</form>
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
</td>
|
||||
|
||||
Reference in new issue
Block a user