mirror of
https://github.com/aljazceru/mutiny-web.git
synced 2025-12-24 01:24:28 +01:00
add log downloader
This commit is contained in:
22
src/components/Logs.tsx
Normal file
22
src/components/Logs.tsx
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import { Button, Card, NiceP, VStack } from "~/components/layout";
|
||||||
|
import { useMegaStore } from "~/state/megaStore";
|
||||||
|
import { downloadTextFile } from "~/utils/download";
|
||||||
|
|
||||||
|
export function Logs() {
|
||||||
|
const [state, _] = useMegaStore()
|
||||||
|
|
||||||
|
async function handleSave() {
|
||||||
|
const logs = await state.mutiny_wallet?.get_logs()
|
||||||
|
downloadTextFile(logs.join("") || "", "mutiny-logs.txt", "text/plain")
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Card>
|
||||||
|
<VStack>
|
||||||
|
<NiceP>Something screwy going on? Check out the logs!</NiceP>
|
||||||
|
<Button onClick={handleSave}>Download Logs</Button>
|
||||||
|
</VStack>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import { createForm, url } from '@modular-forms/solid';
|
import { createForm, url } from '@modular-forms/solid';
|
||||||
import { TextField } from '~/components/layout/TextField';
|
import { TextField } from '~/components/layout/TextField';
|
||||||
import { MutinyWalletSettingStrings, getExistingSettings } from '~/logic/mutinyWalletSetup';
|
import { MutinyWalletSettingStrings, getExistingSettings } from '~/logic/mutinyWalletSetup';
|
||||||
import { Button, SmallHeader } from '~/components/layout';
|
import { Button, Card, SmallHeader } from '~/components/layout';
|
||||||
import { showToast } from './Toaster';
|
import { showToast } from './Toaster';
|
||||||
import eify from '~/utils/eify';
|
import eify from '~/utils/eify';
|
||||||
import { useMegaStore } from '~/state/megaStore';
|
import { useMegaStore } from '~/state/megaStore';
|
||||||
@@ -24,7 +24,8 @@ export function SettingsStringsEditor() {
|
|||||||
console.log(values)
|
console.log(values)
|
||||||
}
|
}
|
||||||
|
|
||||||
return <Form onSubmit={handleSubmit} class="flex flex-col gap-4">
|
return <Card>
|
||||||
|
<Form onSubmit={handleSubmit} class="flex flex-col gap-4">
|
||||||
<h2 class="text-2xl font-light">Don't trust us! Use your own servers to back Mutiny.</h2>
|
<h2 class="text-2xl font-light">Don't trust us! Use your own servers to back Mutiny.</h2>
|
||||||
<div class="flex flex-col gap-2">
|
<div class="flex flex-col gap-2">
|
||||||
<SmallHeader>Network</SmallHeader>
|
<SmallHeader>Network</SmallHeader>
|
||||||
@@ -55,5 +56,6 @@ export function SettingsStringsEditor() {
|
|||||||
</Field>
|
</Field>
|
||||||
<Button type="submit">Save</Button>
|
<Button type="submit">Save</Button>
|
||||||
</Form>
|
</Form>
|
||||||
|
</Card>
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import { ButtonLink, DefaultMain, LargeHeader, MutinyWalletGuard, SafeArea, VStack } from "~/components/layout";
|
import { ButtonLink, DefaultMain, LargeHeader, MutinyWalletGuard, SafeArea, VStack } from "~/components/layout";
|
||||||
import { BackLink } from "~/components/layout/BackLink";
|
import { BackLink } from "~/components/layout/BackLink";
|
||||||
|
import { Logs } from "~/components/Logs";
|
||||||
import NavBar from "~/components/NavBar";
|
import NavBar from "~/components/NavBar";
|
||||||
import { SeedWords } from "~/components/SeedWords";
|
import { SeedWords } from "~/components/SeedWords";
|
||||||
import { SettingsStringsEditor } from "~/components/SettingsStringsEditor";
|
import { SettingsStringsEditor } from "~/components/SettingsStringsEditor";
|
||||||
@@ -20,6 +21,7 @@ export default function Settings() {
|
|||||||
<SeedWords words={store.mutiny_wallet?.show_seed() || ""} />
|
<SeedWords words={store.mutiny_wallet?.show_seed() || ""} />
|
||||||
</VStack>
|
</VStack>
|
||||||
<SettingsStringsEditor />
|
<SettingsStringsEditor />
|
||||||
|
<Logs />
|
||||||
<ButtonLink href="/admin">"I know what I'm doing"</ButtonLink>
|
<ButtonLink href="/admin">"I know what I'm doing"</ButtonLink>
|
||||||
</VStack>
|
</VStack>
|
||||||
</DefaultMain>
|
</DefaultMain>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// https://stackoverflow.com/questions/34156282/how-do-i-save-json-to-local-text-file
|
// https://stackoverflow.com/questions/34156282/how-do-i-save-json-to-local-text-file
|
||||||
|
|
||||||
export function downloadTextFile(content: string, fileName: string) {
|
export function downloadTextFile(content: string, fileName: string, type: string) {
|
||||||
const contentType = "application/json";
|
const contentType = type ? type : "application/json";
|
||||||
const a = document.createElement("a");
|
const a = document.createElement("a");
|
||||||
const file = new Blob([content], { type: contentType });
|
const file = new Blob([content], { type: contentType });
|
||||||
a.href = URL.createObjectURL(file);
|
a.href = URL.createObjectURL(file);
|
||||||
|
|||||||
Reference in New Issue
Block a user