landed the sysadmin menu page, and the code to render menus as full-page

This commit is contained in:
2025-10-13 21:44:14 -06:00
parent b1270a262e
commit e08ca22f57
5 changed files with 111 additions and 1 deletions
+1
View File
@@ -58,6 +58,7 @@ func setupEcho() *echo.Echo {
e.POST("/profile_photo", ui.AmWrap(ProfilePhoto))
e.GET("/user/:uname", ui.AmWrap(ShowProfile))
e.POST("/quick_email", ui.AmWrap(QuickEMail))
e.GET("/sysadmin", ui.AmWrap(SysAdminMenu))
return e
}
+39
View File
@@ -0,0 +1,39 @@
/*
* Amsterdam Web Communities System
* Copyright (c) 2025 Erbosoft Metaverse Design Solutions, All Rights Reserved
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
// Package main contains the high-level Amsterdam logic.
package main
import (
"errors"
"net/http"
"git.erbosoft.com/amy/amsterdam/database"
"git.erbosoft.com/amy/amsterdam/ui"
)
/* SysAdminMenu renders the system administration menu.
* Parameters:
* ctxt - The AmContext for the request.
* Returns:
* Command string dictating what to be rendered.
* Data as a parameter for the command string.
* Standard Go error status.
*/
func SysAdminMenu(ctxt ui.AmContext) (string, any, error) {
u := ctxt.CurrentUser()
if !database.AmTestPermission("Global.SysAdminAccess", u.BaseLevel) {
ctxt.SetRC(http.StatusForbidden)
return ui.ErrorPage(ctxt, errors.New("you are not authorized access to this page"))
}
menu := ui.AmMenu("sysadmin")
ctxt.VarMap().Set("menu", menu)
ctxt.VarMap().Set("amsterdam_pageTitle", menu.Title)
return "framed_template", "menu.jet", nil
}
+27 -1
View File
@@ -27,5 +27,31 @@ menudefs:
- text: "About Amsterdam"
link: "/about"
- text: "System Administration"
link: "/TODO/sysadmin"
link: "/sysadmin"
permission: "Global.SysAdminAccess"
- id: "sysadmin"
title: "System Administration"
permSet: "user"
warning: >
<strong>Note:</strong> These tools provide access to sensitive system administration functions.
Use with care and review all changes before applying them to the system.
items:
- text: "Edit Global Properties"
link: "/TODO/sysadmin/global"
permission: "Global.SysAdminAccess"
- text: "View/Edit IP Address Bans"
link: "/TODO/sysadmin/ip_bans"
permission: "Global.SysAdminAccess"
- text: "View/Edit Banned Users"
link: "/TODO/sysadmin/user_bans"
disabled: true
permission: "Global.SysAdminAccess"
- text: "User Account Management"
link: "/TODO/sysadmin/find_user"
permission: "Global.SysAdminAccess"
- text: "System Audit Logs"
link: "/TODO/sysadmin/audit"
permission: "Global.SysAdminAccess"
- text: "Import User Accounts"
link: "/TODO/sysadmin/import"
permission: "Global.SysAdminAccess"
+2
View File
@@ -25,6 +25,7 @@ type MenuItem struct {
P *MenuDefinition
}
// Show checks permissions to see if we can display the menu item.
func (mi *MenuItem) Show(ctxt AmContext) bool {
if mi.Permission == "" {
return true
@@ -45,6 +46,7 @@ type MenuDefinition struct {
ID string `yaml:"id"`
Title string `yaml:"title"`
PermSet string `yaml:"permSet"`
Warning string `yaml:"warning"`
Items []MenuItem `yaml:"items"`
}
+42
View File
@@ -0,0 +1,42 @@
{*
* Amsterdam Web Communities System
* Copyright (c) 2025 Erbosoft Metaverse Design Solutions, All Rights Reserved
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*}
<div class="p-4">
<!-- Page Title -->
<div class="mb-6">
<h1 class="text-blue-800 text-4xl font-bold mb-2">{{ menu.Title }}</h1>
<hr class="border-2 border-gray-400 w-4/5 mb-4">
</div>
<!-- Administration Menu -->
<div class="max-w-2xl">
<div class="bg-gray-50 p-6 rounded-lg">
<nav class="space-y-3">
{{ ctxt := . }}
{{ range menu.Items }}
{{ if .Show(ctxt) }}
<div class="flex items-start gap-3">
<span class="text-lg pt-0.5">🟣</span>
{{ if .Disabled }}
<span class="text-gray-500 font-medium">{{ .Text }}</span>
{{ else }}
<a href="{{ .Link }}" class="text-blue-700 hover:text-blue-900 font-medium">{{ .Text }}</a>
{{ end }}
</div>
{{ end }}
{{ end }}
</nav>
</div>
{{ if menu.Warning != "" }}
<div class="mt-6 p-4 bg-yellow-50 border-l-4 border-yellow-400">
<p class="text-sm text-gray-700">{{ menu.Warning | raw }}</p>
</div>
{{ end }}
</div>
</div>