mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-04-25 08:56:21 +00:00
update notification_events.py
This commit is contained in:
@@ -27,18 +27,26 @@ export function AuthSetup({ onComplete }: AuthSetupProps) {
|
||||
const checkOnboardingStatus = async () => {
|
||||
try {
|
||||
const response = await fetch(getApiUrl("/api/auth/status"))
|
||||
|
||||
// Check if response is valid JSON before parsing
|
||||
if (!response.ok) {
|
||||
// API not available - don't show modal in preview
|
||||
return
|
||||
}
|
||||
|
||||
const contentType = response.headers.get("content-type")
|
||||
if (!contentType || !contentType.includes("application/json")) {
|
||||
return
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
console.log("[v0] Auth status for modal check:", data)
|
||||
|
||||
// Show modal if auth is not configured and not declined
|
||||
if (!data.auth_configured) {
|
||||
setTimeout(() => setOpen(true), 500)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("[v0] Failed to check auth status:", error)
|
||||
// Fail-safe: show modal if we can't check status
|
||||
setTimeout(() => setOpen(true), 500)
|
||||
} catch {
|
||||
// API not available (preview environment) - don't show modal
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -299,6 +299,19 @@ export function NotificationSettings() {
|
||||
fallback_commands: string[]
|
||||
error: string
|
||||
}>({ status: "idle", fallback_commands: [], error: "" })
|
||||
const [systemHostname, setSystemHostname] = useState<string>("")
|
||||
|
||||
// Load system hostname for display name placeholder
|
||||
const loadSystemHostname = useCallback(async () => {
|
||||
try {
|
||||
const data = await fetchApi<{ hostname?: string }>("/api/system")
|
||||
if (data.hostname) {
|
||||
setSystemHostname(data.hostname)
|
||||
}
|
||||
} catch {
|
||||
// Ignore - will show generic placeholder
|
||||
}
|
||||
}, [])
|
||||
|
||||
const loadConfig = useCallback(async () => {
|
||||
try {
|
||||
@@ -366,7 +379,8 @@ export function NotificationSettings() {
|
||||
useEffect(() => {
|
||||
loadConfig()
|
||||
loadStatus()
|
||||
}, [loadConfig, loadStatus])
|
||||
loadSystemHostname()
|
||||
}, [loadConfig, loadStatus, loadSystemHostname])
|
||||
|
||||
useEffect(() => {
|
||||
if (showHistory) loadHistory()
|
||||
@@ -1505,6 +1519,25 @@ export function NotificationSettings() {
|
||||
</div>{/* close bordered channel container */}
|
||||
</div>
|
||||
|
||||
{/* ── Display Name ── */}
|
||||
<div className="space-y-2 pb-3 border-b border-border/50">
|
||||
<div className="flex items-center gap-2">
|
||||
<Server className="h-4 w-4 text-blue-400" />
|
||||
<Label className="text-xs sm:text-sm text-foreground/80">Display Name</Label>
|
||||
</div>
|
||||
<Input
|
||||
className={`h-9 text-sm ${!editMode ? "opacity-50 cursor-not-allowed" : ""}`}
|
||||
placeholder={systemHostname || "System hostname"}
|
||||
value={config.hostname || (editMode ? "" : systemHostname)}
|
||||
onChange={e => updateConfig(p => ({ ...p, hostname: e.target.value }))}
|
||||
disabled={!editMode}
|
||||
readOnly={!editMode}
|
||||
/>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Name shown in notifications. Edit to customize, or leave empty to use the system hostname.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* ── Advanced: AI Enhancement ── */}
|
||||
<div>
|
||||
<div className="flex items-center justify-between py-1">
|
||||
|
||||
@@ -641,11 +641,18 @@ export function Security() {
|
||||
const checkAuthStatus = async () => {
|
||||
try {
|
||||
const response = await fetch(getApiUrl("/api/auth/status"))
|
||||
|
||||
// Check if response is valid JSON before parsing
|
||||
if (!response.ok) return
|
||||
|
||||
const contentType = response.headers.get("content-type")
|
||||
if (!contentType || !contentType.includes("application/json")) return
|
||||
|
||||
const data = await response.json()
|
||||
setAuthEnabled(data.auth_enabled || false)
|
||||
setTotpEnabled(data.totp_enabled || false)
|
||||
} catch (err) {
|
||||
console.error("Failed to check auth status:", err)
|
||||
} catch {
|
||||
// API not available (preview environment)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user