Merge Luke and Zac

This commit is contained in:
Karmaa
2025-09-07 21:23:48 -05:00
committed by LukeGus
parent 60928ae191
commit 5f6792dc0d
38 changed files with 6648 additions and 3100 deletions

View File

@@ -12,11 +12,12 @@ interface SSHHostData {
folder?: string;
tags?: string[];
pin?: boolean;
authType: 'password' | 'key';
authType: 'password' | 'key' | 'credential';
password?: string;
key?: File | null;
keyPassword?: string;
keyType?: string;
credentialId?: number | null;
enableTerminal?: boolean;
enableTunnel?: boolean;
enableFileManager?: boolean;
@@ -38,6 +39,7 @@ interface SSHHost {
key?: string;
keyPassword?: string;
keyType?: string;
credentialId?: number;
enableTerminal: boolean;
enableTunnel: boolean;
enableFileManager: boolean;
@@ -338,10 +340,12 @@ export async function createSSHHost(hostData: SSHHostData): Promise<SSHHost> {
tags: hostData.tags || [],
pin: hostData.pin || false,
authMethod: hostData.authType,
authType: hostData.authType,
password: hostData.authType === 'password' ? hostData.password : '',
key: hostData.authType === 'key' ? hostData.key : null,
keyPassword: hostData.authType === 'key' ? hostData.keyPassword : '',
keyType: hostData.authType === 'key' ? hostData.keyType : '',
credentialId: hostData.authType === 'credential' ? hostData.credentialId : null,
enableTerminal: hostData.enableTerminal !== false,
enableTunnel: hostData.enableTunnel !== false,
enableFileManager: hostData.enableFileManager !== false,
@@ -389,10 +393,12 @@ export async function updateSSHHost(hostId: number, hostData: SSHHostData): Prom
tags: hostData.tags || [],
pin: hostData.pin || false,
authMethod: hostData.authType,
authType: hostData.authType,
password: hostData.authType === 'password' ? hostData.password : '',
key: hostData.authType === 'key' ? hostData.key : null,
keyPassword: hostData.authType === 'key' ? hostData.keyPassword : '',
keyType: hostData.authType === 'key' ? hostData.keyType : '',
credentialId: hostData.authType === 'credential' ? hostData.credentialId : null,
enableTerminal: hostData.enableTerminal !== false,
enableTunnel: hostData.enableTunnel !== false,
enableFileManager: hostData.enableFileManager !== false,
@@ -817,8 +823,9 @@ export async function getOIDCConfig(): Promise<any> {
try {
const response = await authApi.get('/users/oidc-config');
return response.data;
} catch (error) {
handleApiError(error, 'fetch OIDC config');
} catch (error: any) {
console.warn('Failed to fetch OIDC config:', error.response?.data?.error || error.message);
return null;
}
}
@@ -1024,7 +1031,7 @@ export async function getReleasesRSS(perPage: number = 100): Promise<any> {
export async function getVersionInfo(): Promise<any> {
try {
const response = await authApi.get('/version/');
const response = await authApi.get('/version');
return response.data;
} catch (error) {
handleApiError(error, 'fetch version info');
@@ -1042,4 +1049,105 @@ export async function getDatabaseHealth(): Promise<any> {
} catch (error) {
handleApiError(error, 'check database health');
}
}
// ============================================================================
// SSH CREDENTIALS MANAGEMENT
// ============================================================================
export async function getCredentials(): Promise<any> {
try {
const response = await authApi.get('/credentials');
return response.data;
} catch (error) {
handleApiError(error, 'fetch credentials');
}
}
export async function getCredentialDetails(credentialId: number): Promise<any> {
try {
const response = await authApi.get(`/credentials/${credentialId}`);
return response.data;
} catch (error) {
handleApiError(error, 'fetch credential details');
}
}
export async function createCredential(credentialData: any): Promise<any> {
try {
const response = await authApi.post('/credentials', credentialData);
return response.data;
} catch (error) {
handleApiError(error, 'create credential');
}
}
export async function updateCredential(credentialId: number, credentialData: any): Promise<any> {
try {
const response = await authApi.put(`/credentials/${credentialId}`, credentialData);
return response.data;
} catch (error) {
handleApiError(error, 'update credential');
}
}
export async function deleteCredential(credentialId: number): Promise<any> {
try {
const response = await authApi.delete(`/credentials/${credentialId}`);
return response.data;
} catch (error) {
handleApiError(error, 'delete credential');
}
}
export async function getCredentialHosts(credentialId: number): Promise<any> {
try {
const response = await authApi.get(`/credentials/${credentialId}/hosts`);
return response.data;
} catch (error) {
handleApiError(error, 'fetch credential hosts');
}
}
export async function getCredentialFolders(): Promise<any> {
try {
const response = await authApi.get('/credentials/folders');
return response.data;
} catch (error) {
handleApiError(error, 'fetch credential folders');
}
}
export async function applyCredentialToHost(credentialId: number, hostId: number): Promise<any> {
try {
const response = await authApi.post(`/credentials/${credentialId}/apply-to-host/${hostId}`);
return response.data;
} catch (error) {
handleApiError(error, 'apply credential to host');
}
}
// ============================================================================
// SSH FOLDER MANAGEMENT
// ============================================================================
export async function getFoldersWithStats(): Promise<any> {
try {
const response = await authApi.get('/ssh/db/folders/with-stats');
return response.data;
} catch (error) {
handleApiError(error, 'fetch folders with statistics');
}
}
export async function renameFolder(oldName: string, newName: string): Promise<any> {
try {
const response = await authApi.put('/ssh/db/folders/rename', {
oldName,
newName
});
return response.data;
} catch (error) {
handleApiError(error, 'rename folder');
}
}