chore: update advanced settings to easily allow downloading of logs
This commit is contained in:
parent
9092d92193
commit
e56d3789ca
2 changed files with 96 additions and 0 deletions
|
|
@ -32,6 +32,8 @@ export default function AdvancedSettingsPage() {
|
||||||
const settingsQuery = api.settings.getSettings.useQuery();
|
const settingsQuery = api.settings.getSettings.useQuery();
|
||||||
const telemetryQuery = api.settings.getTelemetrySettings.useQuery();
|
const telemetryQuery = api.settings.getTelemetrySettings.useQuery();
|
||||||
const dataPathQuery = api.settings.getDataPath.useQuery();
|
const dataPathQuery = api.settings.getDataPath.useQuery();
|
||||||
|
const logFilePathQuery = api.settings.getLogFilePath.useQuery();
|
||||||
|
const machineIdQuery = api.settings.getMachineId.useQuery();
|
||||||
const utils = api.useUtils();
|
const utils = api.useUtils();
|
||||||
|
|
||||||
const updateTranscriptionSettingsMutation =
|
const updateTranscriptionSettingsMutation =
|
||||||
|
|
@ -73,6 +75,17 @@ export default function AdvancedSettingsPage() {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const downloadLogFileMutation = api.settings.downloadLogFile.useMutation({
|
||||||
|
onSuccess: (data) => {
|
||||||
|
if (data.success) {
|
||||||
|
toast.success("Log file saved successfully");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onError: () => {
|
||||||
|
toast.error("Failed to save log file");
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
// Load settings when query data is available
|
// Load settings when query data is available
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (settingsQuery.data?.transcription) {
|
if (settingsQuery.data?.transcription) {
|
||||||
|
|
@ -99,6 +112,13 @@ export default function AdvancedSettingsPage() {
|
||||||
window.electronAPI.openExternal("https://amical.ai/docs/telemetry");
|
window.electronAPI.openExternal("https://amical.ai/docs/telemetry");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleCopyMachineId = async () => {
|
||||||
|
if (machineIdQuery.data) {
|
||||||
|
await navigator.clipboard.writeText(machineIdQuery.data);
|
||||||
|
toast.success("Machine ID copied to clipboard");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="container mx-auto p-6 max-w-5xl">
|
<div className="container mx-auto p-6 max-w-5xl">
|
||||||
<div className="mb-8">
|
<div className="mb-8">
|
||||||
|
|
@ -176,6 +196,44 @@ export default function AdvancedSettingsPage() {
|
||||||
className="cursor-default"
|
className="cursor-default"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Label htmlFor="log-location">Log File Location</Label>
|
||||||
|
<div className="flex gap-2">
|
||||||
|
<Input
|
||||||
|
id="log-location"
|
||||||
|
value={logFilePathQuery.data || "Loading..."}
|
||||||
|
disabled
|
||||||
|
className="cursor-default flex-1"
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
onClick={() => downloadLogFileMutation.mutate()}
|
||||||
|
disabled={downloadLogFileMutation.isPending}
|
||||||
|
>
|
||||||
|
Download
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Label htmlFor="machine-id">Machine ID</Label>
|
||||||
|
<div className="flex gap-2">
|
||||||
|
<Input
|
||||||
|
id="machine-id"
|
||||||
|
value={machineIdQuery.data || "Loading..."}
|
||||||
|
disabled
|
||||||
|
className="cursor-default flex-1 font-mono text-xs"
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
onClick={handleCopyMachineId}
|
||||||
|
disabled={!machineIdQuery.data}
|
||||||
|
>
|
||||||
|
Copy
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -481,6 +481,44 @@ export const settingsRouter = createRouter({
|
||||||
return app.getPath("userData");
|
return app.getPath("userData");
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
// Get log file path
|
||||||
|
getLogFilePath: procedure.query(() => {
|
||||||
|
const isDev = process.env.NODE_ENV === "development" || !app.isPackaged;
|
||||||
|
return isDev
|
||||||
|
? path.join(app.getPath("userData"), "logs", "amical-dev.log")
|
||||||
|
: path.join(app.getPath("logs"), "amical.log");
|
||||||
|
}),
|
||||||
|
|
||||||
|
// Get machine ID for display
|
||||||
|
getMachineId: procedure.query(async ({ ctx }) => {
|
||||||
|
const telemetryService = ctx.serviceManager.getService("telemetryService");
|
||||||
|
return telemetryService?.getMachineId() ?? "";
|
||||||
|
}),
|
||||||
|
|
||||||
|
// Download log file via save dialog
|
||||||
|
downloadLogFile: procedure.mutation(async () => {
|
||||||
|
const { dialog, BrowserWindow } = await import("electron");
|
||||||
|
const isDev = process.env.NODE_ENV === "development" || !app.isPackaged;
|
||||||
|
const logPath = isDev
|
||||||
|
? path.join(app.getPath("userData"), "logs", "amical-dev.log")
|
||||||
|
: path.join(app.getPath("logs"), "amical.log");
|
||||||
|
|
||||||
|
const focusedWindow = BrowserWindow.getFocusedWindow();
|
||||||
|
const saveOptions = {
|
||||||
|
defaultPath: `amical-logs-${new Date().toISOString().split("T")[0]}.log`,
|
||||||
|
filters: [{ name: "Log Files", extensions: ["log", "txt"] }],
|
||||||
|
};
|
||||||
|
const { filePath } = focusedWindow
|
||||||
|
? await dialog.showSaveDialog(focusedWindow, saveOptions)
|
||||||
|
: await dialog.showSaveDialog(saveOptions);
|
||||||
|
|
||||||
|
if (filePath) {
|
||||||
|
await fs.copyFile(logPath, filePath);
|
||||||
|
return { success: true, path: filePath };
|
||||||
|
}
|
||||||
|
return { success: false };
|
||||||
|
}),
|
||||||
|
|
||||||
// Get app preferences (launch at login, minimize to tray, etc.)
|
// Get app preferences (launch at login, minimize to tray, etc.)
|
||||||
getPreferences: procedure.query(async ({ ctx }) => {
|
getPreferences: procedure.query(async ({ ctx }) => {
|
||||||
const settingsService = ctx.serviceManager.getService("settingsService");
|
const settingsService = ctx.serviceManager.getService("settingsService");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue