fixes and improvements
This commit is contained in:
@@ -31,6 +31,7 @@ import { Applications } from "./pages/Applications";
|
||||
import { Settings } from "./pages/Settings";
|
||||
import { UsersPage } from "./pages/Users";
|
||||
import { FileBrowser } from "./pages/FileBrowser";
|
||||
import { Actions } from "./pages/Actions";
|
||||
import { getAppTheme } from "./theme";
|
||||
import { getOidcConfig, isOidcConfigured, setAccessToken } from "./auth";
|
||||
|
||||
@@ -180,6 +181,12 @@ function Shell({
|
||||
to="/applications"
|
||||
/>
|
||||
<Tab value="/users" label="Users" component={NavLink} to="/users" />
|
||||
<Tab
|
||||
value="/actions"
|
||||
label="Actions"
|
||||
component={NavLink}
|
||||
to="/actions"
|
||||
/>
|
||||
<Tab value="/files" label="Files" component={NavLink} to="/files" />
|
||||
<Tab
|
||||
value="/settings"
|
||||
@@ -200,6 +207,7 @@ function Shell({
|
||||
<Route path="/applications" element={<Applications />} />
|
||||
<Route path="/media" element={<Applications />} />
|
||||
<Route path="/users" element={<UsersPage />} />
|
||||
<Route path="/actions" element={<Actions />} />
|
||||
<Route path="/files" element={<FileBrowser />} />
|
||||
<Route path="/settings" element={<Settings />} />
|
||||
</Routes>
|
||||
|
||||
@@ -15,6 +15,12 @@ import type {
|
||||
MonitoringStatus,
|
||||
MonitoringMetrics,
|
||||
DiskSpace,
|
||||
SSHKey,
|
||||
SSHKeyInput,
|
||||
SSHKeyGenerated,
|
||||
SavedTask,
|
||||
SavedTaskInput,
|
||||
SavedTaskRun,
|
||||
MonitoringMachine,
|
||||
MonitoringMachineInput,
|
||||
MonitoringMachineAction,
|
||||
@@ -200,11 +206,84 @@ export const restartCollector = (machineId?: string) =>
|
||||
|
||||
export const fetchMonitoringSettings = () =>
|
||||
get<MonitoringMachine[]>("/api/settings/machines");
|
||||
export const fetchSSHKeys = () => get<SSHKey[]>("/api/settings/ssh-keys");
|
||||
export const generateSSHKey = (payload: {
|
||||
name: string;
|
||||
passphrase: string;
|
||||
notes: string;
|
||||
bits?: number;
|
||||
}) => post<SSHKeyGenerated>("/api/settings/ssh-keys/generate", payload);
|
||||
export const fetchMonitoringMachineActions = (machineId: string, limit = 10) =>
|
||||
get<{ items: MonitoringMachineAction[]; total: number }>(
|
||||
`/api/monitoring/machines/${encodeURIComponent(machineId)}/actions`,
|
||||
{ limit: String(limit) },
|
||||
);
|
||||
export const saveSSHKey = (key: SSHKeyInput) =>
|
||||
fetch(
|
||||
buildUrl(
|
||||
key.id
|
||||
? `/api/settings/ssh-keys/${encodeURIComponent(key.id)}`
|
||||
: "/api/settings/ssh-keys",
|
||||
),
|
||||
{
|
||||
method: key.id ? "PUT" : "POST",
|
||||
headers: buildHeaders(true),
|
||||
body: JSON.stringify(key),
|
||||
},
|
||||
).then(async (response) => {
|
||||
if (!response.ok) {
|
||||
throw new Error(`${response.status}: ${await readErrorDetail(response)}`);
|
||||
}
|
||||
return response.json() as Promise<SSHKey>;
|
||||
});
|
||||
export const deleteSSHKey = (keyId: string) =>
|
||||
del<{ status: string }>(
|
||||
`/api/settings/ssh-keys/${encodeURIComponent(keyId)}`,
|
||||
);
|
||||
|
||||
export const fetchSavedTasks = () => get<SavedTask[]>("/api/tasks");
|
||||
export const fetchSavedTaskRuns = (taskId: string, limit = 10) =>
|
||||
get<{ items: SavedTaskRun[]; total: number }>(
|
||||
`/api/tasks/${encodeURIComponent(taskId)}/runs`,
|
||||
{
|
||||
limit: String(limit),
|
||||
},
|
||||
);
|
||||
export const saveTask = (task: SavedTaskInput) =>
|
||||
fetch(
|
||||
buildUrl(
|
||||
task.id ? `/api/tasks/${encodeURIComponent(task.id)}` : "/api/tasks",
|
||||
),
|
||||
{
|
||||
method: task.id ? "PUT" : "POST",
|
||||
headers: buildHeaders(true),
|
||||
body: JSON.stringify(task),
|
||||
},
|
||||
).then(async (response) => {
|
||||
if (!response.ok) {
|
||||
throw new Error(`${response.status}: ${await readErrorDetail(response)}`);
|
||||
}
|
||||
return response.json() as Promise<SavedTask>;
|
||||
});
|
||||
export const deleteTask = (taskId: string) =>
|
||||
del<{ status: string }>(`/api/tasks/${encodeURIComponent(taskId)}`);
|
||||
export const runTask = (taskId: string, machineId?: string) =>
|
||||
post<{
|
||||
task_id: string;
|
||||
task_name: string;
|
||||
machine_id: string;
|
||||
machine_name: string;
|
||||
task_type: string;
|
||||
exit_status: number;
|
||||
stdout: string;
|
||||
stderr: string;
|
||||
}>(
|
||||
machineId
|
||||
? `/api/tasks/run?machine_id=${encodeURIComponent(machineId)}`
|
||||
: "/api/tasks/run",
|
||||
{ task_id: taskId },
|
||||
);
|
||||
|
||||
export const saveMonitoringMachine = (machine: MonitoringMachineInput) =>
|
||||
fetch(
|
||||
buildUrl(
|
||||
|
||||
@@ -89,6 +89,73 @@ export interface NowPlayingSession {
|
||||
session_id: string;
|
||||
}
|
||||
|
||||
export interface SSHKey {
|
||||
id: string;
|
||||
name: string;
|
||||
private_key_set: boolean;
|
||||
passphrase_set: boolean;
|
||||
public_key: string;
|
||||
fingerprint: string;
|
||||
usage_count: number;
|
||||
notes: string;
|
||||
}
|
||||
|
||||
export interface SSHKeyInput {
|
||||
id?: string | null;
|
||||
name: string;
|
||||
private_key: string;
|
||||
passphrase: string;
|
||||
notes: string;
|
||||
}
|
||||
|
||||
export interface SSHKeyGenerated {
|
||||
name: string;
|
||||
private_key: string;
|
||||
passphrase: string;
|
||||
notes: string;
|
||||
public_key: string;
|
||||
fingerprint: string;
|
||||
usage_count: number;
|
||||
}
|
||||
|
||||
export interface SavedTask {
|
||||
id: string;
|
||||
name: string;
|
||||
task_type: "shell" | "python";
|
||||
content: string;
|
||||
enabled: boolean;
|
||||
default_machine_id: string;
|
||||
notes: string;
|
||||
created_at: number;
|
||||
updated_at: number;
|
||||
}
|
||||
|
||||
export interface SavedTaskInput {
|
||||
id?: string | null;
|
||||
name: string;
|
||||
task_type: "shell" | "python";
|
||||
content: string;
|
||||
enabled: boolean;
|
||||
default_machine_id: string;
|
||||
notes: string;
|
||||
}
|
||||
|
||||
export interface SavedTaskRun {
|
||||
id: string;
|
||||
task_id: string;
|
||||
task_name: string;
|
||||
machine_id: string;
|
||||
machine_name: string;
|
||||
task_type: "shell" | "python";
|
||||
status: string;
|
||||
created_at: number;
|
||||
duration_ms: number;
|
||||
request_id: string;
|
||||
stdout_tail: string;
|
||||
stderr_tail: string;
|
||||
error: string;
|
||||
}
|
||||
|
||||
export interface MonitoringMachine {
|
||||
id: string;
|
||||
name: string;
|
||||
@@ -100,6 +167,9 @@ export interface MonitoringMachine {
|
||||
username: string;
|
||||
key_directory: string;
|
||||
key_name: string;
|
||||
ssh_key_id: string;
|
||||
ssh_private_key_set: boolean;
|
||||
ssh_private_key_passphrase_set: boolean;
|
||||
password_set: boolean;
|
||||
media_root: string;
|
||||
path_prefix: string;
|
||||
@@ -122,6 +192,9 @@ export interface MonitoringMachineInput {
|
||||
username: string;
|
||||
key_directory: string;
|
||||
key_name: string;
|
||||
ssh_key_id: string;
|
||||
ssh_private_key: string;
|
||||
ssh_private_key_passphrase: string;
|
||||
password: string;
|
||||
media_root: string;
|
||||
path_prefix: string;
|
||||
@@ -133,6 +206,44 @@ export interface MonitoringMachineInput {
|
||||
notes: string;
|
||||
}
|
||||
|
||||
export interface SavedTask {
|
||||
id: string;
|
||||
name: string;
|
||||
task_type: "shell" | "python";
|
||||
content: string;
|
||||
enabled: boolean;
|
||||
default_machine_id: string;
|
||||
notes: string;
|
||||
created_at: number;
|
||||
updated_at: number;
|
||||
}
|
||||
|
||||
export interface SavedTaskInput {
|
||||
id?: string | null;
|
||||
name: string;
|
||||
task_type: "shell" | "python";
|
||||
content: string;
|
||||
enabled: boolean;
|
||||
default_machine_id: string;
|
||||
notes: string;
|
||||
}
|
||||
|
||||
export interface SavedTaskRun {
|
||||
id: string;
|
||||
task_id: string;
|
||||
task_name: string;
|
||||
machine_id: string;
|
||||
machine_name: string;
|
||||
task_type: "shell" | "python";
|
||||
status: string;
|
||||
created_at: number;
|
||||
duration_ms: number;
|
||||
request_id: string;
|
||||
stdout_tail: string;
|
||||
stderr_tail: string;
|
||||
error: string;
|
||||
}
|
||||
|
||||
export interface MonitoringMachineAction {
|
||||
machine_id: string;
|
||||
machine_name: string;
|
||||
|
||||
Reference in New Issue
Block a user