|
| 1 | +// internal/web/templates/list_table_v2.templ — full-width "Table" |
| 2 | +// view for /users, /groups, /computers. Companion to UsersListV2 / |
| 3 | +// GroupsListV2 / ComputersListV2 (List view) and GraphPageV2 (Graph |
| 4 | +// view). The third option in the segmented toggle. |
| 5 | +// |
| 6 | +// Goal: scan many rows fast. No filter rail, no drawer. Each row links |
| 7 | +// directly to the entity's detail page — clicking goes "all the way", |
| 8 | +// not into a side pane. |
| 9 | +package templates |
| 10 | + |
| 11 | +import ( |
| 12 | + "fmt" |
| 13 | + |
| 14 | + ldap "github.com/netresearch/simple-ldap-go" |
| 15 | +) |
| 16 | + |
| 17 | +// UsersListTableV2 renders the full-width users table. |
| 18 | +templ UsersListTableV2(users []ldap.User, currentView string, flashes []Flash, palettePinned []PinnedEntry) { |
| 19 | + @baseV2PageScroll("Users — Table") { |
| 20 | + @topnavV2("/users") |
| 21 | + <main id="main-content" class="list-table-page"> |
| 22 | + <header class="list-page__head"> |
| 23 | + <div class="list-page__head-titles"> |
| 24 | + <h1 class="list-page__title">Users</h1> |
| 25 | + <p class="list-page__count">{ fmt.Sprintf("%d users", len(users)) }</p> |
| 26 | + </div> |
| 27 | + <div class="list-page__head-controls"> |
| 28 | + @listGraphToggle("/users", currentView, "") |
| 29 | + </div> |
| 30 | + </header> |
| 31 | + @listFlashes(flashes) |
| 32 | + <table class="list-table"> |
| 33 | + <thead> |
| 34 | + <tr> |
| 35 | + <th scope="col">CN</th> |
| 36 | + <th scope="col">SAM account</th> |
| 37 | + <th scope="col">Mail</th> |
| 38 | + <th scope="col">Status</th> |
| 39 | + </tr> |
| 40 | + </thead> |
| 41 | + <tbody> |
| 42 | + for _, u := range users { |
| 43 | + <tr> |
| 44 | + <td><a class="list-table__link" href={ userDetailHref(u) }>{ u.CN() }</a></td> |
| 45 | + <td>{ u.SAMAccountName }</td> |
| 46 | + <td>{ derefString(u.Mail) }</td> |
| 47 | + <td>{ userStatusLabel(u) }</td> |
| 48 | + </tr> |
| 49 | + } |
| 50 | + </tbody> |
| 51 | + </table> |
| 52 | + @paletteV2WithPinned(palettePinned) |
| 53 | + </main> |
| 54 | + } |
| 55 | +} |
| 56 | + |
| 57 | +// GroupsListTableV2 renders the full-width groups table. |
| 58 | +templ GroupsListTableV2(groups []ldap.Group, currentView string, flashes []Flash, palettePinned []PinnedEntry) { |
| 59 | + @baseV2PageScroll("Groups — Table") { |
| 60 | + @topnavV2("/groups") |
| 61 | + <main id="main-content" class="list-table-page"> |
| 62 | + <header class="list-page__head"> |
| 63 | + <div class="list-page__head-titles"> |
| 64 | + <h1 class="list-page__title">Groups</h1> |
| 65 | + <p class="list-page__count">{ fmt.Sprintf("%d groups", len(groups)) }</p> |
| 66 | + </div> |
| 67 | + <div class="list-page__head-controls"> |
| 68 | + @listGraphToggle("/groups", currentView, "") |
| 69 | + </div> |
| 70 | + </header> |
| 71 | + @listFlashes(flashes) |
| 72 | + <table class="list-table"> |
| 73 | + <thead> |
| 74 | + <tr> |
| 75 | + <th scope="col">CN</th> |
| 76 | + <th scope="col">Members</th> |
| 77 | + <th scope="col">DN</th> |
| 78 | + </tr> |
| 79 | + </thead> |
| 80 | + <tbody> |
| 81 | + for _, g := range groups { |
| 82 | + <tr> |
| 83 | + <td><a class="list-table__link" href={ groupDetailHref(g) }>{ g.CN() }</a></td> |
| 84 | + <td class="list-table__num">{ fmt.Sprintf("%d", len(g.Members)) }</td> |
| 85 | + <td class="list-table__dn">{ g.DN() }</td> |
| 86 | + </tr> |
| 87 | + } |
| 88 | + </tbody> |
| 89 | + </table> |
| 90 | + @paletteV2WithPinned(palettePinned) |
| 91 | + </main> |
| 92 | + } |
| 93 | +} |
| 94 | + |
| 95 | +// ComputersListTableV2 renders the full-width computers table. |
| 96 | +templ ComputersListTableV2(computers []ldap.Computer, currentView string, flashes []Flash, palettePinned []PinnedEntry) { |
| 97 | + @baseV2PageScroll("Computers — Table") { |
| 98 | + @topnavV2("/computers") |
| 99 | + <main id="main-content" class="list-table-page"> |
| 100 | + <header class="list-page__head"> |
| 101 | + <div class="list-page__head-titles"> |
| 102 | + <h1 class="list-page__title">Computers</h1> |
| 103 | + <p class="list-page__count">{ fmt.Sprintf("%d computers", len(computers)) }</p> |
| 104 | + </div> |
| 105 | + <div class="list-page__head-controls"> |
| 106 | + @listGraphToggle("/computers", currentView, "") |
| 107 | + </div> |
| 108 | + </header> |
| 109 | + @listFlashes(flashes) |
| 110 | + <table class="list-table"> |
| 111 | + <thead> |
| 112 | + <tr> |
| 113 | + <th scope="col">CN</th> |
| 114 | + <th scope="col">SAM account</th> |
| 115 | + <th scope="col">Status</th> |
| 116 | + <th scope="col">DN</th> |
| 117 | + </tr> |
| 118 | + </thead> |
| 119 | + <tbody> |
| 120 | + for _, c := range computers { |
| 121 | + <tr> |
| 122 | + <td><a class="list-table__link" href={ computerDetailHref(c) }>{ c.CN() }</a></td> |
| 123 | + <td>{ c.SAMAccountName }</td> |
| 124 | + <td>{ computerStatusLabel(c) }</td> |
| 125 | + <td class="list-table__dn">{ c.DN() }</td> |
| 126 | + </tr> |
| 127 | + } |
| 128 | + </tbody> |
| 129 | + </table> |
| 130 | + @paletteV2WithPinned(palettePinned) |
| 131 | + </main> |
| 132 | + } |
| 133 | +} |
| 134 | + |
| 135 | +// userStatusLabel — "Enabled" / "Disabled" cell content. |
| 136 | +func userStatusLabel(u ldap.User) string { |
| 137 | + if u.Enabled { |
| 138 | + return "Enabled" |
| 139 | + } |
| 140 | + |
| 141 | + return "Disabled" |
| 142 | +} |
| 143 | + |
| 144 | +// computerStatusLabel — "Enabled" / "Disabled" cell content. |
| 145 | +func computerStatusLabel(c ldap.Computer) string { |
| 146 | + if c.Enabled { |
| 147 | + return "Enabled" |
| 148 | + } |
| 149 | + |
| 150 | + return "Disabled" |
| 151 | +} |
0 commit comments