diff --git a/src/lib/components/misc/Field.svelte b/src/lib/components/misc/Field.svelte new file mode 100644 index 0000000..34b5691 --- /dev/null +++ b/src/lib/components/misc/Field.svelte @@ -0,0 +1,35 @@ + + +
{problem}
+ {:else if help} +{help}
+ {/if} ++ {@render children()} + {label} +
diff --git a/src/lib/components/misc/Status.svelte b/src/lib/components/misc/Status.svelte new file mode 100644 index 0000000..4e7ce5e --- /dev/null +++ b/src/lib/components/misc/Status.svelte @@ -0,0 +1,15 @@ + + +{#if action.busy} + {busy} +{:else if action.message} + {action.message} +{/if} diff --git a/src/lib/components/misc/action.svelte.ts b/src/lib/components/misc/action.svelte.ts new file mode 100644 index 0000000..995bf60 --- /dev/null +++ b/src/lib/components/misc/action.svelte.ts @@ -0,0 +1,66 @@ +import { ApiError } from "#lib/api/client.js"; + +const UNAUTHORIZED = 401; +const ARM_MS = 3000; + +export function errorText(error: unknown): string { + if (error instanceof ApiError) { + if (error.status === UNAUTHORIZED) { + return "Only the owner can do this"; + } + return Object.values(error.errors)[0]?.[0] ?? error.message; + } + return error instanceof Error ? error.message : String(error); +} + +export class Action { + busy = $state(false); + message = $state(""); + failed = $state(false); + errors = $stateLoading administrations
+ {:else if query.error} +{errorText(query.error)}
+ {:else} +{errorText(query.error)}
+{:else} +Loading administration
+{/if} diff --git a/src/routes/administrations/groups.ts b/src/routes/administrations/groups.ts new file mode 100644 index 0000000..122f865 --- /dev/null +++ b/src/routes/administrations/groups.ts @@ -0,0 +1,45 @@ +import { api } from "#lib/api/client.js"; +import { all } from "#lib/api/lists.js"; +import type { One, UserGroup } from "#lib/api/types.js"; + +export interface Member { + roles?: string[]; + user_email: string; + user_id: string; + you?: boolean; +} + +export type Group = UserGroup & { + members?: Member[]; + primary_currency_name?: string; +}; + +const ROLES: RecordLoading attachments
+ {:else if query.error} +{errorText(query.error)}
+ {:else} +{errorText(query.error)}
+{:else} +Loading attachment
+{/if} diff --git a/src/routes/currencies/+page.svelte b/src/routes/currencies/+page.svelte new file mode 100644 index 0000000..c3748a4 --- /dev/null +++ b/src/routes/currencies/+page.svelte @@ -0,0 +1,213 @@ + + +Loading currencies
+ {:else if query.error} +{errorText(query.error)}
+ {:else} +{errorText(query.error)}
+{:else if query.isPending} +Loading currency
+{:else} +There is no currency with this id.
+{/if} diff --git a/src/routes/exchange-rates/+page.svelte b/src/routes/exchange-rates/+page.svelte new file mode 100644 index 0000000..09d4a1e --- /dev/null +++ b/src/routes/exchange-rates/+page.svelte @@ -0,0 +1,164 @@ + + +Loading exchange rates
+ {:else if rates.error} +{errorText(rates.error)}
+ {:else} +Loading exchange rates
+ {:else if query.error} +{errorText(query.error)}
+ {:else} +Looks like {sample}
+ {/if} ++ Exchange rates are switched off in the Firefly III configuration, so + this has no effect yet. +
+ {/if} +Loading recurring transactions
+ {:else if query.error} +{errorText(query.error)}
+ {:else} +{r.description}
+ {/if} + {#if !r.active} ++ This recurring transaction is not active and will not generate new + transactions. +
+ {/if} + {#if r.nr_of_repetitions} ++ This recurring transaction will be created at most + {r.nr_of_repetitions} + times, and has been created {count} times already. +
+ {/if} +| {formatDate(date)} | ++ {#if fired[date]} + {fired[date]} + {:else if createdDates.has(date)} + Created + {:else} + + {/if} + | +
| No upcoming dates. | +
| Description | +Source account | +Destination account | +Amount | +Category | +Budget | +Other | +
|---|---|---|---|---|---|---|
| {tx.description} | ++ {tx.source_name} + | ++ {tx.destination_name} + | +
+ |
+ + {#if tx.category_id} + {tx.category_name} + {/if} + | ++ {#if tx.budget_id} + {tx.budget_name} + {/if} + | +
+ {#if tx.tags?.length}
+ Tags: {tx.tags.join(", ")}
+ {/if}
+ {#if tx.piggy_bank_id}
+
+ Piggy bank:
+ {tx.piggy_bank_name}
+
+ {/if}
+ {#if tx.subscription_id}
+
+ Subscription:
+ {tx.subscription_name}
+
+ {/if}
+ |
+
{errorText(query.error)}
+{:else} +Loading recurring transaction
+{/if} diff --git a/src/routes/settings/links/+page.svelte b/src/routes/settings/links/+page.svelte new file mode 100644 index 0000000..4d909ca --- /dev/null +++ b/src/routes/settings/links/+page.svelte @@ -0,0 +1,164 @@ + + +Loading link types
+ {:else if types.error} +{errorText(types.error)}
+ {:else} +{errorText(query.error)}
+{:else} +Loading link type
+{/if} diff --git a/src/routes/settings/links/queries.ts b/src/routes/settings/links/queries.ts new file mode 100644 index 0000000..a990209 --- /dev/null +++ b/src/routes/settings/links/queries.ts @@ -0,0 +1,19 @@ +import { api } from "#lib/api/client.js"; +import { all } from "#lib/api/lists.js"; +import type { LinkType, One, TransactionLink } from "#lib/api/types.js"; + +export const linkQueries = { + links: (name?: string) => ({ + queryFn: () => + all{errorText(type.error)}
+ {:else if links.isPending} +Loading links
+ {:else if links.error} +{errorText(links.error)}
+ {:else} +Loading attempts
+{:else if query.error} +{errorText(query.error)}
+{:else} + {#each query.data ?? [] as attempt (attempt.id)} + {@const a = attempt.attributes} ++ Attempt at {formatDateTime(a.created_at)} + {a.status_code ?? "no answer"} +
+ {#if a.logs} +{a.logs}
+ {/if}
+ {#if a.response}
+ {a.response}
+ {/if}
+ No attempts yet.
+ {/each} +{/if} diff --git a/src/routes/webhooks/Disabled.svelte b/src/routes/webhooks/Disabled.svelte new file mode 100644 index 0000000..a1dec20 --- /dev/null +++ b/src/routes/webhooks/Disabled.svelte @@ -0,0 +1,9 @@ + + +Loading webhooks
+ {:else if query.error} +{errorText(query.error)}
+ {:else} +{errorText(query.error)}
+{:else if w} +Loading messages
+ {:else if messages.error} +{errorText(messages.error)}
+ {:else} +{pretty(current.attributes.message)}
+ Loading webhook
+{/if} diff --git a/src/routes/webhooks/webhooks.ts b/src/routes/webhooks/webhooks.ts new file mode 100644 index 0000000..7b8d77c --- /dev/null +++ b/src/routes/webhooks/webhooks.ts @@ -0,0 +1,32 @@ +import { ApiError } from "#lib/api/client.js"; + +const NOT_FOUND = 404; + +export const TRIGGERS: Record