fix: general qol additions and new analytics/telemetrics feature

This commit is contained in:
LukeGus
2026-07-20 13:29:03 -05:00
parent 00c0fe7cab
commit c1c06272d7
38 changed files with 1701 additions and 606 deletions
+13 -1
View File
@@ -1,6 +1,6 @@
import { authApi, handleApiError } from "@/main-axios";
export type AcmeChallengeType = "http-webroot" | "dns-cloudflare";
export type AcmeChallengeType = "http-webroot" | "dns-cloudflare" | "manual";
export type AcmeSettings = {
enabled: boolean;
@@ -45,3 +45,15 @@ export async function requestAcmeCertificate(): Promise<
handleApiError(error, "request ACME certificate");
}
}
export async function uploadManualSslCertificate(payload: {
certificate: string;
privateKey: string;
}): Promise<AcmeSettings & { success: boolean }> {
try {
const response = await authApi.post("/users/manual-ssl-upload", payload);
return response.data;
} catch (error) {
handleApiError(error, "upload manual SSL certificate");
}
}
+6 -1
View File
@@ -99,7 +99,12 @@ export async function adminDeleteUserHost(
export async function adminGetHostPassword(
targetUserId: string,
hostId: number,
field: "password" | "sudoPassword" | "vncPassword" = "password",
field:
| "password"
| "sudoPassword"
| "vncPassword"
| "key"
| "keyPassword" = "password",
): Promise<string | null> {
try {
const response = await sshHostApi.get(
+6 -1
View File
@@ -96,7 +96,12 @@ export async function getSSHHostWithCredentials(
export async function getHostPassword(
hostId: number,
field: "password" | "sudoPassword" | "vncPassword" = "password",
field:
| "password"
| "sudoPassword"
| "vncPassword"
| "key"
| "keyPassword" = "password",
): Promise<string | null> {
try {
const response = await sshHostApi.get(
+10 -4
View File
@@ -208,12 +208,18 @@ export async function getGuacamoleToken(
export async function getGuacamoleTokenFromHost(
hostId: number,
protocol?: "rdp" | "vnc" | "telnet",
promptedCredentials?: { username?: string; password?: string },
): Promise<GuacamoleTokenResponse> {
try {
const response = await authApi.post(
`/guacamole/connect-host/${hostId}`,
protocol ? { protocol } : {},
);
const response = await authApi.post(`/guacamole/connect-host/${hostId}`, {
...(protocol ? { protocol } : {}),
...(promptedCredentials?.username
? { promptedUsername: promptedCredentials.username }
: {}),
...(promptedCredentials?.password
? { promptedPassword: promptedCredentials.password }
: {}),
});
return response.data;
} catch (error) {
throw handleApiError(error, "get guacamole token from host");
+18
View File
@@ -1,5 +1,6 @@
import { authApi } from "@/main-axios";
import { createTtlRequestCache } from "@/lib/ttl-request-cache";
import type { TerminalTheme } from "@/lib/terminal-themes";
// OPEN TABS API
// ============================================================================
@@ -82,6 +83,12 @@ export async function getActiveSessions(): Promise<ActiveSessionInfo[]> {
// USER PREFERENCES API
// ============================================================================
export interface SavedCustomTheme {
id: string;
name: string;
colors: TerminalTheme["colors"];
}
export interface UserPreferences {
reopenTabsOnLogin: boolean;
theme?: string | null;
@@ -102,6 +109,17 @@ export interface UserPreferences {
hiddenRailTabs?: string | null;
compactHostView?: boolean | null;
statusColorScheme?: string | null;
customThemes?: string | null;
}
export function parseCustomThemes(raw?: string | null): SavedCustomTheme[] {
if (!raw) return [];
try {
const parsed = JSON.parse(raw);
return Array.isArray(parsed) ? parsed : [];
} catch {
return [];
}
}
export async function getUserPreferences(): Promise<UserPreferences> {
+26
View File
@@ -145,6 +145,32 @@ export async function updateGuacamoleSettings(settings: {
}
}
// ============================================================================
// ANALYTICS SETTINGS
// ============================================================================
export async function getAnalyticsEnabled(): Promise<{ enabled: boolean }> {
try {
const response = await authApi.get("/users/analytics-enabled");
return response.data;
} catch (error) {
handleApiError(error, "fetch analytics enabled setting");
}
}
export async function updateAnalyticsEnabled(
enabled: boolean,
): Promise<{ enabled: boolean }> {
try {
const response = await authApi.patch("/users/analytics-enabled", {
enabled,
});
return response.data;
} catch (error) {
handleApiError(error, "update analytics enabled setting");
}
}
// ============================================================================
// HOST DEFAULTS SETTINGS
// ============================================================================