Initial commit with CI workflow
All checks were successful
Build Container / build (push) Successful in 1m18s
All checks were successful
Build Container / build (push) Successful in 1m18s
- Flask backend with SSH discovery and Claude AI integration - React/Vite frontend with Tailwind CSS - Docker multi-stage build - Gitea Actions workflow for container builds 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
64
frontend/src/api/client.js
Normal file
64
frontend/src/api/client.js
Normal file
@@ -0,0 +1,64 @@
|
||||
const API_BASE = '/api';
|
||||
|
||||
export async function fetchApi(endpoint, options = {}) {
|
||||
const url = `${API_BASE}${endpoint}`;
|
||||
const response = await fetch(url, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
...options.headers,
|
||||
},
|
||||
...options,
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const error = await response.json().catch(() => ({ error: 'Unknown error' }));
|
||||
throw new Error(error.error || `HTTP ${response.status}`);
|
||||
}
|
||||
|
||||
return response.json();
|
||||
}
|
||||
|
||||
export const api = {
|
||||
// Settings
|
||||
getSettings: () => fetchApi('/settings'),
|
||||
updateSettings: (settings) => fetchApi('/settings', {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify(settings),
|
||||
}),
|
||||
|
||||
// Scanning
|
||||
startScan: (hostname, username = 'root', port = 22) => fetchApi('/scan', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ hostname, username, port }),
|
||||
}),
|
||||
getScan: (scanId) => fetchApi(`/scan/${scanId}`),
|
||||
|
||||
// Commands
|
||||
runCommand: (scanId, command, reason) => fetchApi(`/scan/${scanId}/command`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ command, reason }),
|
||||
}),
|
||||
|
||||
// Approvals
|
||||
getPendingApprovals: () => fetchApi('/approvals'),
|
||||
approveRequest: (approvalId) => fetchApi(`/approvals/${approvalId}/approve`, {
|
||||
method: 'POST',
|
||||
}),
|
||||
rejectRequest: (approvalId) => fetchApi(`/approvals/${approvalId}/reject`, {
|
||||
method: 'POST',
|
||||
}),
|
||||
|
||||
// Monitors
|
||||
getMonitors: () => fetchApi('/monitors'),
|
||||
createDefaultMonitors: (scanId) => fetchApi('/monitors/create-defaults', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ scan_id: scanId }),
|
||||
}),
|
||||
createSuggestedMonitors: (scanId, monitorIndices) => fetchApi('/monitors/create-suggested', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ scan_id: scanId, monitors: monitorIndices }),
|
||||
}),
|
||||
|
||||
// Uptime Kuma
|
||||
testKumaConnection: () => fetchApi('/kuma/test'),
|
||||
};
|
||||
Reference in New Issue
Block a user