mirror of
https://github.com/kennethnym/aris.git
synced 2026-04-26 19:51:17 +01:00
Compare commits
1 Commits
feat/admin
...
feat/calda
| Author | SHA1 | Date | |
|---|---|---|---|
|
21a078ac40
|
@@ -20,13 +20,7 @@ import {
|
|||||||
import { Separator } from "@/components/ui/separator"
|
import { Separator } from "@/components/ui/separator"
|
||||||
import { Switch } from "@/components/ui/switch"
|
import { Switch } from "@/components/ui/switch"
|
||||||
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip"
|
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip"
|
||||||
import {
|
import { fetchSourceConfig, pushLocation, replaceSource, updateProviderConfig } from "@/lib/api"
|
||||||
fetchSourceConfig,
|
|
||||||
pushLocation,
|
|
||||||
replaceSource,
|
|
||||||
updateProviderConfig,
|
|
||||||
updateSourceCredentials,
|
|
||||||
} from "@/lib/api"
|
|
||||||
|
|
||||||
interface SourceConfigPanelProps {
|
interface SourceConfigPanelProps {
|
||||||
source: SourceDefinition
|
source: SourceDefinition
|
||||||
@@ -89,12 +83,8 @@ export function SourceConfigPanel({ source, onUpdate }: SourceConfigPanelProps)
|
|||||||
(v) => typeof v === "string" && v.length > 0,
|
(v) => typeof v === "string" && v.length > 0,
|
||||||
)
|
)
|
||||||
if (hasCredentials) {
|
if (hasCredentials) {
|
||||||
if (source.perUserCredentials) {
|
|
||||||
promises.push(updateSourceCredentials(source.id, credentialFields))
|
|
||||||
} else {
|
|
||||||
promises.push(updateProviderConfig(source.id, { credentials: credentialFields }))
|
promises.push(updateProviderConfig(source.id, { credentials: credentialFields }))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
await Promise.all(promises)
|
await Promise.all(promises)
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -23,8 +23,6 @@ export interface SourceDefinition {
|
|||||||
name: string
|
name: string
|
||||||
description: string
|
description: string
|
||||||
alwaysEnabled?: boolean
|
alwaysEnabled?: boolean
|
||||||
/** When true, secret fields are stored as per-user credentials via /api/sources/:id/credentials. */
|
|
||||||
perUserCredentials?: boolean
|
|
||||||
fields: Record<string, ConfigFieldDef>
|
fields: Record<string, ConfigFieldDef>
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,44 +78,6 @@ const sourceDefinitions: SourceDefinition[] = [
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
id: "aelis.caldav",
|
|
||||||
name: "CalDAV",
|
|
||||||
description: "Calendar events from any CalDAV server (Nextcloud, Radicale, Baikal, etc.).",
|
|
||||||
perUserCredentials: true,
|
|
||||||
fields: {
|
|
||||||
serverUrl: {
|
|
||||||
type: "string",
|
|
||||||
label: "Server URL",
|
|
||||||
required: true,
|
|
||||||
secret: false,
|
|
||||||
description: "CalDAV server URL (e.g. https://nextcloud.example.com/remote.php/dav)",
|
|
||||||
},
|
|
||||||
username: {
|
|
||||||
type: "string",
|
|
||||||
label: "Username",
|
|
||||||
required: true,
|
|
||||||
secret: false,
|
|
||||||
},
|
|
||||||
password: {
|
|
||||||
type: "string",
|
|
||||||
label: "Password",
|
|
||||||
required: true,
|
|
||||||
secret: true,
|
|
||||||
},
|
|
||||||
lookAheadDays: {
|
|
||||||
type: "number",
|
|
||||||
label: "Look-ahead Days",
|
|
||||||
defaultValue: 0,
|
|
||||||
description: "Number of additional days beyond today to fetch events for",
|
|
||||||
},
|
|
||||||
timeZone: {
|
|
||||||
type: "string",
|
|
||||||
label: "Timezone",
|
|
||||||
description: "IANA timezone for determining \"today\" (e.g. Europe/London). Defaults to UTC.",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
id: "aelis.tfl",
|
id: "aelis.tfl",
|
||||||
name: "TfL",
|
name: "TfL",
|
||||||
@@ -204,22 +164,6 @@ export async function updateProviderConfig(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateSourceCredentials(
|
|
||||||
sourceId: string,
|
|
||||||
credentials: Record<string, unknown>,
|
|
||||||
): Promise<void> {
|
|
||||||
const res = await fetch(`${serverBase()}/sources/${sourceId}/credentials`, {
|
|
||||||
method: "PUT",
|
|
||||||
headers: { "Content-Type": "application/json" },
|
|
||||||
credentials: "include",
|
|
||||||
body: JSON.stringify(credentials),
|
|
||||||
})
|
|
||||||
if (!res.ok) {
|
|
||||||
const data = (await res.json()) as { error?: string }
|
|
||||||
throw new Error(data.error ?? `Failed to update credentials: ${res.status}`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface LocationInput {
|
export interface LocationInput {
|
||||||
lat: number
|
lat: number
|
||||||
lng: number
|
lng: number
|
||||||
|
|||||||
Reference in New Issue
Block a user