package web
import (
"strconv"
"git.zb-server.de/ZB-Server/uptimesebi/internal/i18n"
)
// SupportTicket is a ticket as the support pages show it; User and Org
// are filled for admins.
type SupportTicket struct {
ID, Subject, Status string
User, Org string
Updated string
References []SupportReference
Messages []SupportMessage
}
// SupportReference is something a ticket points at; Kind is org, monitor,
// channel, alert_group, status_page or incident.
type SupportReference struct {
Kind, Name string
}
// SupportMessage is one message of a ticket, rendered from Markdown.
type SupportMessage struct {
FromStaff bool
// Author is the admin who answered, for admins only.
Author string
HTML string
At string
}
// SupportOptions are what of the active organization a new ticket can
// point at; Org is empty without one.
type SupportOptions struct {
Org string
Monitors, Channels, AlertGroups, StatusPages, Incidents []SupportOption
}
// SupportOption is one choice of SupportOptions.
type SupportOption struct {
ID, Name string
}
// SupportSettings are how the platform runs support, for its admins.
type SupportSettings struct {
Enabled bool
MaxOpen int
}
// SupportAccount is what admins see about the account behind a ticket.
type SupportAccount struct {
ID, Email, Name, Created, Locale string
Verified, TOTP, Password, Admin bool
Suspended bool
SuspendedReason string
OrgsOwned, OrgLimit int
OpenTickets int64
Orgs []SupportOrg
}
// SupportOrg is an organization of the account with its limits; Current
// marks the one the ticket names. Limits of 0 are unlimited.
type SupportOrg struct {
Name, Slug string
Owner, Current, Suspended bool
SuspendedReason string
Monitors, MonitorLimit int
StatusPages, StatusPageLimit int
RegionsPerMonitor int
}
// SupportStatuses are the states of a ticket, in the order admins filter
// them.
var SupportStatuses = []string{"open", "answered", "closed"}
var supportFilters = append(append([]string{}, SupportStatuses...), "all")
// supportBase is where the support pages live for staff or the account.
func supportBase(staff bool) string {
if staff {
return "/admin/support"
}
return "/support"
}
func supportAPI(t SupportTicket, staff bool) string {
return supportBase(staff) + "/tickets/" + t.ID
}
// usageText shows used of limit, ∞ for no limit.
func usageText(used, limit int) string {
if limit <= 0 {
return strconv.Itoa(used) + " / ∞"
}
return strconv.Itoa(used) + " / " + strconv.Itoa(limit)
}
templ supportStatusLabel(status string) {
{ i18n.T(ctx, "support.status."+status) }
}
templ supportList(tickets []SupportTicket, base string, staff bool) {
}
}
templ supportFlag(on bool, yesID, noID string) {
if on {
{ i18n.T(ctx, yesID) }
} else {
{ i18n.T(ctx, noID) }
}
}
// supportAccountBox gives admins the account behind a ticket at a glance.
templ supportAccountBox(a SupportAccount) {
}
// SupportTicketPage shows a ticket's conversation to its account or, with
// the account's details, to the admins.
templ SupportTicketPage(p Page, me Me, t SupportTicket, account *SupportAccount) {
@consoleShell(p, me) {