2026-06-04 15:16:53 -04:00
|
|
|
import { authApi, handleApiError, statsApi } from "@/main-axios";
|
|
|
|
|
|
|
|
|
|
// GLOBAL MONITORING SETTINGS
|
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
|
|
export async function getGlobalMonitoringSettings(): Promise<{
|
|
|
|
|
statusCheckInterval: number;
|
|
|
|
|
metricsInterval: number;
|
|
|
|
|
}> {
|
|
|
|
|
try {
|
|
|
|
|
const response = await statsApi.get("/global-settings");
|
|
|
|
|
return response.data;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
handleApiError(error, "fetch global monitoring settings");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function updateGlobalMonitoringSettings(settings: {
|
|
|
|
|
statusCheckInterval?: number;
|
|
|
|
|
metricsInterval?: number;
|
|
|
|
|
}): Promise<void> {
|
|
|
|
|
try {
|
|
|
|
|
await statsApi.post("/global-settings", settings);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
handleApiError(error, "update global monitoring settings");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
|
// LOG LEVEL SETTINGS
|
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
|
|
export async function getLogLevel(): Promise<{ level: string }> {
|
|
|
|
|
try {
|
|
|
|
|
const response = await authApi.get("/users/log-level");
|
|
|
|
|
return response.data;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
handleApiError(error, "fetch log level");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function updateLogLevel(level: string): Promise<void> {
|
|
|
|
|
try {
|
|
|
|
|
await authApi.patch("/users/log-level", { level });
|
|
|
|
|
} catch (error) {
|
|
|
|
|
handleApiError(error, "update log level");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
|
// SESSION TIMEOUT SETTINGS
|
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
|
|
export async function getSessionTimeout(): Promise<{ timeoutHours: number }> {
|
|
|
|
|
try {
|
|
|
|
|
const response = await authApi.get("/users/session-timeout");
|
|
|
|
|
return response.data;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
handleApiError(error, "fetch session timeout");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function updateSessionTimeout(
|
|
|
|
|
timeoutHours: number,
|
|
|
|
|
): Promise<void> {
|
|
|
|
|
try {
|
|
|
|
|
await authApi.patch("/users/session-timeout", { timeoutHours });
|
|
|
|
|
} catch (error) {
|
|
|
|
|
handleApiError(error, "update session timeout");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-16 15:59:53 -05:00
|
|
|
// ============================================================================
|
|
|
|
|
// TAILSCALE SETTINGS
|
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
|
|
export async function getTailscaleSettings(): Promise<{
|
|
|
|
|
apiKey: string;
|
|
|
|
|
hasApiKey: boolean;
|
|
|
|
|
}> {
|
|
|
|
|
try {
|
|
|
|
|
const response = await authApi.get("/users/tailscale-settings");
|
|
|
|
|
return response.data;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
handleApiError(error, "fetch Tailscale settings");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function updateTailscaleSettings(
|
|
|
|
|
apiKey: string,
|
|
|
|
|
): Promise<{ hasApiKey: boolean }> {
|
|
|
|
|
try {
|
|
|
|
|
const response = await authApi.patch("/users/tailscale-settings", {
|
|
|
|
|
apiKey,
|
|
|
|
|
});
|
|
|
|
|
return response.data;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
handleApiError(error, "update Tailscale settings");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function getTailscaleDevices(): Promise<{
|
|
|
|
|
devices: Array<{
|
|
|
|
|
id: string;
|
|
|
|
|
name: string;
|
|
|
|
|
hostname: string;
|
|
|
|
|
addresses: string[];
|
|
|
|
|
os: string;
|
|
|
|
|
lastSeen: string;
|
|
|
|
|
}>;
|
|
|
|
|
hasApiKey: boolean;
|
|
|
|
|
}> {
|
|
|
|
|
try {
|
|
|
|
|
const response = await authApi.get("/tailscale/devices");
|
|
|
|
|
return response.data;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
handleApiError(error, "fetch Tailscale devices");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-04 15:16:53 -04:00
|
|
|
// ============================================================================
|
|
|
|
|
// GUACAMOLE SETTINGS
|
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
|
|
export async function getGuacamoleSettings(): Promise<{
|
|
|
|
|
enabled: boolean;
|
|
|
|
|
url: string;
|
|
|
|
|
}> {
|
|
|
|
|
try {
|
|
|
|
|
const response = await authApi.get("/users/guacamole-settings");
|
|
|
|
|
return response.data;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
handleApiError(error, "fetch guacamole settings");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function updateGuacamoleSettings(settings: {
|
|
|
|
|
enabled?: boolean;
|
|
|
|
|
url?: string;
|
|
|
|
|
}): Promise<void> {
|
|
|
|
|
try {
|
|
|
|
|
await authApi.patch("/users/guacamole-settings", settings);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
handleApiError(error, "update guacamole settings");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ============================================================================
|